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 userID, bool isChange, string pwd) { if (userID.Count > 0) { if (isChange == false) { List list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList(); List staffList = UserDAL.StaffRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList(); List userList = new List(); 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 list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList(); List userList = new List(); foreach (var user in list) { user.Password = pwd.MD5(); SetModifyStatus(user); userList.Add(user); } UnitOfWork.BatchUpdate(userList); UnitOfWork.Commit(); } } } } }