SystemModuleController.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. using SysBaseLibs;
  2. using SysDataLibs.TableClass;
  3. using System;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Globalization;
  10. using System.Text;
  11. using Newtonsoft.Json;
  12. using System.Net;
  13. namespace GSMarketSys.Controllers
  14. {
  15. public class SystemModuleController : BaseController
  16. {
  17. #region 用户注册审核
  18. /// <summary>
  19. /// 用户注册审核 页面
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult SysRegistersAudit()
  23. {
  24. ViewBag.SelSystemIDInfo= GetData.Instance.GetSelStr(GSSystem_info.cSystemID, GSSystem_info.cshortName, Tn.GSSystem, GSSystem_info.cSystemType + "='N'", UserSessionInfo.DBConn);
  25. ViewBag.SelRegionInfo = GetData.Instance.GetSelStr(Regions_info.cRegionID, Regions_info.cNames, Tn.Regions, UserSessionInfo.DBConn);
  26. return View();
  27. }
  28. /// <summary>
  29. /// 用户注册审核 操作
  30. /// </summary>
  31. /// <returns></returns>
  32. [HttpPost]
  33. public ActionResult SysRegistersAuditOper()
  34. {
  35. #region Request + new SysRegisters_info
  36. string type = Request["Type"],
  37. id = GetRequest("ID"),
  38. systemId = GetRequest("SystemID"),
  39. warrantNumber = GetRequest("WarrantNumber"),
  40. marketName = GetRequest("MarketName"),
  41. marketId = GetRequest("MarketID"),
  42. validStartTime = GetRequest("ValidStartTime"),
  43. validEndTime = GetRequest("ValidEndTime"),
  44. regionId = GetRequest("RegionId"),
  45. regionName= new Regions_info(regionId, UserSessionInfo.DBConn).Names,
  46. userCode = GetRequest("UserCode"),
  47. userName = GetRequest("UserName"),
  48. linkTel = GetRequest("LinkTel");
  49. SysRegisters_info registersInfo = new SysRegisters_info(id, UserSessionInfo.DBConn)
  50. {
  51. SystemID=systemId,
  52. WarrantNumber=warrantNumber,
  53. MarketID = marketId,
  54. MarketName=marketName,
  55. ValidStartTime=validStartTime,
  56. ValidEndTime=validEndTime,
  57. RegionID=regionId,
  58. RegionName=regionName,
  59. LinkTel=linkTel,
  60. UserCode=userCode,
  61. UserName=userName,
  62. //IsAudit="N",
  63. //RegisterIP="",
  64. //RegisterDate="",
  65. //Password=""
  66. };
  67. #endregion
  68. string lcSql = type == "Del" ? registersInfo.DeleteSql() : registersInfo.UpdateSql();
  69. if (string.IsNullOrEmpty(lcSql))
  70. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
  71. if (UserSessionInfo.DBConn.ExcuteSqlTran(lcSql))
  72. {
  73. if (type != "Aud" || (type == "Aud" && registersInfo.AuditThisInfo(UserSessionInfo)))
  74. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  75. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
  76. }
  77. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  78. }
  79. #endregion
  80. #region SysSetting
  81. // GET: SystemModule
  82. [CheckPowerFilter]
  83. public ActionResult SysSetting()
  84. {
  85. return View();
  86. }
  87. /// <summary>
  88. /// 查询系统配置
  89. /// </summary>
  90. /// <returns></returns>
  91. public ActionResult GetSysSettingListResult()
  92. {
  93. string lcSql = " select * from "+Tn.Sys_Setting;
  94. return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
  95. }
  96. /// <summary>
  97. /// 修改和增加系统配置
  98. /// </summary>
  99. /// <returns></returns>
  100. [CheckPowerFilter]
  101. public ActionResult SysSettingListOper()
  102. {
  103. string type = Request["Type"];
  104. string sysSetCode = Request["SysSetCode"] ?? "";
  105. string sysSetValue = Request["SysSetValue"] ?? "";
  106. string remark = Request["Remark"] ?? "";
  107. string lcSql;
  108. Sys_Setting_info loSysSetting = type == "Edit"? new Sys_Setting_info(Utils.AreaToSQLcs(sysSetCode), UserSessionInfo.DBConn): new Sys_Setting_info();
  109. loSysSetting.SysSetValue = Utils.AreaToSQLcs(sysSetValue);
  110. loSysSetting.Remark = Utils.AreaToSQLcs(remark);
  111. loSysSetting.SysSetCode = Utils.AreaToSQLcs(sysSetCode);
  112. if (type == "Add")
  113. {
  114. if (SysDataLibs.AppEnv.IsExistPrKey(Tn.Sys_Setting, Sys_Setting_info.cSysSetCode, loSysSetting.SysSetCode, UserSessionInfo.DBConn))
  115. {
  116. //JSComm.ShowMessage("用户ID已存在!");
  117. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsExistKeyError"));
  118. }
  119. lcSql = loSysSetting.InsertSql();
  120. }
  121. else if(type == "Del")
  122. {
  123. lcSql = loSysSetting.DeleteSql();
  124. }
  125. else
  126. {
  127. lcSql = loSysSetting.UpdateSql();
  128. }
  129. if(string.IsNullOrEmpty(loSysSetting.SysSetCode)|| string.IsNullOrEmpty(loSysSetting.SysSetValue))
  130. {
  131. return Content(ErrorRebackInfo.GetErrorBackInfo(false,"0","编码或码值不能为空!"));
  132. }
  133. if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
  134. {
  135. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  136. }
  137. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  138. }
  139. public ActionResult SysSettingListReload()
  140. {
  141. try
  142. {
  143. SysDataLibs.AppEnv.SysSetObj.Refresh();
  144. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  145. }
  146. catch
  147. {
  148. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Error"));
  149. }
  150. }
  151. #endregion
  152. #region FunctionListMG
  153. [CheckPowerFilter]
  154. public ActionResult FunctionList()
  155. {
  156. return View();
  157. }
  158. /// <summary>
  159. /// 获取菜单列表
  160. /// </summary>
  161. /// <returns></returns>
  162. public ActionResult FunctionMgList()
  163. {
  164. string lcRevtal = GetFunctions();
  165. //Sonics.SonicLog.LogInfo(lcRevtal);
  166. //Response.Write(lcRevtal);
  167. return Content(lcRevtal);
  168. }
  169. private string GetFunctions()
  170. {
  171. string lcSql = " select * from " + Tn.Sys_Functions + " order by " + Sys_Functions_info.cSort;
  172. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  173. Sys_Functions_info loSysFunction = Sys_Functions_info.CreatTree(loQuery);
  174. string lcRetval = "[" + loSysFunction.ToJason() + "]";
  175. return lcRetval;
  176. }
  177. public ActionResult GetFunctionById()
  178. {
  179. //UserSession _UserSession = Sonics.WebUtils.WebLibs.GetUserSession();
  180. string lcResult = "";
  181. string functionId = Request["FunctionID"];
  182. //Sonics.TableClass.Sys_Functions_info lTbl = new Sonics.TableClass.Sys_Functions_info(FunctionID,_UserSession.DBConn);
  183. string lcSql = " select * from " +Tn.Sys_Functions + " where " + Sys_Functions_info.cFunctionID + " = '" + functionId + "'";
  184. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  185. if (null != loQuery && loQuery.IsOpened && loQuery.RecCount == 1)
  186. {
  187. lcResult = loQuery.CurrentTable.ToJson();
  188. }
  189. return Content(lcResult);
  190. }
  191. private Boolean AddFunction(string fatherId, Sys_Functions_info lTbl,DBConnSql poDbConn)
  192. {
  193. string errEsg = "";
  194. Sys_Functions_info lTbl2 = new Sys_Functions_info();
  195. string lcSql = " select * from " +Tn.Sys_Functions + " where " + Sys_Functions_info.cFunctionID + " = '" + fatherId + "'";
  196. if (SysDataLibs.AppEnv.GetTableInfo(lcSql, lTbl2, poDbConn, ref errEsg))
  197. {
  198. }
  199. lcSql = " update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cIsLeaf + " = 'N' where " + Sys_Functions_info.cFunctionID +
  200. " = '" + fatherId + "'";
  201. lcSql += "; update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cSort + " = " + Sys_Functions_info.cSort + "+1 where " + Sys_Functions_info.cSort + ">" + lTbl2.Sort;
  202. lcSql += "; insert into " + Tn.Sys_Functions + "(" + Sys_Functions_info.cFunctionID + ","
  203. + Sys_Functions_info.cFunctionName + "," + Sys_Functions_info.cURL + ","
  204. + Sys_Functions_info.cFatherID + "," + Sys_Functions_info.cDepth + ","
  205. + Sys_Functions_info.cIsLeaf + "," + Sys_Functions_info.cSort + ","
  206. + Sys_Functions_info.cPath + "," + Sys_Functions_info.cIsFront;
  207. lcSql += " ," + Sys_Functions_info.cIsBack + "," + Sys_Functions_info.cIsBrowse
  208. + "," + Sys_Functions_info.cIsAdd + "," + Sys_Functions_info.cIsDelete
  209. + "," + Sys_Functions_info.cIsUpdate + "," + Sys_Functions_info.cIsPrint
  210. + "," + Sys_Functions_info.cIsAudit + "," + Sys_Functions_info.cUserIDLastMod
  211. + "," + Sys_Functions_info.cTimeCreated + "," + Sys_Functions_info.cTimeLastMod + "," + Sys_Functions_info.cPageName + " ) values("
  212. + "'" + lTbl.FunctionID + "',"
  213. + "'" + lTbl.FunctionName + "',"
  214. + "'" + lTbl.URL + "',"
  215. + "'" + fatherId + "',"
  216. + (Utils.ValI(lTbl2.Depth) + 1) + ","
  217. + "'Y'" + ","
  218. + (Utils.ValI(lTbl2.Sort) + 1) + ","
  219. + "'" + lTbl2.Path + lTbl.FunctionID + ",','"
  220. + (lTbl.IsFront) + "','"
  221. + (lTbl.IsBack) + "','"
  222. + (lTbl.IsBrowse) + "','"
  223. + (lTbl.IsAdd) + "','"
  224. + (lTbl.IsDelete) + "','"
  225. + (lTbl.IsUpdate) + "','"
  226. + (lTbl.IsPrint) + "','"
  227. + (lTbl.IsAudit) + "',"
  228. + "'" + lTbl.UserIDLastMod + "',"
  229. + "'" + lTbl.TimeCreated + "','" + lTbl.TimeLastMod + "','" + lTbl.PageName + "')";
  230. if (poDbConn.ExcuteSqlTran(lcSql) == false)
  231. {
  232. return false;
  233. }
  234. else
  235. {
  236. return true;
  237. }
  238. }
  239. private Boolean UpdateFunction(string functionId,Sys_Functions_info lTbl, DBConnSql poDbConn)
  240. {
  241. string lcSql = " update " + Tn.Sys_Functions + " set " + Sys_Functions_info.cFunctionName + "='" + lTbl.FunctionName + "',"
  242. + Sys_Functions_info.cURL + "='" + lTbl.URL + "',"
  243. + Sys_Functions_info.cIsFront + "='" + lTbl.IsFront + "',"
  244. + Sys_Functions_info.cIsBack + "='" + lTbl.IsBack + "',"
  245. + Sys_Functions_info.cIsBrowse + "='" + lTbl.IsBrowse + "',"
  246. + Sys_Functions_info.cIsAdd + "='" + lTbl.IsAdd + "',"
  247. + Sys_Functions_info.cIsDelete + "='" + lTbl.IsDelete + "',"
  248. + Sys_Functions_info.cIsUpdate + "='" + lTbl.IsUpdate + "',"
  249. + Sys_Functions_info.cIsPrint + "='" + lTbl.IsPrint + "',"
  250. + Sys_Functions_info.cIsAudit + "='" + lTbl.IsAudit + "',"
  251. + Sys_Functions_info.cTimeLastMod + "='" + lTbl.TimeLastMod + "',"
  252. + Sys_Functions_info.cUserIDLastMod + "='" + lTbl.UserIDLastMod + "',"
  253. + Sys_Functions_info.cPageName + "='" + lTbl.PageName + "'";
  254. lcSql += " where " + Sys_Functions_info.cFunctionID + "='" + functionId + "'";
  255. if (!poDbConn.ExcuteSqlTran(lcSql))
  256. {
  257. return false;
  258. }
  259. else
  260. {
  261. return true;
  262. }
  263. }
  264. /// <summary>
  265. /// 功能菜单的删除,上移,下移
  266. /// </summary>
  267. /// <returns></returns>
  268. [CheckPowerFilter]
  269. public ActionResult FunctionMgAjax()
  270. {
  271. string keyno = Request["id"];
  272. string type = Request["Type"];
  273. string lcResult = "";
  274. if (!string.IsNullOrEmpty(keyno) && type == "delete")
  275. {
  276. lcResult = Sys_Functions_info.DeleteFunction(keyno, UserSessionInfo.DBConn) ? "true" : "false";
  277. }
  278. else if (!string.IsNullOrEmpty(keyno) && (type == "up" || type == "down"))
  279. {
  280. lcResult = move(keyno, type, UserSessionInfo.DBConn) ? "true" : "false";
  281. }
  282. return Content(lcResult);
  283. }
  284. //private bool deleteFunction(string poKey, DBConnSql poDBConn)
  285. //{
  286. // bool lcRetval = false;
  287. // Sys_Functions_info lTbl = new Sys_Functions_info(poKey, poDBConn);
  288. // if (poDBConn.ExcuteSqlTran(lTbl.DeleteSql()))
  289. // {
  290. // lcRetval = true;
  291. // }
  292. // return lcRetval;
  293. //}
  294. private bool move(string poKey, string type, DBConnSql poDbConn)
  295. {
  296. bool lcRetval = Sys_Functions_info.MoveFunction(poKey, type, poDbConn);
  297. return lcRetval;
  298. }
  299. /// <summary>
  300. /// 增加和修改功能菜单
  301. /// </summary>
  302. /// <returns></returns>
  303. [CheckPowerFilter]
  304. public ActionResult SysFunctionEditAjax()
  305. {
  306. // UserSession _UserSession = WebLibs.GetUserSession();
  307. string type = Request["Type"];
  308. string pFunctionId = Request["PFunctionID"];
  309. string functionId = Request["FunctionID"];
  310. string cNames = Request["cNames"];
  311. string cUrl = Request["cURL"];
  312. string pageName = Request["PageName"];
  313. //string modifyman = Request["modifyman"];
  314. //string modifyTime = Request["modifyTime"];
  315. string isFront = Request["IsFront"];
  316. string isBack = Request["IsBack"];
  317. string isBrowse = Request["IsBrowse"];
  318. string isAdd = Request["IsAdd"];
  319. string isDelete = Request["IsDelete"];
  320. string isUpdate = Request["IsUpdate"];
  321. string isPrint = Request["IsPrint"];
  322. string isAudit = Request["IsAudit"];
  323. Sys_Functions_info lTbl = null;
  324. if (type == "add")
  325. {
  326. lTbl = new Sys_Functions_info {TimeCreated = DateTime.Now.ToString(CultureInfo.InvariantCulture)};
  327. //lTbl.SysSetCode = Sonics.Utils.AreaToSQLcs(SysSetCode.Trim());
  328. }
  329. else if (type == "modify")
  330. {
  331. lTbl = new Sys_Functions_info(functionId.Trim(), UserSessionInfo.DBConn);
  332. if (string.IsNullOrEmpty(lTbl.FunctionName))
  333. {
  334. //Response.Write("未找到对象" + lTbl.FunctionName);
  335. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_NoExistKeyError"));
  336. }
  337. }
  338. if (lTbl != null)
  339. {
  340. lTbl.FunctionID = Utils.AreaToSQLcs(functionId);
  341. //lTbl.FatherID = Utils.AreaToSQLcs(functionID);
  342. lTbl.FunctionName = Utils.AreaToSQLcs(cNames);
  343. lTbl.IsAdd = isAdd;
  344. lTbl.IsBack = isBack;
  345. lTbl.IsBrowse = isBrowse;
  346. lTbl.IsDelete = isDelete;
  347. lTbl.IsFront = isFront;
  348. lTbl.IsAudit = isAudit;
  349. lTbl.IsPrint = isPrint;
  350. lTbl.IsUpdate = isUpdate;
  351. lTbl.URL = Utils.AreaToSQLcs(cUrl);
  352. lTbl.PageName = Utils.AreaToSQLcs(pageName);
  353. lTbl.UserIDLastMod = UserSessionInfo.UserInfo.UserCode;
  354. lTbl.TimeLastMod = DateTime.Now.ToString(CultureInfo.InvariantCulture);
  355. if (string.IsNullOrEmpty(lTbl.FunctionID) || string.IsNullOrEmpty(lTbl.FunctionName))
  356. {
  357. return Content(ErrorRebackInfo.GetErrorBackInfo(false,"0","菜单名称或编号不能为空!"));
  358. }
  359. if (type == "add")
  360. {
  361. if (string.IsNullOrEmpty(pFunctionId))
  362. {
  363. return Content(ErrorRebackInfo.GetErrorBackInfo(false, "0", "父节点编号不能为空!"));
  364. }
  365. if (SysDataLibs.AppEnv.IsExistPrKey(Tn.Sys_Functions, Sys_Functions_info.cFunctionID, lTbl.FunctionID, UserSessionInfo.DBConn))
  366. {
  367. //Response.Write("该编号已经存在!");
  368. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_IsExistKeyError"));
  369. }
  370. if (AddFunction(pFunctionId, lTbl, UserSessionInfo.DBConn))
  371. {
  372. //Alert.ShowInTop("添加成功!");
  373. //PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
  374. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  375. }
  376. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  377. }
  378. if (type == "modify")
  379. {
  380. if (UpdateFunction(functionId, lTbl, UserSessionInfo.DBConn))
  381. {
  382. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  383. }
  384. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  385. }
  386. }
  387. return null;
  388. }
  389. public ActionResult GetFunctionForEasyUiTree()
  390. {
  391. 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 +
  392. " ";
  393. //Sonics.snQuery loQuery = null;
  394. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  395. StringBuilder sb = new StringBuilder();
  396. sb.Append("[");
  397. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  398. {
  399. loQuery.MoveFirst();
  400. for (int i = 0; i < loQuery.RecCount; i++)
  401. {
  402. sb.Append("{");
  403. sb.Append("\"id\":\"" + loQuery.GetString("id") + "\",\"parentId\":\"" + loQuery.GetString("parentId") + "\",\"name\":\"" + loQuery.GetString("name") + "\"");
  404. sb.Append("},");
  405. loQuery.MoveNext();
  406. }
  407. }
  408. sb.Remove(sb.Length - 1, 1);
  409. sb.Append("]");
  410. return Content(sb.ToString());
  411. }
  412. #endregion
  413. #region Sys_Status
  414. public ActionResult SysStatusList()
  415. {
  416. return View();
  417. }
  418. public ActionResult GetSysStatusList()
  419. {
  420. string lcSql = " select * from " + Tn.Sys_Status;
  421. return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
  422. }
  423. public ActionResult GetSysStatusById()
  424. {
  425. string lcId = Request["ID"];
  426. return Content(GetData.Instance.GetResultById(Utils.AreaToSQLcs(lcId), Tn.Sys_Status, Sys_Status_info.cSysStatusID));
  427. }
  428. public ActionResult SysStatusListOper()
  429. {
  430. string type = Request["Type"];
  431. string sysStatusId = Request["SysStatusID"] ?? "";
  432. string tableName = Request["TableName"] ?? "";
  433. string colName = Request["ColName"] ?? "";
  434. string codeValue = Request["CodeValue"] ?? "";
  435. string displayValue = Request["DisplayValue"] ?? "";
  436. string lcSql;
  437. Sys_Status_info loSysStatus = (type == "Edit")||(type== "Del") ? new Sys_Status_info(Utils.AreaToSQLcs(sysStatusId), UserSessionInfo.DBConn) : new Sys_Status_info();
  438. loSysStatus.SysStatusID = Utils.AreaToSQLcs(sysStatusId);
  439. loSysStatus.TableName = Utils.AreaToSQLcs(tableName);
  440. loSysStatus.ColName = Utils.AreaToSQLcs(colName);
  441. loSysStatus.CodeValue = Utils.AreaToSQLcs(codeValue);
  442. loSysStatus.DisplayValue = Utils.AreaToSQLcs(displayValue);
  443. if (type == "Add")
  444. {
  445. lcSql = loSysStatus.InsertSql();
  446. }
  447. else if (type == "Del")
  448. {
  449. lcSql = loSysStatus.DeleteSql();
  450. }
  451. else
  452. {
  453. lcSql = loSysStatus.UpdateSql();
  454. }
  455. if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
  456. {
  457. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  458. }
  459. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  460. //return null;
  461. }
  462. #endregion
  463. #region SysHelpes
  464. public ActionResult SysHelpesList()
  465. {
  466. return View();
  467. }
  468. public ActionResult GetSysHelpesList()
  469. {
  470. string lcSql = " select * from " + Tn.Sys_Helps;
  471. return Content(GetData.Instance.GetResult(lcSql, UserSessionInfo.DBConn));
  472. }
  473. public ActionResult GetSysHelpeById()
  474. {
  475. string lcId = Request["ID"];
  476. return Content(GetData.Instance.GetResultById(Utils.AreaToSQLcs(lcId), Tn.Sys_Helps, Sys_Helps_info.cHelpId));
  477. }
  478. [ValidateInput(false)]
  479. public ActionResult SysHelpsListOper()
  480. {
  481. string type = Request["Type"];
  482. string helpId = Request["HelpId"] ?? "";
  483. string functionId = Request["FunctionId"] ?? "";
  484. string helpTitle = Request["HelpTitle"] ?? "";
  485. string helpKeyWords = Request["HelpKeyWords"] ?? "";
  486. string sequence = Request["Sequence"] ?? "";
  487. string helpContent = Request["HelpContent"] ?? "";
  488. string lcSql;
  489. Sys_Helps_info loSysHelps = (type == "Edit") || (type == "Del") ? new Sys_Helps_info(Utils.AreaToSQLcs(helpId), UserSessionInfo.DBConn) : new Sys_Helps_info();
  490. loSysHelps.HelpId = Utils.AreaToSQLcs(helpId);
  491. loSysHelps.FunctionId = Utils.AreaToSQLcs(functionId);
  492. loSysHelps.HelpTitle = Utils.AreaToSQLcs(helpTitle);
  493. loSysHelps.HelpKeyWords = Utils.AreaToSQLcs(helpKeyWords);
  494. loSysHelps.Sequence = Utils.AreaToSQLcs(sequence);
  495. loSysHelps.HelpContent = helpContent;
  496. if (type == "Add")
  497. {
  498. lcSql = loSysHelps.InsertSql();
  499. }
  500. else if (type == "Del")
  501. {
  502. lcSql = loSysHelps.DeleteSql();
  503. }
  504. else
  505. {
  506. lcSql = loSysHelps.UpdateSql();
  507. }
  508. if (UserSessionInfo.DBConn.ExecuteSql(lcSql))
  509. {
  510. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_Success"));
  511. }
  512. //return Content("{\"Success\":\"false\",\"errorInfo\":\"" + "操作失败!" + UserSessionInfo.DBConn.ErrorMsg + "\"}");
  513. return Content(SysRebackDisplayInfo.Instance.GetDisplayValue("Oper_DBError"));
  514. }
  515. [HttpPost]
  516. public ActionResult UploadImage()
  517. {
  518. string savePath = "../Images/upload/Helps/";
  519. //string saveUrl = "http://www.cnblogs.com/Content/Images/";
  520. string fileTypes = "gif,jpg,jpeg,png,bmp";
  521. int maxSize = 1000000;
  522. Hashtable hash;
  523. HttpPostedFileBase file = Request.Files["imgFile"];
  524. if (file == null)
  525. {
  526. hash = new Hashtable
  527. {
  528. ["error"] = 0,
  529. ["url"] = "请选择文件"
  530. };
  531. return Json(hash);
  532. }
  533. string dirPath = Server.MapPath(savePath);
  534. if (!Directory.Exists(dirPath))
  535. {
  536. hash = new Hashtable
  537. {
  538. ["error"] = 0,
  539. ["url"] = "上传目录不存在"
  540. };
  541. return Json(hash);
  542. }
  543. string fileName = file.FileName;
  544. string fileExt="";
  545. if (!string.IsNullOrEmpty(fileName))
  546. fileExt = Path.GetExtension(fileName).ToLower();
  547. //ArrayList fileTypeList = ArrayList.Adapter(fileTypes.Split(','));
  548. if (file.InputStream == null || file.InputStream.Length > maxSize)
  549. {
  550. hash = new Hashtable
  551. {
  552. ["error"] = 0,
  553. ["url"] = "上传文件大小超过限制"
  554. };
  555. return Json(hash);
  556. }
  557. if (string.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
  558. {
  559. hash = new Hashtable
  560. {
  561. ["error"] = 0,
  562. ["url"] = "上传文件扩展名是不允许的扩展名"
  563. };
  564. return Json(hash);
  565. }
  566. string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
  567. string filePath = dirPath + newFileName;
  568. file.SaveAs(filePath);
  569. string fileUrl = savePath + newFileName;
  570. hash = new Hashtable
  571. {
  572. ["error"] = 0,
  573. ["url"] = fileUrl
  574. };
  575. return Json(hash, "text/html;charset=UTF-8");
  576. }
  577. /// <summary>
  578. /// 帮助页面
  579. /// </summary>
  580. /// <returns></returns>
  581. public ActionResult SysHelpsShow()
  582. {
  583. string lcSql = "SELECT * FROM " + Tn.Sys_Helps + " WHERE " + Sys_Helps_info.cFunctionId + " IN ( " + UserSessionInfo.UserFunctionIdList + " ) ORDER BY Sequence ";
  584. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  585. //StringBuilder loOutHeader = new StringBuilder();
  586. //StringBuilder loOutContent = new StringBuilder();
  587. var loHelpList = new List<HelpViewModel>();
  588. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  589. {
  590. loQuery.MoveFirst();
  591. //loOutHeader.AppendFormat(
  592. // "<a name=\"directorylists\" id=\"directorylists\"></a><font size=3><b><center>目录</center></b></font><br>");
  593. for (int i = 0; i < loQuery.RecCount; i++)
  594. {
  595. //string lcHref = loQuery.GetString("HelpId") + "_" + loQuery.GetString("Sequence");
  596. //loOutHeader.AppendFormat("<b>{0}&nbsp;&nbsp;<a href=\"#{1}\"> <font size=2>{2}</font></a></b><br>", (i + 1) + "",
  597. // lcHref, loQuery.GetString("HelpTitle"));
  598. //loOutContent.AppendFormat(
  599. // "<a name=\"{0}\" id=\"{0}\"></a> <b>{1}&nbsp; <font size=3 color=blue>{2}</font></b> <br> {3}<br>",
  600. // lcHref, (i + 1) + "", loQuery.GetString("HelpTitle"), loQuery.GetString("HelpContent"));
  601. loHelpList.Add(new HelpViewModel()
  602. {
  603. HelpId = loQuery.GetString("HelpId"),
  604. FunctionId = loQuery.GetString("FunctionId"),
  605. HelpTitle = loQuery.GetString("HelpTitle"),
  606. HelpKeyWords = loQuery.GetString("HelpKeyWords"),
  607. HelpContent = loQuery.GetString("HelpContent"),
  608. Sequence = loQuery.GetString("Sequence"),
  609. });
  610. loQuery.MoveNext();
  611. }
  612. }
  613. //ViewBag.HlepHeader = loOutHeader.ToString();
  614. //ViewBag.HelpContent = loOutContent.ToString();
  615. return View(loHelpList);
  616. }
  617. #endregion
  618. #region SysLogView
  619. public ActionResult SysLogView()
  620. {
  621. ViewBag.SelSysLogType = GetData.Instance.GetSelStr(Sys_Log_info.cSysLogType,Tn.Sys_Log,UserSessionInfo.DBConn);
  622. return View();
  623. }
  624. public ActionResult GetSysLogList()
  625. {
  626. string lcSql = " 1=1 ";
  627. string rows = Request["rows"];
  628. string page = Request["page"];
  629. string userId = Utils.AreaToSQLcs(Request["UserID"]).Trim();
  630. string startTime = Utils.AreaToSQLcs(Request["StartTime"]).Trim();
  631. string endTime = Utils.AreaToSQLcs(Request["EndTime"]).Trim();
  632. string sysLogTypeId = Utils.AreaToSQLcs(Request["SysLogTypeID"]).Trim();
  633. if (!string.IsNullOrEmpty(userId))
  634. {
  635. lcSql += " and " + Sys_Log_info.cUserId + " = '" + userId + "'";
  636. }
  637. if (!string.IsNullOrEmpty(startTime))
  638. {
  639. lcSql += " and " + Sys_Log_info.cLogDate + " > '" + startTime + "'";
  640. }
  641. if (!string.IsNullOrEmpty(endTime))
  642. {
  643. lcSql += " and " + Sys_Log_info.cLogDate + " < '" + endTime + "'";
  644. }
  645. if (!string.IsNullOrEmpty(sysLogTypeId))
  646. {
  647. lcSql += " and " + Sys_Log_info.cSysLogType + " = '" + sysLogTypeId + "'";
  648. }
  649. 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));
  650. }
  651. #endregion
  652. #region SpecialFunction
  653. public ActionResult SFunction()
  654. {
  655. return View();
  656. }
  657. public ActionResult SFunctionExecNone()
  658. {
  659. string lcResult = "";
  660. string lcSql = Request["txtScript"];
  661. string type = Utils.AreaToSQLcs(Request["Type"]);
  662. if (!UserSessionInfo.IsSystem && !UserSessionInfo.IsAdvance)
  663. {
  664. return Content("没有权限执行该操作");
  665. }
  666. if (type == "0")
  667. {
  668. lcResult = UserSessionInfo.DBConn.ExcuteSqlTran(lcSql) ? "执行成功" : UserSessionInfo.DBConn.ErrorMsg;
  669. }
  670. else if (type == "1")
  671. {
  672. try
  673. {
  674. rsQuery loQuery = UserSessionInfo.DBConn.OpenQuery(lcSql);
  675. if (loQuery != null && loQuery.IsOpened)
  676. {
  677. // txtScript0.Text = (loQuery.CurrentTable);
  678. StringBuilder loBuilder = new StringBuilder();
  679. loBuilder.AppendLine("AllFields:" + loQuery.AllFields);
  680. loBuilder.AppendLine();
  681. loBuilder.AppendLine("RecCount:" + loQuery.RecCount);
  682. Array array1 = UtilStr.StrToArray(loQuery.AllFields);
  683. loQuery.MoveFirst();
  684. loBuilder.AppendLine();
  685. loBuilder.AppendLine("<Records>");
  686. for (int i = 0; i < loQuery.RecCount; i++)
  687. {
  688. loBuilder.AppendLine(" <record>");
  689. for (int j = 0; j < array1.Length; j++)
  690. {
  691. string lcField = array1.GetValue(j).ToString();
  692. loBuilder.AppendLine(" <" + lcField + ">" + loQuery.GetString(lcField) + "</" + lcField + ">");
  693. }
  694. loBuilder.AppendLine(" </record>");
  695. loQuery.MoveNext();
  696. }
  697. loBuilder.AppendLine("</Records>");
  698. lcResult = loBuilder.ToString();
  699. }
  700. else
  701. lcResult = "执行错误";
  702. }
  703. catch (Exception err)
  704. {
  705. lcResult += "\r\nSource:\r\n" + err.Source;
  706. lcResult += "\r\nStackTrace:\r\n" + err.StackTrace;
  707. lcResult += "\r\nMessage:\r\n" + err.Message;
  708. }
  709. }
  710. return Content(lcResult);
  711. }
  712. public ActionResult SFunctionExecQuery()
  713. {
  714. string lcContent = Server.UrlDecode(Request["txtHttpContent"]);
  715. string lcUrl = Request["url"];
  716. //string lcDataStr = JsonConvert.SerializeObject(lcContent);
  717. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(lcUrl);
  718. request.Method = "POST";
  719. request.ContentType = "application/x-www-form-urlencoded";
  720. //request.ContentLength = Encoding.GetEncoding("GB2312").GetByteCount(lcContent);
  721. byte[] data = Encoding.GetEncoding("GB2312").GetBytes(lcContent);
  722. request.ContentLength = data.Length;
  723. Stream newStream = request.GetRequestStream();
  724. newStream.Write(data, 0, data.Length);
  725. newStream.Close();
  726. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  727. Stream res = response.GetResponseStream();
  728. if (res != null)
  729. {
  730. StreamReader resReader = new StreamReader(res, Encoding.GetEncoding("utf-8"));
  731. string retString = resReader.ReadToEnd();
  732. resReader.Close();
  733. res.Close();
  734. //return retString;
  735. return Content(retString);
  736. }
  737. return Content("NULL");
  738. }
  739. #endregion
  740. /// <summary>
  741. /// 万年历 页面
  742. /// </summary>
  743. /// <returns></returns>
  744. public ActionResult Calendar()
  745. {
  746. ViewBag.SelSystemIDInfo = GetData.Instance.GetSelStr(GSSystem_info.cSystemID, GSSystem_info.cshortName, Tn.GSSystem, GSSystem_info.cSystemType + "='N'", UserSessionInfo.DBConn);
  747. ViewBag.SelRegionInfo = GetData.Instance.GetSelStr(Regions_info.cRegionID, Regions_info.cNames, Tn.Regions, UserSessionInfo.DBConn);
  748. return View();
  749. }
  750. /// <summary>
  751. /// 获取Requset[key]值,并ToSQL处理
  752. /// </summary>
  753. /// <param name="key"></param>
  754. /// <param name="type"></param>
  755. /// <returns></returns>
  756. private string GetRequest(string key, string type = "string")
  757. {
  758. string lcRetval = Request[key] ?? "";
  759. if (type.ToLower() == "int")
  760. lcRetval = GetData.Instance.SetIntDefault(lcRetval);
  761. return Utils.AreaToSQLcs(lcRetval);
  762. }
  763. }
  764. }