using SysBaseLibs;
using SysDataLibs.TableClass;
using System;
using System.Web;
using System.Web.Mvc;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Globalization;
using System.Text;
using Newtonsoft.Json;
using System.Net;
namespace GSMarketSys.Controllers
{
public class SystemModuleController : BaseController
{
#region 用户注册审核
///
/// 用户注册审核 页面
///
///
public ActionResult SysRegistersAudit()
{
ViewBag.SelSystemIDInfo= GetData.Instance.GetSelStr(GSSystem_info.cSystemID, GSSystem_info.cshortName, Tn.GSSystem, GSSystem_info.cSystemType + "='N'", UserSessionInfo.DBConn);
ViewBag.SelRegionInfo = GetData.Instance.GetSelStr(Regions_info.cRegionID, Regions_info.cNames, Tn.Regions, UserSessionInfo.DBConn);
return View();
}
///
/// 用户注册审核 操作
///
///
[HttpPost]
public ActionResult SysRegistersAuditOper()
{
#region Request + new SysRegisters_info
string type = Request["Type"],
id = GetRequest("ID"),
systemId = GetRequest("SystemID"),
warrantNumber = GetRequest("WarrantNumber"),
marketName = GetRequest("MarketName"),
marketId = GetRequest("MarketID"),
validStartTime = GetRequest("ValidStartTime"),
validEndTime = GetRequest("ValidEndTime"),
regionId = GetRequest("RegionId"),
regionName= new Regions_info(regionId, UserSessionInfo.DBConn).Names,
userCode = GetRequest("UserCode"),
userName = GetRequest("UserName"),
linkTel = GetRequest("LinkTel");
SysRegisters_info registersInfo = new SysRegisters_info(id, UserSessionInfo.DBConn)
{
SystemID=systemId,
WarrantNumber=warrantNumber,
MarketID = marketId,
MarketName=marketName,
ValidStartTime=validStartTime,
ValidEndTime=validEndTime,
RegionID=regionId,
RegionName=regionName,
LinkTel=linkTel,
UserCode=userCode,
UserName=userName,
//IsAudit="N",
//RegisterIP="",
//RegisterDate="",
//Password=""
};
#endregion
string lcSql = type == "Del" ? registersInfo.DeleteSql() : registersInfo.UpdateSql();
if (string.IsNullOrEmpty(lcSql))
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
if (UserSessionInfo.DBConn.ExcuteSqlTran(lcSql))
{
if (type != "Aud" || (type == "Aud" && registersInfo.AuditThisInfo(UserSessionInfo)))
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
}
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
}
#endregion
#region SysSetting
// GET: SystemModule
[CheckPowerFilter]
public ActionResult SysSetting()
{
return View();
}
///
/// 查询系统配置
///
///
public ActionResult GetSysSettingListResult()
{
string lcSql = " select * from "+Tn.Sys_Setting;
return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
}
///
/// 修改和增加系统配置
///
///
[CheckPowerFilter]
public ActionResult SysSettingListOper()
{
string type = Request["Type"];
string sysSetCode = Request["SysSetCode"] ?? "";
string sysSetValue = Request["SysSetValue"] ?? "";
string remark = Request["Remark"] ?? "";
string lcSql;
Sys_Setting_info loSysSetting = type == "Edit"? new Sys_Setting_info(Utils.AreaToSQLcs(sysSetCode), UserSessionInfo.DBConn): new Sys_Setting_info();
loSysSetting.SysSetValue = Utils.AreaToSQLcs(sysSetValue);
loSysSetting.Remark = Utils.AreaToSQLcs(remark);
loSysSetting.SysSetCode = Utils.AreaToSQLcs(sysSetCode);
if (type == "Add")
{
if (SysDataLibs.AppEnv.IsExistPrKey(Tn.Sys_Setting, Sys_Setting_info.cSysSetCode, loSysSetting.SysSetCode, UserSessionInfo.DBConn))
{
//JSComm.ShowMessage("用户ID已存在!");
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsExistKeyError"));
}
lcSql = loSysSetting.InsertSql();
}
else if(type == "Del")
{
lcSql = loSysSetting.DeleteSql();
}
else
{
lcSql = loSysSetting.UpdateSql();
}
if(string.IsNullOrEmpty(loSysSetting.SysSetCode)|| string.IsNullOrEmpty(loSysSetting.SysSetValue))
{
return Content(ErrorRebackInfo.GetErrorBackInfo(false,"0","编码或码值不能为空!"));
}
if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
{
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
}
public ActionResult SysSettingListReload()
{
try
{
SysDataLibs.AppEnv.SysSetObj.Refresh();
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
catch
{
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
}
}
#endregion
#region FunctionListMG
[CheckPowerFilter]
public ActionResult FunctionList()
{
return View();
}
///
/// 获取菜单列表
///
///
public ActionResult FunctionMgList()
{
string lcRevtal = GetFunctions();
//Sonics.SonicLog.LogInfo(lcRevtal);
//Response.Write(lcRevtal);
return Content(lcRevtal);
}
private string GetFunctions()
{
string lcSql = " select * from " + Tn.Sys_Functions + " order by " + Sys_Functions_info.cSort;
rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
Sys_Functions_info loSysFunction = Sys_Functions_info.CreatTree(loQuery);
string lcRetval = "[" + loSysFunction.ToJason() + "]";
return lcRetval;
}
public ActionResult GetFunctionById()
{
//UserSession _UserSession = Sonics.WebUtils.WebLibs.GetUserSession();
string lcResult = "";
string functionId = Request["FunctionID"];
//Sonics.TableClass.Sys_Functions_info lTbl = new Sonics.TableClass.Sys_Functions_info(FunctionID,_UserSession.DBConn);
string lcSql = " select * from " +Tn.Sys_Functions + " where " + Sys_Functions_info.cFunctionID + " = '" + functionId + "'";
rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
if (null != loQuery && loQuery.IsOpened && loQuery.RecCount == 1)
{
lcResult = loQuery.CurrentTable.ToJson();
}
return Content(lcResult);
}
private Boolean AddFunction(string fatherId, Sys_Functions_info lTbl,DBConnSql poDbConn)
{
string errEsg = "";
Sys_Functions_info lTbl2 = new Sys_Functions_info();
string lcSql = " select * from " +Tn.Sys_Functions + " where " + Sys_Functions_info.cFunctionID + " = '" + fatherId + "'";
if (SysDataLibs.AppEnv.GetTableInfo(lcSql, lTbl2, poDbConn, ref errEsg))
{
}
lcSql = " update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cIsLeaf + " = 'N' where " + Sys_Functions_info.cFunctionID +
" = '" + fatherId + "'";
lcSql += "; update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cSort + " = " + Sys_Functions_info.cSort + "+1 where " + Sys_Functions_info.cSort + ">" + lTbl2.Sort;
lcSql += "; insert into " + Tn.Sys_Functions + "(" + Sys_Functions_info.cFunctionID + ","
+ Sys_Functions_info.cFunctionName + "," + Sys_Functions_info.cURL + ","
+ Sys_Functions_info.cFatherID + "," + Sys_Functions_info.cDepth + ","
+ Sys_Functions_info.cIsLeaf + "," + Sys_Functions_info.cSort + ","
+ Sys_Functions_info.cPath + "," + Sys_Functions_info.cIsFront;
lcSql += " ," + Sys_Functions_info.cIsBack + "," + Sys_Functions_info.cIsBrowse
+ "," + Sys_Functions_info.cIsAdd + "," + Sys_Functions_info.cIsDelete
+ "," + Sys_Functions_info.cIsUpdate + "," + Sys_Functions_info.cIsPrint
+ "," + Sys_Functions_info.cIsAudit + "," + Sys_Functions_info.cUserIDLastMod
+ "," + Sys_Functions_info.cTimeCreated + "," + Sys_Functions_info.cTimeLastMod + "," + Sys_Functions_info.cPageName + " ) values("
+ "'" + lTbl.FunctionID + "',"
+ "'" + lTbl.FunctionName + "',"
+ "'" + lTbl.URL + "',"
+ "'" + fatherId + "',"
+ (Utils.ValI(lTbl2.Depth) + 1) + ","
+ "'Y'" + ","
+ (Utils.ValI(lTbl2.Sort) + 1) + ","
+ "'" + lTbl2.Path + lTbl.FunctionID + ",','"
+ (lTbl.IsFront) + "','"
+ (lTbl.IsBack) + "','"
+ (lTbl.IsBrowse) + "','"
+ (lTbl.IsAdd) + "','"
+ (lTbl.IsDelete) + "','"
+ (lTbl.IsUpdate) + "','"
+ (lTbl.IsPrint) + "','"
+ (lTbl.IsAudit) + "',"
+ "'" + lTbl.UserIDLastMod + "',"
+ "'" + lTbl.TimeCreated + "','" + lTbl.TimeLastMod + "','" + lTbl.PageName + "')";
if (poDbConn.ExcuteSqlTran(lcSql) == false)
{
return false;
}
else
{
return true;
}
}
private Boolean UpdateFunction(string functionId,Sys_Functions_info lTbl, DBConnSql poDbConn)
{
string lcSql = " update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cFunctionName + "='" + lTbl.FunctionName + "',"
+ Sys_Functions_info.cURL + "='" + lTbl.URL + "',"
+ Sys_Functions_info.cIsFront + "='" + lTbl.IsFront + "',"
+ Sys_Functions_info.cIsBack + "='" + lTbl.IsBack + "',"
+ Sys_Functions_info.cIsBrowse + "='" + lTbl.IsBrowse + "',"
+ Sys_Functions_info.cIsAdd + "='" + lTbl.IsAdd + "',"
+ Sys_Functions_info.cIsDelete + "='" + lTbl.IsDelete + "',"
+ Sys_Functions_info.cIsUpdate + "='" + lTbl.IsUpdate + "',"
+ Sys_Functions_info.cIsPrint + "='" + lTbl.IsPrint + "',"
+ Sys_Functions_info.cIsAudit + "='" + lTbl.IsAudit + "',"
+ Sys_Functions_info.cTimeLastMod + "='" + lTbl.TimeLastMod + "',"
+ Sys_Functions_info.cUserIDLastMod + "='" + lTbl.UserIDLastMod + "',"
+ Sys_Functions_info.cPageName + "='" + lTbl.PageName + "'";
lcSql += " where " + Sys_Functions_info.cFunctionID + "='" + functionId + "'";
if (!poDbConn.ExcuteSqlTran(lcSql))
{
return false;
}
else
{
return true;
}
}
///
/// 功能菜单的删除,上移,下移
///
///
[CheckPowerFilter]
public ActionResult FunctionMgAjax()
{
string keyno = Request["id"];
string type = Request["Type"];
string lcResult = "";
if (!string.IsNullOrEmpty(keyno) && type == "delete")
{
lcResult = Sys_Functions_info.DeleteFunction(keyno, UserSessionInfo.DBConn) ? "true" : "false";
}
else if (!string.IsNullOrEmpty(keyno) && (type == "up" || type == "down"))
{
lcResult = move(keyno, type, UserSessionInfo.DBConn) ? "true" : "false";
}
return Content(lcResult);
}
//private bool deleteFunction(string poKey, DBConnSql poDBConn)
//{
// bool lcRetval = false;
// Sys_Functions_info lTbl = new Sys_Functions_info(poKey, poDBConn);
// if (poDBConn.ExcuteSqlTran(lTbl.DeleteSql()))
// {
// lcRetval = true;
// }
// return lcRetval;
//}
private bool move(string poKey, string type, DBConnSql poDbConn)
{
bool lcRetval = Sys_Functions_info.MoveFunction(poKey, type, poDbConn);
return lcRetval;
}
///
/// 增加和修改功能菜单
///
///
[CheckPowerFilter]
public ActionResult SysFunctionEditAjax()
{
// UserSession _UserSession = WebLibs.GetUserSession();
string type = Request["Type"];
string pFunctionId = Request["PFunctionID"];
string functionId = Request["FunctionID"];
string cNames = Request["cNames"];
string cUrl = Request["cURL"];
string pageName = Request["PageName"];
//string modifyman = Request["modifyman"];
//string modifyTime = Request["modifyTime"];
string isFront = Request["IsFront"];
string isBack = Request["IsBack"];
string isBrowse = Request["IsBrowse"];
string isAdd = Request["IsAdd"];
string isDelete = Request["IsDelete"];
string isUpdate = Request["IsUpdate"];
string isPrint = Request["IsPrint"];
string isAudit = Request["IsAudit"];
Sys_Functions_info lTbl = null;
if (type == "add")
{
lTbl = new Sys_Functions_info {TimeCreated = DateTime.Now.ToString(CultureInfo.InvariantCulture)};
//lTbl.SysSetCode = Sonics.Utils.AreaToSQLcs(SysSetCode.Trim());
}
else if (type == "modify")
{
lTbl = new Sys_Functions_info(functionId.Trim(), UserSessionInfo.DBConn);
if (string.IsNullOrEmpty(lTbl.FunctionName))
{
//Response.Write("未找到对象" + lTbl.FunctionName);
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_NoExistKeyError"));
}
}
if (lTbl != null)
{
lTbl.FunctionID = Utils.AreaToSQLcs(functionId);
//lTbl.FatherID = Utils.AreaToSQLcs(functionID);
lTbl.FunctionName = Utils.AreaToSQLcs(cNames);
lTbl.IsAdd = isAdd;
lTbl.IsBack = isBack;
lTbl.IsBrowse = isBrowse;
lTbl.IsDelete = isDelete;
lTbl.IsFront = isFront;
lTbl.IsAudit = isAudit;
lTbl.IsPrint = isPrint;
lTbl.IsUpdate = isUpdate;
lTbl.URL = Utils.AreaToSQLcs(cUrl);
lTbl.PageName = Utils.AreaToSQLcs(pageName);
lTbl.UserIDLastMod = UserSessionInfo.UserInfo.UserCode;
lTbl.TimeLastMod = DateTime.Now.ToString(CultureInfo.InvariantCulture);
if (string.IsNullOrEmpty(lTbl.FunctionID) || string.IsNullOrEmpty(lTbl.FunctionName))
{
return Content(ErrorRebackInfo.GetErrorBackInfo(false,"0","菜单名称或编号不能为空!"));
}
if (type == "add")
{
if (string.IsNullOrEmpty(pFunctionId))
{
return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "父节点编号不能为空!"));
}
if (SysDataLibs.AppEnv.IsExistPrKey(Tn.Sys_Functions, Sys_Functions_info.cFunctionID, lTbl.FunctionID, UserSessionInfo.DBConn))
{
//Response.Write("该编号已经存在!");
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsExistKeyError"));
}
if (AddFunction(pFunctionId, lTbl, UserSessionInfo.DBConn))
{
//Alert.ShowInTop("添加成功!");
//PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
}
if (type == "modify")
{
if (UpdateFunction(functionId, lTbl, UserSessionInfo.DBConn))
{
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
}
}
return null;
}
public ActionResult GetFunctionForEasyUiTree()
{
string lcSql = "Select " + Sys_Functions_info.cFunctionID + " as id," + Sys_Functions_info.cFatherID + " as parentId," + Sys_Functions_info.cFunctionName + " as name from " + Tn.Sys_Functions +
" ";
//Sonics.snQuery loQuery = null;
rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
StringBuilder sb = new StringBuilder();
sb.Append("[");
if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
{
loQuery.MoveFirst();
for (int i = 0; i < loQuery.RecCount; i++)
{
sb.Append("{");
sb.Append("\"id\":\"" + loQuery.GetString("id") + "\",\"parentId\":\"" + loQuery.GetString("parentId") + "\",\"name\":\"" + loQuery.GetString("name") + "\"");
sb.Append("},");
loQuery.MoveNext();
}
}
sb.Remove(sb.Length - 1, 1);
sb.Append("]");
return Content(sb.ToString());
}
#endregion
#region Sys_Status
public ActionResult SysStatusList()
{
return View();
}
public ActionResult GetSysStatusList()
{
string lcSql = " select * from " + Tn.Sys_Status;
return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
}
public ActionResult GetSysStatusById()
{
string lcId = Request["ID"];
return Content(GetData.Instance.GetResultById(Utils.AreaToSQLcs(lcId), Tn.Sys_Status, Sys_Status_info.cSysStatusID));
}
public ActionResult SysStatusListOper()
{
string type = Request["Type"];
string sysStatusId = Request["SysStatusID"] ?? "";
string tableName = Request["TableName"] ?? "";
string colName = Request["ColName"] ?? "";
string codeValue = Request["CodeValue"] ?? "";
string displayValue = Request["DisplayValue"] ?? "";
string lcSql;
Sys_Status_info loSysStatus = (type == "Edit")||(type== "Del") ? new Sys_Status_info(Utils.AreaToSQLcs(sysStatusId), UserSessionInfo.DBConn) : new Sys_Status_info();
loSysStatus.SysStatusID = Utils.AreaToSQLcs(sysStatusId);
loSysStatus.TableName = Utils.AreaToSQLcs(tableName);
loSysStatus.ColName = Utils.AreaToSQLcs(colName);
loSysStatus.CodeValue = Utils.AreaToSQLcs(codeValue);
loSysStatus.DisplayValue = Utils.AreaToSQLcs(displayValue);
if (type == "Add")
{
lcSql = loSysStatus.InsertSql();
}
else if (type == "Del")
{
lcSql = loSysStatus.DeleteSql();
}
else
{
lcSql = loSysStatus.UpdateSql();
}
if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
{
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
//return null;
}
#endregion
#region SysHelpes
public ActionResult SysHelpesList()
{
return View();
}
public ActionResult GetSysHelpesList()
{
string lcSql = " select * from " + Tn.Sys_Helps;
return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
}
public ActionResult GetSysHelpeById()
{
string lcId = Request["ID"];
return Content(GetData.Instance.GetResultById(Utils.AreaToSQLcs(lcId), Tn.Sys_Helps, Sys_Helps_info.cHelpId));
}
[ValidateInput(false)]
public ActionResult SysHelpsListOper()
{
string type = Request["Type"];
string helpId = Request["HelpId"] ?? "";
string functionId = Request["FunctionId"] ?? "";
string helpTitle = Request["HelpTitle"] ?? "";
string helpKeyWords = Request["HelpKeyWords"] ?? "";
string sequence = Request["Sequence"] ?? "";
string helpContent = Request["HelpContent"] ?? "";
string lcSql;
Sys_Helps_info loSysHelps = (type == "Edit") || (type == "Del") ? new Sys_Helps_info(Utils.AreaToSQLcs(helpId), UserSessionInfo.DBConn) : new Sys_Helps_info();
loSysHelps.HelpId = Utils.AreaToSQLcs(helpId);
loSysHelps.FunctionId = Utils.AreaToSQLcs(functionId);
loSysHelps.HelpTitle = Utils.AreaToSQLcs(helpTitle);
loSysHelps.HelpKeyWords = Utils.AreaToSQLcs(helpKeyWords);
loSysHelps.Sequence = Utils.AreaToSQLcs(sequence);
loSysHelps.HelpContent = helpContent;
if (type == "Add")
{
lcSql = loSysHelps.InsertSql();
}
else if (type == "Del")
{
lcSql = loSysHelps.DeleteSql();
}
else
{
lcSql = loSysHelps.UpdateSql();
}
if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
{
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
}
//return Content("{\"Success\":\"false\",\"errorInfo\":\"" + "操作失败!" + UserSessionInfo.DBConn.ErrorMsg + "\"}");
return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
}
[HttpPost]
public ActionResult UploadImage()
{
string savePath = "../Images/upload/Helps/";
//string saveUrl = "http://www.cnblogs.com/Content/Images/";
string fileTypes = "gif,jpg,jpeg,png,bmp";
int maxSize = 1000000;
Hashtable hash;
HttpPostedFileBase file = Request.Files["imgFile"];
if (file == null)
{
hash = new Hashtable
{
["error"] = 0,
["url"] = "请选择文件"
};
return Json(hash);
}
string dirPath = Server.MapPath(savePath);
if (!Directory.Exists(dirPath))
{
hash = new Hashtable
{
["error"] = 0,
["url"] = "上传目录不存在"
};
return Json(hash);
}
string fileName = file.FileName;
string fileExt="";
if (!string.IsNullOrEmpty(fileName))
fileExt = Path.GetExtension(fileName).ToLower();
//ArrayList fileTypeList = ArrayList.Adapter(fileTypes.Split(','));
if (file.InputStream == null || file.InputStream.Length > maxSize)
{
hash = new Hashtable
{
["error"] = 0,
["url"] = "上传文件大小超过限制"
};
return Json(hash);
}
if (string.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
{
hash = new Hashtable
{
["error"] = 0,
["url"] = "上传文件扩展名是不允许的扩展名"
};
return Json(hash);
}
string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
string filePath = dirPath + newFileName;
file.SaveAs(filePath);
string fileUrl = savePath + newFileName;
hash = new Hashtable
{
["error"] = 0,
["url"] = fileUrl
};
return Json(hash, "text/html;charset=UTF-8");
}
///
/// 帮助页面
///
///
public ActionResult SysHelpsShow()
{
string lcSql = "SELECT * FROM " + Tn.Sys_Helps + " WHERE " + Sys_Helps_info.cFunctionId + " IN ( " + UserSessionInfo.UserFunctionIdList + " ) ORDER BY Sequence ";
rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
//StringBuilder loOutHeader = new StringBuilder();
//StringBuilder loOutContent = new StringBuilder();
var loHelpList = new List();
if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
{
loQuery.MoveFirst();
//loOutHeader.AppendFormat(
// "目录
");
for (int i = 0; i < loQuery.RecCount; i++)
{
//string lcHref = loQuery.GetString("HelpId") + "_" + loQuery.GetString("Sequence");
//loOutHeader.AppendFormat("{0} {2}
", (i + 1) + "",
// lcHref, loQuery.GetString("HelpTitle"));
//loOutContent.AppendFormat(
// " {1} {2}
{3}
",
// lcHref, (i + 1) + "", loQuery.GetString("HelpTitle"), loQuery.GetString("HelpContent"));
loHelpList.Add(new HelpViewModel()
{
HelpId = loQuery.GetString("HelpId"),
FunctionId = loQuery.GetString("FunctionId"),
HelpTitle = loQuery.GetString("HelpTitle"),
HelpKeyWords = loQuery.GetString("HelpKeyWords"),
HelpContent = loQuery.GetString("HelpContent"),
Sequence = loQuery.GetString("Sequence"),
});
loQuery.MoveNext();
}
}
//ViewBag.HlepHeader = loOutHeader.ToString();
//ViewBag.HelpContent = loOutContent.ToString();
return View(loHelpList);
}
#endregion
#region SysLogView
public ActionResult SysLogView()
{
ViewBag.SelSysLogType = GetData.Instance.GetSelStr(Sys_Log_info.cSysLogType,Tn.Sys_Log,UserSessionInfo.DBConn);
return View();
}
public ActionResult GetSysLogList()
{
string lcSql = " 1=1 ";
string rows = Request["rows"];
string page = Request["page"];
string userId = Utils.AreaToSQLcs(Request["UserID"]).Trim();
string startTime = Utils.AreaToSQLcs(Request["StartTime"]).Trim();
string endTime = Utils.AreaToSQLcs(Request["EndTime"]).Trim();
string sysLogTypeId = Utils.AreaToSQLcs(Request["SysLogTypeID"]).Trim();
if (!string.IsNullOrEmpty(userId))
{
lcSql += " and " + Sys_Log_info.cUserId + " = '" + userId + "'";
}
if (!string.IsNullOrEmpty(startTime))
{
lcSql += " and " + Sys_Log_info.cLogDate + " > '" + startTime + "'";
}
if (!string.IsNullOrEmpty(endTime))
{
lcSql += " and " + Sys_Log_info.cLogDate + " < '" + endTime + "'";
}
if (!string.IsNullOrEmpty(sysLogTypeId))
{
lcSql += " and " + Sys_Log_info.cSysLogType + " = '" + sysLogTypeId + "'";
}
return Content(GetData.Instance.GetResultSysStatesTran(Tn.Sys_Log, "*", lcSql, Sys_Log_info.cLogDate + " desc", Utils.ValI(page), Utils.ValI(rows), Tn.Sys_Log, Sys_Log_info.cSysLogType, UserSessionInfo.DBConn));
}
#endregion
#region SpecialFunction
public ActionResult SFunction()
{
return View();
}
public ActionResult SFunctionExecNone()
{
string lcResult = "";
string lcSql = Request["txtScript"];
string type = Utils.AreaToSQLcs(Request["Type"]);
if (!UserSessionInfo.IsSystem && !UserSessionInfo.IsAdvance)
{
return Content("没有权限执行该操作");
}
if (type == "0")
{
lcResult = UserSessionInfo.DBConn.ExcuteSqlTran(lcSql) ? "执行成功" : UserSessionInfo.DBConn.ErrorMsg;
}
else if (type == "1")
{
try
{
rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
if (loQuery != null && loQuery.IsOpened)
{
// txtScript0.Text = (loQuery.CurrentTable);
StringBuilder loBuilder = new StringBuilder();
loBuilder.AppendLine("AllFields:" + loQuery.AllFields);
loBuilder.AppendLine();
loBuilder.AppendLine("RecCount:" + loQuery.RecCount);
Array array1 = UtilStr.StrToArray(loQuery.AllFields);
loQuery.MoveFirst();
loBuilder.AppendLine();
loBuilder.AppendLine("");
for (int i = 0; i < loQuery.RecCount; i++)
{
loBuilder.AppendLine(" ");
for (int j = 0; j < array1.Length; j++)
{
string lcField = array1.GetValue(j).ToString();
loBuilder.AppendLine(" <" + lcField + ">" + loQuery.GetString(lcField) + "" + lcField + ">");
}
loBuilder.AppendLine(" ");
loQuery.MoveNext();
}
loBuilder.AppendLine("");
lcResult = loBuilder.ToString();
}
else
lcResult = "执行错误";
}
catch (Exception err)
{
lcResult += "\r\nSource:\r\n" + err.Source;
lcResult += "\r\nStackTrace:\r\n" + err.StackTrace;
lcResult += "\r\nMessage:\r\n" + err.Message;
}
}
return Content(lcResult);
}
public ActionResult SFunctionExecQuery()
{
string lcContent = Server.UrlDecode(Request["txtHttpContent"]);
string lcUrl = Request["url"];
//string lcDataStr = JsonConvert.SerializeObject(lcContent);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(lcUrl);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
//request.ContentLength = Encoding.GetEncoding("GB2312").GetByteCount(lcContent);
byte[] data = Encoding.GetEncoding("GB2312").GetBytes(lcContent);
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream res = response.GetResponseStream();
if (res != null)
{
StreamReader resReader = new StreamReader(res, Encoding.GetEncoding("utf-8"));
string retString = resReader.ReadToEnd();
resReader.Close();
res.Close();
//return retString;
return Content(retString);
}
return Content("NULL");
}
#endregion
///
/// 万年历 页面
///
///
public ActionResult Calendar()
{
ViewBag.SelSystemIDInfo = GetData.Instance.GetSelStr(GSSystem_info.cSystemID, GSSystem_info.cshortName, Tn.GSSystem, GSSystem_info.cSystemType + "='N'", UserSessionInfo.DBConn);
ViewBag.SelRegionInfo = GetData.Instance.GetSelStr(Regions_info.cRegionID, Regions_info.cNames, Tn.Regions, UserSessionInfo.DBConn);
return View();
}
///
/// 获取Requset[key]值,并ToSQL处理
///
///
///
///
private string GetRequest(string key, string type = "string")
{
string lcRetval = Request[key] ?? "";
if (type.ToLower() == "int")
lcRetval = GetData.Instance.SetIntDefault(lcRetval);
return Utils.AreaToSQLcs(lcRetval);
}
}
}