地铁二期项目正式开始

SystemManageController.cs 69KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. using YTSoft.BaseCallCenter.Model;
  12. using YTSoft.BaseCallCenter.MVCWeb.Commons;
  13. using YTSoft.BaseCallCenter.MVCWeb.Models;
  14. using YTSoft.Common;
  15. using YTSoft.DBUtility;
  16. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  17. {
  18. public class SystemManageController : BaseController
  19. {
  20. #region 部门管理
  21. BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
  22. BLL.T_SYS_Time timeBLL = new BLL.T_SYS_Time();
  23. BLL.T_Sys_UserAccount userbll = new BLL.T_Sys_UserAccount();
  24. BLL.T_RiskLevel levelbll = new BLL.T_RiskLevel();
  25. public static BLL.T_SMS_InternalMessages mesbll = new BLL.T_SMS_InternalMessages();
  26. /// <summary>
  27. /// 部门列表
  28. /// </summary>
  29. /// <returns></returns>
  30. public ActionResult DepartmentList()
  31. {
  32. WorkOrderMyModel model = new WorkOrderMyModel();
  33. return View(model);
  34. }
  35. ///通过部门父级节点获取数据
  36. /// </summary>
  37. /// <param name="fid"></param>
  38. /// <returns></returns>
  39. public string GetDepartmentJsonModel(int parentId)
  40. {
  41. AddAction("t_sys_department", parentId.ToMyString(), "获取父级树结构", "");
  42. return Newtonsoft.Json.JsonConvert.SerializeObject(deptBLL.GetDepartmentJsonModel(parentId));
  43. }
  44. /// <summary>
  45. /// 部门编辑
  46. /// </summary>
  47. /// <param name="editType">类型1、新增 2、修改</param>
  48. /// /// <returns></returns>
  49. public ActionResult DepartmentEdit(int deptId, int editType)
  50. {
  51. AddAction("t_sys_department", deptId.ToMyString(), "打开部门编辑页面", "");
  52. Model.T_Sys_Department viewModel = new Model.T_Sys_Department();
  53. //当前对象实体
  54. if (editType == 1)
  55. {
  56. viewModel.F_ParentId = deptId;
  57. viewModel.F_Sort = 1;
  58. }
  59. else
  60. {
  61. Model.T_Sys_Department deptModel = deptBLL.GetModel(deptId);
  62. viewModel = deptModel;
  63. }
  64. return View(viewModel);
  65. }
  66. /// <summary>
  67. /// 保存编辑
  68. /// </summary>
  69. /// <param name="workOrderBaseModel"></param>
  70. /// <returns></returns>
  71. [AcceptVerbs(HttpVerbs.Post)]
  72. public bool SaveDeptData(T_Sys_Department deptModel)
  73. {
  74. if (deptModel.F_DeptId > 0)
  75. {
  76. AddAction("t_sys_department", deptModel.F_DeptId.ToMyString(), "更新部门", deptModel.F_DeptName);
  77. return deptBLL.Update(deptModel);
  78. }
  79. else
  80. {
  81. int id = deptBLL.Add(deptModel);
  82. AddAction("t_sys_department", id.ToMyString(), "添加部门", deptModel.F_DeptName);
  83. return id> 0;
  84. }
  85. }
  86. /// <summary>
  87. /// 删除部门
  88. /// </summary>
  89. /// <param name="workOrderBaseModel"></param>
  90. /// <returns></returns>
  91. [AcceptVerbs(HttpVerbs.Get)]
  92. public bool DeleteDeptData(int deptId)
  93. {
  94. AddAction("t_sys_department", deptId.ToMyString(), "删除部门");
  95. return deptBLL.Delete(deptId);
  96. }
  97. /// <summary>
  98. /// 获取部门数据
  99. /// </summary>
  100. /// <param name="page">当前页码</param>
  101. /// <param name="limit">每页数据量</param>
  102. /// <returns></returns>
  103. [ActionName("DeptDate")]
  104. [HttpGet]
  105. public string DeptDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  106. {
  107. //数据结果集
  108. ResponseData dataModel = new ResponseData();
  109. string sql = "";
  110. if (parentId != null)
  111. {
  112. sql += " and F_ParentId=" + parentId;
  113. }
  114. DataTable dt = new DataTable();
  115. int recordCount = 0;
  116. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  117. dt = BLL.PagerBLL.GetListPager(
  118. "T_Sys_Department",
  119. "F_DeptId",
  120. "*",
  121. sql,
  122. "ORDER BY F_Sort asc ",
  123. limit,
  124. page,
  125. true,
  126. out recordCount);
  127. dataModel.code = 0;
  128. dataModel.count = recordCount;
  129. dataModel.data = dt;
  130. AddAction("t_sys_department", parentId.ToMyString(), "获取部门列表", "");
  131. return JsonConvert.SerializeObject(dataModel);
  132. }
  133. #endregion
  134. #region 角色管理
  135. BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
  136. public ActionResult RoleList()
  137. {
  138. WorkOrderMyModel model = new WorkOrderMyModel();
  139. return View(model);
  140. }
  141. /// <summary>
  142. /// 获取角色列表
  143. /// </summary>
  144. /// <param name="page">当前页码</param>
  145. /// <param name="limit">每页数据量</param>
  146. /// <returns></returns>
  147. [ActionName("RoleDate")]
  148. [HttpGet]
  149. public string RoleDate(DateTime? NowDateTime, int page, int limit)
  150. {
  151. AddAction("t_sys_roleinfo", "page", "查询角色列表",page.ToMyString()+"-"+ limit.ToMyString());
  152. //数据结果集
  153. ResponseData dataModel = new ResponseData();
  154. string sql = "";
  155. DataTable dt = new DataTable();
  156. int recordCount = 0;
  157. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  158. dt = BLL.PagerBLL.GetListPager(
  159. "T_Sys_RoleInfo",
  160. "F_RoleId",
  161. "*",
  162. sql,
  163. "ORDER BY F_RoleId",
  164. limit,
  165. page,
  166. true,
  167. out recordCount);
  168. dataModel.code = 0;
  169. dataModel.count = recordCount;
  170. dataModel.data = dt;
  171. return JsonConvert.SerializeObject(dataModel);
  172. }
  173. /// <summary>
  174. /// 编辑角色
  175. /// </summary>
  176. /// <returns></returns>
  177. public ActionResult RoleEdit(int? roleId)
  178. {
  179. Model.T_Sys_RoleInfo viewModel = new Model.T_Sys_RoleInfo();
  180. if (roleId != null && roleId > 0)
  181. {
  182. viewModel = roleBLL.GetModel(int.Parse(roleId.ToString()));
  183. AddAction("t_sys_roleinfo", roleId.ToMyString(), "打开角色编辑页", "角色名称:"+ viewModel.F_RoleName, "敏感信息");
  184. }
  185. return View(viewModel);
  186. }
  187. /// <summary>
  188. /// 保存编辑
  189. /// </summary>
  190. /// <param name="workOrderBaseModel"></param>
  191. /// <returns></returns>
  192. [AcceptVerbs(HttpVerbs.Post)]
  193. public bool SaveRoleEdit(T_Sys_RoleInfo roleInfoModel)
  194. {
  195. roleInfoModel.F_RoleCode = roleInfoModel.F_RoleCode.ToMyString();
  196. if (roleInfoModel.F_RoleId > 0)
  197. {
  198. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", roleInfoModel.F_RoleName);
  199. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", "数据:" + JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  200. return roleBLL.Update(roleInfoModel);
  201. }
  202. else
  203. {
  204. int id = roleBLL.Add(roleInfoModel);
  205. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", roleInfoModel.F_RoleName);
  206. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", "数据:" +JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  207. return id > 0;
  208. }
  209. }
  210. /// <summary>
  211. /// 删除数据
  212. /// </summary>
  213. /// <param name="workOrderBaseModel"></param>
  214. /// <returns></returns>
  215. [AcceptVerbs(HttpVerbs.Get)]
  216. public bool DeleteRoleData(string roleId)
  217. {
  218. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色");
  219. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色", "数据:" + roleId.ToMyString(), "敏感信息");
  220. return roleBLL.DeleteList(roleId);
  221. }
  222. #endregion
  223. #region 获取菜单树
  224. public class DicSeaarchModel
  225. {
  226. public string RootCode
  227. {
  228. get;
  229. set;
  230. }
  231. }
  232. /// <summary>
  233. /// 初始化字典结构
  234. /// </summary>
  235. /// <param name="rootCode"></param>
  236. /// <returns></returns>
  237. public ActionResult MenuTree(string rootCode)
  238. {
  239. DicSeaarchModel model = new DicSeaarchModel();
  240. model.RootCode = rootCode;
  241. return View(model);
  242. }
  243. /// <summary>
  244. /// 获取字典数据
  245. /// </summary>
  246. /// <param name="rootCode"></param>
  247. /// <returns></returns>
  248. public string GetMenuTreeData(int roleId)
  249. {
  250. try
  251. {
  252. AddAction("T_Sys_ModuleFunctions".ToLower(), roleId.ToMyString(), "获取角色字典", "角色id"+ roleId.ToMyString());
  253. return "[" + Newtonsoft.Json.JsonConvert.SerializeObject(roleBLL.GetMenuTree(roleId)).Replace("Checked", "checked") + "]";
  254. }
  255. catch (Exception ex)
  256. {
  257. return "";
  258. }
  259. }
  260. /// <summary>
  261. ///授权
  262. /// </summary>
  263. /// <returns></returns>
  264. [AcceptVerbs(HttpVerbs.Get)]
  265. public bool AcceptList(int roleId, string MenuIdStr)
  266. {
  267. bool accRersult = false;
  268. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权", "角色id" + roleId.ToMyString()+"功能菜单"+ MenuIdStr);
  269. if (roleBLL.AddRolesMenuList(roleId, MenuIdStr))
  270. {
  271. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权角色功能", string.Format("给角色{0}授权菜单功能{1}", roleId, MenuIdStr), "敏感信息");
  272. accRersult = true;
  273. }
  274. return accRersult;
  275. }
  276. #endregion
  277. #region 业务类型管理
  278. BLL.T_Wo_WorkOrderType dicTittleBLL = new BLL.T_Wo_WorkOrderType();
  279. public ActionResult BusinessTypeList()
  280. {
  281. WorkOrderMyModel model = new WorkOrderMyModel();
  282. return View(model);
  283. }
  284. ///通过dic编码获取dic值
  285. /// </summary>
  286. /// <param name="fid"></param>
  287. /// <returns></returns>
  288. public string GetDicTittleJson(int parentId)
  289. {
  290. AddAction("t_wo_workordertype".ToLower(), parentId.ToMyString(), "获取业务类型");
  291. return Newtonsoft.Json.JsonConvert.SerializeObject(dicTittleBLL.GetDicTittleJsonModel(parentId));
  292. }
  293. /// <summary>
  294. /// 获取业务类型数据
  295. /// </summary>
  296. /// <param name="page">当前页码</param>
  297. /// <param name="limit">每页数据量</param>
  298. /// <returns></returns>
  299. [ActionName("OrderTypeDate")]
  300. [HttpGet]
  301. public string OrderTypeDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  302. {
  303. AddAction("t_wo_workordertype".ToLower(),"page", "获取业务类型列表", page.ToMyString() + "-" + limit.ToMyString());
  304. //数据结果集
  305. ResponseData dataModel = new ResponseData();
  306. string sql = "";
  307. if (parentId != null && parentId > 0)
  308. {
  309. sql += " and F_ParentId=" + parentId;
  310. }
  311. DataTable dt = new DataTable();
  312. int recordCount = 0;
  313. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  314. dt = BLL.PagerBLL.GetListPager(
  315. "T_Wo_WorkOrderType",
  316. "F_WorkOrderTypeId",
  317. "*",
  318. sql,
  319. "ORDER BY F_Sort asc ",
  320. limit,
  321. page,
  322. true,
  323. out recordCount);
  324. dataModel.code = 0;
  325. dataModel.count = recordCount;
  326. dataModel.data = dt;
  327. return JsonConvert.SerializeObject(dataModel);
  328. }
  329. /// <summary>
  330. /// 编辑业务类型
  331. /// </summary>
  332. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  333. /// <param name="editType">类型1、新增 2、修改</param>
  334. /// <returns></returns>
  335. public ActionResult BussinessTypeEdit(int F_WorkOrderTypeId, int editType)
  336. {
  337. AddAction("t_wo_workordertype".ToLower(), F_WorkOrderTypeId.ToMyString(), "打开业务类型编辑页");
  338. Model.T_Wo_WorkOrderType viewModel = new Model.T_Wo_WorkOrderType();
  339. //当前对象实体
  340. Model.T_Wo_WorkOrderType orderTypeModel = dicTittleBLL.GetModel(F_WorkOrderTypeId);
  341. if (editType == 1)
  342. {
  343. viewModel.F_ParentId = orderTypeModel.F_WorkOrderTypeId;
  344. viewModel.F_ParentName = orderTypeModel.F_ParentName;
  345. viewModel.F_Sort = 1;
  346. }
  347. else
  348. {
  349. viewModel = orderTypeModel;
  350. }
  351. return View(viewModel);
  352. }
  353. /// <summary>
  354. /// 保存编辑
  355. /// </summary>
  356. /// <param name="workOrderBaseModel"></param>
  357. /// <returns></returns>
  358. [AcceptVerbs(HttpVerbs.Post)]
  359. public bool SaveBussiTypeData(T_Wo_WorkOrderType WorkOrderTypeModel)
  360. {
  361. ////当前用户信息
  362. //workOrderBaseModel.F_USERID = F_UserID;//id
  363. //workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
  364. //workOrderBaseModel.F_REPAIRMANNAME = "12";//姓名
  365. if (WorkOrderTypeModel.F_WorkOrderTypeId > 0)
  366. {
  367. AddAction("t_wo_workordertype", WorkOrderTypeModel.F_WorkOrderTypeId.ToMyString(), "更新工单分类",WorkOrderTypeModel.F_Name);
  368. return dicTittleBLL.Update(WorkOrderTypeModel) > 0;
  369. }
  370. else
  371. {
  372. int id = dicTittleBLL.Add(WorkOrderTypeModel);
  373. AddAction("t_wo_workordertype", id.ToMyString(), "添加工单分类", WorkOrderTypeModel.F_Name);
  374. return id > 0;
  375. }
  376. }
  377. /// <summary>
  378. /// 删除数据
  379. /// </summary>
  380. /// <param name="workOrderBaseModel"></param>
  381. /// <returns></returns>
  382. [AcceptVerbs(HttpVerbs.Get)]
  383. public bool DeleteBussiTypeData(int WorkOrderTypeId)
  384. {
  385. AddAction("T_Sys_ModuleFunctions", WorkOrderTypeId.ToMyString(), "删除工单分类","", "敏感信息");
  386. AddAction("t_wo_workordertype", WorkOrderTypeId.ToMyString(), "删除工单分类");
  387. return dicTittleBLL.Delete(WorkOrderTypeId);
  388. }
  389. #endregion
  390. #region 字典管理
  391. BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  392. BLL.T_Sys_DictionaryBase dicBaseBLL = new BLL.T_Sys_DictionaryBase();
  393. /// <summary>
  394. /// 字典列表
  395. /// </summary>
  396. /// <returns></returns>
  397. public ActionResult DictionaryList()
  398. {
  399. WorkOrderMyModel model = new WorkOrderMyModel();
  400. return View(model);
  401. }
  402. ///通过字典获取数据
  403. /// </summary>
  404. /// <param name="fid"></param>
  405. /// <returns></returns>
  406. public string GetDictionaryJsonModel(int parentId)
  407. {
  408. return Newtonsoft.Json.JsonConvert.SerializeObject(dicBaseBLL.GetDictionaryJsonModel());
  409. }
  410. /// <summary>
  411. /// 获取字典值数据
  412. /// </summary>
  413. /// <param name="page">当前页码</param>
  414. /// <param name="limit">每页数据量</param>
  415. /// <returns></returns>
  416. [ActionName("DictionaryDate")]
  417. [HttpGet]
  418. public string DictionaryDate(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  419. {
  420. AddAction("t_sys_dictionarybase".ToLower(),"page", "获取字典列表", page+"-"+ limit);
  421. //数据结果集
  422. ResponseData dataModel = new ResponseData();
  423. string sql = "";
  424. if (!string.IsNullOrEmpty(dictionaryFlag) && dictionaryFlag != "0")
  425. {
  426. sql += " and F_DictionaryFlag='" + dictionaryFlag + "'";
  427. }
  428. DataTable dt = new DataTable();
  429. int recordCount = 0;
  430. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  431. if (string.IsNullOrEmpty(dictionaryFlag) || dictionaryFlag != "0")
  432. {
  433. dt = BLL.PagerBLL.GetListPager(
  434. "T_Sys_DictionaryValue",
  435. "F_DictionaryValueId",
  436. "*",
  437. sql,
  438. "ORDER BY F_Sort asc ",
  439. limit,
  440. page,
  441. true,
  442. out recordCount);
  443. }
  444. else
  445. {
  446. dt = BLL.PagerBLL.GetListPager(
  447. "T_Sys_DictionaryBase",
  448. "F_DictionaryName",
  449. "*,F_DictionaryName as F_Name",
  450. sql,
  451. "ORDER BY F_Sort asc ",
  452. limit,
  453. page,
  454. true,
  455. out recordCount);
  456. }
  457. dataModel.code = 0;
  458. dataModel.count = recordCount;
  459. dataModel.data = dt;
  460. return JsonConvert.SerializeObject(dataModel);
  461. }
  462. /// <summary>
  463. /// 获取字典值数据
  464. /// </summary>
  465. /// <param name="page">当前页码</param>
  466. /// <param name="limit">每页数据量</param>
  467. /// <returns></returns>
  468. [ActionName("DictionaryDateOut")]
  469. [HttpGet]
  470. public string DictionaryDateOut(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  471. {
  472. AddAction("t_sys_dictionarybase".ToLower(), "page", "获取字典列表", page + "-" + limit);
  473. //数据结果集
  474. ResponseData dataModel = new ResponseData();
  475. string sql = "and (F_DictionaryFlag='ZDXX' OR F_DictionaryFlag='ZDXX2')";
  476. DataTable dt = new DataTable();
  477. int recordCount = 0;
  478. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  479. dt = BLL.PagerBLL.GetListPager(
  480. "T_Sys_DictionaryValue",
  481. "F_DictionaryValueId",
  482. "*",
  483. sql,
  484. "ORDER BY F_Sort asc ",
  485. limit,
  486. page,
  487. true,
  488. out recordCount);
  489. dataModel.code = 0;
  490. dataModel.count = recordCount;
  491. dataModel.data = dt;
  492. return JsonConvert.SerializeObject(dataModel);
  493. }
  494. /// <summary>
  495. /// 字典项编辑
  496. /// </summary>
  497. /// <param name="editType">类型1、新增 2、修改</param>
  498. /// /// <returns></returns>
  499. public ActionResult DictionaryBaseEdit(string dicCode, int editType)
  500. {
  501. AddAction("t_sys_dictionarybase".ToLower(), dicCode, "打开字典编辑页");
  502. Model.T_Sys_DictionaryBase viewModel = new Model.T_Sys_DictionaryBase();
  503. //当前对象实体
  504. if (editType == 1)
  505. {
  506. viewModel.F_Sort = 1;
  507. }
  508. else
  509. {
  510. Model.T_Sys_DictionaryBase dicBaseModel = dicBaseBLL.GetModel(dicCode);
  511. viewModel = dicBaseModel;
  512. }
  513. return View(viewModel);
  514. }
  515. /// <summary>
  516. /// 保存字典项编辑
  517. /// </summary>
  518. /// <param name="workOrderBaseModel"></param>
  519. /// <returns></returns>
  520. [AcceptVerbs(HttpVerbs.Post)]
  521. public bool SaveDictionaryBaseData(T_Sys_DictionaryBase dicBaseModel)
  522. {
  523. try
  524. {
  525. if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
  526. {
  527. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "更新字典项");
  528. return dicBaseBLL.Update(dicBaseModel);
  529. }
  530. else
  531. {
  532. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "添加字典项");
  533. return dicBaseBLL.Add(dicBaseModel);
  534. }
  535. }
  536. catch (Exception ex)
  537. {
  538. LogHelper.Default.WriteError("字典操作失败",ex);
  539. return false;
  540. }
  541. }
  542. /// <summary>
  543. /// 删除字典项
  544. /// </summary>
  545. /// <param name="workOrderBaseModel"></param>
  546. /// <returns></returns>
  547. [AcceptVerbs(HttpVerbs.Get)]
  548. public bool DeleteBaseData(string baseCode)
  549. {
  550. AddAction("t_sys_dictionarybase", baseCode,"删除字典项");
  551. return dicBaseBLL.Delete(baseCode);
  552. }
  553. /// <summary>
  554. /// 字典值编辑
  555. /// </summary>
  556. /// <param name="editType">类型1、新增 2、修改</param>
  557. /// /// <returns></returns>
  558. public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
  559. {
  560. AddAction("t_sys_dictionarybase".ToLower(), valueId.ToMyString(), "打开字典值编辑页");
  561. Model.T_Sys_DictionaryValue viewModel = new Model.T_Sys_DictionaryValue();
  562. //当前对象实体
  563. if (editType == 1)
  564. {
  565. viewModel.F_Sort = 1;
  566. viewModel.F_DictionaryFlag = parentCode;
  567. }
  568. else
  569. {
  570. Model.T_Sys_DictionaryValue dicValueModel = dicValueBLL.GetModel(int.Parse(valueId.ToString()));
  571. viewModel = dicValueModel;
  572. }
  573. return View(viewModel);
  574. }
  575. /// <summary>
  576. /// 保存字典值
  577. /// </summary>
  578. /// <param name="workOrderBaseModel"></param>
  579. /// <returns></returns>
  580. [AcceptVerbs(HttpVerbs.Post)]
  581. public bool SaveDictionaryValueData(T_Sys_DictionaryValue dicBaseModel)
  582. {
  583. if (dicBaseModel.F_DictionaryValueId > 0)
  584. {
  585. AddAction("t_sys_dictionaryvalue", dicBaseModel.F_DictionaryValueId.ToMyString(), "更新字典值");
  586. return dicValueBLL.Update(dicBaseModel);
  587. }
  588. else
  589. {
  590. int id = dicValueBLL.Add(dicBaseModel);
  591. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "添加字典值");
  592. return id > 0;
  593. }
  594. }
  595. /// <summary>
  596. /// 删除字典值
  597. /// </summary>
  598. /// <param name="workOrderBaseModel"></param>
  599. /// <returns></returns>
  600. [AcceptVerbs(HttpVerbs.Get)]
  601. public bool DeleteValueData(int id)
  602. {
  603. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "删除字典值");
  604. return dicValueBLL.Delete(id);
  605. }
  606. #endregion
  607. #region 菜单管理
  608. BLL.T_Sys_ModuleFunctions menuBLL = new BLL.T_Sys_ModuleFunctions();
  609. /// <summary>
  610. /// 部门列表
  611. /// </summary>
  612. /// <returns></returns>
  613. public ActionResult MenuList()
  614. {
  615. WorkOrderMyModel model = new WorkOrderMyModel();
  616. return View(model);
  617. }
  618. ///通过部门父级节点获取数据
  619. /// </summary>
  620. /// <param name="fid"></param>
  621. /// <returns></returns>
  622. public string GetMenuJsonModel(int parentId)
  623. {
  624. AddAction("t_sys_modulefunctions", parentId.ToMyString(), "获取父级下菜单","父级id:"+ parentId);
  625. return Newtonsoft.Json.JsonConvert.SerializeObject(menuBLL.GetMenuJsonModel(parentId));
  626. }
  627. /// <summary>
  628. /// 获取部门数据
  629. /// </summary>
  630. /// <param name="page">当前页码</param>
  631. /// <param name="limit">每页数据量</param>
  632. /// <returns></returns>
  633. [ActionName("MenuDate")]
  634. [HttpGet]
  635. public string MenuDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  636. {
  637. AddAction("t_sys_modulefunctions", "page", "获取菜单列表",page+"-"+limit);
  638. //数据结果集
  639. ResponseData dataModel = new ResponseData();
  640. string sql = "";
  641. if (parentId != null)
  642. {
  643. sql += " and F_ParentId=" + parentId;
  644. }
  645. DataTable dt = new DataTable();
  646. int recordCount = 0;
  647. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  648. dt = BLL.PagerBLL.GetListPager(
  649. "T_Sys_ModuleFunctions",
  650. "F_FunctionId",
  651. "* ,(CASE F_StateFlag WHEN 1 THEN '启用' WHEN 0 THEN '禁用' ELSE NULL END ) as F_StateFlagName",
  652. sql,
  653. "ORDER BY F_Sort asc ",
  654. limit,
  655. page,
  656. true,
  657. out recordCount);
  658. dataModel.code = 0;
  659. dataModel.count = recordCount;
  660. dataModel.data = dt;
  661. return JsonConvert.SerializeObject(dataModel);
  662. }
  663. /// <summary>
  664. /// 功能编辑
  665. /// </summary>
  666. /// <param name="editType">类型1、新增 2、修改</param>
  667. /// /// <returns></returns>
  668. public ActionResult MenuEdit(int menuId, int editType)
  669. {
  670. Model.T_Sys_ModuleFunctions viewModel = new Model.T_Sys_ModuleFunctions();
  671. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "打开功能编辑页", "菜单编号"+ menuId);
  672. //当前对象实体
  673. if (editType == 1)
  674. {
  675. viewModel.F_ParentId = menuId;
  676. viewModel.F_Sort = 1;
  677. }
  678. else
  679. {
  680. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  681. viewModel = deptModel;
  682. }
  683. return View(viewModel);
  684. }
  685. /// <summary>
  686. /// 保存编辑
  687. /// </summary>
  688. /// <param name="workOrderBaseModel"></param>
  689. /// <returns></returns>
  690. [AcceptVerbs(HttpVerbs.Post)]
  691. public bool SaveMenuData(T_Sys_ModuleFunctions menuModel)
  692. {
  693. if (menuModel.F_FunctionId > 0)
  694. {
  695. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", menuModel.F_Name);
  696. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", "数据:"+JsonConvert.SerializeObject(menuModel), "主要设置");
  697. return menuBLL.Update(menuModel);
  698. }
  699. else
  700. {
  701. int id = menuBLL.Add(menuModel);
  702. AddAction("t_sys_modulefunctions", id.ToMyString(), "添加菜单", menuModel.F_Name);
  703. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "添加菜单", "数据:" + JsonConvert.SerializeObject(menuModel), "主要设置");
  704. return id > 0;
  705. }
  706. }
  707. /// <summary>
  708. /// 删除功能
  709. /// </summary>
  710. /// <param name="workOrderBaseModel"></param>
  711. /// <returns></returns>
  712. [AcceptVerbs(HttpVerbs.Get)]
  713. public bool DeleteMenuData(int menuId)
  714. {
  715. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  716. AddAction("t_sys_modulefunctions", deptModel.F_FunctionId.ToMyString(), "删除菜单", "数据:" + JsonConvert.SerializeObject(deptModel), "主要设置");
  717. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "删除菜单");
  718. return menuBLL.Delete(menuId);
  719. }
  720. #endregion
  721. #region 用户管理
  722. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  723. /// <summary>
  724. /// 部门列表
  725. /// </summary>
  726. /// <returns></returns>
  727. public ActionResult UserList()
  728. {
  729. WorkOrderMyModel model = new WorkOrderMyModel();
  730. return View(model);
  731. }
  732. /// <summary>
  733. /// 用户编辑
  734. /// </summary>
  735. /// <param name="editType">类型1、新增 2、修改</param>
  736. /// /// <returns></returns>
  737. public ActionResult UserEdit(int? userId, int? deptId, int editType)
  738. {
  739. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "用户编号/部门" + userId+"-"+ deptId);
  740. Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
  741. //当前对象实体
  742. if (editType == 1)
  743. {
  744. viewModel.F_DeptId = int.Parse(deptId.ToString());
  745. AddAction("t_sys_useraccount", deptId.ToMyString(), "打开用户添加页", "", "敏感信息");
  746. }
  747. else
  748. {
  749. Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
  750. viewModel = userModel;
  751. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  752. }
  753. //获取部门列表
  754. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  755. //获取角色列表
  756. viewModel.RoleInfoList = roleBLL.GetModelList("");
  757. return View(viewModel);
  758. }
  759. /// <summary>
  760. /// 保存编辑
  761. /// </summary>
  762. /// <param name="workOrderBaseModel"></param>
  763. /// <returns></returns>
  764. [AcceptVerbs(HttpVerbs.Post)]
  765. public bool SaveUserData(T_Sys_UserAccount userModel)
  766. {
  767. BLL.T_Sys_RoleInfo bll = new BLL.T_Sys_RoleInfo();
  768. BLL.T_Sys_UserAccount blluser = new BLL.T_Sys_UserAccount();
  769. if (userModel.F_UserId > 0)
  770. {
  771. Model.T_Sys_UserAccount oldusermodel = blluser.GetModel(userModel.F_UserId);
  772. Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
  773. Model.T_Sys_RoleInfo role = bll.GetModel(oldusermodel.F_RoleId);//要修改账户的角色
  774. //要修改de账号 角色代码,登录人不是系统管理员,返回false
  775. if (role.F_RoleCode == "XTGLY" || role.F_RoleCode == "YWGLY")
  776. {
  777. if (role2.F_RoleCode != "XTGLY")
  778. {
  779. return false;
  780. }
  781. }
  782. Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要修改账户的改了之后的角色
  783. if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
  784. {
  785. if (role2.F_RoleCode != "XTGLY")
  786. {
  787. return false;
  788. }
  789. }
  790. }
  791. userModel.F_WorkNumber = userModel.F_UserCode;
  792. if (userModel.F_UserId > 0)
  793. {
  794. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
  795. oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
  796. oldUserModel.F_UserName = userModel.F_UserName;
  797. oldUserModel.F_UserCode = userModel.F_UserCode;
  798. oldUserModel.F_DeptId = userModel.F_DeptId;
  799. oldUserModel.F_RoleId = userModel.F_RoleId;
  800. oldUserModel.F_SexFlag = userModel.F_SexFlag;
  801. oldUserModel.F_Telephone = userModel.F_Telephone;
  802. oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
  803. oldUserModel.F_SeatRight = userModel.F_SeatRight;
  804. oldUserModel.F_Password = userModel.F_Password;
  805. oldUserModel.F_Remark = userModel.F_Remark;
  806. oldUserModel.F_ExtensionNumber = userModel.F_ExtensionNumber.ToMyString();
  807. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
  808. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  809. return userBLL.Update(oldUserModel);
  810. }
  811. else
  812. {
  813. Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
  814. Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要添加账户的的角色
  815. if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
  816. {
  817. if (role2.F_RoleCode != "XTGLY")
  818. {
  819. return false;
  820. }
  821. }
  822. userModel.F_HJType = 0;
  823. userModel.F_GroupId = 1;
  824. if (userModel.F_SeatFlag)//&&false)
  825. {
  826. #region 调用接口插入用户信息
  827. try
  828. {
  829. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
  830. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  831. StringBuilder returnStr = new StringBuilder();
  832. string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
  833. UserInfo model = new UserInfo();
  834. model.name = userModel.F_UserCode;
  835. object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
  836. string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
  837. ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
  838. userModel.F_PId = ResultModel.data;
  839. }
  840. catch (Exception ex)
  841. {
  842. }
  843. #endregion
  844. }
  845. int userid = userBLL.Add(userModel);
  846. AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
  847. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  848. return userid > 0;
  849. }
  850. }
  851. /// <summary>
  852. /// 删除用户
  853. /// </summary>
  854. /// <param name="workOrderBaseModel"></param>
  855. /// <returns></returns>
  856. [AcceptVerbs(HttpVerbs.Get)]
  857. public bool DeleteUserData(int userId)
  858. {
  859. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
  860. if (F_RoleID != 17 &&(oldUserModel.F_RoleId==17 || oldUserModel.F_RoleId == 57))
  861. {
  862. return false;
  863. }
  864. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
  865. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  866. return userBLL.Delete(userId);
  867. }
  868. /// <summary>
  869. /// 获取用户数据
  870. /// </summary>
  871. /// <param name="page">当前页码</param>
  872. /// <param name="limit">每页数据量</param>
  873. /// <returns></returns>
  874. [ActionName("UserDate")]
  875. [HttpGet]
  876. public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
  877. {
  878. AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
  879. //数据结果集
  880. ResponseData dataModel = new ResponseData();
  881. string sql = "";
  882. if (deptId != null && deptId > 0)
  883. {
  884. sql += " and F_DeptId=" + deptId;
  885. }
  886. DataTable dt = new DataTable();
  887. int recordCount = 0;
  888. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  889. dt = BLL.PagerBLL.GetListPager(
  890. "T_Sys_UserAccount",
  891. "F_UserId",
  892. "*"
  893. + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
  894. + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
  895. + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
  896. + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
  897. ,
  898. sql,
  899. "ORDER BY F_UserCode asc ",
  900. limit,
  901. page,
  902. true,
  903. out recordCount);
  904. dataModel.code = 0;
  905. dataModel.count = recordCount;
  906. dataModel.data = dt;
  907. return JsonConvert.SerializeObject(dataModel);
  908. }
  909. #endregion
  910. #region 修改密码
  911. /// <summary>
  912. ///用户修改个人密码
  913. /// </summary>
  914. /// <param name="id"></param>
  915. /// <returns></returns>
  916. public ActionResult UserPwdEdit()
  917. {
  918. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
  919. Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
  920. if (F_UserID > 0)
  921. {
  922. model = userBLL.GetModel(F_UserID);
  923. }
  924. return View(model);
  925. }
  926. /// </summary>
  927. [AcceptVerbs(HttpVerbs.Post)]
  928. public ActionResult CheckPwd(string pwd)
  929. {
  930. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
  931. return Json(new
  932. {
  933. code = chkrslt.RSL ? 0 : 1,
  934. msg = chkrslt.MSG
  935. });
  936. }
  937. /// <summary>
  938. ///保存修改密码
  939. /// </summary>
  940. [AcceptVerbs(HttpVerbs.Post)]
  941. public string UpdateUserPwd(Model.T_Sys_UserAccount model)
  942. {
  943. //checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
  944. //if(!chkrslt.RSL)
  945. //{
  946. // return chkrslt.MSG;
  947. //}
  948. string AddRersult = "false";
  949. if (model.F_UserId > 0)
  950. {
  951. Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
  952. if (newModel != null && newModel.F_Password == model.oldPwd)
  953. {
  954. newModel.F_Password = model.password;
  955. if (userBLL.Update(newModel))
  956. {
  957. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
  958. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
  959. AddRersult = "True";
  960. }
  961. }
  962. else
  963. {
  964. AddRersult = "旧密码不正确!";
  965. }
  966. }
  967. return AddRersult;
  968. }
  969. #endregion
  970. #region 基本信息
  971. /// <summary>
  972. /// 用户编辑
  973. /// </summary>
  974. /// <param name="editType">类型1、新增 2、修改</param>
  975. /// /// <returns></returns>
  976. public ActionResult UserView()
  977. {
  978. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  979. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
  980. if (string.IsNullOrEmpty(userModel.F_HomePhone))
  981. {
  982. userModel.F_HomePhone = "/Content/images/face.jpg";
  983. }
  984. else
  985. {
  986. if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
  987. {
  988. userModel.F_HomePhone = "/Content/images/face.jpg";
  989. }
  990. }
  991. return View(userModel);
  992. }
  993. #endregion
  994. #region 图片上传
  995. /// <summary>
  996. /// 图片上传
  997. /// </summary>
  998. /// <returns></returns>
  999. [AcceptVerbs(HttpVerbs.Post)]
  1000. public ActionResult UploadFile()
  1001. {
  1002. try
  1003. {
  1004. if (Request.Files.Count > 0)
  1005. {
  1006. string uppath = string.Empty;
  1007. string savepath = string.Empty;
  1008. HttpPostedFileBase imgFile = Request.Files[0];
  1009. if (imgFile != null)
  1010. {
  1011. //创建图片新的名称
  1012. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  1013. //获得上传图片的路径
  1014. string strPath = imgFile.FileName;
  1015. //获得上传图片的类型(后缀名)
  1016. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  1017. //拼写数据库保存的相对路径字符串
  1018. savepath = "/Content/HeadImg/images/";
  1019. //拼写上传图片的路径
  1020. uppath = Server.MapPath("~/Content/HeadImg/images/");
  1021. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  1022. {
  1023. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  1024. }
  1025. uppath += nameImg + "." + type;
  1026. savepath += nameImg + "." + type;
  1027. //上传图片
  1028. imgFile.SaveAs(uppath); //原图片路径
  1029. }
  1030. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  1031. userModel.F_HomePhone = savepath;
  1032. if (userBLL.Update(userModel))
  1033. {
  1034. return Json(new
  1035. {
  1036. code = 0,
  1037. src = savepath,
  1038. msg = "上传成功"
  1039. });
  1040. }
  1041. else
  1042. {
  1043. return Json(new
  1044. {
  1045. code = 1,
  1046. src = "",
  1047. msg = "上传出错 请检查图片名称或图片内容"
  1048. });
  1049. }
  1050. }
  1051. else
  1052. {
  1053. return Json(new
  1054. {
  1055. code = 1,
  1056. src = "",
  1057. msg = "上传出错 请检查图片名称或图片内容"
  1058. });
  1059. }
  1060. }
  1061. catch (Exception ex)
  1062. {
  1063. return Json(new
  1064. {
  1065. code = 1,
  1066. src = "",
  1067. msg = "上传出错: " + ex.Message
  1068. });
  1069. }
  1070. }
  1071. #endregion
  1072. #region 公告管理
  1073. /// <summary>
  1074. /// 公告管理
  1075. /// </summary>
  1076. /// <returns></returns>
  1077. public ActionResult noticeManage()
  1078. {
  1079. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1080. return View(noticeModel);
  1081. }
  1082. public ActionResult test()
  1083. {
  1084. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1085. return View(noticeModel);
  1086. }
  1087. /// <summary>
  1088. /// 获取公告数据
  1089. /// </summary>
  1090. /// <param name="page">当前页码</param>
  1091. /// <param name="limit">每页数据量</param>
  1092. /// <returns></returns>
  1093. [ActionName("NoticeListDate")]
  1094. [HttpGet]
  1095. public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  1096. {
  1097. AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
  1098. //数据结果集
  1099. ResponseData dataModel = new ResponseData();
  1100. string sql = "";
  1101. if (parentId != null)
  1102. {
  1103. sql += " and F_ParentId=" + parentId;
  1104. }
  1105. DataTable dt = new DataTable();
  1106. int recordCount = 0;
  1107. Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
  1108. dt = BLL.PagerBLL.GetListPager(
  1109. "T_Msg_NoticeInfo",
  1110. "F_NoticeId",
  1111. "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew,isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) )as F_ModifyDateNew ",
  1112. sql,
  1113. "ORDER BY isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) ) desc ",
  1114. limit,
  1115. page,
  1116. true,
  1117. out recordCount);
  1118. dataModel.code = 0;
  1119. dataModel.count = recordCount;
  1120. dataModel.data = dt;
  1121. return JsonConvert.SerializeObject(dataModel);
  1122. }
  1123. BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
  1124. BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
  1125. BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
  1126. /// <summary>
  1127. /// 编辑公告
  1128. /// </summary>
  1129. /// <param name="editType">类型1、新增 2、修改</param>
  1130. /// /// <returns></returns>
  1131. public ActionResult NoticeEdit(int? noticeId, int editType)
  1132. {
  1133. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
  1134. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1135. //当前对象实体
  1136. if (editType == 1)
  1137. {
  1138. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1139. //viewModel.UseList = userBLL.GetModelList("");
  1140. }
  1141. else
  1142. {
  1143. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1144. viewModel = userModel;
  1145. if (!string.IsNullOrEmpty(userModel.F_ReceiveInfo))
  1146. {
  1147. int deviceid = userModel.F_DeviceId == null ? 0 : (int)userModel.F_DeviceId;
  1148. viewModel.UseList = userBLL.GetModelList("F_UserId=" + deviceid);
  1149. viewModel.DepartmentList = deptBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1150. }
  1151. }
  1152. //获取部门列表
  1153. return View(viewModel);
  1154. }
  1155. /// <summary>
  1156. /// 查看公告
  1157. /// </summary>
  1158. /// <param name="editType">类型1、新增 2、修改</param>
  1159. /// /// <returns></returns>
  1160. public ActionResult NoticeView(int? noticeId)
  1161. {
  1162. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
  1163. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1164. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1165. viewModel.UseList = userBLL.GetModelList("");
  1166. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1167. viewModel = userModel;
  1168. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1169. //获取部门列表
  1170. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1171. return View(viewModel);
  1172. }
  1173. /// <summary>
  1174. /// 保存编辑公告
  1175. /// </summary>
  1176. /// <param name="workOrderBaseModel"></param>
  1177. /// <returns></returns>
  1178. [AcceptVerbs(HttpVerbs.Post)]
  1179. public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
  1180. {
  1181. bool result = false;
  1182. DataTable dt = new DataTable();
  1183. DataTable dtuser = new DataTable();
  1184. int noticeid = 0;
  1185. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1186. DateTime? readdate =null;
  1187. try
  1188. {
  1189. //获取当前用户
  1190. noticeinfoModel.F_CreateBy = F_UserID;
  1191. noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
  1192. if (noticeinfoModel.F_NoticeId > 0)
  1193. {
  1194. noticeid = noticeinfoModel.F_NoticeId;
  1195. Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
  1196. dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
  1197. if (dt.Rows.Count > 0)
  1198. {
  1199. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
  1200. foreach (DataRow dr in dtuser.Rows)
  1201. {
  1202. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1203. result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
  1204. }
  1205. }
  1206. readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
  1207. oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
  1208. oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
  1209. oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
  1210. oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
  1211. oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
  1212. oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
  1213. oldnoticeinfoModel.F_State = 1;
  1214. oldnoticeinfoModel.F_ModifyDate = DateTime.Now;
  1215. oldnoticeinfoModel.F_ModifyBy = F_UserID;
  1216. result = noticeBLL.Update(oldnoticeinfoModel);
  1217. AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
  1218. }
  1219. else
  1220. {
  1221. noticeid = 0;
  1222. noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
  1223. noticeinfoModel.F_State = 1;
  1224. noticeinfoModel.F_CreateOn = DateTime.Now;
  1225. noticeinfoModel.F_ModifyDate = DateTime.Now;
  1226. readdate = noticeinfoModel.F_CreateOn;
  1227. noticeid = noticeBLL.Add(noticeinfoModel);
  1228. if (noticeid > 0)
  1229. {
  1230. result = true;
  1231. }
  1232. ////添加公告的时候把公告user表添加数据
  1233. //List<T_Sys_UserAccount> userlist= userbll.GetModelList("");
  1234. //foreach (T_Sys_UserAccount item in userlist)
  1235. //{
  1236. // Model.usernotice usernoticemodel = new usernotice();
  1237. // usernoticemodel.F_noticeid = noticeid;
  1238. // usernoticemodel.F_userid = item.F_UserId;
  1239. // usernoticemodel.F_state = 0;
  1240. // usernoticebll.Add(usernoticemodel);
  1241. //}
  1242. AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
  1243. }
  1244. //指定方式发送公告
  1245. if (noticeinfoModel.F_DeviceId > 0)
  1246. {//指定人员发公告
  1247. noticeuserModel.F_NoticeId = noticeid;
  1248. noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
  1249. noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
  1250. //if (readdate.ToString() != "")
  1251. //{ noticeuserModel.F_ReadDate = readdate; }
  1252. //else
  1253. //{
  1254. // noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1255. //}
  1256. noticeuserModel.F_State = 0;
  1257. noticeuserModel.F_Type = 0;
  1258. result = noticeuserBLL.Add(noticeuserModel);
  1259. }
  1260. else
  1261. {//指定部门发公告
  1262. dt = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
  1263. if (dt.Rows.Count > 0)
  1264. {
  1265. noticeuserModel.F_NoticeId = noticeid;
  1266. //if (readdate.ToString()!="")
  1267. //{ noticeuserModel.F_ReadDate = readdate; }
  1268. //else {
  1269. //noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1270. //}
  1271. foreach (DataRow dr in dt.Rows)
  1272. {
  1273. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1274. noticeuserModel.F_UserName = dr["F_UserName"].ToString();
  1275. noticeuserModel.F_State = 0;
  1276. noticeuserModel.F_Type = 0;
  1277. result = noticeuserBLL.Add(noticeuserModel);
  1278. }
  1279. }
  1280. }
  1281. }
  1282. catch (Exception) { }
  1283. finally
  1284. {
  1285. dt.Clear();
  1286. dt.Dispose();
  1287. }
  1288. return result;
  1289. }
  1290. /// <summary>
  1291. /// 删除公告
  1292. /// </summary>
  1293. /// <param name="workOrderBaseModel"></param>
  1294. /// <returns></returns>
  1295. [AcceptVerbs(HttpVerbs.Get)]
  1296. public bool DeleteNoticeData(int noticeId)
  1297. {
  1298. bool res = false;
  1299. DataTable dt = new DataTable();
  1300. DataTable dtuser = new DataTable();
  1301. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1302. try
  1303. {
  1304. dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
  1305. if (dt.Rows.Count > 0)
  1306. {
  1307. res = noticeBLL.Delete(noticeId);
  1308. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
  1309. //指定部门发公告
  1310. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
  1311. foreach (DataRow dr in dtuser.Rows)
  1312. {
  1313. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1314. noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
  1315. }
  1316. }
  1317. }
  1318. catch (Exception) { }
  1319. finally {
  1320. dt.Clear();
  1321. dt.Dispose();
  1322. dtuser.Clear();
  1323. dtuser.Dispose();
  1324. }
  1325. return res;
  1326. }
  1327. /// <summary>
  1328. /// 未接根据recordid更新回访信息
  1329. /// </summary>
  1330. /// <param name="SetCallRecordHfInfo"></param>
  1331. /// <returns></returns>
  1332. [ActionName("SetNoticeState")]
  1333. [HttpGet]
  1334. public string SetNoticeState(string id, string timeno)
  1335. {
  1336. string res = "";
  1337. try
  1338. {
  1339. Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
  1340. model.F_State =1;
  1341. model.F_NoticeId = Convert.ToInt32(id);
  1342. bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
  1343. if (bl)
  1344. {
  1345. res = "success";
  1346. }
  1347. }
  1348. catch
  1349. { }
  1350. return res;
  1351. }
  1352. [ActionName("CookieData")]
  1353. [HttpGet]
  1354. public string CookieData() {
  1355. return F_UserID.ToString();
  1356. }
  1357. #endregion
  1358. /// <summary>
  1359. /// 工作时间管理
  1360. /// </summary>
  1361. /// <returns></returns>
  1362. public ActionResult workTimeManage()
  1363. {
  1364. Model.T_SYS_Time timeModel = new Model.T_SYS_Time();
  1365. return View(timeModel);
  1366. }
  1367. /// <summary>
  1368. /// 获取工作时间数据
  1369. /// </summary>
  1370. /// <param name="page">当前页码</param>
  1371. /// <param name="limit">每页数据量</param>
  1372. /// <returns></returns>
  1373. [ActionName("workTimeListData")]
  1374. [HttpGet]
  1375. public string workTimeListData()
  1376. {
  1377. //数据结果集
  1378. ResponseData dataModel = new ResponseData();
  1379. string sql = " select top 1 * from T_SYS_Time";
  1380. DataTable dt= DbHelperSQL.Query(sql).Tables[0];
  1381. dataModel.code = 0;
  1382. dataModel.count = 1;
  1383. dataModel.data = dt;
  1384. return JsonConvert.SerializeObject(dataModel);
  1385. }
  1386. public ActionResult workTimeEdit(int workTimeId )
  1387. {
  1388. Model.T_SYS_Time viewModel = new Model.T_SYS_Time();
  1389. // Model.T_SYS_Time userModel = timeBLL.GetModel(workTimeId);
  1390. //获取部门列表
  1391. return View(viewModel);
  1392. }
  1393. [AcceptVerbs(HttpVerbs.Post)]
  1394. public bool SaveWorkTimeData(T_SYS_Time systimeModel)
  1395. {
  1396. bool result = false;
  1397. DataTable dt = new DataTable();
  1398. DataTable dtuser = new DataTable();
  1399. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1400. try
  1401. {
  1402. Model.T_SYS_Time oldsystimeModel = timeBLL.GetModel();
  1403. oldsystimeModel.F_WorkEndTimes = systimeModel.F_WorkEndTimes;
  1404. oldsystimeModel.F_WorkStartTimes = systimeModel.F_WorkStartTimes;
  1405. result = timeBLL.Update(oldsystimeModel);
  1406. AddAction("t_sys_time", "1", "修改工作时间", "", F_UserCode + "在" + DateTime.Now.ToString() + "修改工作时间");
  1407. }
  1408. catch (Exception) { }
  1409. finally
  1410. {
  1411. dt.Clear();
  1412. dt.Dispose();
  1413. }
  1414. return result;
  1415. }
  1416. public string GetUnreadData()
  1417. {
  1418. DataTable dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeUsers().GetList("1=1 and F_ReadDate is null and F_UserId= " + F_UserID + "order by F_ReadDate desc").Tables[0];
  1419. DataTable dtinfo = new DataTable();
  1420. if (dt.Rows.Count > 0)
  1421. {
  1422. List<int> noticelist = (from r in dt.AsEnumerable() select r.Field<int>("F_NoticeId")).ToList<int>();
  1423. dtinfo = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_State=1 and F_NoticeId in ( '" + string.Join("','", noticelist) + "') order by ISNULL(F_ModifyDate,F_CreateOn) desc").Tables[0];
  1424. }
  1425. return JsonConvert.SerializeObject(dtinfo);
  1426. }
  1427. public bool readNoticeData(int noticeid)
  1428. {
  1429. BLL.T_Msg_NoticeUsers noticeUsers = new BLL.T_Msg_NoticeUsers();
  1430. Model.T_Msg_NoticeUsers model= noticeUsers.GetModel(noticeid,F_UserID);
  1431. model.F_ReadDate = DateTime.Now;
  1432. noticeUsers.Update(model);
  1433. return true;
  1434. }
  1435. #region 风险等级管理
  1436. public ActionResult RiskLevelList()
  1437. {
  1438. WorkOrderMyModel model = new WorkOrderMyModel();
  1439. return View(model);
  1440. }
  1441. [ActionName("riskLevelData")]
  1442. [HttpGet]
  1443. public string riskLevelData(string name,string level, int page, int limit)
  1444. {
  1445. //数据结果集
  1446. ResponseData dataModel = new ResponseData();
  1447. string sql = " and F_isdelete=0 ";
  1448. if (!string.IsNullOrEmpty( name))
  1449. {
  1450. sql += " and F_LabelName='"+name+"' " ;
  1451. }
  1452. if (!string.IsNullOrEmpty(level ))
  1453. {
  1454. sql += " and F_Level='"+ level + "' " ;
  1455. }
  1456. DataTable dt = new DataTable();
  1457. int recordCount = 0;
  1458. Model.PageData<Model.T_RiskLevel> pageModel = new Model.PageData<Model.T_RiskLevel>();
  1459. dt = BLL.PagerBLL.GetListPager(
  1460. "T_RiskLevel",
  1461. "F_Id",
  1462. "*",
  1463. sql,
  1464. "ORDER BY F_CreateTime desc ",
  1465. limit,
  1466. page,
  1467. true,
  1468. out recordCount);
  1469. //dataModel.code = 0;
  1470. //dataModel.count = recordCount;
  1471. //dataModel.data = dt;
  1472. // AddAction("T_RiskLevel", parentId.ToMyString(), "获取风险等级列表", "");
  1473. return Success("成功", dt, recordCount);
  1474. }
  1475. [AcceptVerbs(HttpVerbs.Get)]
  1476. public string GetRiskLevelDataById(int riskId)
  1477. {
  1478. var model = levelbll.GetModel(riskId);
  1479. if (model!=null)
  1480. {
  1481. return Success("成功",model);
  1482. }
  1483. else
  1484. {
  1485. return Error("没有数据");
  1486. }
  1487. }
  1488. [AcceptVerbs(HttpVerbs.Get)]
  1489. public string GetAllRiskLevelList()
  1490. {
  1491. var model = levelbll.GetModelList("F_IsDelete=0");
  1492. if (model != null)
  1493. {
  1494. return Success("成功", model);
  1495. }
  1496. else
  1497. {
  1498. return Error("没有数据");
  1499. }
  1500. }
  1501. [AcceptVerbs(HttpVerbs.Get)]
  1502. public bool DeleteRiskLevelData(int riskId)
  1503. {
  1504. AddAction("T_RiskLevel", riskId.ToMyString(), "删除风险等级标签");
  1505. return levelbll.Delete(riskId);
  1506. }
  1507. /// <summary>
  1508. /// 风险管理编辑
  1509. /// </summary>
  1510. /// <param name="editType">类型1、新增 2、修改</param>
  1511. /// /// <returns></returns>
  1512. public ActionResult RiskLevelEdit(int riskId, int editType=1)
  1513. {
  1514. AddAction("T_RiskLevel", riskId.ToMyString(), "打开风险管理编辑页面", "");
  1515. RiskLevelEditModel viewModel = new RiskLevelEditModel();
  1516. //当前对象实体
  1517. if (editType == 1)
  1518. {
  1519. }
  1520. else
  1521. {
  1522. Model.T_RiskLevel deptModel = levelbll.GetModel(riskId);
  1523. viewModel.F_LabelName = deptModel.F_LabelName;
  1524. viewModel.F_Id = deptModel.F_Id;
  1525. viewModel.F_Note = deptModel.F_Note;
  1526. viewModel.F_Level = deptModel.F_Level;
  1527. viewModel.F_AutoDesc = JsonConvert.DeserializeObject<List<AutoDesc>>(deptModel.F_AutoDesc);
  1528. }
  1529. return View(viewModel);
  1530. }
  1531. /// <summary>
  1532. /// 保存编辑
  1533. /// </summary>
  1534. /// <param name="workOrderBaseModel"></param>
  1535. /// <returns></returns>
  1536. [AcceptVerbs(HttpVerbs.Post)]
  1537. public string SaveRiskLevelData(T_RiskLevel levelModel, List<AutoDesc> autodesc = null)
  1538. {
  1539. if (autodesc!=null && autodesc.Count>3)
  1540. {
  1541. return Error("自动类型的设置不能大于3条");
  1542. }
  1543. if (levelModel.F_Id > 0)
  1544. {
  1545. var model = levelbll.GetModel(levelModel.F_Id);
  1546. AddAction("T_RiskLevel", levelModel.F_Id.ToMyString(), "更新风险管理标签", levelModel.F_LabelName);
  1547. if (levelModel.F_Level=="自动")
  1548. {
  1549. model.F_AutoDesc = JsonConvert.SerializeObject(autodesc);
  1550. }
  1551. model.F_UpdateTime =DateTime.Now;
  1552. model.F_LabelName = levelModel.F_LabelName;
  1553. model.F_Note = levelModel.F_Note;
  1554. model.F_Level = levelModel.F_Level;
  1555. bool res = levelbll.Update(model);
  1556. if (res)
  1557. {
  1558. return Success("更新成功");
  1559. }
  1560. else
  1561. {
  1562. return Error("更新失败");
  1563. }
  1564. }
  1565. else
  1566. {
  1567. if (levelModel.F_Level == "自动")
  1568. {
  1569. levelModel.F_AutoDesc = JsonConvert.SerializeObject(autodesc);
  1570. }
  1571. levelModel.F_IsDelete = 0;
  1572. levelModel.F_CreateTime = DateTime.Now;
  1573. int id = levelbll.Add(levelModel);
  1574. AddAction("T_RiskLevel", id.ToMyString(), "添加风险管理标签", levelModel.F_LabelName);
  1575. if (id > 0)
  1576. {
  1577. return Success("添加成功");
  1578. }
  1579. else
  1580. {
  1581. return Error("添加失败");
  1582. }
  1583. }
  1584. }
  1585. #endregion
  1586. #region 消息通知
  1587. [AcceptVerbs(HttpVerbs.Post)]
  1588. public bool UpdateState(string[] ids, int state = 0)
  1589. {
  1590. if (ids != null && ids.Length > 0)
  1591. {
  1592. string idd = " ";
  1593. foreach (string str in ids)
  1594. {
  1595. idd += str + ",";
  1596. }
  1597. string sj = "null";
  1598. if (state == 1)
  1599. {
  1600. sj = "getdate()";
  1601. }
  1602. string sql = "update T_SMS_InternalMessages set SMS_IsRead=" + state + ",SMS_ReadTime=" + sj + " where SMS_Id in(" + idd.TrimEnd(',') + ")";
  1603. if (!string.IsNullOrEmpty(idd.Trim()))
  1604. {
  1605. if (DbHelperSQL.ExecuteSql(sql) > 0)
  1606. {
  1607. return true;
  1608. }
  1609. else
  1610. {
  1611. return false;
  1612. }
  1613. }
  1614. else
  1615. {
  1616. return false;
  1617. }
  1618. }
  1619. else
  1620. {
  1621. return false;
  1622. }
  1623. }
  1624. [ActionName("internalMessageData")]
  1625. [HttpGet]
  1626. public string internalMessageData(int page, int limit)
  1627. {
  1628. //数据结果集
  1629. ResponseData dataModel = new ResponseData();
  1630. string sql = " and SMS_IsRead=0 and SMS_IsDelete=0";
  1631. sql += " and SMS_ReceiveUserCode=" + F_UserCode;
  1632. DataTable dt = new DataTable();
  1633. int recordCount = 0;
  1634. Model.PageData<Model.T_SMS_InternalMessages> pageModel = new Model.PageData<Model.T_SMS_InternalMessages>();
  1635. dt = BLL.PagerBLL.GetListPager(
  1636. "T_SMS_InternalMessages",
  1637. "SMS_Id",
  1638. "*",
  1639. sql,
  1640. "ORDER BY SMS_SendTime desc ",
  1641. limit,
  1642. page,
  1643. true,
  1644. out recordCount);
  1645. dataModel.code = 0;
  1646. dataModel.count = recordCount;
  1647. dataModel.data = dt;
  1648. return JsonConvert.SerializeObject(dataModel);
  1649. }
  1650. #endregion
  1651. }
  1652. #region 接口基本信息
  1653. /// <summary>
  1654. /// 用户信息
  1655. /// </summary>
  1656. public class UserInfo
  1657. {
  1658. public int id
  1659. {
  1660. get;
  1661. set;
  1662. }
  1663. public string name
  1664. {
  1665. get;
  1666. set;
  1667. }
  1668. }
  1669. /// <summary>
  1670. /// 返回结果信息
  1671. /// </summary>
  1672. public class ResponseResult
  1673. {
  1674. public int code
  1675. {
  1676. get;
  1677. set;
  1678. }
  1679. public int data
  1680. {
  1681. get;
  1682. set;
  1683. }
  1684. }
  1685. /// <summary>
  1686. /// 返回结果信息
  1687. /// </summary>
  1688. public class WXResponseResult
  1689. {
  1690. public int customer
  1691. {
  1692. get;
  1693. set;
  1694. }
  1695. public int service
  1696. {
  1697. get;
  1698. set;
  1699. }
  1700. public int total
  1701. {
  1702. get;
  1703. set;
  1704. }
  1705. }
  1706. public class AutoDesc
  1707. {
  1708. public string text { get; set; }
  1709. public int minutes { get; set; }
  1710. public int total { get; set; }
  1711. public string level { get; set; }
  1712. }
  1713. public class RiskLevelEditModel
  1714. {
  1715. public int F_Id
  1716. { get; set; }
  1717. /// <summary>
  1718. ///
  1719. /// </summary>
  1720. public string F_LabelName
  1721. { get; set; }
  1722. /// <summary>
  1723. ///
  1724. /// </summary>
  1725. public string F_Level
  1726. { get; set; }
  1727. /// <summary>
  1728. ///
  1729. /// </summary>
  1730. public List<AutoDesc> F_AutoDesc
  1731. { get; set; }
  1732. /// <summary>
  1733. ///
  1734. /// </summary>
  1735. public string F_Note
  1736. { get; set; }
  1737. }
  1738. #endregion
  1739. }