地铁二期项目正式开始

SystemManageController.cs 52KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  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. if (roleInfoModel.F_RoleId > 0)
  191. {
  192. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", roleInfoModel.F_RoleName);
  193. AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", "数据:" + JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  194. return roleBLL.Update(roleInfoModel);
  195. }
  196. else
  197. {
  198. int id = roleBLL.Add(roleInfoModel);
  199. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", roleInfoModel.F_RoleName);
  200. AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", "数据:" +JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
  201. return id > 0;
  202. }
  203. }
  204. /// <summary>
  205. /// 删除数据
  206. /// </summary>
  207. /// <param name="workOrderBaseModel"></param>
  208. /// <returns></returns>
  209. [AcceptVerbs(HttpVerbs.Get)]
  210. public bool DeleteRoleData(string roleId)
  211. {
  212. Model.T_Sys_RoleInfo viewModel = roleBLL.GetModel(int.Parse(roleId.ToString()));
  213. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色");
  214. AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色", "数据:" + JsonConvert.SerializeObject(viewModel), "敏感信息");
  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="editType">类型1、新增 2、修改</param>
  461. /// /// <returns></returns>
  462. public ActionResult DictionaryBaseEdit(string dicCode, int editType)
  463. {
  464. AddAction("t_sys_dictionarybase".ToLower(), dicCode, "打开字典编辑页");
  465. Model.T_Sys_DictionaryBase viewModel = new Model.T_Sys_DictionaryBase();
  466. //当前对象实体
  467. if (editType == 1)
  468. {
  469. viewModel.F_Sort = 1;
  470. }
  471. else
  472. {
  473. Model.T_Sys_DictionaryBase dicBaseModel = dicBaseBLL.GetModel(dicCode);
  474. viewModel = dicBaseModel;
  475. }
  476. return View(viewModel);
  477. }
  478. /// <summary>
  479. /// 保存字典项编辑
  480. /// </summary>
  481. /// <param name="workOrderBaseModel"></param>
  482. /// <returns></returns>
  483. [AcceptVerbs(HttpVerbs.Post)]
  484. public bool SaveDictionaryBaseData(T_Sys_DictionaryBase dicBaseModel)
  485. {
  486. if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
  487. {
  488. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "更新字典项");
  489. return dicBaseBLL.Update(dicBaseModel);
  490. }
  491. else
  492. {
  493. AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "添加字典项");
  494. return dicBaseBLL.Add(dicBaseModel);
  495. }
  496. }
  497. /// <summary>
  498. /// 删除字典项
  499. /// </summary>
  500. /// <param name="workOrderBaseModel"></param>
  501. /// <returns></returns>
  502. [AcceptVerbs(HttpVerbs.Get)]
  503. public bool DeleteBaseData(string baseCode)
  504. {
  505. AddAction("t_sys_dictionarybase", baseCode,"删除字典项");
  506. return dicBaseBLL.Delete(baseCode);
  507. }
  508. /// <summary>
  509. /// 字典值编辑
  510. /// </summary>
  511. /// <param name="editType">类型1、新增 2、修改</param>
  512. /// /// <returns></returns>
  513. public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
  514. {
  515. AddAction("t_sys_dictionarybase".ToLower(), valueId.ToMyString(), "打开字典值编辑页");
  516. Model.T_Sys_DictionaryValue viewModel = new Model.T_Sys_DictionaryValue();
  517. //当前对象实体
  518. if (editType == 1)
  519. {
  520. viewModel.F_Sort = 1;
  521. viewModel.F_DictionaryFlag = parentCode;
  522. }
  523. else
  524. {
  525. Model.T_Sys_DictionaryValue dicValueModel = dicValueBLL.GetModel(int.Parse(valueId.ToString()));
  526. viewModel = dicValueModel;
  527. }
  528. return View(viewModel);
  529. }
  530. /// <summary>
  531. /// 保存字典值
  532. /// </summary>
  533. /// <param name="workOrderBaseModel"></param>
  534. /// <returns></returns>
  535. [AcceptVerbs(HttpVerbs.Post)]
  536. public bool SaveDictionaryValueData(T_Sys_DictionaryValue dicBaseModel)
  537. {
  538. if (dicBaseModel.F_DictionaryValueId > 0)
  539. {
  540. AddAction("t_sys_dictionaryvalue", dicBaseModel.F_DictionaryValueId.ToMyString(), "更新字典值");
  541. return dicValueBLL.Update(dicBaseModel);
  542. }
  543. else
  544. {
  545. int id = dicValueBLL.Add(dicBaseModel);
  546. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "添加字典值");
  547. return id > 0;
  548. }
  549. }
  550. /// <summary>
  551. /// 删除字典值
  552. /// </summary>
  553. /// <param name="workOrderBaseModel"></param>
  554. /// <returns></returns>
  555. [AcceptVerbs(HttpVerbs.Get)]
  556. public bool DeleteValueData(int id)
  557. {
  558. AddAction("t_sys_dictionaryvalue", id.ToMyString(), "删除字典值");
  559. return dicValueBLL.Delete(id);
  560. }
  561. #endregion
  562. #region 菜单管理
  563. BLL.T_Sys_ModuleFunctions menuBLL = new BLL.T_Sys_ModuleFunctions();
  564. /// <summary>
  565. /// 部门列表
  566. /// </summary>
  567. /// <returns></returns>
  568. public ActionResult MenuList()
  569. {
  570. WorkOrderMyModel model = new WorkOrderMyModel();
  571. return View(model);
  572. }
  573. ///通过部门父级节点获取数据
  574. /// </summary>
  575. /// <param name="fid"></param>
  576. /// <returns></returns>
  577. public string GetMenuJsonModel(int parentId)
  578. {
  579. AddAction("t_sys_modulefunctions", parentId.ToMyString(), "获取父级下菜单","父级id:"+ parentId);
  580. return Newtonsoft.Json.JsonConvert.SerializeObject(menuBLL.GetMenuJsonModel(parentId));
  581. }
  582. /// <summary>
  583. /// 获取部门数据
  584. /// </summary>
  585. /// <param name="page">当前页码</param>
  586. /// <param name="limit">每页数据量</param>
  587. /// <returns></returns>
  588. [ActionName("MenuDate")]
  589. [HttpGet]
  590. public string MenuDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  591. {
  592. AddAction("t_sys_modulefunctions", "page", "获取菜单列表",page+"-"+limit);
  593. //数据结果集
  594. ResponseData dataModel = new ResponseData();
  595. string sql = "";
  596. if (parentId != null)
  597. {
  598. sql += " and F_ParentId=" + parentId;
  599. }
  600. DataTable dt = new DataTable();
  601. int recordCount = 0;
  602. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  603. dt = BLL.PagerBLL.GetListPager(
  604. "T_Sys_ModuleFunctions",
  605. "F_FunctionId",
  606. "* ,(CASE F_StateFlag WHEN 1 THEN '启用' WHEN 0 THEN '禁用' ELSE NULL END ) as F_StateFlagName",
  607. sql,
  608. "ORDER BY F_Sort asc ",
  609. limit,
  610. page,
  611. true,
  612. out recordCount);
  613. dataModel.code = 0;
  614. dataModel.count = recordCount;
  615. dataModel.data = dt;
  616. return JsonConvert.SerializeObject(dataModel);
  617. }
  618. /// <summary>
  619. /// 功能编辑
  620. /// </summary>
  621. /// <param name="editType">类型1、新增 2、修改</param>
  622. /// /// <returns></returns>
  623. public ActionResult MenuEdit(int menuId, int editType)
  624. {
  625. Model.T_Sys_ModuleFunctions viewModel = new Model.T_Sys_ModuleFunctions();
  626. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "打开功能编辑页", "菜单编号"+ menuId);
  627. //当前对象实体
  628. if (editType == 1)
  629. {
  630. viewModel.F_ParentId = menuId;
  631. viewModel.F_Sort = 1;
  632. }
  633. else
  634. {
  635. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  636. viewModel = deptModel;
  637. }
  638. return View(viewModel);
  639. }
  640. /// <summary>
  641. /// 保存编辑
  642. /// </summary>
  643. /// <param name="workOrderBaseModel"></param>
  644. /// <returns></returns>
  645. [AcceptVerbs(HttpVerbs.Post)]
  646. public bool SaveMenuData(T_Sys_ModuleFunctions menuModel)
  647. {
  648. if (menuModel.F_FunctionId > 0)
  649. {
  650. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", menuModel.F_Name);
  651. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", "数据:"+JsonConvert.SerializeObject(menuModel), "主要设置");
  652. return menuBLL.Update(menuModel);
  653. }
  654. else
  655. {
  656. int id = menuBLL.Add(menuModel);
  657. AddAction("t_sys_modulefunctions", id.ToMyString(), "添加菜单", menuModel.F_Name);
  658. AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "添加菜单", "数据:" + JsonConvert.SerializeObject(menuModel), "主要设置");
  659. return id > 0;
  660. }
  661. }
  662. /// <summary>
  663. /// 删除功能
  664. /// </summary>
  665. /// <param name="workOrderBaseModel"></param>
  666. /// <returns></returns>
  667. [AcceptVerbs(HttpVerbs.Get)]
  668. public bool DeleteMenuData(int menuId)
  669. {
  670. Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
  671. AddAction("t_sys_modulefunctions", deptModel.F_FunctionId.ToMyString(), "删除菜单", "数据:" + JsonConvert.SerializeObject(deptModel), "主要设置");
  672. AddAction("t_sys_modulefunctions", menuId.ToMyString(), "删除菜单");
  673. return menuBLL.Delete(menuId);
  674. }
  675. #endregion
  676. #region 用户管理
  677. BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
  678. /// <summary>
  679. /// 部门列表
  680. /// </summary>
  681. /// <returns></returns>
  682. public ActionResult UserList()
  683. {
  684. WorkOrderMyModel model = new WorkOrderMyModel();
  685. return View(model);
  686. }
  687. /// <summary>
  688. /// 用户编辑
  689. /// </summary>
  690. /// <param name="editType">类型1、新增 2、修改</param>
  691. /// /// <returns></returns>
  692. public ActionResult UserEdit(int? userId, int? deptId, int editType)
  693. {
  694. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "用户编号/部门" + userId+"-"+ deptId);
  695. Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
  696. //当前对象实体
  697. if (editType == 1)
  698. {
  699. viewModel.F_DeptId = int.Parse(deptId.ToString());
  700. AddAction("t_sys_useraccount", deptId.ToMyString(), "打开用户添加页", "", "敏感信息");
  701. }
  702. else
  703. {
  704. Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
  705. viewModel = userModel;
  706. AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  707. }
  708. //获取部门列表
  709. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  710. //获取角色列表
  711. viewModel.RoleInfoList = roleBLL.GetModelList("");
  712. return View(viewModel);
  713. }
  714. /// <summary>
  715. /// 保存编辑
  716. /// </summary>
  717. /// <param name="workOrderBaseModel"></param>
  718. /// <returns></returns>
  719. [AcceptVerbs(HttpVerbs.Post)]
  720. public bool SaveUserData(T_Sys_UserAccount userModel)
  721. {
  722. userModel.F_WorkNumber = userModel.F_UserCode;
  723. if (userModel.F_UserId > 0)
  724. {
  725. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
  726. oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
  727. oldUserModel.F_UserName = userModel.F_UserName;
  728. oldUserModel.F_UserCode = userModel.F_UserCode;
  729. oldUserModel.F_DeptId = userModel.F_DeptId;
  730. oldUserModel.F_RoleId = userModel.F_RoleId;
  731. oldUserModel.F_SexFlag = userModel.F_SexFlag;
  732. oldUserModel.F_Telephone = userModel.F_Telephone;
  733. oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
  734. oldUserModel.F_SeatRight = userModel.F_SeatRight;
  735. oldUserModel.F_Password = userModel.F_Password;
  736. oldUserModel.F_Remark = userModel.F_Remark;
  737. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
  738. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  739. return userBLL.Update(oldUserModel);
  740. }
  741. else
  742. {
  743. userModel.F_HJType = 0;
  744. userModel.F_GroupId = 1;
  745. if (userModel.F_SeatFlag&&false)
  746. {
  747. #region 调用接口插入用户信息
  748. try
  749. {
  750. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
  751. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  752. StringBuilder returnStr = new StringBuilder();
  753. string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
  754. UserInfo model = new UserInfo();
  755. model.name = userModel.F_UserCode;
  756. object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
  757. string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
  758. ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
  759. userModel.F_PId = ResultModel.data;
  760. }
  761. catch (Exception ex)
  762. {
  763. }
  764. #endregion
  765. }
  766. int userid = userBLL.Add(userModel);
  767. AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
  768. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  769. return userid > 0;
  770. }
  771. }
  772. /// <summary>
  773. /// 删除用户
  774. /// </summary>
  775. /// <param name="workOrderBaseModel"></param>
  776. /// <returns></returns>
  777. [AcceptVerbs(HttpVerbs.Get)]
  778. public bool DeleteUserData(int userId)
  779. {
  780. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
  781. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
  782. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  783. return userBLL.Delete(userId);
  784. }
  785. /// <summary>
  786. /// 获取用户数据
  787. /// </summary>
  788. /// <param name="page">当前页码</param>
  789. /// <param name="limit">每页数据量</param>
  790. /// <returns></returns>
  791. [ActionName("UserDate")]
  792. [HttpGet]
  793. public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
  794. {
  795. AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
  796. //数据结果集
  797. ResponseData dataModel = new ResponseData();
  798. string sql = "";
  799. if (deptId != null && deptId > 0)
  800. {
  801. sql += " and F_DeptId=" + deptId;
  802. }
  803. DataTable dt = new DataTable();
  804. int recordCount = 0;
  805. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  806. dt = BLL.PagerBLL.GetListPager(
  807. "T_Sys_UserAccount",
  808. "F_UserId",
  809. "*"
  810. + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
  811. + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
  812. + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
  813. + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
  814. ,
  815. sql,
  816. "ORDER BY F_UserCode asc ",
  817. limit,
  818. page,
  819. true,
  820. out recordCount);
  821. dataModel.code = 0;
  822. dataModel.count = recordCount;
  823. dataModel.data = dt;
  824. return JsonConvert.SerializeObject(dataModel);
  825. }
  826. #endregion
  827. #region 修改密码
  828. /// <summary>
  829. ///用户修改个人密码
  830. /// </summary>
  831. /// <param name="id"></param>
  832. /// <returns></returns>
  833. public ActionResult UserPwdEdit()
  834. {
  835. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
  836. Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
  837. if (F_UserID > 0)
  838. {
  839. model = userBLL.GetModel(F_UserID);
  840. }
  841. return View(model);
  842. }
  843. /// </summary>
  844. [AcceptVerbs(HttpVerbs.Post)]
  845. public ActionResult CheckPwd(string pwd)
  846. {
  847. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
  848. return Json(new
  849. {
  850. code = chkrslt.RSL ? 0 : 1,
  851. msg = chkrslt.MSG
  852. });
  853. }
  854. /// <summary>
  855. ///保存修改密码
  856. /// </summary>
  857. [AcceptVerbs(HttpVerbs.Post)]
  858. public string UpdateUserPwd(Model.T_Sys_UserAccount model)
  859. {
  860. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
  861. if(!chkrslt.RSL)
  862. {
  863. return chkrslt.MSG;
  864. }
  865. string AddRersult = "false";
  866. if (model.F_UserId > 0)
  867. {
  868. Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
  869. if (newModel != null && newModel.F_Password == model.oldPwd)
  870. {
  871. newModel.F_Password = model.password;
  872. if (userBLL.Update(newModel))
  873. {
  874. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
  875. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
  876. AddRersult = "True";
  877. }
  878. }
  879. else
  880. {
  881. AddRersult = "旧密码不正确!";
  882. }
  883. }
  884. return AddRersult;
  885. }
  886. #endregion
  887. #region 基本信息
  888. /// <summary>
  889. /// 用户编辑
  890. /// </summary>
  891. /// <param name="editType">类型1、新增 2、修改</param>
  892. /// /// <returns></returns>
  893. public ActionResult UserView()
  894. {
  895. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  896. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
  897. if (string.IsNullOrEmpty(userModel.F_HomePhone))
  898. {
  899. userModel.F_HomePhone = "/Content/images/face.jpg";
  900. }
  901. else
  902. {
  903. if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
  904. {
  905. userModel.F_HomePhone = "/Content/images/face.jpg";
  906. }
  907. }
  908. return View(userModel);
  909. }
  910. #endregion
  911. #region 图片上传
  912. /// <summary>
  913. /// 图片上传
  914. /// </summary>
  915. /// <returns></returns>
  916. [AcceptVerbs(HttpVerbs.Post)]
  917. public ActionResult UploadFile()
  918. {
  919. try
  920. {
  921. if (Request.Files.Count > 0)
  922. {
  923. string uppath = string.Empty;
  924. string savepath = string.Empty;
  925. HttpPostedFileBase imgFile = Request.Files[0];
  926. if (imgFile != null)
  927. {
  928. //创建图片新的名称
  929. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  930. //获得上传图片的路径
  931. string strPath = imgFile.FileName;
  932. //获得上传图片的类型(后缀名)
  933. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  934. //拼写数据库保存的相对路径字符串
  935. savepath = "/Content/HeadImg/images/";
  936. //拼写上传图片的路径
  937. uppath = Server.MapPath("~/Content/HeadImg/images/");
  938. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  939. {
  940. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  941. }
  942. uppath += nameImg + "." + type;
  943. savepath += nameImg + "." + type;
  944. //上传图片
  945. imgFile.SaveAs(uppath); //原图片路径
  946. }
  947. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  948. userModel.F_HomePhone = savepath;
  949. if (userBLL.Update(userModel))
  950. {
  951. return Json(new
  952. {
  953. code = 0,
  954. src = savepath,
  955. msg = "上传成功"
  956. });
  957. }
  958. else
  959. {
  960. return Json(new
  961. {
  962. code = 1,
  963. src = "",
  964. msg = "上传出错 请检查图片名称或图片内容"
  965. });
  966. }
  967. }
  968. else
  969. {
  970. return Json(new
  971. {
  972. code = 1,
  973. src = "",
  974. msg = "上传出错 请检查图片名称或图片内容"
  975. });
  976. }
  977. }
  978. catch (Exception ex)
  979. {
  980. return Json(new
  981. {
  982. code = 1,
  983. src = "",
  984. msg = "上传出错: " + ex.Message
  985. });
  986. }
  987. }
  988. #endregion
  989. #region 公告管理
  990. /// <summary>
  991. /// 公告管理
  992. /// </summary>
  993. /// <returns></returns>
  994. public ActionResult noticeManage()
  995. {
  996. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  997. return View(noticeModel);
  998. }
  999. public ActionResult test()
  1000. {
  1001. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1002. return View(noticeModel);
  1003. }
  1004. /// <summary>
  1005. /// 获取公告数据
  1006. /// </summary>
  1007. /// <param name="page">当前页码</param>
  1008. /// <param name="limit">每页数据量</param>
  1009. /// <returns></returns>
  1010. [ActionName("NoticeListDate")]
  1011. [HttpGet]
  1012. public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  1013. {
  1014. AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
  1015. //数据结果集
  1016. ResponseData dataModel = new ResponseData();
  1017. string sql = "";
  1018. if (parentId != null)
  1019. {
  1020. sql += " and F_ParentId=" + parentId;
  1021. }
  1022. DataTable dt = new DataTable();
  1023. int recordCount = 0;
  1024. Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
  1025. dt = BLL.PagerBLL.GetListPager(
  1026. "T_Msg_NoticeInfo",
  1027. "F_NoticeId",
  1028. "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew ",
  1029. sql,
  1030. "ORDER BY F_NoticeId desc ",
  1031. limit,
  1032. page,
  1033. true,
  1034. out recordCount);
  1035. dataModel.code = 0;
  1036. dataModel.count = recordCount;
  1037. dataModel.data = dt;
  1038. return JsonConvert.SerializeObject(dataModel);
  1039. }
  1040. BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
  1041. BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
  1042. BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
  1043. /// <summary>
  1044. /// 编辑公告
  1045. /// </summary>
  1046. /// <param name="editType">类型1、新增 2、修改</param>
  1047. /// /// <returns></returns>
  1048. public ActionResult NoticeEdit(int? noticeId, int editType)
  1049. {
  1050. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
  1051. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1052. //当前对象实体
  1053. if (editType == 1)
  1054. {
  1055. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1056. viewModel.UseList = userBLL.GetModelList("");
  1057. }
  1058. else
  1059. {
  1060. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1061. viewModel = userModel;
  1062. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1063. }
  1064. //获取部门列表
  1065. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1066. return View(viewModel);
  1067. }
  1068. /// <summary>
  1069. /// 查看公告
  1070. /// </summary>
  1071. /// <param name="editType">类型1、新增 2、修改</param>
  1072. /// /// <returns></returns>
  1073. public ActionResult NoticeView(int? noticeId)
  1074. {
  1075. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
  1076. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1077. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1078. viewModel.UseList = userBLL.GetModelList("");
  1079. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1080. viewModel = userModel;
  1081. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1082. //获取部门列表
  1083. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1084. return View(viewModel);
  1085. }
  1086. /// <summary>
  1087. /// 保存编辑公告
  1088. /// </summary>
  1089. /// <param name="workOrderBaseModel"></param>
  1090. /// <returns></returns>
  1091. [AcceptVerbs(HttpVerbs.Post)]
  1092. public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
  1093. {
  1094. bool result = false;
  1095. DataTable dt = new DataTable();
  1096. DataTable dtuser = new DataTable();
  1097. int noticeid = 0;
  1098. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1099. DateTime? readdate =null;
  1100. try
  1101. {
  1102. //获取当前用户
  1103. noticeinfoModel.F_CreateBy = F_UserID;
  1104. noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
  1105. if (noticeinfoModel.F_NoticeId > 0)
  1106. {
  1107. noticeid = noticeinfoModel.F_NoticeId;
  1108. Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
  1109. dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
  1110. if (dt.Rows.Count > 0)
  1111. {
  1112. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
  1113. foreach (DataRow dr in dtuser.Rows)
  1114. {
  1115. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1116. result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
  1117. }
  1118. }
  1119. readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
  1120. oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
  1121. oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
  1122. oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
  1123. oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
  1124. oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
  1125. oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
  1126. oldnoticeinfoModel.F_State = 1;
  1127. result = noticeBLL.Update(oldnoticeinfoModel);
  1128. AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
  1129. }
  1130. else
  1131. {
  1132. noticeid = 0;
  1133. noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
  1134. noticeinfoModel.F_State = 1;
  1135. noticeinfoModel.F_CreateOn = DateTime.Now;
  1136. readdate = noticeinfoModel.F_CreateOn;
  1137. noticeid = noticeBLL.Add(noticeinfoModel);
  1138. AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
  1139. }
  1140. //指定方式发送公告
  1141. if (noticeinfoModel.F_DeviceId > 0)
  1142. {//指定人员发公告
  1143. noticeuserModel.F_NoticeId = noticeid;
  1144. noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
  1145. noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
  1146. if (readdate.ToString() != "")
  1147. { noticeuserModel.F_ReadDate = readdate; }
  1148. else
  1149. {
  1150. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1151. }
  1152. noticeuserModel.F_State = 0;
  1153. noticeuserModel.F_Type = 0;
  1154. result = noticeuserBLL.Add(noticeuserModel);
  1155. }
  1156. else
  1157. {//指定部门发公告
  1158. dt = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
  1159. if (dt.Rows.Count > 0)
  1160. {
  1161. noticeuserModel.F_NoticeId = noticeid;
  1162. if (readdate.ToString()!="")
  1163. { noticeuserModel.F_ReadDate = readdate; }
  1164. else {
  1165. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1166. }
  1167. foreach (DataRow dr in dt.Rows)
  1168. {
  1169. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1170. noticeuserModel.F_UserName = dr["F_UserName"].ToString();
  1171. noticeuserModel.F_State = 0;
  1172. noticeuserModel.F_Type = 0;
  1173. result = noticeuserBLL.Add(noticeuserModel);
  1174. }
  1175. }
  1176. }
  1177. }
  1178. catch (Exception) { }
  1179. finally
  1180. {
  1181. dt.Clear();
  1182. dt.Dispose();
  1183. }
  1184. return result;
  1185. }
  1186. /// <summary>
  1187. /// 删除公告
  1188. /// </summary>
  1189. /// <param name="workOrderBaseModel"></param>
  1190. /// <returns></returns>
  1191. [AcceptVerbs(HttpVerbs.Get)]
  1192. public bool DeleteNoticeData(int noticeId)
  1193. {
  1194. bool res = false;
  1195. DataTable dt = new DataTable();
  1196. DataTable dtuser = new DataTable();
  1197. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1198. try
  1199. {
  1200. dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
  1201. if (dt.Rows.Count > 0)
  1202. {
  1203. res = noticeBLL.Delete(noticeId);
  1204. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
  1205. //指定部门发公告
  1206. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
  1207. foreach (DataRow dr in dtuser.Rows)
  1208. {
  1209. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1210. noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
  1211. }
  1212. }
  1213. }
  1214. catch (Exception) { }
  1215. finally {
  1216. dt.Clear();
  1217. dt.Dispose();
  1218. dtuser.Clear();
  1219. dtuser.Dispose();
  1220. }
  1221. return res;
  1222. }
  1223. /// <summary>
  1224. /// 未接根据recordid更新回访信息
  1225. /// </summary>
  1226. /// <param name="SetCallRecordHfInfo"></param>
  1227. /// <returns></returns>
  1228. [ActionName("SetNoticeState")]
  1229. [HttpGet]
  1230. public string SetNoticeState(string id, string timeno)
  1231. {
  1232. string res = "";
  1233. try
  1234. {
  1235. Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
  1236. model.F_State =1;
  1237. model.F_NoticeId = Convert.ToInt32(id);
  1238. bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
  1239. if (bl)
  1240. {
  1241. res = "success";
  1242. }
  1243. }
  1244. catch
  1245. { }
  1246. return res;
  1247. }
  1248. [ActionName("CookieData")]
  1249. [HttpGet]
  1250. public string CookieData() {
  1251. return F_UserID.ToString();
  1252. }
  1253. #endregion
  1254. }
  1255. #region 接口基本信息
  1256. /// <summary>
  1257. /// 用户信息
  1258. /// </summary>
  1259. public class UserInfo
  1260. {
  1261. public int id
  1262. {
  1263. get;
  1264. set;
  1265. }
  1266. public string name
  1267. {
  1268. get;
  1269. set;
  1270. }
  1271. }
  1272. /// <summary>
  1273. /// 返回结果信息
  1274. /// </summary>
  1275. public class ResponseResult
  1276. {
  1277. public int code
  1278. {
  1279. get;
  1280. set;
  1281. }
  1282. public int data
  1283. {
  1284. get;
  1285. set;
  1286. }
  1287. }
  1288. /// <summary>
  1289. /// 返回结果信息
  1290. /// </summary>
  1291. public class WXResponseResult
  1292. {
  1293. public int customer
  1294. {
  1295. get;
  1296. set;
  1297. }
  1298. public int service
  1299. {
  1300. get;
  1301. set;
  1302. }
  1303. public int total
  1304. {
  1305. get;
  1306. set;
  1307. }
  1308. }
  1309. #endregion
  1310. }