地铁二期项目正式开始

SystemManageController.cs 55KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553
  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. BLL.T_Sys_RoleInfo bll = new BLL.T_Sys_RoleInfo();
  763. Model.T_Sys_RoleInfo role = bll.GetModel(userModel.F_RoleId);
  764. //要修改de账号 角色代码,登录人不是系统管理员,返回false
  765. if (role.F_RoleCode== "XTGLY" || role.F_RoleCode == "YWGLY")
  766. {
  767. Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID);
  768. if (role2.F_RoleCode !="XTGLY" )
  769. {
  770. return false;
  771. }
  772. }
  773. userModel.F_WorkNumber = userModel.F_UserCode;
  774. if (userModel.F_UserId > 0)
  775. {
  776. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
  777. oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
  778. oldUserModel.F_UserName = userModel.F_UserName;
  779. oldUserModel.F_UserCode = userModel.F_UserCode;
  780. oldUserModel.F_DeptId = userModel.F_DeptId;
  781. oldUserModel.F_RoleId = userModel.F_RoleId;
  782. oldUserModel.F_SexFlag = userModel.F_SexFlag;
  783. oldUserModel.F_Telephone = userModel.F_Telephone;
  784. oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
  785. oldUserModel.F_SeatRight = userModel.F_SeatRight;
  786. oldUserModel.F_Password = userModel.F_Password;
  787. oldUserModel.F_Remark = userModel.F_Remark;
  788. oldUserModel.F_ExtensionNumber = userModel.F_ExtensionNumber.ToMyString();
  789. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
  790. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  791. return userBLL.Update(oldUserModel);
  792. }
  793. else
  794. {
  795. userModel.F_HJType = 0;
  796. userModel.F_GroupId = 1;
  797. if (userModel.F_SeatFlag)//&&false)
  798. {
  799. #region 调用接口插入用户信息
  800. try
  801. {
  802. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
  803. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  804. StringBuilder returnStr = new StringBuilder();
  805. string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
  806. UserInfo model = new UserInfo();
  807. model.name = userModel.F_UserCode;
  808. object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
  809. string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
  810. ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
  811. userModel.F_PId = ResultModel.data;
  812. }
  813. catch (Exception ex)
  814. {
  815. }
  816. #endregion
  817. }
  818. int userid = userBLL.Add(userModel);
  819. AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
  820. AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
  821. return userid > 0;
  822. }
  823. }
  824. /// <summary>
  825. /// 删除用户
  826. /// </summary>
  827. /// <param name="workOrderBaseModel"></param>
  828. /// <returns></returns>
  829. [AcceptVerbs(HttpVerbs.Get)]
  830. public bool DeleteUserData(int userId)
  831. {
  832. T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
  833. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
  834. AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
  835. return userBLL.Delete(userId);
  836. }
  837. /// <summary>
  838. /// 获取用户数据
  839. /// </summary>
  840. /// <param name="page">当前页码</param>
  841. /// <param name="limit">每页数据量</param>
  842. /// <returns></returns>
  843. [ActionName("UserDate")]
  844. [HttpGet]
  845. public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
  846. {
  847. AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
  848. //数据结果集
  849. ResponseData dataModel = new ResponseData();
  850. string sql = "";
  851. if (deptId != null && deptId > 0)
  852. {
  853. sql += " and F_DeptId=" + deptId;
  854. }
  855. DataTable dt = new DataTable();
  856. int recordCount = 0;
  857. Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
  858. dt = BLL.PagerBLL.GetListPager(
  859. "T_Sys_UserAccount",
  860. "F_UserId",
  861. "*"
  862. + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
  863. + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
  864. + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
  865. + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
  866. ,
  867. sql,
  868. "ORDER BY F_UserCode asc ",
  869. limit,
  870. page,
  871. true,
  872. out recordCount);
  873. dataModel.code = 0;
  874. dataModel.count = recordCount;
  875. dataModel.data = dt;
  876. return JsonConvert.SerializeObject(dataModel);
  877. }
  878. #endregion
  879. #region 修改密码
  880. /// <summary>
  881. ///用户修改个人密码
  882. /// </summary>
  883. /// <param name="id"></param>
  884. /// <returns></returns>
  885. public ActionResult UserPwdEdit()
  886. {
  887. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
  888. Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
  889. if (F_UserID > 0)
  890. {
  891. model = userBLL.GetModel(F_UserID);
  892. }
  893. return View(model);
  894. }
  895. /// </summary>
  896. [AcceptVerbs(HttpVerbs.Post)]
  897. public ActionResult CheckPwd(string pwd)
  898. {
  899. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
  900. return Json(new
  901. {
  902. code = chkrslt.RSL ? 0 : 1,
  903. msg = chkrslt.MSG
  904. });
  905. }
  906. /// <summary>
  907. ///保存修改密码
  908. /// </summary>
  909. [AcceptVerbs(HttpVerbs.Post)]
  910. public string UpdateUserPwd(Model.T_Sys_UserAccount model)
  911. {
  912. checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
  913. if(!chkrslt.RSL)
  914. {
  915. return chkrslt.MSG;
  916. }
  917. string AddRersult = "false";
  918. if (model.F_UserId > 0)
  919. {
  920. Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
  921. if (newModel != null && newModel.F_Password == model.oldPwd)
  922. {
  923. newModel.F_Password = model.password;
  924. if (userBLL.Update(newModel))
  925. {
  926. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
  927. AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
  928. AddRersult = "True";
  929. }
  930. }
  931. else
  932. {
  933. AddRersult = "旧密码不正确!";
  934. }
  935. }
  936. return AddRersult;
  937. }
  938. #endregion
  939. #region 基本信息
  940. /// <summary>
  941. /// 用户编辑
  942. /// </summary>
  943. /// <param name="editType">类型1、新增 2、修改</param>
  944. /// /// <returns></returns>
  945. public ActionResult UserView()
  946. {
  947. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  948. AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
  949. if (string.IsNullOrEmpty(userModel.F_HomePhone))
  950. {
  951. userModel.F_HomePhone = "/Content/images/face.jpg";
  952. }
  953. else
  954. {
  955. if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
  956. {
  957. userModel.F_HomePhone = "/Content/images/face.jpg";
  958. }
  959. }
  960. return View(userModel);
  961. }
  962. #endregion
  963. #region 图片上传
  964. /// <summary>
  965. /// 图片上传
  966. /// </summary>
  967. /// <returns></returns>
  968. [AcceptVerbs(HttpVerbs.Post)]
  969. public ActionResult UploadFile()
  970. {
  971. try
  972. {
  973. if (Request.Files.Count > 0)
  974. {
  975. string uppath = string.Empty;
  976. string savepath = string.Empty;
  977. HttpPostedFileBase imgFile = Request.Files[0];
  978. if (imgFile != null)
  979. {
  980. //创建图片新的名称
  981. string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
  982. //获得上传图片的路径
  983. string strPath = imgFile.FileName;
  984. //获得上传图片的类型(后缀名)
  985. string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
  986. //拼写数据库保存的相对路径字符串
  987. savepath = "/Content/HeadImg/images/";
  988. //拼写上传图片的路径
  989. uppath = Server.MapPath("~/Content/HeadImg/images/");
  990. if (!Directory.Exists(Path.GetDirectoryName(uppath)))
  991. {
  992. Directory.CreateDirectory(Path.GetDirectoryName(uppath));
  993. }
  994. uppath += nameImg + "." + type;
  995. savepath += nameImg + "." + type;
  996. //上传图片
  997. imgFile.SaveAs(uppath); //原图片路径
  998. }
  999. Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
  1000. userModel.F_HomePhone = savepath;
  1001. if (userBLL.Update(userModel))
  1002. {
  1003. return Json(new
  1004. {
  1005. code = 0,
  1006. src = savepath,
  1007. msg = "上传成功"
  1008. });
  1009. }
  1010. else
  1011. {
  1012. return Json(new
  1013. {
  1014. code = 1,
  1015. src = "",
  1016. msg = "上传出错 请检查图片名称或图片内容"
  1017. });
  1018. }
  1019. }
  1020. else
  1021. {
  1022. return Json(new
  1023. {
  1024. code = 1,
  1025. src = "",
  1026. msg = "上传出错 请检查图片名称或图片内容"
  1027. });
  1028. }
  1029. }
  1030. catch (Exception ex)
  1031. {
  1032. return Json(new
  1033. {
  1034. code = 1,
  1035. src = "",
  1036. msg = "上传出错: " + ex.Message
  1037. });
  1038. }
  1039. }
  1040. #endregion
  1041. #region 公告管理
  1042. /// <summary>
  1043. /// 公告管理
  1044. /// </summary>
  1045. /// <returns></returns>
  1046. public ActionResult noticeManage()
  1047. {
  1048. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1049. return View(noticeModel);
  1050. }
  1051. public ActionResult test()
  1052. {
  1053. Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
  1054. return View(noticeModel);
  1055. }
  1056. /// <summary>
  1057. /// 获取公告数据
  1058. /// </summary>
  1059. /// <param name="page">当前页码</param>
  1060. /// <param name="limit">每页数据量</param>
  1061. /// <returns></returns>
  1062. [ActionName("NoticeListDate")]
  1063. [HttpGet]
  1064. public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
  1065. {
  1066. AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
  1067. //数据结果集
  1068. ResponseData dataModel = new ResponseData();
  1069. string sql = "";
  1070. if (parentId != null)
  1071. {
  1072. sql += " and F_ParentId=" + parentId;
  1073. }
  1074. DataTable dt = new DataTable();
  1075. int recordCount = 0;
  1076. Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
  1077. dt = BLL.PagerBLL.GetListPager(
  1078. "T_Msg_NoticeInfo",
  1079. "F_NoticeId",
  1080. "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew ",
  1081. sql,
  1082. "ORDER BY F_NoticeId desc ",
  1083. limit,
  1084. page,
  1085. true,
  1086. out recordCount);
  1087. dataModel.code = 0;
  1088. dataModel.count = recordCount;
  1089. dataModel.data = dt;
  1090. return JsonConvert.SerializeObject(dataModel);
  1091. }
  1092. BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
  1093. BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
  1094. BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
  1095. /// <summary>
  1096. /// 编辑公告
  1097. /// </summary>
  1098. /// <param name="editType">类型1、新增 2、修改</param>
  1099. /// /// <returns></returns>
  1100. public ActionResult NoticeEdit(int? noticeId, int editType)
  1101. {
  1102. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
  1103. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1104. //当前对象实体
  1105. if (editType == 1)
  1106. {
  1107. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1108. //viewModel.UseList = userBLL.GetModelList("");
  1109. }
  1110. else
  1111. {
  1112. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1113. viewModel = userModel;
  1114. if (!string.IsNullOrEmpty(userModel.F_ReceiveInfo))
  1115. {
  1116. viewModel.UseList = userBLL.GetModelList("F_UserId=" + userModel.F_DeviceId);
  1117. viewModel.DepartmentList = deptBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1118. }
  1119. }
  1120. //获取部门列表
  1121. return View(viewModel);
  1122. }
  1123. /// <summary>
  1124. /// 查看公告
  1125. /// </summary>
  1126. /// <param name="editType">类型1、新增 2、修改</param>
  1127. /// /// <returns></returns>
  1128. public ActionResult NoticeView(int? noticeId)
  1129. {
  1130. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
  1131. Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
  1132. viewModel.F_NoticeId = int.Parse(noticeId.ToString());
  1133. viewModel.UseList = userBLL.GetModelList("");
  1134. Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
  1135. viewModel = userModel;
  1136. viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
  1137. //获取部门列表
  1138. viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
  1139. return View(viewModel);
  1140. }
  1141. /// <summary>
  1142. /// 保存编辑公告
  1143. /// </summary>
  1144. /// <param name="workOrderBaseModel"></param>
  1145. /// <returns></returns>
  1146. [AcceptVerbs(HttpVerbs.Post)]
  1147. public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
  1148. {
  1149. bool result = false;
  1150. DataTable dt = new DataTable();
  1151. DataTable dtuser = new DataTable();
  1152. int noticeid = 0;
  1153. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1154. DateTime? readdate =null;
  1155. try
  1156. {
  1157. //获取当前用户
  1158. noticeinfoModel.F_CreateBy = F_UserID;
  1159. noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
  1160. if (noticeinfoModel.F_NoticeId > 0)
  1161. {
  1162. noticeid = noticeinfoModel.F_NoticeId;
  1163. Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
  1164. dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
  1165. if (dt.Rows.Count > 0)
  1166. {
  1167. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
  1168. foreach (DataRow dr in dtuser.Rows)
  1169. {
  1170. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1171. result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
  1172. }
  1173. }
  1174. readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
  1175. oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
  1176. oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
  1177. oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
  1178. oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
  1179. oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
  1180. oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
  1181. oldnoticeinfoModel.F_State = 1;
  1182. oldnoticeinfoModel.F_ModifyDate = DateTime.Now;
  1183. oldnoticeinfoModel.F_ModifyBy = F_UserID;
  1184. result = noticeBLL.Update(oldnoticeinfoModel);
  1185. AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
  1186. }
  1187. else
  1188. {
  1189. noticeid = 0;
  1190. noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
  1191. noticeinfoModel.F_State = 1;
  1192. noticeinfoModel.F_CreateOn = DateTime.Now;
  1193. readdate = noticeinfoModel.F_CreateOn;
  1194. noticeid = noticeBLL.Add(noticeinfoModel);
  1195. AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
  1196. }
  1197. //指定方式发送公告
  1198. if (noticeinfoModel.F_DeviceId > 0)
  1199. {//指定人员发公告
  1200. noticeuserModel.F_NoticeId = noticeid;
  1201. noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
  1202. noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
  1203. if (readdate.ToString() != "")
  1204. { noticeuserModel.F_ReadDate = readdate; }
  1205. else
  1206. {
  1207. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1208. }
  1209. noticeuserModel.F_State = 0;
  1210. noticeuserModel.F_Type = 0;
  1211. result = noticeuserBLL.Add(noticeuserModel);
  1212. }
  1213. else
  1214. {//指定部门发公告
  1215. dt = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
  1216. if (dt.Rows.Count > 0)
  1217. {
  1218. noticeuserModel.F_NoticeId = noticeid;
  1219. if (readdate.ToString()!="")
  1220. { noticeuserModel.F_ReadDate = readdate; }
  1221. else {
  1222. noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
  1223. }
  1224. foreach (DataRow dr in dt.Rows)
  1225. {
  1226. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1227. noticeuserModel.F_UserName = dr["F_UserName"].ToString();
  1228. noticeuserModel.F_State = 0;
  1229. noticeuserModel.F_Type = 0;
  1230. result = noticeuserBLL.Add(noticeuserModel);
  1231. }
  1232. }
  1233. }
  1234. }
  1235. catch (Exception) { }
  1236. finally
  1237. {
  1238. dt.Clear();
  1239. dt.Dispose();
  1240. }
  1241. return result;
  1242. }
  1243. /// <summary>
  1244. /// 删除公告
  1245. /// </summary>
  1246. /// <param name="workOrderBaseModel"></param>
  1247. /// <returns></returns>
  1248. [AcceptVerbs(HttpVerbs.Get)]
  1249. public bool DeleteNoticeData(int noticeId)
  1250. {
  1251. bool res = false;
  1252. DataTable dt = new DataTable();
  1253. DataTable dtuser = new DataTable();
  1254. Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
  1255. try
  1256. {
  1257. dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
  1258. if (dt.Rows.Count > 0)
  1259. {
  1260. res = noticeBLL.Delete(noticeId);
  1261. AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
  1262. //指定部门发公告
  1263. dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
  1264. foreach (DataRow dr in dtuser.Rows)
  1265. {
  1266. noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
  1267. noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
  1268. }
  1269. }
  1270. }
  1271. catch (Exception) { }
  1272. finally {
  1273. dt.Clear();
  1274. dt.Dispose();
  1275. dtuser.Clear();
  1276. dtuser.Dispose();
  1277. }
  1278. return res;
  1279. }
  1280. /// <summary>
  1281. /// 未接根据recordid更新回访信息
  1282. /// </summary>
  1283. /// <param name="SetCallRecordHfInfo"></param>
  1284. /// <returns></returns>
  1285. [ActionName("SetNoticeState")]
  1286. [HttpGet]
  1287. public string SetNoticeState(string id, string timeno)
  1288. {
  1289. string res = "";
  1290. try
  1291. {
  1292. Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
  1293. model.F_State =1;
  1294. model.F_NoticeId = Convert.ToInt32(id);
  1295. bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
  1296. if (bl)
  1297. {
  1298. res = "success";
  1299. }
  1300. }
  1301. catch
  1302. { }
  1303. return res;
  1304. }
  1305. [ActionName("CookieData")]
  1306. [HttpGet]
  1307. public string CookieData() {
  1308. return F_UserID.ToString();
  1309. }
  1310. #endregion
  1311. }
  1312. #region 接口基本信息
  1313. /// <summary>
  1314. /// 用户信息
  1315. /// </summary>
  1316. public class UserInfo
  1317. {
  1318. public int id
  1319. {
  1320. get;
  1321. set;
  1322. }
  1323. public string name
  1324. {
  1325. get;
  1326. set;
  1327. }
  1328. }
  1329. /// <summary>
  1330. /// 返回结果信息
  1331. /// </summary>
  1332. public class ResponseResult
  1333. {
  1334. public int code
  1335. {
  1336. get;
  1337. set;
  1338. }
  1339. public int data
  1340. {
  1341. get;
  1342. set;
  1343. }
  1344. }
  1345. /// <summary>
  1346. /// 返回结果信息
  1347. /// </summary>
  1348. public class WXResponseResult
  1349. {
  1350. public int customer
  1351. {
  1352. get;
  1353. set;
  1354. }
  1355. public int service
  1356. {
  1357. get;
  1358. set;
  1359. }
  1360. public int total
  1361. {
  1362. get;
  1363. set;
  1364. }
  1365. }
  1366. #endregion
  1367. }