123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- 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 用户注册审核
- /// <summary>
- /// 用户注册审核 页面
- /// </summary>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 用户注册审核 操作
- /// </summary>
- /// <returns></returns>
- [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();
- }
- /// <summary>
- /// 查询系统配置
- /// </summary>
- /// <returns></returns>
- public ActionResult GetSysSettingListResult()
- {
- string lcSql = " select * from "+Tn.Sys_Setting;
- return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
- }
- /// <summary>
- /// 修改和增加系统配置
- /// </summary>
- /// <returns></returns>
- [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();
- }
- /// <summary>
- /// 获取菜单列表
- /// </summary>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 功能菜单的删除,上移,下移
- /// </summary>
- /// <returns></returns>
- [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;
- }
- /// <summary>
- /// 增加和修改功能菜单
- /// </summary>
- /// <returns></returns>
- [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");
- }
- /// <summary>
- /// 帮助页面
- /// </summary>
- /// <returns></returns>
- 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<HelpViewModel>();
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.MoveFirst();
- //loOutHeader.AppendFormat(
- // "<a name=\"directorylists\" id=\"directorylists\"></a><font size=3><b><center>目录</center></b></font><br>");
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- //string lcHref = loQuery.GetString("HelpId") + "_" + loQuery.GetString("Sequence");
- //loOutHeader.AppendFormat("<b>{0} <a href=\"#{1}\"> <font size=2>{2}</font></a></b><br>", (i + 1) + "",
- // lcHref, loQuery.GetString("HelpTitle"));
- //loOutContent.AppendFormat(
- // "<a name=\"{0}\" id=\"{0}\"></a> <b>{1} <font size=3 color=blue>{2}</font></b> <br> {3}<br>",
- // 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("<Records>");
- for (int i = 0; i < loQuery.RecCount; i++)
- {
- loBuilder.AppendLine(" <record>");
- for (int j = 0; j < array1.Length; j++)
- {
- string lcField = array1.GetValue(j).ToString();
- loBuilder.AppendLine(" <" + lcField + ">" + loQuery.GetString(lcField) + "</" + lcField + ">");
- }
- loBuilder.AppendLine(" </record>");
- loQuery.MoveNext();
- }
- loBuilder.AppendLine("</Records>");
- 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
- /// <summary>
- /// 万年历 页面
- /// </summary>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 获取Requset[key]值,并ToSQL处理
- /// </summary>
- /// <param name="key"></param>
- /// <param name="type"></param>
- /// <returns></returns>
- 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);
- }
- }
- }
|