123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.Entity;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.Repositories;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.ViewModel.SystemView;
- using EMIS.Utility;
- using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
- using EMIS.DataLogic.UniversityManage.TeacherManage;
- using EMIS.ViewModel;
- using EMIS.Utility.SSO;
- using EMIS.ViewModel.SystemManage.UserManage;
- namespace EMIS.CommonLogic.SystemServices
- {
- public class UserServices : BaseServices, IUserServices
- {
- public UserDAL UserDAL { get; set; }
- public StaffDAL StaffDAL { get; set; }
- public RoleDAL RoleDAL { get; set; }
- public CampusDAL CampusDAL { get; set; }
- public CollegeDAL CollegeDAL { get; set; }
- public Lazy<IControlItemServices> ControlItemServices { get; set; }
- public EMIS.DataLogic.Repositories.HRService.UsersRepository CommUserRepository { get; set; }
- public bool Login(string loginID, string password)
- {
- var encryptPassword = password.ToUpper();
- //var encryptPassword = Bowin.Common.Utility.StringEx.MD5(password);
- var userName = UserDAL.UserRepository.GetList(u => u.RecordStatus == (int)SYS_STATUS.USABLE && u.Name == loginID).ToList();
- if(userName.Count>1)
- {
- throw new Exception("由于您的名字在系统中存在重名情况,请使用工号进行登录。");
- }
- var user = UserDAL.UserRepository.GetList(u => u.RecordStatus == (int)SYS_STATUS.USABLE && (u.LoginID == loginID||u.Name==loginID) && u.Password == encryptPassword)
- .Include(x => x.CF_Student).FirstOrDefault();
- if (user == null) return false;
- if (user.CF_Student != null)
- {
- ControlItemServices.Value.CheckLoginControlItems(user.UserID);
- }
- return true;
- }
- public Entities.Sys_User GetUserByLoginID(string loginID, bool isNeedEnable = true)
- {
- Expression<Func<Sys_User, bool>> user = (p => p.LoginID == loginID.Trim()||p.Name==loginID);
- if (isNeedEnable)
- {
- //user = user.And(p => p.RecordStatus == 1); 加了个方法代替,因为日后很可能会重用
- return UserDAL.GetSingleEnableUser(user);
- }
- else
- {
- return UserDAL.UserRepository.GetSingle(user,
- (x => x.CF_Staff.CF_College.CF_Campus.CF_University),
- (x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CF_Campus.CF_University));
- }
- }
- public List<Sys_User> GetUserListByLoginID(IList<string> loginIDList, bool isNeedEnable = true)
- {
- Expression<Func<Sys_User, bool>> userExp = (x => loginIDList.Contains(x.LoginID));
- if (isNeedEnable)
- {
- userExp = userExp.And(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- }
- return UserDAL.UserRepository.GetList(userExp).ToList();
- }
- public UserView GetUserViewByID(Guid userID)
- {
- Expression<Func<Sys_User, bool>> userExp = p => p.UserID == userID;
- return UserDAL.GetUserView(userExp, (x => true)).FirstOrDefault();
- }
- /// <summary>
- /// 教师用户列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="roleID"></param>
- /// <param name="dataRangeID"></param>
- /// <param name="stauts"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<UserView> GetUserViewList(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? roleID, int? dataRangeID, int? stauts, int pageIndex, int pageSize)
- {
- Expression<Func<Sys_User, bool>> exp = (x => true);
- Expression<Func<Sys_Role, bool>> roleExp = (x => true);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.CollegeID == collegeID.Value);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.DepartmentID == departmentID.Value);
- }
- //if (roleID.HasValue)
- //{
- // exp = exp.And(x => x.Sys_Role.Any(w => w.RoleID == roleID));
- // //roleExp = roleExp.And(x => x.RoleID == roleID.Value);
- //}
- //if (dataRangeID.HasValue)
- //{
- // exp = exp.And(x => x.Sys_Role.Any(w => w.DefaultDataRange == dataRangeID.Value));
- // //roleExp = roleExp.And(x => x.DefaultDataRange == dataRangeID.Value);
- //}
- if (stauts.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == stauts);
- }
- IQueryable<UserView> q = UserDAL.GetUserView(exp, roleExp);
-
- if (roleID.HasValue)
- {
- q = q.Where(x => x.RoleID == roleID);
- }
- if (dataRangeID.HasValue)
- {
- q = q.Where(x => x.DataRange == dataRangeID);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- q = this.GetQueryByDataRangeByDepartment(q);
- return q.OrderBy(x => x.CollegeCode).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize);
- }
- /// <summary>
- /// 教师用户列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="roleID"></param>
- /// <param name="dataRangeID"></param>
- /// <returns></returns>
- public IList<UserView> GetUserViewList(ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? roleID, int? dataRangeID)
- {
- Expression<Func<Sys_User, bool>> exp = (x => true);
- Expression<Func<Sys_Role, bool>> roleExp = (x => true);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.CF_Department.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.CF_Department.CollegeID == collegeID.Value);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.CF_Staff.DepartmentID == departmentID.Value);
- }
- if (roleID.HasValue)
- {
- roleExp = roleExp.And(x => x.RoleID == roleID.Value);
- }
- if (dataRangeID.HasValue)
- {
- roleExp = roleExp.And(x => x.DefaultDataRange == dataRangeID.Value);
- }
- IQueryable<UserView> q = UserDAL.GetUserView(exp, roleExp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return q.OrderBy(x => x.CollegeCode).ThenBy(x => x.LoginID).ToList();
- }
- /// <summary>
- /// 学生用户列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="educationID"></param>
- /// <param name="schoolYearID"></param>
- /// <param name="standardID"></param>
- /// <param name="learnFormID"></param>
- /// <param name="classMajorID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentUserView> GetStudentUserViewList(ViewModel.ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? educationID, int? schoolYearID, int? standardID, int? learnFormID,
- Guid? classMajorID,string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<Sys_User, bool>> exp = (x => true);
- Expression<Func<Sys_Role, bool>> roleExp = (x => true);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID.Value);
- }
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == educationID.Value);
- }
- if (schoolYearID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == schoolYearID.Value);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID.Value);
- }
- if (learnFormID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learnFormID.Value);
- }
- if (classMajorID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.ClassmajorID == classMajorID);
- }
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- IQueryable<StudentUserView> q = UserDAL.GetStudentUserView(exp, roleExp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(q).OrderBy(x => x.Grade).ThenBy(x => x.ClassNo).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize);
- }
- /// <summary>
- /// 学生用户列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="educationID"></param>
- /// <param name="schoolYearID"></param>
- /// <param name="standardID"></param>
- /// <param name="learnFormID"></param>
- /// <param name="classMajorID"></param>
- /// <returns></returns>
- public IList<StudentUserView> GetStudentUserViewList(ViewModel.ConfiguretView configuretView,
- Guid? campusID, Guid? collegeID, int? educationID, int? schoolYearID, int? standardID, int? learnFormID,
- Guid? classMajorID, string LearnSystem)
- {
- Expression<Func<Sys_User, bool>> exp = (x => true);
- Expression<Func<Sys_Role, bool>> roleExp = (x => true);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID == campusID.Value);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID.Value);
- }
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == educationID.Value);
- }
- if (schoolYearID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == schoolYearID.Value);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID.Value);
- }
- if (learnFormID.HasValue)
- {
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learnFormID.Value);
- }
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
- }
- IQueryable<StudentUserView> q = UserDAL.GetStudentUserView(exp, roleExp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return q.OrderBy(x => x.Grade).ThenBy(x => x.ClassNo).ThenBy(x => x.LoginID).ToList();
- }
- /// <summary>
- /// 批量初始化密码
- /// </summary>
- /// <param name="userID">主键ID</param>
- /// <returns></returns>
- public virtual 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<Sys_User> userList = new List<Sys_User>();
- foreach (var user in list)
- {
- 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();
- }
- }
- }
- /// <summary>
- /// 启用
- /// </summary>
- /// <param name="userID">主键ID</param>
- /// <returns></returns>
- public void Usable(IList<Guid?> userID)
- {
- if (userID.Count > 0)
- {
- UnitOfWork.Update<Sys_User>(
- x => new Sys_User { RecordStatus = (int)SYS_STATUS.USABLE },
- x => userID.Contains(x.UserID)
- );
- List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
- foreach (var user in list)
- {
- SetModifyStatus(user);
- UnitOfWork.Update(user);
- UnitOfWork.Commit();
- }
- }
- }
- /// <summary>
- /// 禁用
- /// </summary>
- /// <param name="userID">主键ID</param>
- /// <returns></returns>
- public void UnUsable(IList<Guid?> userID)
- {
- if (userID.Count > 0)
- {
- UnitOfWork.Update<Sys_User>(
- x => new Sys_User { RecordStatus = (int)SYS_STATUS.UNUSABLE },
- x => userID.Contains(x.UserID)
- );
- List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
- foreach (var user in list)
- {
- SetModifyStatus(user);
- UnitOfWork.Update(user);
- UnitOfWork.Commit();
- }
- }
- }
- /// <summary>
- /// 保存用户角色
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- public void SaveUserRoles(Guid userID, IList<Guid?> roleID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.Sys_Role));
- var roleList = this.RoleDAL.RoleRepository.GetList(x => roleID.Contains(x.RoleID)).ToList();
- user.Sys_Role = new HashSet<Sys_Role>();
- roleList.ForEach(x => user.Sys_Role.Add(x));
- this.UnitOfWork.Commit();
- }
- public IList<CF_Campus> GetUserInchargeCampus(Guid userID)
- {
- var campusList = this.StaffDAL.GetUserInChargeCampus(x => x.UserID == userID).ToList();
- return campusList;
- }
- public IList<CF_College> GetUserInchargeCollege(Guid userID)
- {
- var collegeList = this.StaffDAL.GetUserInChargeCollege(x => x.UserID == userID).ToList();
- return collegeList;
- }
- public IList<CF_Department> GetUserInchargeDepartment(Guid userID)
- {
- var departmentList = StaffDAL.GetUserInChargeDepartment(x => x.UserID == userID).ToList();
- return departmentList;
- }
- public IList<Sys_Role> GetUserRoles(Guid userID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.Sys_Role));
- var roleList = user.Sys_Role.ToList();
- return roleList;
- }
- public Sys_Role GetMaxPrivilegeRoleByUserID(Guid userID)
- {
- var role = RoleDAL.RoleRepository.GetList(x => x.Sys_User.Any(w => w.UserID == userID))
- .OrderByDescending(x => x.Sys_FunctionCode.Count())
- .FirstOrDefault();
- return role;
- }
- /// <summary>
- /// 保存用户所属校区
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- public void SaveUserCampus(Guid userID, IList<Guid?> campusID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.CF_Staff.CF_StaffManageCampus));
- if (user.CF_Staff == null) throw new Exception("该用户并非教职工用户,请补全该用户的教职工信息再进行操作,或选择其他用户进行操作。");
- //var campusList = this.CampusDAL.campusRepository.GetList(x => campusID.Contains(x.CampusID)).ToList();
- user.CF_Staff.CF_StaffManageCampus.ToList().ForEach(x => this.UnitOfWork.Remove(x));
- campusID.ForEach(x => {
- CF_StaffManageCampus staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = userID;
- staffManageCampus.CampusID = x;
- this.SetNewStatus(staffManageCampus);
- this.UnitOfWork.Add(staffManageCampus);
- });
- this.UnitOfWork.Commit();
- }
- /// <summary>
- /// 保存用户所属学院
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- public void SaveUserCollege(Guid userID, IList<Guid?> collegeID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.CF_Staff.CF_StaffManageCollege));
- if (user.CF_Staff == null) throw new Exception("该用户并非教职工用户,请补全该用户的教职工信息再进行操作,或选择其他用户进行操作。");
- user.CF_Staff.CF_StaffManageCollege.ToList().ForEach(x => this.UnitOfWork.Remove(x));
- collegeID.ForEach(x =>
- {
- CF_StaffManageCollege staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = userID;
- staffManageCollege.CollegeID = x;
- this.SetNewStatus(staffManageCollege);
- this.UnitOfWork.Add(staffManageCollege);
- });
- this.UnitOfWork.Commit();
- }
- /// <summary>
- /// 保存用户所属教研室
- /// </summary>
- /// <param name="userID"></param>
- /// <param name="departmentID"></param>
- public void SaveUserDepartment(Guid userID, IList<Guid?> departmentID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.CF_Staff.CF_StaffManageDepartment));
- if (user.CF_Staff == null) throw new Exception("该用户并非教职工用户,请补全该用户的教职工信息再进行操作,或选择其他用户进行操作。");
- user.CF_Staff.CF_StaffManageDepartment.ToList().ForEach(x => this.UnitOfWork.Remove(x));
- departmentID.ForEach(x =>
- {
- CF_StaffManageDepartment staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = userID;
- staffManageDepartment.DepartmentID = x;
- this.SetNewStatus(staffManageDepartment);
- this.UnitOfWork.Add(staffManageDepartment);
- });
- this.UnitOfWork.Commit();
- }
- public IList<RoleView> GetUserRolesView(Guid userID)
- {
- return RoleDAL.GetRoleView(x => x.Sys_User.Any(w => w.UserID == userID)).OrderBy(x => x.TypeID).ThenBy(x => x.OrderNo).ToList();
- }
- public string GetUserEmail(Guid userID)
- {
- var user = UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.CF_Staff.CF_StaffProfile), (x => x.CF_Student.CF_StudentContact));
- if (user == null) throw new Exception("指定的用户信息不存在。");
- if (user.CF_Student != null && user.CF_Student.CF_StudentContact != null)
- {
- return user.CF_Student.CF_StudentContact.Email;
- }
- else if (user.CF_Staff != null && user.CF_Staff.CF_StaffProfile != null)
- {
- return user.CF_Staff.CF_StaffProfile.Email;
- }
- else
- {
- throw new Exception("用户并没有注册电子邮箱信息。");
- }
- }
- public void ChangePassword(ChangePasswordView password, Guid userID)
- {
- var user = this.UserDAL.UserRepository.GetSingle(x => x.UserID == userID, (x => x.Sys_MailVerifyCode));
- user.Password = password.Password.MD5();
- user.Sys_MailVerifyCode = null;
- UnitOfWork.Commit();
- }
- public Sys_User GetUserByID(Guid userID)
- {
- return this.UserDAL.UserRepository.Entities.Where(x => x.UserID == userID).FirstOrDefault();
- }
- public void SynHRServices()
- {
- var exceptUser = new string[] { "admin" };
- var hrUsers = CommUserRepository.GetList(x => !exceptUser.Contains(x.userid)).ToList();
- var staffs = StaffDAL.staffRepository.GetList(x => !exceptUser.Contains(x.Sys_User.LoginID))
- .Include(x => x.Sys_User).Include(x => x.CF_StaffProfile).ToList();
- hrUsers.ForEach(x => x.status = "D");
- foreach (var staff in staffs)
- {
- var hrUser = hrUsers.FirstOrDefault(x => x.userid == staff.Sys_User.LoginID);
- if (hrUser == null)
- {
- hrUser = new Entities.HRServices.Comm_Users();
- hrUser.userid = staff.Sys_User.LoginID;
- hrUser.loginid = staff.Sys_User.LoginID;
- hrUser.createdt = DateTime.Now;
- this.HRUnitOfWork.Add(hrUser);
- }
- hrUser.username = staff.Sys_User.Name;
- if (staff.DepartmentID.HasValue)
- {
- hrUser.dpid = staff.DepartmentID.ToString();
- }
- else
- {
- hrUser.dpid = staff.CollegeID.ToString();
- }
- hrUser.telephone = staff.CF_StaffProfile.Telephone;
- hrUser.mobile = staff.CF_StaffProfile.Mobile;
- hrUser.email = staff.CF_StaffProfile.Email;
- hrUser.cardid = staff.Sys_User.LoginID;
- hrUser.employeeclassid = "";
- hrUser.jobtypeid = "教师";
- hrUser.birthday = staff.BirthDate;
- switch (staff.SexID)
- {
- case (int)CF_Sex.Male:
- hrUser.sex = "1";
- break;
- case (int)CF_Sex.Female:
- hrUser.sex = "2";
- break;
- default:
- hrUser.sex = "0";
- break;
- }
- hrUser.orderNo = "1";
- hrUser.userrole = "";
- hrUser.userligion = "";
- hrUser.password = staff.Sys_User.Password;
- hrUser.status = "A";
- hrUser.updatedt = DateTime.Now;
- hrUser.istmpuser = false;
- }
- this.HRUnitOfWork.Commit();
- }
- public virtual string SSOLogin()
- {
- return SSO.SSOLogin();
- }
- }
- }
|