UserServices.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.Entities;
  6. using Bowin.Common.Utility;
  7. namespace EMIS.ExtensionLogic.ServiceLogic.SystemServices
  8. {
  9. public class UserServices : EMIS.CommonLogic.SystemServices.UserServices
  10. {
  11. public override void BatchInitPassword(IList<Guid?> userID, bool isChange, string pwd)
  12. {
  13. if (userID.Count > 0)
  14. {
  15. if (isChange == false)
  16. {
  17. List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
  18. List<CF_Staff> staffList = UserDAL.StaffRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
  19. List<Sys_User> userList = new List<Sys_User>();
  20. foreach (var user in list)
  21. {
  22. var staff = staffList.FirstOrDefault(x => x.UserID == user.UserID);
  23. if (staff != null && staff.CertificatesNum != null && staff.CertificatesNum.IsNotEmpty())
  24. {
  25. var idNumber = staff.CertificatesNum.Substring(staff.CertificatesNum.Length - 6, 6);
  26. user.Password = ("A" + idNumber).MD5();
  27. }
  28. else
  29. {
  30. user.Password = ("A" + user.LoginID).MD5();
  31. }
  32. SetModifyStatus(user);
  33. userList.Add(user);
  34. }
  35. UnitOfWork.BatchUpdate(userList);
  36. UnitOfWork.Commit();
  37. }
  38. else
  39. {
  40. List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
  41. List<Sys_User> userList = new List<Sys_User>();
  42. foreach (var user in list)
  43. {
  44. user.Password = pwd.MD5();
  45. SetModifyStatus(user);
  46. userList.Add(user);
  47. }
  48. UnitOfWork.BatchUpdate(userList);
  49. UnitOfWork.Commit();
  50. }
  51. }
  52. }
  53. }
  54. }