地铁二期项目正式开始

SystemManageController.cs 57KB

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