地铁二期项目正式开始

SystemManageController.cs 60KB

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