12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.Entities;
- using Bowin.Common.Utility;
- namespace EMIS.ExtensionLogic.ServiceLogic.SystemServices
- {
- public class UserServices : EMIS.CommonLogic.SystemServices.UserServices
- {
- public override void BatchInitPassword(IList<Guid?> userID, bool isChange, string pwd)
- {
- if (userID.Count > 0)
- {
- if (isChange == false)
- {
- List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
- List<CF_Staff> staffList = UserDAL.StaffRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
- List<Sys_User> userList = new List<Sys_User>();
- foreach (var user in list)
- {
- var staff = staffList.FirstOrDefault(x => x.UserID == user.UserID);
- if (staff != null && staff.CertificatesNum != null && staff.CertificatesNum.IsNotEmpty())
- {
- var idNumber = staff.CertificatesNum.Substring(staff.CertificatesNum.Length - 6, 6);
- user.Password = ("A" + idNumber).MD5();
- }
- else
- {
- user.Password = ("A" + user.LoginID).MD5();
- }
- SetModifyStatus(user);
- userList.Add(user);
- }
- UnitOfWork.BatchUpdate(userList);
- UnitOfWork.Commit();
- }
- else
- {
- List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
- List<Sys_User> userList = new List<Sys_User>();
- foreach (var user in list)
- {
- user.Password = pwd.MD5();
- SetModifyStatus(user);
- userList.Add(user);
- }
- UnitOfWork.BatchUpdate(userList);
- UnitOfWork.Commit();
- }
- }
- }
- }
- }
|