地铁二期项目正式开始

SystemManageController.cs 54KB

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