Geen omschrijving

UserAccountController.cs 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Controllers.Sms;
  6. using CallCenterApi.Interface.Models.Input;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Text.RegularExpressions;
  12. using System.Web;
  13. using System.Web.Mvc;
  14. namespace CallCenterApi.Interface.Controllers
  15. {
  16. [Authority]
  17. public class UserAccountController : BaseController
  18. {
  19. private BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  20. private BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  21. private BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  22. //用户列表
  23. //[Authority]
  24. public ActionResult GetList(int isdc=0)
  25. {
  26. DataTable dt = new DataTable();
  27. string sql = " ";
  28. try
  29. {
  30. //用户管理中,加个筛选项根据角色筛选(筛选二级单位时,可以看到该二级单位下的所有人员)
  31. string roleId = RequestString.GetQueryString("roleId");
  32. string rolecode = RequestString.GetQueryString("rolecode");
  33. //用户管理中,加个筛选项根据角色筛选(筛选二级单位时,可以看到该二级单位下的所有人员)
  34. string Key = RequestString.GetQueryString("Key");
  35. int Id = RequestString.GetInt("Id", 0);
  36. int activation = RequestString.GetInt("activation", -1);
  37. string strpageindex = RequestString.GetQueryString("page");
  38. int pageindex = 1;
  39. string strpagesize = RequestString.GetQueryString("pagesize");
  40. int pagesize = 10;
  41. if (Id > 0)
  42. {
  43. sql += " and F_DeptId=" + Id;
  44. }
  45. if (User.F_RoleCode == "GLY" || User.F_RoleCode == "YSZY" || User.F_RoleCode == "ZXLD" || User.F_RoleCode == "ZXHWY"|| User.F_RoleCode == "MTDD" || User.F_RoleCode == "DMTSH")
  46. {
  47. }
  48. else
  49. {
  50. sql += "and F_DeptId in (select F_DeptId from T_Sys_Department where F_State=0 and ( F_DeptId='" + User.F_DeptId + "' or F_PartentId='" + User.F_DeptId + "'))";
  51. }
  52. if (!string.IsNullOrWhiteSpace(Key))
  53. {
  54. // sql = "";
  55. string str = string.Format(" and (F_UserCode like '%{0}%' or F_UserName like '%{1}%')", Key, Key);
  56. sql += str;
  57. }
  58. if (activation>-1)
  59. {
  60. if (activation==0)
  61. {
  62. sql += "and F_LastActiveTime=F_CreateOn";
  63. }
  64. else
  65. {
  66. sql += "and F_LastActiveTime>F_CreateOn";
  67. }
  68. }
  69. if (!string.IsNullOrWhiteSpace(roleId))
  70. {
  71. // sql = "";
  72. string str = string.Format(" and (F_RoleId = '{0}' )", roleId);
  73. sql += str;
  74. }
  75. if (!string.IsNullOrWhiteSpace(rolecode))
  76. {
  77. // sql = "";
  78. string str = string.Format(" and F_RoleId in ({0})", rolecode);
  79. sql += str;
  80. }
  81. if (strpageindex.Trim() != "")
  82. {
  83. pageindex = Convert.ToInt32(strpageindex);
  84. }
  85. if (strpagesize.Trim() != "")
  86. {
  87. pagesize = Convert.ToInt32(strpagesize);
  88. }
  89. if (isdc==1)
  90. {
  91. var dtdc = DbHelperSQL.Query(" select F_UserCode 工号, F_UserName 姓名,F_Company 单位,F_Department 科室,F_Post 职务, F_Mobile 手机号码,F_Telephone 办公电话 from T_Sys_UserAccount WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  92. var msg = new NPOIHelper().ExportToExcel("单位信息列表", dtdc);
  93. if (msg == "")
  94. {
  95. return Success("导出成功");
  96. }
  97. else
  98. {
  99. return Error("导出失败");
  100. }
  101. }
  102. if (isdc ==2)
  103. {
  104. var dtdc = DbHelperSQL.Query("select F_UserCode 坐席工号, F_UserName 用户名称, F_Telephone 用户电话, F_Mobile 用户手机, (select F_RoleName from T_Sys_RoleInfo where F_RoleId = a.F_RoleId ) 用户角色,(select F_DeptName from T_Sys_Department where F_DeptId = a.F_DeptId ) 用户部门,(case F_DeleteFlag when 0 then '正常' else '禁用' end ) 用户状态 ,(case when a.F_CreateOn =a.F_LastActiveTime then '未激活' when a.F_LastActiveTime > a.F_CreateOn then '已激活' else '未激活' end) 是否激活 ,F_CreateOn 创建时间 from T_Sys_UserAccount a WITH(NOLOCK) where 1=1 " + sql).Tables[0];
  105. var msg = new NPOIHelper().ExportToExcel("用户列表", dtdc);
  106. if (msg == "")
  107. {
  108. return Success("导出成功");
  109. }
  110. else
  111. {
  112. return Error("导出失败");
  113. }
  114. }
  115. else
  116. {
  117. int recordCount = 0;
  118. dt = BLL.PagerBLL.GetListPager(
  119. "T_Sys_UserAccount",
  120. "F_UserId",
  121. "*",
  122. sql,
  123. "ORDER BY F_UserId desc",
  124. pagesize,
  125. pageindex,
  126. true,
  127. out recordCount);
  128. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  129. var obj = new
  130. {
  131. rows = modelList.Select(x => new
  132. {
  133. F_UserId = x.F_UserId,
  134. F_UserCode = x.F_UserCode,
  135. F_ExtensionNumber = x.F_ExtensionNumber,
  136. F_UserName = x.F_UserName,
  137. F_GroupName = x.F_GroupName,
  138. F_DeptId = x.F_DeptId,
  139. F_RoleId = x.F_RoleId,
  140. F_GroupId = x.F_GroupId,
  141. F_SeatFlag = x.F_SeatFlag,
  142. F_SeatRight = x.F_SeatRight,
  143. F_SeatLevel = x.F_SeatLevel,
  144. F_SexFlag = x.F_SexFlag,
  145. F_RemindFlag = x.F_RemindFlag,
  146. F_Remark = x.F_Remark,
  147. F_Telephone = x.F_Telephone,
  148. F_Mobile = x.F_Mobile,
  149. F_HomePhone = x.F_HomePhone,
  150. F_Birthday = x.F_Birthday,
  151. F_CreateOn = x.F_CreateOn,
  152. F_CancelOn = x.F_CancelOn,
  153. F_DeleteFlag = x.F_DeleteFlag,
  154. F_APPOnFlag = x.F_APPOnFlag,
  155. F_LastActiveTime = x.F_LastActiveTime,
  156. F_See = x.F_See,
  157. F_HJType = x.F_HJType,
  158. F_PId = x.F_PId,
  159. F_TmId = x.F_TmId,
  160. F_RoleName = x.F_RoleName,
  161. F_DeptName = x.F_DeptName,
  162. F_WorkNumber = x.F_WorkNumber,
  163. F_Company = x.F_Company,
  164. F_Department = x.F_Department,
  165. F_Post = x.F_Post,
  166. F_IsSms=x.F_IsSms,
  167. F_SeartGroupCode = x.F_SeartGroupCode
  168. }),
  169. total = recordCount
  170. };
  171. return Content(obj.ToJson());
  172. }
  173. }
  174. catch (Exception err)
  175. {
  176. return Error("错误:" + err.ToString());
  177. }
  178. finally
  179. {
  180. dt.Clear();
  181. dt.Dispose();
  182. }
  183. }
  184. //获取用户信息
  185. //[Authority]
  186. public ActionResult GetUser(int userId = 0, string userCode = "")
  187. {
  188. string sql = "";
  189. if (userId > 0)
  190. {
  191. sql += " and F_UserId=" + userId;
  192. }
  193. if (!string.IsNullOrWhiteSpace(userCode))
  194. {
  195. sql += " and F_UserCode='" + userCode+"'";
  196. }
  197. if (string.IsNullOrWhiteSpace(sql))
  198. return Error("获取失败");
  199. Model.T_Sys_UserAccount User = sysUserAccountBll.GetModelList(" 1=1 " + sql).FirstOrDefault();
  200. if (User == null) return Error("获取失败");
  201. var depModel = departmentBLL.GetModel(User.F_DeptId);
  202. var zxzModel = dicValueBLL.GetModel(User.F_GroupId ?? 0);
  203. return Success("获取成功", new
  204. {
  205. F_UserId = User.F_UserId,
  206. F_UserCode = User.F_UserCode,
  207. F_ExtensionNumber = User.F_ExtensionNumber,
  208. F_UserName = User.F_UserName,
  209. F_DeptId = User.F_DeptId,
  210. F_RoleId = User.F_RoleId,
  211. F_GroupId = User.F_GroupId,
  212. F_SeatFlag = User.F_SeatFlag,
  213. F_SeatRight = User.F_SeatRight,
  214. F_SeatLevel = User.F_SeatLevel,
  215. F_SexFlag = User.F_SexFlag,
  216. F_RemindFlag = User.F_RemindFlag,
  217. F_Remark = User.F_Remark,
  218. F_Telephone = User.F_Telephone,
  219. F_Mobile = User.F_Mobile,
  220. F_HomePhone = User.F_HomePhone,
  221. F_Birthday = (User.F_Birthday ?? DateTime.MinValue).ToString("yyyy-MM-dd"),
  222. F_CreateOn = User.F_CreateOn,
  223. F_CancelOn = User.F_CancelOn,
  224. F_DeleteFlag = User.F_DeleteFlag,
  225. F_APPOnFlag = User.F_APPOnFlag,
  226. F_LastActiveTime = User.F_LastActiveTime,
  227. F_See = User.F_See,
  228. F_HJType = User.F_HJType ?? 0,
  229. F_PId = User.F_PId,
  230. F_TmId = User.F_TmId,
  231. F_WorkNumber = User.F_WorkNumber,
  232. F_Name= User.F_Name ,
  233. F_Company = User.F_Company ,
  234. F_Department = User.F_Department ,
  235. F_Post = User.F_Post ,
  236. F_IsSms = User.F_IsSms,
  237. //zxzname = zxzModel?.F_Name ?? "",
  238. depname = depModel?.F_DeptName ?? "",
  239. F_SeartGroupCode = User.F_SeartGroupCode,
  240. F_SeartGroupID = User.F_SeartGroupID
  241. });
  242. }
  243. //[Authority]
  244. //添加用户信息
  245. public ActionResult AddUsers(UserAccountInput input)
  246. {
  247. Regex reg = new Regex(@"^[1-9]\d*$");
  248. if (!reg.IsMatch(input.Usercode.Trim()))
  249. {
  250. return Error("工号必须为正整数");
  251. }
  252. Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
  253. userAccountModel.F_UserCode = input.Usercode.Trim();
  254. userAccountModel.F_UserName = input.Username.Trim();
  255. userAccountModel.F_Password = input.Password.Trim();
  256. //userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  257. userAccountModel.F_WorkNumber = input.Usercode;
  258. userAccountModel.F_DeptId = input.DeptId;
  259. userAccountModel.F_RoleId = input.RoleId;
  260. userAccountModel.F_GroupId = input.GroupId;
  261. userAccountModel.F_SeatFlag = input.IsSeat;
  262. userAccountModel.F_SeatRight = input.SearRight;
  263. userAccountModel.F_SexFlag = input.Sex;
  264. userAccountModel.F_Remark = input.Remark;
  265. userAccountModel.F_Mobile = input.Mobile;
  266. userAccountModel.F_Telephone = input.Telphone;
  267. userAccountModel.F_Birthday = input.Birth;
  268. userAccountModel.F_CreateOn = DateTime.Now;
  269. userAccountModel.F_DeleteFlag = 0;
  270. userAccountModel.F_ModifytTime = DateTime.Now;
  271. userAccountModel.F_LastActiveTime = DateTime.Now;
  272. userAccountModel.F_IsSms = input.F_IsSms;
  273. //userAccountModel.F_HJType = input.HjType;
  274. var model = sysUserAccountBll.GetModel(input.Usercode);
  275. if (model != null)
  276. return Error("当前员工工号存在,请更换!");
  277. if (input.GroupId != 0)
  278. {
  279. userAccountModel.F_SeartGroupID = input.GroupId;
  280. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  281. if (sm != null)
  282. {
  283. userAccountModel.F_SeartGroupCode = sm.F_ZXZName;
  284. }
  285. }
  286. if (input.IsSeat)
  287. {
  288. // userAccountModel.F_WorkNumber = input.Usercode.Trim();
  289. if (input.ClassId.Value > 0)
  290. {
  291. var cls = new BLL.T_Sys_Class().GetModel(input.ClassId.Value);
  292. userAccountModel.F_ClassCode = (cls != null ? cls.F_Code : "");
  293. }
  294. SysConfigController sys = new SysConfigController();
  295. //话务人员限制权限判断
  296. if (sys.IsValidSeatPermission())
  297. {
  298. if (sysUserAccountBll.Add(userAccountModel) > 0)
  299. return Success("新增成功!");
  300. else
  301. return Error("新增失败!");
  302. }
  303. else
  304. {
  305. return Error("话务人员数量已超!");
  306. }
  307. }
  308. if (sysUserAccountBll.Add(userAccountModel) > 0)
  309. return Success("新增成功!");
  310. else
  311. return Error("新增失败!");
  312. }
  313. //[Authority]
  314. //修改用户信息
  315. public ActionResult EditUsers(UserAccountInput input)
  316. {
  317. Regex reg = new Regex(@"^[1-9]\d*$");
  318. if (!reg.IsMatch(input.Usercode.Trim()))
  319. {
  320. return Error("工号必须为正整数");
  321. }
  322. BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  323. Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList(" F_UserId = " + input.UserId).FirstOrDefault();
  324. if (userAccountModel == null)
  325. return Error("获取用户失败");
  326. userAccountModel.F_UserCode = input.Usercode.Trim();
  327. userAccountModel.F_UserName = input.Username.Trim();
  328. //userAccountModel.F_Password = input.Password.Trim();
  329. //userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  330. userAccountModel.F_WorkNumber = input.Usercode;
  331. userAccountModel.F_DeptId = input.DeptId;
  332. userAccountModel.F_RoleId = input.RoleId;
  333. // userAccountModel.F_GroupId = input.GroupId;
  334. userAccountModel.F_SeatFlag = input.IsSeat;
  335. userAccountModel.F_SeatRight = input.SearRight;
  336. userAccountModel.F_SexFlag = input.Sex;
  337. userAccountModel.F_Remark = input.Remark;
  338. userAccountModel.F_Mobile = input.Mobile;
  339. userAccountModel.F_Telephone = input.Telphone;
  340. userAccountModel.F_Birthday = input.Birth;
  341. userAccountModel.F_IsSms = input.F_IsSms;
  342. userAccountModel.F_ModifytTime = DateTime.Now;
  343. //userAccountModel.F_DeleteFlag = 0;
  344. //userAccountModel.F_HJType = input.HjType;
  345. if (input.GroupId != 0)
  346. {
  347. userAccountModel.F_SeartGroupID = input.GroupId;
  348. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  349. if (sm != null)
  350. {
  351. userAccountModel.F_SeartGroupCode = sm.F_ZXZName;
  352. }
  353. }
  354. if (input.IsSeat)
  355. {
  356. //userAccountModel.F_WorkNumber = input.Usercode.Trim();
  357. if (input.ClassId.Value > 0)
  358. {
  359. var cls = new BLL.T_Sys_Class().GetModel(input.ClassId.Value);
  360. userAccountModel.F_ClassCode = (cls != null ? cls.F_Code : "");
  361. }
  362. SysConfigController sys = new SysConfigController();
  363. //话务人员限制权限判断
  364. if (sys.IsValidSeatPermission())
  365. {
  366. if (sysUserAccountBll.Update(userAccountModel))
  367. return Success("编辑成功!");
  368. else
  369. return Error("编辑失败!");
  370. }
  371. else
  372. {
  373. return Error("话务人员数量已超!");
  374. }
  375. }
  376. if (sysUserAccountBll.Update(userAccountModel))
  377. return Success("编辑成功!");
  378. else
  379. return Error("编辑失败!");
  380. }
  381. //[Authority]
  382. //删除/禁用/启用 用户
  383. public ActionResult DelUsers(string[] ids, int state = 0)
  384. {
  385. if (ids == null || ids.Length <= 0)
  386. return Error("请选择用户");
  387. var idStr = string.Join(",", ids);
  388. if (string.IsNullOrEmpty(idStr))
  389. return Error("请选择用户");
  390. SysConfigController sys = new SysConfigController();
  391. //话务人员限制权限判断
  392. if (state == 0) {
  393. if (sys.IsValidSeatPermission())
  394. {
  395. if (sysUserAccountBll.DeleteList(idStr, state))
  396. return Success("设置成功");
  397. else
  398. return Error("设置失败");
  399. }
  400. else
  401. {
  402. return Error("话务人员数量已超!");
  403. }
  404. }
  405. if (sysUserAccountBll.DeleteList(idStr, state))
  406. return Success("设置成功");
  407. else
  408. return Error("设置失败");
  409. }
  410. //[Authority]
  411. //删除用户
  412. public ActionResult WLDelUsers(string[] ids)
  413. {
  414. if (ids == null || ids.Length <= 0)
  415. return Error("请选择用户");
  416. var idStr = string.Join(",", ids);
  417. if (string.IsNullOrEmpty(idStr))
  418. return Error("请选择用户");
  419. if (sysUserAccountBll.DeleteList(idStr))
  420. return Success("删除成功");
  421. else
  422. return Error("删除失败");
  423. }
  424. //获取坐席列表
  425. public ActionResult GetSeatList()
  426. {
  427. //List<Model.T_Sys_UserAccount> userSeartList = sysUserAccountBll.GetModelList(" f_seatflag=1 ");
  428. var drs = sysUserAccountBll.GetModelList ("f_seatflag=1");
  429. var userSeartList = from r in drs select new {
  430. F_UserId =r .F_UserId ,
  431. F_UserName = r.F_UserName,
  432. F_UserCode = r.F_UserCode
  433. };
  434. // var result = userSeartList.OrderBy(p => p.F_UserName.Substring(p.F_UserName.Length - 1)).ToList();
  435. return Success("列表加载成功", userSeartList);
  436. }
  437. //根据角色获取用户
  438. public ActionResult GetUsersList(string rolecode)
  439. {
  440. var sql = " 1=1 ";
  441. if (!string.IsNullOrWhiteSpace(rolecode.Trim()))
  442. {
  443. string F_RoleId = DbHelperSQL.GetSingle("select F_RoleId from T_Sys_RoleInfo with(nolock) where F_RoleCode='" + rolecode.Trim() + "'")?.ToString() ?? "0";
  444. sql += " and F_RoleId = " + F_RoleId;
  445. }
  446. //List<Model.T_Sys_UserAccount> userList = sysUserAccountBll.GetModelList(sql, " f_userid desc ");
  447. var userList = sysUserAccountBll.GetList(sql, " f_userid desc ").Tables[0];
  448. return Success("列表加载成功", userList);
  449. }
  450. //根据部门获取用户
  451. public ActionResult GetDeptUserList(int deptid = 0)
  452. {
  453. var DeptUserList = sysUserAccountBll.GetList("F_DeptId='" + deptid + "' ", " f_userid desc ");
  454. return Success("列表加载成功", DeptUserList);
  455. }
  456. //[Authority]
  457. //获取当前用户信息
  458. public ActionResult GetNowUser()
  459. {
  460. if (User == null)
  461. return Error("获取失败");
  462. Model.T_Sys_RoleInfo roleModel = new BLL.T_Sys_RoleInfo().GetModel(User.F_RoleId);
  463. var obj = new
  464. {
  465. user = User,
  466. role = roleModel
  467. };
  468. return Success("获取成功", obj);
  469. }
  470. //[Authority]
  471. /// <summary>
  472. /// 重置密码
  473. /// </summary>
  474. /// <param name="usercode"></param>
  475. /// <param name="pwd"></param>
  476. /// <returns></returns>
  477. public ActionResult ResetPwd(string usercode = "", string pwd = "")
  478. {
  479. if (string.IsNullOrWhiteSpace(pwd))
  480. return Error("请输入密码");
  481. var model = sysUserAccountBll.GetModel(usercode);
  482. if (model == null) return Error("此用户不存在");
  483. model.F_Password = pwd;
  484. if (sysUserAccountBll.Update(model))
  485. return Success("重置密码成功");
  486. else
  487. return Error("重置密码失败");
  488. }
  489. public class VerificationCode
  490. {
  491. public string mobile { set; get; }
  492. public string code { set; get; }
  493. public DateTime Time { set; get; }
  494. }
  495. public ActionResult SendCode(string mobile)
  496. {
  497. if (string .IsNullOrEmpty (mobile))
  498. {
  499. return Error("请输入将要发送的号码");
  500. }
  501. int codes = new Random().Next(1000, 9999);
  502. // string msg = codes.ToString ();
  503. // bool n = SMSController.AddSmS(0, msg, "你的验证码是"+ codes+".十分钟有效.", mobile, "168411", "");
  504. string mag = "[\"" + codes.ToString() + "\"]";
  505. string v = SmsNewController.AddSmS(0, "你的验证码是" + codes + ".十分钟有效.", mobile, "681240638956277760", mag,
  506. "");
  507. if (v=="")
  508. {
  509. return Success("发送成功");
  510. }
  511. else
  512. return Error ("发送失败");
  513. }
  514. public ActionResult GetUserModify( )
  515. {
  516. if (string.IsNullOrEmpty(User.F_Mobile))
  517. return Error("请填写手机号");
  518. if (string.IsNullOrEmpty(User.F_Company) || string.IsNullOrEmpty(User.F_Department) || string.IsNullOrEmpty(User.F_Post))
  519. return Error("用户信息不完整");
  520. if (User.F_ModifytTime!=null )
  521. {
  522. if (((DateTime )User.F_ModifytTime).Month != DateTime.Now.Month)
  523. {
  524. if (DateTime.Now.Day >= 5)
  525. {
  526. return Error("请及时修改密码");
  527. }
  528. }
  529. }
  530. return Success("成功");
  531. }
  532. public ActionResult UpdatePwd(string name , string company,string department,string post,
  533. string mobile,string phone, string code, string usercode = "", string pwd = "", string oldPwd = ""
  534. )
  535. {
  536. //if (string.IsNullOrEmpty(code))
  537. // return Error("请输入短信验证码");
  538. if (string.IsNullOrWhiteSpace(pwd))
  539. return Error("请输入密码");
  540. if (string.IsNullOrEmpty(company) || string.IsNullOrEmpty(department) || string.IsNullOrEmpty(post)|| string.IsNullOrEmpty(name))
  541. return Error("用户信息不完整");
  542. var model = sysUserAccountBll.GetModel(usercode);
  543. if (model == null) return Error("此用户不存在");
  544. if (pwd.Equals(oldPwd))
  545. return Error("新密码不能和原密码相同");
  546. if (!model.F_Password.Equals(oldPwd)) return Error("原密码不正确");
  547. if (string.IsNullOrEmpty(mobile))
  548. return Error("请输入手机号码");
  549. //string msgcount = "你的验证码是" + code + ".十分钟有效.";
  550. //var sms = new BLL.T_SMS_RecvSMS().GetModelList("Content='"+ msgcount+ "' and CallerNum='"+ mobile+ "'order by RecvTime desc");
  551. //if (sms != null&& sms.Count >0)
  552. //{
  553. // var modelSms = sms.First();
  554. // if ((DateTime.Now - modelSms.RecvTime ).Minutes > 10)
  555. // {
  556. // return Error("验证码已失效");
  557. // }
  558. //}
  559. //else
  560. // return Error("请获取验证码");
  561. model.F_Password = pwd;
  562. if (!string.IsNullOrEmpty(name))
  563. model.F_UserName = name;
  564. if (!string.IsNullOrEmpty(company))
  565. model.F_Company = company;
  566. if (!string.IsNullOrEmpty(department))
  567. model.F_Department = department;
  568. if (!string.IsNullOrEmpty(post))
  569. model.F_Post = post;
  570. if (!string.IsNullOrEmpty(mobile))
  571. model.F_Mobile = mobile;
  572. if (!string.IsNullOrEmpty(phone))
  573. model.F_Telephone = phone;
  574. model.F_ModifytTime = DateTime.Now;
  575. if (sysUserAccountBll.Update(model))
  576. return Success("修改成功");
  577. else
  578. return Error("修改失败");
  579. }
  580. #region App手机端 用户列表
  581. /// <summary>
  582. /// App手机端 用户列表
  583. /// </summary>
  584. /// <returns></returns>
  585. //[Authority]
  586. public ActionResult GetAppUserList()
  587. {
  588. DataTable dt = new DataTable();
  589. string sql = " 1=1 and F_RoleId=2 ";
  590. try
  591. {
  592. string Key = RequestString.GetQueryString("Key");
  593. if (!string.IsNullOrWhiteSpace(Key))
  594. {
  595. string str = string.Format(" and (F_DeptId IN (SELECT F_DeptId FROM dbo.T_Sys_Department WHERE F_DeptName like '%{0}%') or F_UserName like '%{1}%' or F_Mobile like '%{2}%' or F_Telephone like '%{3}%' or F_HomePhone like '%{3}%')", Key, Key, Key, Key, Key);
  596. sql += str;
  597. }
  598. dt = sysUserAccountBll.GetListNoCache(sql).Tables[0];
  599. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  600. return Success("获取成功",
  601. modelList.Select(x => new
  602. {
  603. F_UserId = x.F_UserId,
  604. F_UserCode = x.F_UserCode,
  605. F_UserName = x.F_UserName,
  606. F_DeptId = x.F_DeptId,
  607. F_SexFlag = x.F_SexFlag,
  608. F_Remark = x.F_Remark,
  609. F_Telephone = x.F_Telephone,
  610. F_Mobile = x.F_Mobile,
  611. F_HomePhone = x.F_HomePhone,
  612. F_Birthday = x.F_Birthday,
  613. F_CreateOn = x.F_CreateOn,
  614. F_APPOnFlag = x.F_APPOnFlag,
  615. F_LastActiveTime = x.F_LastActiveTime,
  616. F_RoleName = x.F_RoleName,
  617. F_DeptName = x.F_DeptName
  618. })
  619. );
  620. }
  621. catch (Exception err)
  622. {
  623. return Error("错误:" + err.ToString());
  624. }
  625. finally
  626. {
  627. dt.Clear();
  628. dt.Dispose();
  629. }
  630. }
  631. #endregion
  632. }
  633. }