地铁二期项目正式开始

SystemManageController.cs 54KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  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. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  16. {
  17. public class SystemManageController : BaseController
  18. {
  19. #region 部门管理
  20. BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
  21. /// <summary>
  22. /// 部门列表
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult DepartmentList()
  26. {
  27. WorkOrderMyModel model = new WorkOrderMyModel();
  28. return View(model);
  29. }
  30. ///通过部门父级节点获取数据
  31. /// </summary>
  32. /// <param name="fid"></param>
  33. /// <returns></returns>
  34. public string GetDepartmentJsonModel(int parentId)
  35. {
  36. AddAction("t_sys_department", parentId.ToMyString(), "获取父级树结构", "");
  37. return Newtonsoft.Json.JsonConvert.SerializeObject(deptBLL.GetDepartmentJsonModel(parentId));
  38. }
  39. /// <summary>
  40. /// 部门编辑
  41. /// </summary>
  42. /// <param name="editType">类型1、新增 2、修改</param>
  43. /// /// <returns></returns>
  44. public ActionResult DepartmentEdit(int deptId, int editType)
  45. {
  46. AddAction("t_sys_department", deptId.ToMyString(), "打开部门编辑页面", "");
  47. Model.T_Sys_Department viewModel = new Model.T_Sys_Department();
  48. //当前对象实体
  49. if (editType == 1)
  50. {
  51. viewModel.F_ParentId = deptId;
  52. viewModel.F_Sort = 1;
  53. }
  54. else
  55. {
  56. Model.T_Sys_Department deptModel = deptBLL.GetModel(deptId);
  57. viewModel = deptModel;
  58. }
  59. return View(viewModel);
  60. }
  61. /// <summary>
  62. /// 保存编辑
  63. /// </summary>
  64. /// <param name="workOrderBaseModel"></param>
  65. /// <returns></returns>
  66. [AcceptVerbs(HttpVerbs.Post)]
  67. public bool SaveDeptData(T_Sys_Department deptModel)
  68. {
  69. if (deptModel.F_DeptId > 0)
  70. {
  71. AddAction("t_sys_department", deptModel.F_DeptId.ToMyString(), "更新部门", deptModel.F_DeptName);
  72. return deptBLL.Update(deptModel);
  73. }
  74. else
  75. {
  76. int id = deptBLL.Add(deptModel);
  77. AddAction("t_sys_department", id.ToMyString(), "添加部门", deptModel.F_DeptName);
  78. return id> 0;
  79. }
  80. }
  81. /// <summary>
  82. /// 删除部门
  83. /// </summary>
  84. /// <param name="workOrderBaseModel"></param>
  85. /// <returns></returns>
  86. [AcceptVerbs(HttpVerbs.Get)]
  87. public bool DeleteDeptData(int deptId)
  88. {
  89. AddAction("t_sys_department", deptId.ToMyString(), "删除部门");
  90. return deptBLL.Delete(deptId);
  91. }
  92. /// <summary>
  93. /// 获取部门数据
  94. /// </summary>
  95. /// <param name="page">当前页码</param>
  96. /// <param name="limit">每页数据量</param>
  97. /// <returns></returns>
  98. [ActionName("DeptDate")]
  99. [HttpGet]
  100. public string DeptDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  101. {
  102. //数据结果集
  103. ResponseData dataModel = new ResponseData();
  104. string sql = "";
  105. if (parentId != null)
  106. {
  107. sql += " and F_ParentId=" + parentId;
  108. }
  109. DataTable dt = new DataTable();
  110. int recordCount = 0;
  111. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  112. dt = BLL.PagerBLL.GetListPager(
  113. "T_Sys_Department",
  114. "F_DeptId",
  115. "*",
  116. sql,
  117. "ORDER BY F_Sort asc ",
  118. limit,
  119. page,
  120. true,
  121. out recordCount);
  122. dataModel.code = 0;
  123. dataModel.count = recordCount;
  124. dataModel.data = dt;
  125. AddAction("t_sys_department", parentId.ToMyString(), "获取部门列表", "");
  126. return JsonConvert.SerializeObject(dataModel);
  127. }
  128. #endregion
  129. #region 角色管理
  130. BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
  131. public ActionResult RoleList()
  132. {
  133. WorkOrderMyModel model = new WorkOrderMyModel();
  134. return View(model);
  135. }
  136. /// <summary>
  137. /// 获取角色列表
  138. /// </summary>
  139. /// <param name="page">当前页码</param>
  140. /// <param name="limit">每页数据量</param>
  141. /// <returns></returns>
  142. [ActionName("RoleDate")]
  143. [HttpGet]
  144. public string RoleDate(DateTime? NowDateTime, int page, int limit)
  145. {
  146. AddAction("t_sys_roleinfo", "page", "查询角色列表",page.ToMyString()+"-"+ limit.ToMyString());
  147. //数据结果集
  148. ResponseData dataModel = new ResponseData();
  149. string sql = "";
  150. DataTable dt = new DataTable();
  151. int recordCount = 0;
  152. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  153. dt = BLL.PagerBLL.GetListPager(
  154. "T_Sys_RoleInfo",
  155. "F_RoleId",
  156. "*",
  157. sql,
  158. "ORDER BY F_RoleId",
  159. limit,
  160. page,
  161. true,
  162. out recordCount);
  163. dataModel.code = 0;
  164. dataModel.count = recordCount;
  165. dataModel.data = dt;
  166. return JsonConvert.SerializeObject(dataModel);
  167. }
  168. /// <summary>
  169. /// 编辑角色
  170. /// </summary>
  171. /// <returns></returns>
  172. public ActionResult RoleEdit(int? roleId)
  173. {
  174. Model.T_Sys_RoleInfo viewModel = new Model.T_Sys_RoleInfo();
  175. if (roleId != null && roleId > 0)
  176. {
  177. viewModel = roleBLL.GetModel(int.Parse(roleId.ToString()));
  178. AddAction("t_sys_roleinfo", roleId.ToMyString(), "打开角色编辑页", "角色名称:"+ viewModel.F_RoleName, "敏感信息");
  179. }
  180. return View(viewModel);
  181. }
  182. /// <summary>
  183. /// 保存编辑
  184. /// </summary>
  185. /// <param name="workOrderBaseModel"></param>
  186. /// <returns></returns>
  187. [AcceptVerbs(HttpVerbs.Post)]
  188. public bool SaveRoleEdit(T_Sys_RoleInfo roleInfoModel)
  189. {
  190. roleInfoModel.F_RoleCode = roleInfoModel.F_RoleCode.ToMyString();
  191. if (roleInfoModel.F_RoleId > 0)
  192. {
  193. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", roleInfoModel.F_RoleName);
  194. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", "数据:" + JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  195. return roleBLL.Update(roleInfoModel);
  196. }
  197. else
  198. {
  199. int id = roleBLL.Add(roleInfoModel);
  200. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", roleInfoModel.F_RoleName);
  201. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", "数据:" +JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  202. return id > 0;
  203. }
  204. }
  205. /// <summary>
  206. /// 删除数据
  207. /// </summary>
  208. /// <param name="workOrderBaseModel"></param>
  209. /// <returns></returns>
  210. [AcceptVerbs(HttpVerbs.Get)]
  211. public bool DeleteRoleData(string roleId)
  212. {
  213. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色");
  214. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色", "数据:" + roleId.ToMyString(), "敏感信息");
  215. return roleBLL.DeleteList(roleId);
  216. }
  217. #endregion
  218. #region 获取菜单树
  219. public class DicSeaarchModel
  220. {
  221. public string RootCode
  222. {
  223. get;
  224. set;
  225. }
  226. }
  227. /// <summary>
  228. /// 初始化字典结构
  229. /// </summary>
  230. /// <param name="rootCode"></param>
  231. /// <returns></returns>
  232. public ActionResult MenuTree(string rootCode)
  233. {
  234. DicSeaarchModel model = new DicSeaarchModel();
  235. model.RootCode = rootCode;
  236. return View(model);
  237. }
  238. /// <summary>
  239. /// 获取字典数据
  240. /// </summary>
  241. /// <param name="rootCode"></param>
  242. /// <returns></returns>
  243. public string GetMenuTreeData(int roleId)
  244. {
  245. try
  246. {
  247. AddAction("T_Sys_ModuleFunctions".ToLower(), roleId.ToMyString(), "获取角色字典", "角色id"+ roleId.ToMyString());
  248. return "[" + Newtonsoft.Json.JsonConvert.SerializeObject(roleBLL.GetMenuTree(roleId)).Replace("Checked", "checked") + "]";
  249. }
  250. catch (Exception ex)
  251. {
  252. return "";
  253. }
  254. }
  255. /// <summary>
  256. ///授权
  257. /// </summary>
  258. /// <returns></returns>
  259. [AcceptVerbs(HttpVerbs.Get)]
  260. public bool AcceptList(int roleId, string MenuIdStr)
  261. {
  262. bool accRersult = false;
  263. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权", "角色id" + roleId.ToMyString()+"功能菜单"+ MenuIdStr);
  264. if (roleBLL.AddRolesMenuList(roleId, MenuIdStr))
  265. {
  266. AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权角色功能", string.Format("给角色{0}授权菜单功能{1}", roleId, MenuIdStr), "敏感信息");
  267. accRersult = true;
  268. }
  269. return accRersult;
  270. }
  271. #endregion
  272. #region 业务类型管理
  273. BLL.T_Wo_WorkOrderType dicTittleBLL = new BLL.T_Wo_WorkOrderType();
  274. public ActionResult BusinessTypeList()
  275. {
  276. WorkOrderMyModel model = new WorkOrderMyModel();
  277. return View(model);
  278. }
  279. ///通过dic编码获取dic值
  280. /// </summary>
  281. /// <param name="fid"></param>
  282. /// <returns></returns>
  283. public string GetDicTittleJson(int parentId)
  284. {
  285. AddAction("t_wo_workordertype".ToLower(), parentId.ToMyString(), "获取业务类型");
  286. return Newtonsoft.Json.JsonConvert.SerializeObject(dicTittleBLL.GetDicTittleJsonModel(parentId));
  287. }
  288. /// <summary>
  289. /// 获取业务类型数据
  290. /// </summary>
  291. /// <param name="page">当前页码</param>
  292. /// <param name="limit">每页数据量</param>
  293. /// <returns></returns>
  294. [ActionName("OrderTypeDate")]
  295. [HttpGet]
  296. public string OrderTypeDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  297. {
  298. AddAction("t_wo_workordertype".ToLower(),"page", "获取业务类型列表", page.ToMyString() + "-" + limit.ToMyString());
  299. //数据结果集
  300. ResponseData dataModel = new ResponseData();
  301. string sql = "";
  302. if (parentId != null && parentId > 0)
  303. {
  304. sql += " and F_ParentId=" + parentId;
  305. }
  306. DataTable dt = new DataTable();
  307. int recordCount = 0;
  308. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  309. dt = BLL.PagerBLL.GetListPager(
  310. "T_Wo_WorkOrderType",
  311. "F_WorkOrderTypeId",
  312. "*",
  313. sql,
  314. "ORDER BY F_Sort asc ",
  315. limit,
  316. page,
  317. true,
  318. out recordCount);
  319. dataModel.code = 0;
  320. dataModel.count = recordCount;
  321. dataModel.data = dt;
  322. return JsonConvert.SerializeObject(dataModel);
  323. }
  324. /// <summary>
  325. /// 编辑业务类型
  326. /// </summary>
  327. /// <param name="F_WorkOrderTypeId">当前选中id</param>
  328. /// <param name="editType">类型1、新增 2、修改</param>
  329. /// <returns></returns>
  330. public ActionResult BussinessTypeEdit(int F_WorkOrderTypeId, int editType)
  331. {
  332. AddAction("t_wo_workordertype".ToLower(), F_WorkOrderTypeId.ToMyString(), "打开业务类型编辑页");
  333. Model.T_Wo_WorkOrderType viewModel = new Model.T_Wo_WorkOrderType();
  334. //当前对象实体
  335. Model.T_Wo_WorkOrderType orderTypeModel = dicTittleBLL.GetModel(F_WorkOrderTypeId);
  336. if (editType == 1)
  337. {
  338. viewModel.F_ParentId = orderTypeModel.F_WorkOrderTypeId;
  339. viewModel.F_ParentName = orderTypeModel.F_ParentName;
  340. viewModel.F_Sort = 1;
  341. }
  342. else
  343. {
  344. viewModel = orderTypeModel;
  345. }
  346. return View(viewModel);
  347. }
  348. /// <summary>
  349. /// 保存编辑
  350. /// </summary>
  351. /// <param name="workOrderBaseModel"></param>
  352. /// <returns></returns>
  353. [AcceptVerbs(HttpVerbs.Post)]
  354. public bool SaveBussiTypeData(T_Wo_WorkOrderType WorkOrderTypeModel)
  355. {
  356. ////当前用户信息
  357. //workOrderBaseModel.F_USERID = F_UserID;//id
  358. //workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
  359. //workOrderBaseModel.F_REPAIRMANNAME = "12";//姓名
  360. if (WorkOrderTypeModel.F_WorkOrderTypeId > 0)
  361. {
  362. AddAction("t_wo_workordertype", WorkOrderTypeModel.F_WorkOrderTypeId.ToMyString(), "更新工单分类",WorkOrderTypeModel.F_Name);
  363. return dicTittleBLL.Update(WorkOrderTypeModel) > 0;
  364. }
  365. else
  366. {
  367. int id = dicTittleBLL.Add(WorkOrderTypeModel);
  368. AddAction("t_wo_workordertype", id.ToMyString(), "添加工单分类", WorkOrderTypeModel.F_Name);
  369. return id > 0;
  370. }
  371. }
  372. /// <summary>
  373. /// 删除数据
  374. /// </summary>
  375. /// <param name="workOrderBaseModel"></param>
  376. /// <returns></returns>
  377. [AcceptVerbs(HttpVerbs.Get)]
  378. public bool DeleteBussiTypeData(int WorkOrderTypeId)
  379. {
  380. AddAction("T_Sys_ModuleFunctions", WorkOrderTypeId.ToMyString(), "删除工单分类","", "敏感信息");
  381. AddAction("t_wo_workordertype", WorkOrderTypeId.ToMyString(), "删除工单分类");
  382. return dicTittleBLL.Delete(WorkOrderTypeId);
  383. }
  384. #endregion
  385. #region 字典管理
  386. BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  387. BLL.T_Sys_DictionaryBase dicBaseBLL = new BLL.T_Sys_DictionaryBase();
  388. /// <summary>
  389. /// 字典列表
  390. /// </summary>
  391. /// <returns></returns>
  392. public ActionResult DictionaryList()
  393. {
  394. WorkOrderMyModel model = new WorkOrderMyModel();
  395. return View(model);
  396. }
  397. ///通过字典获取数据
  398. /// </summary>
  399. /// <param name="fid"></param>
  400. /// <returns></returns>
  401. public string GetDictionaryJsonModel(int parentId)
  402. {
  403. return Newtonsoft.Json.JsonConvert.SerializeObject(dicBaseBLL.GetDictionaryJsonModel());
  404. }
  405. /// <summary>
  406. /// 获取字典值数据
  407. /// </summary>
  408. /// <param name="page">当前页码</param>
  409. /// <param name="limit">每页数据量</param>
  410. /// <returns></returns>
  411. [ActionName("DictionaryDate")]
  412. [HttpGet]
  413. public string DictionaryDate(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  414. {
  415. AddAction("t_sys_dictionarybase".ToLower(),"page", "获取字典列表", page+"-"+ limit);
  416. //数据结果集
  417. ResponseData dataModel = new ResponseData();
  418. string sql = "";
  419. if (!string.IsNullOrEmpty(dictionaryFlag) && dictionaryFlag != "0")
  420. {
  421. sql += " and F_DictionaryFlag='" + dictionaryFlag + "'";
  422. }
  423. DataTable dt = new DataTable();
  424. int recordCount = 0;
  425. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  426. if (string.IsNullOrEmpty(dictionaryFlag) || dictionaryFlag != "0")
  427. {
  428. dt = BLL.PagerBLL.GetListPager(
  429. "T_Sys_DictionaryValue",
  430. "F_DictionaryValueId",
  431. "*",
  432. sql,
  433. "ORDER BY F_Sort asc ",
  434. limit,
  435. page,
  436. true,
  437. out recordCount);
  438. }
  439. else
  440. {
  441. dt = BLL.PagerBLL.GetListPager(
  442. "T_Sys_DictionaryBase",
  443. "F_DictionaryName",
  444. "*,F_DictionaryName as F_Name",
  445. sql,
  446. "ORDER BY F_Sort asc ",
  447. limit,
  448. page,
  449. true,
  450. out recordCount);
  451. }
  452. dataModel.code = 0;
  453. dataModel.count = recordCount;
  454. dataModel.data = dt;
  455. return JsonConvert.SerializeObject(dataModel);
  456. }
  457. /// <summary>
  458. /// 获取字典值数据
  459. /// </summary>
  460. /// <param name="page">当前页码</param>
  461. /// <param name="limit">每页数据量</param>
  462. /// <returns></returns>
  463. [ActionName("DictionaryDateOut")]
  464. [HttpGet]
  465. public string DictionaryDateOut(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
  466. {
  467. AddAction("t_sys_dictionarybase".ToLower(), "page", "获取字典列表", page + "-" + limit);
  468. //数据结果集
  469. ResponseData dataModel = new ResponseData();
  470. string sql = "and (F_DictionaryFlag='ZDXX' OR F_DictionaryFlag='ZDXX2')";
  471. DataTable dt = new DataTable();
  472. int recordCount = 0;
  473. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  474. dt = BLL.PagerBLL.GetListPager(
  475. "T_Sys_DictionaryValue",
  476. "F_DictionaryValueId",
  477. "*",
  478. sql,
  479. "ORDER BY F_Sort asc ",
  480. limit,
  481. page,
  482. true,
  483. out recordCount);
  484. dataModel.code = 0;
  485. dataModel.count = recordCount;
  486. dataModel.data = dt;
  487. return JsonConvert.SerializeObject(dataModel);
  488. }
  489. /// <summary>
  490. /// 字典项编辑
  491. /// </summary>
  492. /// <param name="editType">类型1、新增 2、修改</param>
  493. /// /// <returns></returns>
  494. public ActionResult DictionaryBaseEdit(string dicCode, int editType)
  495. {
  496. AddAction("t_sys_dictionarybase".ToLower(), dicCode, "打开字典编辑页");
  497. Model.T_Sys_DictionaryBase viewModel = new Model.T_Sys_DictionaryBase();
  498. //当前对象实体
  499. if (editType == 1)
  500. {
  501. viewModel.F_Sort = 1;
  502. }
  503. else
  504. {
  505. Model.T_Sys_DictionaryBase dicBaseModel = dicBaseBLL.GetModel(dicCode);
  506. viewModel = dicBaseModel;
  507. }
  508. return View(viewModel);
  509. }
  510. /// <summary>
  511. /// 保存字典项编辑
  512. /// </summary>
  513. /// <param name="workOrderBaseModel"></param>
  514. /// <returns></returns>
  515. [AcceptVerbs(HttpVerbs.Post)]
  516. public bool SaveDictionaryBaseData(T_Sys_DictionaryBase dicBaseModel)
  517. {
  518. try
  519. {
  520. if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
  521. {
  522. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "更新字典项");
  523. return dicBaseBLL.Update(dicBaseModel);
  524. }
  525. else
  526. {
  527. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "添加字典项");
  528. return dicBaseBLL.Add(dicBaseModel);
  529. }
  530. }
  531. catch (Exception ex)
  532. {
  533. LogHelper.Default.WriteError("字典操作失败",ex);
  534. return false;
  535. }
  536. }
  537. /// <summary>
  538. /// 删除字典项
  539. /// </summary>
  540. /// <param name="workOrderBaseModel"></param>
  541. /// <returns></returns>
  542. [AcceptVerbs(HttpVerbs.Get)]
  543. public bool DeleteBaseData(string baseCode)
  544. {
  545. AddAction("t_sys_dictionarybase", baseCode,"删除字典项");
  546. return dicBaseBLL.Delete(baseCode);
  547. }
  548. /// <summary>
  549. /// 字典值编辑
  550. /// </summary>
  551. /// <param name="editType">类型1、新增 2、修改</param>
  552. /// /// <returns></returns>
  553. public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
  554. {
  555. AddAction("t_sys_dictionarybase".ToLower(), valueId.ToMyString(), "打开字典值编辑页");
  556. Model.T_Sys_DictionaryValue viewModel = new Model.T_Sys_DictionaryValue();
  557. //当前对象实体
  558. if (editType == 1)
  559. {
  560. viewModel.F_Sort = 1;
  561. viewModel.F_DictionaryFlag = parentCode;
  562. }
  563. else
  564. {
  565. Model.T_Sys_DictionaryValue dicValueModel = dicValueBLL.GetModel(int.Parse(valueId.ToString()));
  566. viewModel = dicValueModel;
  567. }
  568. return View(viewModel);
  569. }
  570. /// <summary>
  571. /// 保存字典值
  572. /// </summary>
  573. /// <param name="workOrderBaseModel"></param>
  574. /// <returns></returns>
  575. [AcceptVerbs(HttpVerbs.Post)]
  576. public bool SaveDictionaryValueData(T_Sys_DictionaryValue dicBaseModel)
  577. {
  578. if (dicBaseModel.F_DictionaryValueId > 0)
  579. {
  580. AddAction("t_sys_dictionaryvalue", dicBaseModel.F_DictionaryValueId.ToMyString(), "更新字典值");
  581. return dicValueBLL.Update(dicBaseModel);
  582. }
  583. else
  584. {
  585. int id = dicValueBLL.Add(dicBaseModel);
  586. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "添加字典值");
  587. return id > 0;
  588. }
  589. }
  590. /// <summary>
  591. /// 删除字典值
  592. /// </summary>
  593. /// <param name="workOrderBaseModel"></param>
  594. /// <returns></returns>
  595. [AcceptVerbs(HttpVerbs.Get)]
  596. public bool DeleteValueData(int id)
  597. {
  598. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "删除字典值");
  599. return dicValueBLL.Delete(id);
  600. }
  601. #endregion
  602. #region 菜单管理
  603. BLL.T_Sys_ModuleFunctions menuBLL = new BLL.T_Sys_ModuleFunctions();
  604. /// <summary>
  605. /// 部门列表
  606. /// </summary>
  607. /// <returns></returns>
  608. public ActionResult MenuList()
  609. {
  610. WorkOrderMyModel model = new WorkOrderMyModel();
  611. return View(model);
  612. }
  613. ///通过部门父级节点获取数据
  614. /// </summary>
  615. /// <param name="fid"></param>
  616. /// <returns></returns>
  617. public string GetMenuJsonModel(int parentId)
  618. {
  619. AddAction("t_sys_modulefunctions", parentId.ToMyString(), "获取父级下菜单","父级id:"+ parentId);
  620. return Newtonsoft.Json.JsonConvert.SerializeObject(menuBLL.GetMenuJsonModel(parentId));
  621. }
  622. /// <summary>
  623. /// 获取部门数据
  624. /// </summary>
  625. /// <param name="page">当前页码</param>
  626. /// <param name="limit">每页数据量</param>
  627. /// <returns></returns>
  628. [ActionName("MenuDate")]
  629. [HttpGet]
  630. public string MenuDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  631. {
  632. AddAction("t_sys_modulefunctions", "page", "获取菜单列表",page+"-"+limit);
  633. //数据结果集
  634. ResponseData dataModel = new ResponseData();
  635. string sql = "";
  636. if (parentId != null)
  637. {
  638. sql += " and F_ParentId=" + parentId;
  639. }
  640. DataTable dt = new DataTable();
  641. int recordCount = 0;
  642. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  643. dt = BLL.PagerBLL.GetListPager(
  644. "T_Sys_ModuleFunctions",
  645. "F_FunctionId",
  646. "* ,(CASE F_StateFlag WHEN 1 THEN '启用' WHEN 0 THEN '禁用' ELSE NULL END ) as F_StateFlagName",
  647. sql,
  648. "ORDER BY F_Sort asc ",
  649. limit,
  650. page,
  651. true,
  652. out recordCount);
  653. dataModel.code = 0;
  654. dataModel.count = recordCount;
  655. dataModel.data = dt;
  656. return JsonConvert.SerializeObject(dataModel);
  657. }
  658. /// <summary>
  659. /// 功能编辑
  660. /// </summary>
  661. /// <param name="editType">类型1、新增 2、修改</param>
  662. /// /// <returns></returns>
  663. public ActionResult MenuEdit(int menuId, int editType)
  664. {
  665. Model.T_Sys_ModuleFunctions viewModel = new Model.T_Sys_ModuleFunctions();
  666. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "打开功能编辑页", "菜单编号"+ menuId);
  667. //当前对象实体
  668. if (editType == 1)
  669. {
  670. viewModel.F_ParentId = menuId;
  671. viewModel.F_Sort = 1;
  672. }
  673. else
  674. {
  675. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  676. viewModel = deptModel;
  677. }
  678. return View(viewModel);
  679. }
  680. /// <summary>
  681. /// 保存编辑
  682. /// </summary>
  683. /// <param name="workOrderBaseModel"></param>
  684. /// <returns></returns>
  685. [AcceptVerbs(HttpVerbs.Post)]
  686. public bool SaveMenuData(T_Sys_ModuleFunctions menuModel)
  687. {
  688. if (menuModel.F_FunctionId > 0)
  689. {
  690. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", menuModel.F_Name);
  691. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", "数据:"+JsonConvert.SerializeObject(menuModel), "主要设置");
  692. return menuBLL.Update(menuModel);
  693. }
  694. else
  695. {
  696. int id = menuBLL.Add(menuModel);
  697. AddAction("t_sys_modulefunctions", id.ToMyString(), "添加菜单", menuModel.F_Name);
  698. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "添加菜单", "数据:" + JsonConvert.SerializeObject(menuModel), "主要设置");
  699. return id > 0;
  700. }
  701. }
  702. /// <summary>
  703. /// 删除功能
  704. /// </summary>
  705. /// <param name="workOrderBaseModel"></param>
  706. /// <returns></returns>
  707. [AcceptVerbs(HttpVerbs.Get)]
  708. public bool DeleteMenuData(int menuId)
  709. {
  710. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  711. AddAction("t_sys_modulefunctions", deptModel.F_FunctionId.ToMyString(), "删除菜单", "数据:" + JsonConvert.SerializeObject(deptModel), "主要设置");
  712. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "删除菜单");
  713. return menuBLL.Delete(menuId);
  714. }
  715. #endregion
  716. #region 用户管理
  717. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  718. /// <summary>
  719. /// 部门列表
  720. /// </summary>
  721. /// <returns></returns>
  722. public ActionResult UserList()
  723. {
  724. WorkOrderMyModel model = new WorkOrderMyModel();
  725. return View(model);
  726. }
  727. /// <summary>
  728. /// 用户编辑
  729. /// </summary>
  730. /// <param name="editType">类型1、新增 2、修改</param>
  731. /// /// <returns></returns>
  732. public ActionResult UserEdit(int? userId, int? deptId, int editType)
  733. {
  734. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "用户编号/部门" + userId+"-"+ deptId);
  735. Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
  736. //当前对象实体
  737. if (editType == 1)
  738. {
  739. viewModel.F_DeptId = int.Parse(deptId.ToString());
  740. AddAction("t_sys_useraccount", deptId.ToMyString(), "打开用户添加页", "", "敏感信息");
  741. }
  742. else
  743. {
  744. Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
  745. viewModel = userModel;
  746. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  747. }
  748. //获取部门列表
  749. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  750. //获取角色列表
  751. viewModel.RoleInfoList = roleBLL.GetModelList("");
  752. return View(viewModel);
  753. }
  754. /// <summary>
  755. /// 保存编辑
  756. /// </summary>
  757. /// <param name="workOrderBaseModel"></param>
  758. /// <returns></returns>
  759. [AcceptVerbs(HttpVerbs.Post)]
  760. public bool SaveUserData(T_Sys_UserAccount userModel)
  761. {
  762. userModel.F_WorkNumber = userModel.F_UserCode;
  763. if (userModel.F_UserId > 0)
  764. {
  765. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
  766. oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
  767. oldUserModel.F_UserName = userModel.F_UserName;
  768. oldUserModel.F_UserCode = userModel.F_UserCode;
  769. oldUserModel.F_DeptId = userModel.F_DeptId;
  770. oldUserModel.F_RoleId = userModel.F_RoleId;
  771. oldUserModel.F_SexFlag = userModel.F_SexFlag;
  772. oldUserModel.F_Telephone = userModel.F_Telephone;
  773. oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
  774. oldUserModel.F_SeatRight = userModel.F_SeatRight;
  775. oldUserModel.F_Password = userModel.F_Password;
  776. oldUserModel.F_Remark = userModel.F_Remark;
  777. oldUserModel.F_ExtensionNumber = userModel.F_ExtensionNumber.ToMyString();
  778. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
  779. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  780. return userBLL.Update(oldUserModel);
  781. }
  782. else
  783. {
  784. userModel.F_HJType = 0;
  785. userModel.F_GroupId = 1;
  786. if (userModel.F_SeatFlag&&false)
  787. {
  788. #region 调用接口插入用户信息
  789. try
  790. {
  791. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
  792. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  793. StringBuilder returnStr = new StringBuilder();
  794. string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
  795. UserInfo model = new UserInfo();
  796. model.name = userModel.F_UserCode;
  797. object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
  798. string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
  799. ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
  800. userModel.F_PId = ResultModel.data;
  801. }
  802. catch (Exception ex)
  803. {
  804. }
  805. #endregion
  806. }
  807. int userid = userBLL.Add(userModel);
  808. AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
  809. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  810. return userid > 0;
  811. }
  812. }
  813. /// <summary>
  814. /// 删除用户
  815. /// </summary>
  816. /// <param name="workOrderBaseModel"></param>
  817. /// <returns></returns>
  818. [AcceptVerbs(HttpVerbs.Get)]
  819. public bool DeleteUserData(int userId)
  820. {
  821. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
  822. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
  823. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  824. return userBLL.Delete(userId);
  825. }
  826. /// <summary>
  827. /// 获取用户数据
  828. /// </summary>
  829. /// <param name="page">当前页码</param>
  830. /// <param name="limit">每页数据量</param>
  831. /// <returns></returns>
  832. [ActionName("UserDate")]
  833. [HttpGet]
  834. public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
  835. {
  836. AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
  837. //数据结果集
  838. ResponseData dataModel = new ResponseData();
  839. string sql = "";
  840. if (deptId != null && deptId > 0)
  841. {
  842. sql += " and F_DeptId=" + deptId;
  843. }
  844. DataTable dt = new DataTable();
  845. int recordCount = 0;
  846. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  847. dt = BLL.PagerBLL.GetListPager(
  848. "T_Sys_UserAccount",
  849. "F_UserId",
  850. "*"
  851. + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
  852. + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
  853. + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
  854. + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
  855. ,
  856. sql,
  857. "ORDER BY F_UserCode asc ",
  858. limit,
  859. page,
  860. true,
  861. out recordCount);
  862. dataModel.code = 0;
  863. dataModel.count = recordCount;
  864. dataModel.data = dt;
  865. return JsonConvert.SerializeObject(dataModel);
  866. }
  867. #endregion
  868. #region 修改密码
  869. /// <summary>
  870. ///用户修改个人密码
  871. /// </summary>
  872. /// <param name="id"></param>
  873. /// <returns></returns>
  874. public ActionResult UserPwdEdit()
  875. {
  876. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
  877. Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
  878. if (F_UserID > 0)
  879. {
  880. model = userBLL.GetModel(F_UserID);
  881. }
  882. return View(model);
  883. }
  884. /// </summary>
  885. [AcceptVerbs(HttpVerbs.Post)]
  886. public ActionResult CheckPwd(string pwd)
  887. {
  888. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
  889. return Json(new
  890. {
  891. code = chkrslt.RSL ? 0 : 1,
  892. msg = chkrslt.MSG
  893. });
  894. }
  895. /// <summary>
  896. ///保存修改密码
  897. /// </summary>
  898. [AcceptVerbs(HttpVerbs.Post)]
  899. public string UpdateUserPwd(Model.T_Sys_UserAccount model)
  900. {
  901. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
  902. if(!chkrslt.RSL)
  903. {
  904. return chkrslt.MSG;
  905. }
  906. string AddRersult = "false";
  907. if (model.F_UserId > 0)
  908. {
  909. Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
  910. if (newModel != null && newModel.F_Password == model.oldPwd)
  911. {
  912. newModel.F_Password = model.password;
  913. if (userBLL.Update(newModel))
  914. {
  915. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
  916. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
  917. AddRersult = "True";
  918. }
  919. }
  920. else
  921. {
  922. AddRersult = "旧密码不正确!";
  923. }
  924. }
  925. return AddRersult;
  926. }
  927. #endregion
  928. #region 基本信息
  929. /// <summary>
  930. /// 用户编辑
  931. /// </summary>
  932. /// <param name="editType">类型1、新增 2、修改</param>
  933. /// /// <returns></returns>
  934. public ActionResult UserView()
  935. {
  936. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  937. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
  938. if (string.IsNullOrEmpty(userModel.F_HomePhone))
  939. {
  940. userModel.F_HomePhone = "/Content/images/face.jpg";
  941. }
  942. else
  943. {
  944. if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
  945. {
  946. userModel.F_HomePhone = "/Content/images/face.jpg";
  947. }
  948. }
  949. return View(userModel);
  950. }
  951. #endregion
  952. #region 图片上传
  953. /// <summary>
  954. /// 图片上传
  955. /// </summary>
  956. /// <returns></returns>
  957. [AcceptVerbs(HttpVerbs.Post)]
  958. public ActionResult UploadFile()
  959. {
  960. try
  961. {
  962. if (Request.Files.Count > 0)
  963. {
  964. string uppath = string.Empty;
  965. string savepath = string.Empty;
  966. HttpPostedFileBase imgFile = Request.Files[0];
  967. if (imgFile != null)
  968. {
  969. //创建图片新的名称
  970. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  971. //获得上传图片的路径
  972. string strPath = imgFile.FileName;
  973. //获得上传图片的类型(后缀名)
  974. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  975. //拼写数据库保存的相对路径字符串
  976. savepath = "/Content/HeadImg/images/";
  977. //拼写上传图片的路径
  978. uppath = Server.MapPath("~/Content/HeadImg/images/");
  979. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  980. {
  981. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  982. }
  983. uppath += nameImg + "." + type;
  984. savepath += nameImg + "." + type;
  985. //上传图片
  986. imgFile.SaveAs(uppath); //原图片路径
  987. }
  988. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  989. userModel.F_HomePhone = savepath;
  990. if (userBLL.Update(userModel))
  991. {
  992. return Json(new
  993. {
  994. code = 0,
  995. src = savepath,
  996. msg = "上传成功"
  997. });
  998. }
  999. else
  1000. {
  1001. return Json(new
  1002. {
  1003. code = 1,
  1004. src = "",
  1005. msg = "上传出错 请检查图片名称或图片内容"
  1006. });
  1007. }
  1008. }
  1009. else
  1010. {
  1011. return Json(new
  1012. {
  1013. code = 1,
  1014. src = "",
  1015. msg = "上传出错 请检查图片名称或图片内容"
  1016. });
  1017. }
  1018. }
  1019. catch (Exception ex)
  1020. {
  1021. return Json(new
  1022. {
  1023. code = 1,
  1024. src = "",
  1025. msg = "上传出错: " + ex.Message
  1026. });
  1027. }
  1028. }
  1029. #endregion
  1030. #region 公告管理
  1031. /// <summary>
  1032. /// 公告管理
  1033. /// </summary>
  1034. /// <returns></returns>
  1035. public ActionResult noticeManage()
  1036. {
  1037. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1038. return View(noticeModel);
  1039. }
  1040. public ActionResult test()
  1041. {
  1042. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1043. return View(noticeModel);
  1044. }
  1045. /// <summary>
  1046. /// 获取公告数据
  1047. /// </summary>
  1048. /// <param name="page">当前页码</param>
  1049. /// <param name="limit">每页数据量</param>
  1050. /// <returns></returns>
  1051. [ActionName("NoticeListDate")]
  1052. [HttpGet]
  1053. public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  1054. {
  1055. AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
  1056. //数据结果集
  1057. ResponseData dataModel = new ResponseData();
  1058. string sql = "";
  1059. if (parentId != null)
  1060. {
  1061. sql += " and F_ParentId=" + parentId;
  1062. }
  1063. DataTable dt = new DataTable();
  1064. int recordCount = 0;
  1065. Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
  1066. dt = BLL.PagerBLL.GetListPager(
  1067. "T_Msg_NoticeInfo",
  1068. "F_NoticeId",
  1069. "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew ",
  1070. sql,
  1071. "ORDER BY F_NoticeId desc ",
  1072. limit,
  1073. page,
  1074. true,
  1075. out recordCount);
  1076. dataModel.code = 0;
  1077. dataModel.count = recordCount;
  1078. dataModel.data = dt;
  1079. return JsonConvert.SerializeObject(dataModel);
  1080. }
  1081. BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
  1082. BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
  1083. BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
  1084. /// <summary>
  1085. /// 编辑公告
  1086. /// </summary>
  1087. /// <param name="editType">类型1、新增 2、修改</param>
  1088. /// /// <returns></returns>
  1089. public ActionResult NoticeEdit(int? noticeId, int editType)
  1090. {
  1091. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
  1092. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1093. //当前对象实体
  1094. if (editType == 1)
  1095. {
  1096. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1097. //viewModel.UseList = userBLL.GetModelList("");
  1098. }
  1099. else
  1100. {
  1101. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1102. viewModel = userModel;
  1103. if (!string.IsNullOrEmpty(userModel.F_ReceiveInfo))
  1104. {
  1105. viewModel.UseList = userBLL.GetModelList("F_UserId=" + userModel.F_DeviceId);
  1106. viewModel.DepartmentList = deptBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1107. }
  1108. }
  1109. //获取部门列表
  1110. return View(viewModel);
  1111. }
  1112. /// <summary>
  1113. /// 查看公告
  1114. /// </summary>
  1115. /// <param name="editType">类型1、新增 2、修改</param>
  1116. /// /// <returns></returns>
  1117. public ActionResult NoticeView(int? noticeId)
  1118. {
  1119. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
  1120. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1121. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1122. viewModel.UseList = userBLL.GetModelList("");
  1123. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1124. viewModel = userModel;
  1125. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1126. //获取部门列表
  1127. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1128. return View(viewModel);
  1129. }
  1130. /// <summary>
  1131. /// 保存编辑公告
  1132. /// </summary>
  1133. /// <param name="workOrderBaseModel"></param>
  1134. /// <returns></returns>
  1135. [AcceptVerbs(HttpVerbs.Post)]
  1136. public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
  1137. {
  1138. bool result = false;
  1139. DataTable dt = new DataTable();
  1140. DataTable dtuser = new DataTable();
  1141. int noticeid = 0;
  1142. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1143. DateTime? readdate =null;
  1144. try
  1145. {
  1146. //获取当前用户
  1147. noticeinfoModel.F_CreateBy = F_UserID;
  1148. noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
  1149. if (noticeinfoModel.F_NoticeId > 0)
  1150. {
  1151. noticeid = noticeinfoModel.F_NoticeId;
  1152. Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
  1153. dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
  1154. if (dt.Rows.Count > 0)
  1155. {
  1156. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
  1157. foreach (DataRow dr in dtuser.Rows)
  1158. {
  1159. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1160. result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
  1161. }
  1162. }
  1163. readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
  1164. oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
  1165. oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
  1166. oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
  1167. oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
  1168. oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
  1169. oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
  1170. oldnoticeinfoModel.F_State = 1;
  1171. result = noticeBLL.Update(oldnoticeinfoModel);
  1172. AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
  1173. }
  1174. else
  1175. {
  1176. noticeid = 0;
  1177. noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
  1178. noticeinfoModel.F_State = 1;
  1179. noticeinfoModel.F_CreateOn = DateTime.Now;
  1180. readdate = noticeinfoModel.F_CreateOn;
  1181. noticeid = noticeBLL.Add(noticeinfoModel);
  1182. AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
  1183. }
  1184. //指定方式发送公告
  1185. if (noticeinfoModel.F_DeviceId > 0)
  1186. {//指定人员发公告
  1187. noticeuserModel.F_NoticeId = noticeid;
  1188. noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
  1189. noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
  1190. if (readdate.ToString() != "")
  1191. { noticeuserModel.F_ReadDate = readdate; }
  1192. else
  1193. {
  1194. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1195. }
  1196. noticeuserModel.F_State = 0;
  1197. noticeuserModel.F_Type = 0;
  1198. result = noticeuserBLL.Add(noticeuserModel);
  1199. }
  1200. else
  1201. {//指定部门发公告
  1202. dt = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
  1203. if (dt.Rows.Count > 0)
  1204. {
  1205. noticeuserModel.F_NoticeId = noticeid;
  1206. if (readdate.ToString()!="")
  1207. { noticeuserModel.F_ReadDate = readdate; }
  1208. else {
  1209. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1210. }
  1211. foreach (DataRow dr in dt.Rows)
  1212. {
  1213. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1214. noticeuserModel.F_UserName = dr["F_UserName"].ToString();
  1215. noticeuserModel.F_State = 0;
  1216. noticeuserModel.F_Type = 0;
  1217. result = noticeuserBLL.Add(noticeuserModel);
  1218. }
  1219. }
  1220. }
  1221. }
  1222. catch (Exception) { }
  1223. finally
  1224. {
  1225. dt.Clear();
  1226. dt.Dispose();
  1227. }
  1228. return result;
  1229. }
  1230. /// <summary>
  1231. /// 删除公告
  1232. /// </summary>
  1233. /// <param name="workOrderBaseModel"></param>
  1234. /// <returns></returns>
  1235. [AcceptVerbs(HttpVerbs.Get)]
  1236. public bool DeleteNoticeData(int noticeId)
  1237. {
  1238. bool res = false;
  1239. DataTable dt = new DataTable();
  1240. DataTable dtuser = new DataTable();
  1241. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1242. try
  1243. {
  1244. dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
  1245. if (dt.Rows.Count > 0)
  1246. {
  1247. res = noticeBLL.Delete(noticeId);
  1248. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
  1249. //指定部门发公告
  1250. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
  1251. foreach (DataRow dr in dtuser.Rows)
  1252. {
  1253. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1254. noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
  1255. }
  1256. }
  1257. }
  1258. catch (Exception) { }
  1259. finally {
  1260. dt.Clear();
  1261. dt.Dispose();
  1262. dtuser.Clear();
  1263. dtuser.Dispose();
  1264. }
  1265. return res;
  1266. }
  1267. /// <summary>
  1268. /// 未接根据recordid更新回访信息
  1269. /// </summary>
  1270. /// <param name="SetCallRecordHfInfo"></param>
  1271. /// <returns></returns>
  1272. [ActionName("SetNoticeState")]
  1273. [HttpGet]
  1274. public string SetNoticeState(string id, string timeno)
  1275. {
  1276. string res = "";
  1277. try
  1278. {
  1279. Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
  1280. model.F_State =1;
  1281. model.F_NoticeId = Convert.ToInt32(id);
  1282. bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
  1283. if (bl)
  1284. {
  1285. res = "success";
  1286. }
  1287. }
  1288. catch
  1289. { }
  1290. return res;
  1291. }
  1292. [ActionName("CookieData")]
  1293. [HttpGet]
  1294. public string CookieData() {
  1295. return F_UserID.ToString();
  1296. }
  1297. #endregion
  1298. }
  1299. #region 接口基本信息
  1300. /// <summary>
  1301. /// 用户信息
  1302. /// </summary>
  1303. public class UserInfo
  1304. {
  1305. public int id
  1306. {
  1307. get;
  1308. set;
  1309. }
  1310. public string name
  1311. {
  1312. get;
  1313. set;
  1314. }
  1315. }
  1316. /// <summary>
  1317. /// 返回结果信息
  1318. /// </summary>
  1319. public class ResponseResult
  1320. {
  1321. public int code
  1322. {
  1323. get;
  1324. set;
  1325. }
  1326. public int data
  1327. {
  1328. get;
  1329. set;
  1330. }
  1331. }
  1332. /// <summary>
  1333. /// 返回结果信息
  1334. /// </summary>
  1335. public class WXResponseResult
  1336. {
  1337. public int customer
  1338. {
  1339. get;
  1340. set;
  1341. }
  1342. public int service
  1343. {
  1344. get;
  1345. set;
  1346. }
  1347. public int total
  1348. {
  1349. get;
  1350. set;
  1351. }
  1352. }
  1353. #endregion
  1354. }