using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common; 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.Students; using EMIS.ViewModel.SystemView; using EMIS.Utility; using EMIS.DataLogic.UniversityManage.AdministrativeOrgan; using EMIS.DataLogic.Common.Students; using EMIS.ViewModel; using System.Data; using EMIS.ViewModel.CacheManage; using System.IO; using System.Text.RegularExpressions; using Bowin.Common.Utility; using Bowin.Common.DataTime; using System.Globalization; using EMIS.CommonLogic.CalendarManage; using EMIS.Utility.FormValidate; using System.Web; using System.Transactions; using EMIS.DataLogic; using System.Data.OleDb; namespace EMIS.CommonLogic.Students { public class StudentsServices : BaseServices, IStudentsServices { public Lazy StudentsDAL { get; set; } public Lazy RoleDAL { get; set; } public Lazy InSchoolSettingRepository { get; set; } public Lazy StudentProfileRepository { get; set; } public Lazy StudentContactRepository { get; set; } public Lazy UserRepository { get; set; } public Lazy RecruitstudentsRepository { get; set; } public Lazy StudentAccountRepository { get; set; } public Lazy NewStudentRepository { get; set; } public Lazy ClassmajorRepository { get; set; } public Lazy SchoolyearRepository { get; set; } public Lazy SchoolYearServices { get; set; } public ParameterDAL ParameterDAL { get; set; } public DataRangeDAL DataRangeDAL { get; set; } public IGridResultSet GetStudentUserViewList(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem,int? education, int? reportStatusID, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> classexp = (x => true); Expression> gradeexp = (x => true); Expression> reportExp = (x => x.CF_Schoolyear.IsCurrent == true); if (isPhotos.HasValue) { if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.PhotoUrl != null); } else { exp = exp.And(x => x.PhotoUrl == null); } } if (campusID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID); if (collegeID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID); if (years.HasValue) gradeexp = gradeexp.And(x => x.GradeID == years); if (standardID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID); if (learningformID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID); if (classmajorID.HasValue) exp = exp.And(x => x.ClassmajorID == classmajorID); if (inSchoolStatusID.HasValue) exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID); if (IsGraduation.HasValue) { if (IsGraduation != (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes) exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_StudentStatus.Graduation); else exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_StudentStatus.Graduation); } if(isDream.HasValue){ if(isDream.Value==(int)CF_GeneralPurpose.IsYes){ exp = exp.And(x => x.CF_StudentProfile.IsDreamProject != null); } else { exp=exp.And(x=>x.CF_StudentProfile.IsDreamProject==null); } } if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1") { //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); //dtFormat.ShortDatePattern = "yyyyMMdd"; DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture); //string datestr = date.ToString("u"); //dtFormat.ShortDatePattern = "yyyy-MM-dd"; //dtFormat.DateSeparator = "-"; //DateTime dates = Convert.ToDateTime(datestr, dtFormat); exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0); } if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp, reportExp); if (reportStatusID.HasValue) { query = query.Where(x => x.ReportStatusID == reportStatusID); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } public IList GetStudentViewList(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem, int? education, int? reportStatusID, List UserIDsIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> classexp = (x => true); Expression> gradeexp = (x => true); if (UserIDsIDList != null) { exp = exp.And(x => UserIDsIDList.Contains(x.UserID)); } else { if (isPhotos.HasValue) { if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.PhotoUrl != null); } else { exp = exp.And(x => x.PhotoUrl == null); } } if (campusID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID); if (collegeID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID); if (years.HasValue) gradeexp = gradeexp.And(x => x.GradeID == years); if (standardID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID); if (learningformID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID); if (classmajorID.HasValue) exp = exp.And(x => x.ClassmajorID == classmajorID); if (inSchoolStatusID.HasValue) exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID); if (IsGraduation.HasValue) { if (IsGraduation != (int)EMIS.ViewModel.CF_StudentStatus.Graduation) exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_StudentStatus.Graduation); else exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_StudentStatus.Graduation); } if (isDream.HasValue) { if (isDream.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.CF_StudentProfile.IsDreamProject != null); } else { exp = exp.And(x => x.CF_StudentProfile.IsDreamProject == null); } } if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1") { //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); //dtFormat.ShortDatePattern = "yyyyMMdd"; DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture); //string datestr = date.ToString("u"); //dtFormat.ShortDatePattern = "yyyy-MM-dd"; //dtFormat.DateSeparator = "-"; //DateTime dates = Convert.ToDateTime(datestr, dtFormat); exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0); } if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } } var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp); if (reportStatusID.HasValue) { query = query.Where(x => x.ReportStatusID == reportStatusID); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToList(); } public IGridResultSet GetStudentUserViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? education, int? years, int? standardID, int? learningformID, int? classNum, int? studentStatusID, bool? isPhotos, bool? isOnlyGraduation, bool? isPreviousNotGraduated, int pageIndex, int pageSize) { var currentSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear(); var inschoolStatusList = InSchoolSettingRepository.Value.GetList(x => x.IsSelected == true) .Select(x => x.InSchoolStatusID).Distinct().ToList(); Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && inschoolStatusList.Contains(x.InSchoolStatusID)); Expression> classexp = (x => true); Expression> gradeexp = (x => true); Expression> reportExp = (x => x.CF_Schoolyear.IsCurrent == true); if (campusID.HasValue) { gradeexp = gradeexp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID); } if (collegeID.HasValue) { gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID); } if (education.HasValue) { gradeexp = gradeexp.And(x => x.CF_Facultymajor.EducationID == education.Value); } if (years.HasValue) { gradeexp = gradeexp.And(x => x.GradeID == years); } if (standardID.HasValue) { gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID); } if (learningformID.HasValue) { gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID); } if (classNum.HasValue) { classexp = classexp.And(x => x.ClassNum == classNum); } if (studentStatusID.HasValue) { exp = exp.And(x => x.StudentStatus == studentStatusID); } if (isPhotos.HasValue) { if (isPhotos.Value) { exp = exp.And(x => x.PhotoUrl != null); } else { exp = exp.And(x => x.PhotoUrl == null); } } if (isOnlyGraduation == true) { gradeexp = gradeexp.And(x => x.GraduateSchoolyearID == currentSchoolyear.SchoolYearID); } if (isPreviousNotGraduated == true) { gradeexp = gradeexp.And(x => x.CF_Schoolyear.Value < currentSchoolyear.Value); exp = exp.And(x => x.StudentStatus == (int)CF_StudentStatus.Complete && x.InSchoolStatusID == (int)CF_InschoolStatus.Complete); } var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp, reportExp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } public IList GetStudentViewListByIDList(IList studentUserIDList) { return StudentsDAL.Value.GetStudentQueryable(x => studentUserIDList.Contains(x.UserID)).ToList(); } /// /// 获取可进行异动申请的学生。 /// /// public IGridResultSet GetAbleDifferentDynamicApplyStudentList(ConfiguretView configuretView, int pageIndex, int pageSize) { Expression> filter = w => w.RecordStatus > (int)SYS_STATUS.UNUSABLE; //为何和学籍状态有关? //var studentStatus = new[] //{ // (int?)CF_StudentStatus.Whodid, // (int?)CF_StudentStatus.Thegraduation, // (int?)CF_StudentStatus.Graduation //}; //filter = filter.And(w => !studentStatus.Contains(w.StudentStatus)); //2016年10月13日14:53:40 //PS:异动申请,新增异动的时候,这个异动权限要放开。现在只有在校生能学籍异动,非在校生也能异动才行。【相当于权限放开,可以添加任何在校状态的学生】 // var inSchoolStatusIDs = InSchoolSettingRepository.Value.GetList(w => w.IsSelected == true).Select(s => s.InSchoolStatusID).ToArray(); //filter = filter.And(w => inSchoolStatusIDs.Contains(w.InSchoolStatusID)); var query = StudentsDAL.Value.GetStudentQueryable(filter); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); } query = this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.LoginID); return query.ToGridResultSet(pageIndex, pageSize); } /// /// 导出excel和dbf /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetStudentExportList(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem, int? education, int? reportStatusID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> classexp = (x => true); Expression> gradeexp = (x => true); if (isPhotos.HasValue) { if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.PhotoUrl != null); } else { exp = exp.And(x => x.PhotoUrl == null); } } if (campusID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CF_College.CampusID == campusID); if (collegeID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID); if (years.HasValue) gradeexp = gradeexp.And(x => x.GradeID == years); if (standardID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID); if (learningformID.HasValue) gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID); if (classmajorID.HasValue) exp = exp.And(x => x.ClassmajorID == classmajorID); if (inSchoolStatusID.HasValue) exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID); if (IsGraduation.HasValue) { if (IsGraduation != (int)EMIS.ViewModel.CF_StudentStatus.Graduation) exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_StudentStatus.Graduation); else exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_StudentStatus.Graduation); } if (isDream.HasValue) { if (isDream.Value == (int)CF_GeneralPurpose.IsYes) { exp = exp.And(x => x.CF_StudentProfile.IsDreamProject != null); } else { exp = exp.And(x => x.CF_StudentProfile.IsDreamProject == null); } } if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1") { //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); //dtFormat.ShortDatePattern = "yyyyMMdd"; DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture); //string datestr = date.ToString("u"); //dtFormat.ShortDatePattern = "yyyy-MM-dd"; //dtFormat.DateSeparator = "-"; //DateTime dates = Convert.ToDateTime(datestr, dtFormat); exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0); } if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = StudentsDAL.Value.GetStudentForExcel(exp, classexp, gradeexp); if (reportStatusID.HasValue) { query = query.Where(x => x.ReportStatusID == reportStatusID); } if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode) .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToList(); } public IGridResultSet GetBaseStudentView(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? grademajorID, Guid? classmajorID, Guid? userID, int pageIndex, int pageSize) { Expression> filter = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) filter = filter.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); if (grademajorID.HasValue) filter = filter.And(x => x.CF_Classmajor.GrademajorID == grademajorID); if (classmajorID.HasValue) filter = filter.And(x => x.ClassmajorID == classmajorID); if (userID.HasValue) { filter = filter.And(x => x.UserID == userID); } var query = StudentsDAL.Value.GetBaseStudentViewQueryable(filter); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderByDescending(x => x.LoginID.Length).ThenBy(x => x.LoginID) .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode) .ToGridResultSet(pageIndex, pageSize); } /// /// /// /// /// /// /// public IGridResultSet GetStudentOnlyInSchool(ConfiguretView configuretView, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.InSchoolStatusID == (int)CF_InschoolStatus.InSchool); Expression> classexp = (x => true); Expression> gradeexp = (x => true); Expression> reportExp = (x => x.CF_Schoolyear.IsCurrent == true); var query = StudentsDAL.Value.GetInSchoolStudentViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); } return query.OrderBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetPlanningGraduateList() { Dictionary diction = new Dictionary(); //int key = 0; var query = StudentsDAL.Value.GetPlanningGraduateDictionary().Where(x => x.PlanningGraduateDate != null); List list = query.Select(x => x.PlanningGraduateDate).OrderBy(x => x.Value).ToList(); List stulist = query.OrderBy(x => x.PlanningGraduateDate).ToList(); List datestr = new List(); for (int i = 0; i < stulist.Count; i++) { stulist[i].PlanningGraduateStr = list[i].Value.ToString("yyyyMMdd"); } //List dictionList = query.Select(x => x.PlanningGraduateStr).ToList(); //foreach(DateTime date in dictionList) //{ // diction.Add(key, date); // key++; //} return stulist.AsQueryable().ToGridResultSet(); } public StudentsView GetStudentViewByLoginID(string loginID) { var student = StudentsDAL.Value.GetStudentQueryable(x => x.Sys_User.LoginID == loginID).FirstOrDefault(); return student; } public StudentsView GetStudentViewByIDNum(string idNum) { var student = StudentsDAL.Value.GetStudentQueryable(x => x.IDNumber == idNum).FirstOrDefault(); return student; } /// /// 将数据表写入到DBF文件中 /// /// public void WriteToDbf(DataTable dt, List colList) { string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH; string physicalPath = HttpContext.Current.Server.MapPath(filePath); string newfilePath = (physicalPath.EndsWith("\\") ? physicalPath : physicalPath + "\\") + "StudentInfoExcel"; //连接字符串 string sConn = "Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + newfilePath + "; " + "Extended Properties=dBASE IV;"; OleDbConnection conn = new OleDbConnection(sConn); conn.Open(); var fileName = "Info.dbf"; var filePathAndFile = (physicalPath.EndsWith("\\") ? physicalPath : physicalPath + "\\") + "StudentInfoExcel\\" + fileName; try { //如果存在同名文件则先删除 if (File.Exists(filePathAndFile)) { File.Delete(filePathAndFile); } //建立新表 StringBuilder sbCreate = new StringBuilder(); sbCreate.Append("CREATE TABLE " + fileName + " ("); for (int i = 0; i < colList.Count; i++) { //根据需求不同字段要求字段长度不同——20190923兵良哥要求 sbCreate.Append(colList[i]); if (colList[i].Equals("KSH",StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(18)"); else if (colList[i].Equals("XM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(40)"); else if (colList[i].Equals("XB", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(2)"); else if (colList[i].Equals("CSRQ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(8)"); else if (colList[i].Equals("SFZH", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(18)"); else if (colList[i].Equals("YXDM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(5)"); else if (colList[i].Equals("YXMC", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(60)"); else if (colList[i].Equals("ZYDM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(8)"); else if (colList[i].Equals("ZYMC", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(50)"); else if (colList[i].Equals("XZ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(3)"); else if (colList[i].Equals("XXXS", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(10)"); else if (colList[i].Equals("CC", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(12)"); else if (colList[i].Equals("RXRQ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(8)"); else if (colList[i].Equals("BYRQ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(8)"); else if (colList[i].Equals("BJYJL", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(4)"); else if (colList[i].Equals("ZSBH", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(18)"); else if (colList[i].Equals("XZM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(40)"); else if (colList[i].Equals("SYSSDM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(2)"); else if (colList[i].Equals("XH", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(15)"); else if (colList[i].Equals("ZZMM", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(16)"); else if (colList[i].Equals("MZ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(24)"); else if (colList[i].Equals("FY", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(24)"); else if (colList[i].Equals("XSH", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(24)"); else if (colList[i].Equals("BH", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(24)"); //if (colList[i].Equals("BM", StringComparison.OrdinalIgnoreCase)) // sbCreate.Append(" char(24)"); else if (colList[i].Equals("YJBYRQ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(8)"); else if (colList[i].Equals("BZ", StringComparison.OrdinalIgnoreCase)) sbCreate.Append(" char(50)"); else sbCreate.Append(" char(50)"); if (i != colList.Count - 1) { sbCreate.Append(", "); } else { sbCreate.Append(')'); } } OleDbCommand cmd; cmd = new OleDbCommand(sbCreate.ToString(), conn); cmd.ExecuteNonQuery(); //插入各行 StringBuilder sbInsert = new StringBuilder(); foreach (DataRow dr in dt.Rows) { sbInsert.Clear(); sbInsert.Append("INSERT INTO " + fileName + " ("); for (int i = 0; i < colList.Count; i++) { sbInsert.Append(colList[i]); if (i != colList.Count - 1) { sbInsert.Append(", "); } } sbInsert.Append(") VALUES ("); for (int i = 0; i < dt.Columns.Count; i++) { sbInsert.Append("'" + dr[i].ToString() + "'"); if (i != dt.Columns.Count - 1) { sbInsert.Append(", "); } } sbInsert.Append(')'); cmd = new OleDbCommand(sbInsert.ToString(), conn); cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw ex; } conn.Close(); //var physicalPath = System.IO.Directory.GetCurrentDirectory() + "\\" + dt.TableName + ".dbf"; //FileInfo finfo = new FileInfo(physicalPath); //return finfo; } /// /// 获取信息 /// /// 用户ID /// public Entities.Sys_User GetUser(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return UserRepository.Value.GetSingle(expression, (x => x.Sys_Role)); } /// /// 获取学生扩展表信息 /// /// 用户ID /// public Entities.CF_StudentProfile GetProfile(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return StudentProfileRepository.Value.GetSingle(expression); } /// /// 获取学生信息 /// /// 用户ID /// public Entities.CF_Student GetStudent(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return StudentsDAL.Value.StudentRepository.GetSingle(expression); } /// /// 高考招生表 /// /// 用户ID /// public Entities.CF_Recruitstudents GetRecruit(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return RecruitstudentsRepository.Value.GetSingle(expression); } /// /// 学生缴费表 /// /// 用户ID /// public Entities.CF_StudentAccount GetAccount(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return StudentAccountRepository.Value.GetSingle(expression); } /// /// 学生联系表 /// /// 用户ID /// public Entities.CF_StudentContact GetContact(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return StudentContactRepository.Value.GetSingle(expression); } /// /// 获取学生表列表信息 /// /// public Entities.CF_Student GetStudenter(Guid? userID) { //查询条件 Expression> expression = x => x.UserID == userID; return StudentsDAL.Value.StudentRepository.GetSingle(expression); } public CF_Student GetReplaceGraduateNo(string ReplaceGraduateNo, Guid? userID) { //查询条件 Expression> expression = x => x.ReplaceGraduateNo == ReplaceGraduateNo; expression = expression.And(x => x.UserID != userID); return StudentsDAL.Value.StudentRepository.GetSingle(expression); } public Entities.Sys_User GetUserByLoginID(Guid userid) { Expression> user = p => p.UserID == userid; return UserRepository.Value.GetSingle(user); } /// /// 查询用户ID /// /// /// public StudentsView GetStudentfileView(Guid? userId) { //查询条件 var query = StudentsDAL.Value.GetStudentQueryable(x => x.UserID == userId); //if (userId.HasValue) // query = query.Where(x => x.UserID == userId); return query.FirstOrDefault(); } /// /// 添加 /// /// public void Save(StudentsView studentfileView) { BaseStudentView tempView = StudentsDAL.Value.GetBaseStudentViewQueryable(x => x.Sys_User.UserID == studentfileView.UserID).FirstOrDefault(); var parameter = ParameterDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)CF_ParameterType.StudentInitPassword); var roleList = RoleDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student && x.CF_StudentRole.StudentType == studentfileView.StudentType,(x=>x.CF_StudentRole)).ToList(); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null) throw new Exception("请先设置配置文件的预计毕业月份(春季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null) throw new Exception("请先设置配置文件的预计毕业日期(春季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null) throw new Exception("请先设置配置文件的预计毕业月份(秋季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null) throw new Exception("请先设置配置文件的预计毕业日期(秋季入学)。"); if (studentfileView.GradeMajorID==null) { var GradeMajorID=ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == (Guid)studentfileView.ClassMajorID).Select(w => w.GrademajorID).FirstOrDefault(); studentfileView.GradeMajorID = (Guid)GradeMajorID; } studentfileView.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate((Guid)studentfileView.GradeMajorID)); SaveOrUpdateInternal(studentfileView, tempView, parameter, roleList); this.UnitOfWork.Commit(); } private void SaveOrUpdateInternal(StudentsView studentfileView, BaseStudentView tempView, CF_Parameter parameter, IList roleList) { Sys_User user; CF_Student student; //获取学生信息 CF_StudentProfile studentProfile; CF_StudentContact studentContact; CF_StudentAccount studentAccount; CF_Recruitstudents recruitstudents; List StudentID = new List(); //以导入信息中的学号查找学生,当没有该学生时新增,否则修改学生信息 if (tempView == null) //studentfileView.UserID == Guid.Empty { user = new Sys_User(); user.UserID = Guid.NewGuid(); StudentID.Add(user.UserID); if (parameter == null) { user.Password = ("A" + studentfileView.LoginID).MD5(); } else { if (parameter.Value != null) { user.Password = parameter.Value; } else { user.Password = ("A" + studentfileView.LoginID).MD5(); } } user.CreateTime = DateTime.Now; UnitOfWork.Add(user); SetNewStatus(user); //添加学生表 student = new CF_Student(); student.UserID = user.UserID; student.CreateTime = DateTime.Now; UnitOfWork.Add(student); SetNewStatus(student); //学生扩展信息表 studentProfile = new CF_StudentProfile(); studentProfile.UserID = student.UserID; studentProfile.CreateTime = DateTime.Now; UnitOfWork.Add(studentProfile); SetNewStatus(studentProfile); studentContact = new CF_StudentContact(); studentContact.UserID = student.UserID; studentContact.CreateTime = DateTime.Now; UnitOfWork.Add(studentContact); SetNewStatus(studentContact); studentAccount = new CF_StudentAccount(); studentAccount.UserID = student.UserID; studentAccount.CreateTime = DateTime.Now; UnitOfWork.Add(studentAccount); SetNewStatus(studentAccount); recruitstudents = new CF_Recruitstudents(); recruitstudents.UserID = student.UserID; recruitstudents.CreateTime = DateTime.Now; UnitOfWork.Add(recruitstudents); SetNewStatus(recruitstudents); } else { user = GetUser(tempView.UserID); //studentfileView.UserID SetModifyStatus(user); student = GetStudent(tempView.UserID); //studentfileView.UserID SetModifyStatus(student); studentProfile = GetProfile(tempView.UserID); //studentfileView.UserID SetModifyStatus(studentProfile); studentContact = GetContact(tempView.UserID); //studentfileView.UserID SetModifyStatus(studentContact); studentAccount = GetAccount(tempView.UserID); //studentfileView.UserID SetModifyStatus(studentAccount); recruitstudents = GetRecruit(tempView.UserID); //studentfileView.UserID SetModifyStatus(recruitstudents); } user.LoginID = studentfileView.LoginID; if (!string.IsNullOrEmpty(studentfileView.UserName)) user.Name = studentfileView.UserName; if (studentfileView.ClassMajorID != null) student.ClassmajorID = studentfileView.ClassMajorID; if (studentfileView.SexID != null) student.SexID = (int)studentfileView.SexID; if (studentfileView.CertificatesType != null) student.CertificatesType = studentfileView.CertificatesType; if (!string.IsNullOrEmpty(studentfileView.IDNumber)) student.IDNumber = studentfileView.IDNumber; if (studentfileView.IsDreamProject) student.CF_StudentProfile.IsDreamProject = studentfileView.IsDreamProject; student.Career = studentfileView.Career; if (!string.IsNullOrEmpty(studentfileView.PhotoUrl)) { student.PhotoUrl = studentfileView.PhotoUrl; } student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr; //if (student.PlanningGraduateDate == null) //{ // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID; // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value)); //} student.StudentCardNo = studentfileView.StudentCardNo; //毕、结业证书编号 student.GraduateCardNo = studentfileView.GraduateCardNo; studentProfile.CultureModelID = studentfileView.CultureModel; if (studentfileView.StudentType != null) student.StudentType = studentfileView.StudentType; if (studentfileView.StudentStatus != null) student.StudentStatus = studentfileView.StudentStatus; if (studentfileView.InSchoolStatusID != null) student.InSchoolStatusID = studentfileView.InSchoolStatusID; if (studentfileView.ReplaceGraduateNo != null) student.ReplaceGraduateNo = studentfileView.ReplaceGraduateNo; user.Sys_Role = new HashSet(); roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList(); roleList.ForEach(x => user.Sys_Role.Add(x)); if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl)) { student.GraduationPictureUrl = studentfileView.GraduationPictureUrl; } studentProfile.UsedName = studentfileView.UsedName; studentProfile.DirectorName = studentfileView.DirectorName; student.BirthDate = studentfileView.BirthDate; studentProfile.Country = studentfileView.Country; if (studentfileView.Politics != null) student.PoliticsID = studentfileView.Politics; student.NationID = studentfileView.Nation; studentProfile.Place = studentfileView.Place; studentProfile.HealthStateID = studentfileView.Healthy; studentProfile.BloodGroup = studentfileView.BloodGroup; //studentProfile.BornPlace = studentfileView.BornPlace; studentProfile.Specialty = studentfileView.Specialty; studentProfile.Height = studentfileView.Height; studentProfile.Weight = studentfileView.Weight; student.Remark = studentfileView.Remarks; studentContact.Email = studentfileView.Email; studentContact.QQ = studentfileView.QQ; studentContact.Mobile = studentfileView.Mobile; studentContact.Telephone = studentfileView.Telephone; studentContact.WeChatNum = studentfileView.MicroMsgNo; studentContact.ZIPCode = studentfileView.ZipCode; studentContact.Address = studentfileView.Address; studentContact.WorkUnit = studentfileView.WorkUnit; studentContact.HomeAddress = studentfileView.HomeAddress; studentContact.Recipient = studentfileView.Recipient; studentContact.Dormitory = studentfileView.Dormitory; studentAccount.CardNo = studentfileView.CardNo; studentAccount.BankName = studentfileView.BankName; recruitstudents.EntranceDate = studentfileView.EntranceDate; recruitstudents.EntranceWayID = studentfileView.EntranceWay; recruitstudents.ExamineeNum = studentfileView.ExamineeNum; studentProfile.BornPlace = studentfileView.Placebirth; recruitstudents.ExamineeType = studentfileView.ExamineeType; recruitstudents.FeaturesID = studentfileView.Features; recruitstudents.Score = studentfileView.Score; recruitstudents.TerritorialID = studentfileView.Territorial; recruitstudents.Area = studentfileView.Area; recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID; UnitOfWork.Commit(); if (StudentID.Count > 0) { AddStudentEnd(StudentID); } } /// /// 导入更新 /// /// /// /// /// private void UpdateInternalForImport(StudentsView studentfileView, CF_Student student, CF_Parameter parameter, IList roleList) { SetModifyStatus(student.Sys_User); SetModifyStatus(student); SetModifyStatus(student.CF_StudentProfile); SetModifyStatus(student.CF_StudentContact); SetModifyStatus(student.CF_StudentAccount); SetModifyStatus(student.CF_Recruitstudents); student.Sys_User.LoginID = studentfileView.LoginID; if (!string.IsNullOrEmpty(studentfileView.UserName)) student.Sys_User.Name = studentfileView.UserName; if (studentfileView.ClassMajorID != null) student.ClassmajorID = student.ClassmajorID; if (studentfileView.SexID != null) student.SexID = (int)studentfileView.SexID; if (studentfileView.CertificatesType != null) student.CertificatesType = studentfileView.CertificatesType; if (!string.IsNullOrEmpty(studentfileView.IDNumber)) student.IDNumber = studentfileView.IDNumber; if (studentfileView.IsDreamProject) student.CF_StudentProfile.IsDreamProject = studentfileView.IsDreamProject; if (!string.IsNullOrEmpty(studentfileView.Career)) student.Career = studentfileView.Career; if (!string.IsNullOrEmpty(studentfileView.PhotoUrl)) { student.PhotoUrl = studentfileView.PhotoUrl; } student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr; //if (student.PlanningGraduateDate == null) //{ // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID; // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value)); //} if (!string.IsNullOrEmpty(studentfileView.StudentCardNo)) student.StudentCardNo = studentfileView.StudentCardNo; //毕、结业证书编号 if (!string.IsNullOrEmpty(studentfileView.GraduateCardNo)) student.GraduateCardNo = studentfileView.GraduateCardNo; if (studentfileView.CultureModel != null) student.CF_StudentProfile.CultureModelID = studentfileView.CultureModel; if (studentfileView.StudentType != null) student.StudentType = studentfileView.StudentType; if (studentfileView.StudentStatus != null) student.StudentStatus = studentfileView.StudentStatus; if (studentfileView.InSchoolStatusID != null) student.InSchoolStatusID = studentfileView.InSchoolStatusID; student.Sys_User.Sys_Role = new HashSet(); roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList(); roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x)); if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl)) { student.GraduationPictureUrl = studentfileView.GraduationPictureUrl; } if (!string.IsNullOrEmpty(studentfileView.UsedName)) student.CF_StudentProfile.UsedName = studentfileView.UsedName; if (!string.IsNullOrEmpty(studentfileView.DirectorName)) student.CF_StudentProfile.DirectorName = studentfileView.DirectorName; if (studentfileView.BirthDate != null) student.BirthDate = studentfileView.BirthDate; if (!string.IsNullOrEmpty(studentfileView.Country)) student.CF_StudentProfile.Country = studentfileView.Country; if (studentfileView.Politics != null) student.PoliticsID = studentfileView.Politics; if (studentfileView.Nation != null) student.NationID = studentfileView.Nation; if (!string.IsNullOrEmpty(studentfileView.Place)) student.CF_StudentProfile.Place = studentfileView.Place; if (studentfileView.Healthy != null) student.CF_StudentProfile.HealthStateID = studentfileView.Healthy; if (studentfileView.BloodGroup != null) student.CF_StudentProfile.BloodGroup = studentfileView.BloodGroup; //studentProfile.BornPlace = studentfileView.BornPlace; if (!string.IsNullOrEmpty(studentfileView.Specialty)) student.CF_StudentProfile.Specialty = studentfileView.Specialty; if (!string.IsNullOrEmpty(studentfileView.Height)) student.CF_StudentProfile.Height = studentfileView.Height; if (!string.IsNullOrEmpty(studentfileView.Weight)) student.CF_StudentProfile.Weight = studentfileView.Weight; if (!string.IsNullOrEmpty(studentfileView.Remarks)) student.Remark = studentfileView.Remarks; if (!string.IsNullOrEmpty(studentfileView.Email)) student.CF_StudentContact.Email = studentfileView.Email; if (!string.IsNullOrEmpty(studentfileView.QQ)) student.CF_StudentContact.QQ = studentfileView.QQ; if (!string.IsNullOrEmpty(studentfileView.Mobile)) student.CF_StudentContact.Mobile = studentfileView.Mobile; if (!string.IsNullOrEmpty(studentfileView.Telephone)) student.CF_StudentContact.Telephone = studentfileView.Telephone; if (!string.IsNullOrEmpty(studentfileView.MicroMsgNo)) student.CF_StudentContact.WeChatNum = studentfileView.MicroMsgNo; if (!string.IsNullOrEmpty(studentfileView.ZipCode)) student.CF_StudentContact.ZIPCode = studentfileView.ZipCode; if (!string.IsNullOrEmpty(studentfileView.Address)) student.CF_StudentContact.Address = studentfileView.Address; if (!string.IsNullOrEmpty(studentfileView.WorkUnit)) student.CF_StudentContact.WorkUnit = studentfileView.WorkUnit; if (!string.IsNullOrEmpty(studentfileView.HomeAddress)) student.CF_StudentContact.HomeAddress = studentfileView.HomeAddress; if (!string.IsNullOrEmpty(studentfileView.Recipient)) student.CF_StudentContact.Recipient = studentfileView.Recipient; if (!string.IsNullOrEmpty(studentfileView.Dormitory)) student.CF_StudentContact.Dormitory = studentfileView.Dormitory; if (!string.IsNullOrEmpty(studentfileView.CardNo)) student.CF_StudentAccount.CardNo = studentfileView.CardNo; if (!string.IsNullOrEmpty(studentfileView.BankName)) student.CF_StudentAccount.BankName = studentfileView.BankName; if (studentfileView.EntranceDate != null) student.CF_Recruitstudents.EntranceDate = studentfileView.EntranceDate; if (studentfileView.EntranceWay != null) student.CF_Recruitstudents.EntranceWayID = studentfileView.EntranceWay; if (!string.IsNullOrEmpty(studentfileView.ExamineeNum)) student.CF_Recruitstudents.ExamineeNum = studentfileView.ExamineeNum; if (!string.IsNullOrEmpty(studentfileView.Placebirth)) student.CF_StudentProfile.BornPlace = studentfileView.Placebirth; if (studentfileView.ExamineeType != null) student.CF_Recruitstudents.ExamineeType = studentfileView.ExamineeType; if (studentfileView.Features != null) student.CF_Recruitstudents.FeaturesID = studentfileView.Features; if (studentfileView.Score != null) student.CF_Recruitstudents.Score = studentfileView.Score; if (studentfileView.Territorial != null) student.CF_Recruitstudents.TerritorialID = studentfileView.Territorial; if (!string.IsNullOrEmpty(studentfileView.Area)) student.CF_Recruitstudents.Area = studentfileView.Area; if (studentfileView.EnteringSchoolYearID != null) student.CF_Recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID; } /// /// 导入新增 /// /// /// /// /// private void SaveInternalForImport(List studentfileView, BaseStudentView tempView, CF_Parameter parameter, IList roleList) { List StudentID = new List(); List userList = new List(); List studentList = new List(); //获取学生信息 List studentProfileList = new List(); List studentContactList = new List(); List studentAccountList = new List(); List recruitstudentsList = new List(); for (int i = 0; i < studentfileView.Count(); i++) { var pwd = ""; if (parameter == null) { pwd = ("A" + studentfileView[i].LoginID).MD5(); } else { if (parameter.Value != null) { pwd = parameter.Value; } else { pwd = ("A" + studentfileView[i].LoginID).MD5(); } } Sys_User user = new Sys_User(); int? tpye = null; user.LoginID = studentfileView[i].LoginID; if (!string.IsNullOrEmpty(studentfileView[i].UserName)) user.Name = studentfileView[i].UserName; if (studentfileView[i].StudentType != null) tpye = studentfileView[i].StudentType; user.Sys_Role = new HashSet(); roleList = roleList.Where(x => x.CF_StudentRole.StudentType == tpye).ToList(); roleList.ForEach(x => user.Sys_Role.Add(x)); userList.Add(new Sys_User { UserID = Guid.NewGuid(), Password = pwd, CreateTime = DateTime.Now, LoginID = user.LoginID, Name = user.Name, RecordStatus = (int)SYS_STATUS.USABLE, Sys_Role = user.Sys_Role }); StudentID.Add(userList[i].UserID); CF_Student students = new CF_Student(); students.UserID = userList[i].UserID; if (studentfileView[i].ClassMajorID != null) students.ClassmajorID = studentfileView[i].ClassMajorID; if (studentfileView[i].SexID != null) students.SexID = (int)studentfileView[i].SexID; if (studentfileView[i].BirthDate != null) students.BirthDate = studentfileView[i].BirthDate; if (studentfileView[i].Politics != null) students.PoliticsID = studentfileView[i].Politics; if (studentfileView[i].Nation != null) students.NationID = studentfileView[i].Nation; if (studentfileView[i].CertificatesType != null) students.CertificatesType = studentfileView[i].CertificatesType; if (!string.IsNullOrEmpty(studentfileView[i].IDNumber)) students.IDNumber = studentfileView[i].IDNumber; if (!string.IsNullOrEmpty(studentfileView[i].GraduationPictureUrl)) { students.GraduationPictureUrl = studentfileView[i].GraduationPictureUrl; } if (!string.IsNullOrEmpty(studentfileView[i].Career)) students.Career = studentfileView[i].Career; if (!string.IsNullOrEmpty(studentfileView[i].PhotoUrl)) { students.PhotoUrl = studentfileView[i].PhotoUrl; } students.PlanningGraduateDate = studentfileView[i].PlanningGraduateDate ?? studentfileView[i].PlanningGraduateDateStr; //if (students.PlanningGraduateDate == null) //{ // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView[i].ClassMajorID).FirstOrDefault().GrademajorID; // students.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value)); //} if (!string.IsNullOrEmpty(studentfileView[i].StudentCardNo)) students.StudentCardNo = studentfileView[i].StudentCardNo; //毕、结业证书编号 if (!string.IsNullOrEmpty(studentfileView[i].GraduateCardNo)) students.GraduateCardNo = studentfileView[i].GraduateCardNo; if (studentfileView[i].StudentType != null) students.StudentType = studentfileView[i].StudentType; if (studentfileView[i].StudentStatus != null) students.StudentStatus = studentfileView[i].StudentStatus; if (studentfileView[i].InSchoolStatusID != null) students.InSchoolStatusID = studentfileView[i].InSchoolStatusID; studentList.Add(new CF_Student { UserID = students.UserID, ClassmajorID = students.ClassmajorID, SexID = students.SexID, CertificatesType = students.CertificatesType, IDNumber = students.IDNumber, //IsDreamProject = students.IsDreamProject, Career = students.Career, PhotoUrl = students.PhotoUrl, PlanningGraduateDate = students.PlanningGraduateDate, StudentCardNo = students.StudentCardNo, GraduateCardNo = students.GraduateCardNo, //CultureModel = students.CultureModel, StudentType = students.StudentType, StudentStatus = students.StudentStatus, InSchoolStatusID = students.InSchoolStatusID, CreateTime = DateTime.Now, RecordStatus = (int)SYS_STATUS.USABLE }); CF_StudentProfile studentProfile = new CF_StudentProfile(); if (studentfileView[i].IsDreamProject) studentProfile.IsDreamProject = studentfileView[i].IsDreamProject; if (studentfileView[i].CultureModel != null) studentProfile.CultureModelID = studentfileView[i].CultureModel; if (!string.IsNullOrEmpty(studentfileView[i].UsedName)) studentProfile.UsedName = studentfileView[i].UsedName; if (!string.IsNullOrEmpty(studentfileView[i].DirectorName)) studentProfile.DirectorName = studentfileView[i].DirectorName; if (!string.IsNullOrEmpty(studentfileView[i].Country)) studentProfile.Country = studentfileView[i].Country; if (!string.IsNullOrEmpty(studentfileView[i].Place)) studentProfile.Place = studentfileView[i].Place; if (studentfileView[i].Healthy != null) studentProfile.HealthStateID = studentfileView[i].Healthy; if (studentfileView[i].BloodGroup != null) studentProfile.BloodGroup = studentfileView[i].BloodGroup; //studentProfile.BornPlace = studentfileView.BornPlace; if (!string.IsNullOrEmpty(studentfileView[i].Specialty)) studentProfile.Specialty = studentfileView[i].Specialty; if (!string.IsNullOrEmpty(studentfileView[i].Height)) studentProfile.Height = studentfileView[i].Height; if (!string.IsNullOrEmpty(studentfileView[i].Weight)) studentProfile.Weight = studentfileView[i].Weight; if (!string.IsNullOrEmpty(studentfileView[i].Remarks)) students.Remark = studentfileView[i].Remarks; studentProfileList.Add(new CF_StudentProfile { UserID = students.UserID, UsedName = studentProfile.UsedName, //GraduationPictureUrl=studentProfile.GraduationPictureUrl, DirectorName = studentProfile.DirectorName, //BirthDate=studentProfile.BirthDate, Country = studentProfile.Country, //Politics=studentProfile.Politics, //Nation=studentProfile.Nation, Place = studentProfile.Place, HealthStateID = studentProfile.HealthStateID, BloodGroup = studentProfile.BloodGroup, Specialty = studentProfile.Specialty, Height = studentProfile.Height, Weight = studentProfile.Weight, //Remarks = studentProfile.Remarks, CreateTime = DateTime.Now, RecordStatus = (int)SYS_STATUS.USABLE }); CF_StudentContact studentContact = new CF_StudentContact(); if (!string.IsNullOrEmpty(studentfileView[i].Email)) studentContact.Email = studentfileView[i].Email; if (!string.IsNullOrEmpty(studentfileView[i].QQ)) studentContact.QQ = studentfileView[i].QQ; if (!string.IsNullOrEmpty(studentfileView[i].Mobile)) studentContact.Mobile = studentfileView[i].Mobile; if (!string.IsNullOrEmpty(studentfileView[i].Telephone)) studentContact.Telephone = studentfileView[i].Telephone; if (!string.IsNullOrEmpty(studentfileView[i].MicroMsgNo)) studentContact.WeChatNum = studentfileView[i].MicroMsgNo; if (!string.IsNullOrEmpty(studentfileView[i].ZipCode)) studentContact.ZIPCode = studentfileView[i].ZipCode; if (!string.IsNullOrEmpty(studentfileView[i].Address)) studentContact.Address = studentfileView[i].Address; if (!string.IsNullOrEmpty(studentfileView[i].WorkUnit)) studentContact.WorkUnit = studentfileView[i].WorkUnit; if (!string.IsNullOrEmpty(studentfileView[i].HomeAddress)) studentContact.HomeAddress = studentfileView[i].HomeAddress; if (!string.IsNullOrEmpty(studentfileView[i].Recipient)) studentContact.Recipient = studentfileView[i].Recipient; if (!string.IsNullOrEmpty(studentfileView[i].Dormitory)) studentContact.Dormitory = studentfileView[i].Dormitory; studentContactList.Add(new CF_StudentContact { UserID = students.UserID, Email = studentContact.Email, QQ = studentContact.QQ, Mobile = studentContact.Mobile, Telephone = studentContact.Telephone, WeChatNum = studentContact.WeChatNum, ZIPCode = studentContact.ZIPCode, Address = studentContact.Address, WorkUnit = studentContact.WorkUnit, HomeAddress = studentContact.HomeAddress, Recipient = studentContact.Recipient, Dormitory = studentContact.Dormitory, CreateTime = DateTime.Now, RecordStatus = (int)SYS_STATUS.USABLE }); CF_StudentAccount studentAccount = new CF_StudentAccount(); if (!string.IsNullOrEmpty(studentfileView[i].CardNo)) studentAccount.CardNo = studentfileView[i].CardNo; if (!string.IsNullOrEmpty(studentfileView[i].BankName)) studentAccount.BankName = studentfileView[i].BankName; studentAccountList.Add(new CF_StudentAccount { UserID = students.UserID, CardNo = studentAccount.CardNo, BankName = studentAccount.BankName, CreateTime = DateTime.Now, RecordStatus = (int)SYS_STATUS.USABLE }); CF_Recruitstudents recruitstudents = new CF_Recruitstudents(); if (studentfileView[i].EntranceDate != null) recruitstudents.EntranceDate = studentfileView[i].EntranceDate; if (studentfileView[i].EntranceWay != null) recruitstudents.EntranceWayID = studentfileView[i].EntranceWay; if (!string.IsNullOrEmpty(studentfileView[i].ExamineeNum)) recruitstudents.ExamineeNum = studentfileView[i].ExamineeNum; //if (!string.IsNullOrEmpty(studentfileView[i].Placebirth)) // recruitstudents.PlaceBirth = studentfileView[i].Placebirth; if (studentfileView[i].ExamineeType != null) recruitstudents.ExamineeType = studentfileView[i].ExamineeType; if (studentfileView[i].Features != null) recruitstudents.FeaturesID = studentfileView[i].Features; if (studentfileView[i].Score != null) recruitstudents.Score = studentfileView[i].Score; if (studentfileView[i].Territorial != null) recruitstudents.TerritorialID = studentfileView[i].Territorial; if (!string.IsNullOrEmpty(studentfileView[i].Area)) recruitstudents.Area = studentfileView[i].Area; if (studentfileView[i].EnteringSchoolYearID != null) recruitstudents.EnteringSchoolYearID = studentfileView[i].EnteringSchoolYearID; recruitstudentsList.Add(new CF_Recruitstudents { UserID = students.UserID, EntranceDate = recruitstudents.EntranceDate, EntranceWayID = recruitstudents.EntranceWayID, ExamineeNum = recruitstudents.ExamineeNum, //PlaceBirth=recruitstudents.PlaceBirth, ExamineeType = recruitstudents.ExamineeType, FeaturesID = recruitstudents.FeaturesID, Score = recruitstudents.Score, TerritorialID = recruitstudents.TerritorialID, Area = recruitstudents.Area, EnteringSchoolYearID = recruitstudents.EnteringSchoolYearID, CreateTime = DateTime.Now, RecordStatus = (int)SYS_STATUS.USABLE }); } UnitOfWork.BulkInsert(userList); UnitOfWork.BulkInsert(userList, (x => x.Sys_Role)); UnitOfWork.BulkInsert(studentList); UnitOfWork.BulkInsert(studentProfileList); UnitOfWork.BulkInsert(studentContactList); UnitOfWork.BulkInsert(studentAccountList); UnitOfWork.BulkInsert(recruitstudentsList); //UnitOfWork.Commit(); AddStudentEnd(StudentID); } /// /// 学生添加后进行数据插入 /// /// public virtual void AddStudentEnd(List studentID) { var inschoolStatusList = InSchoolSettingRepository.Value.GetList(x => x.IsSelected == true).Select(x => x.InSchoolStatusID).ToList(); var schoolYear = SchoolYearServices.Value.GetCurrentSchoolYear(); Expression> exp = x => studentID.Contains(x.UserID); //要新增的学生 var studentEntityList = StudentsDAL.Value.StudentRepository.GetList(exp).ToList(); var classIDs = studentEntityList.Select(x => x.ClassmajorID).Distinct().ToList(); var ClassmajorList = StudentsDAL.Value.ClassmajorRepository.GetList(w => classIDs.Contains(w.ClassmajorID), i => i.CF_Grademajor.CF_Schoolyear).ToList(); var grademajorIDList = ClassmajorList.Select(x => x.GrademajorID).Distinct().ToList(); var grademajorList = StudentsDAL.Value.GrademajorRepository.GetList(w => grademajorIDList.Contains(w.GrademajorID)).ToList(); //修改教学数据只需要修改在校的学生 exp = exp.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); #region 5.0 教学任务插入异动学生代码段...... var studentSchedulingClassList = StudentsDAL.Value.GetStudentRelateCourseViewQueryable(exp).ToList(); List educationSchedulingClassStudentInsert = new List(); foreach (var studentSchedulingClass in studentSchedulingClassList) { //情况1:找到同班同学,并且自己学号最小,塞同班同学的第一个班 var classmateSchdulingList = studentSchedulingClass .StudentRelateSchedulingClassViewList .Where(x => x.ClassmajorIDList.Contains(studentSchedulingClass.ClassmajorID)) .OrderBy(x => x.EducationMissionClassName) .ToList(); if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) < 0) { var minMissionClassName = classmateSchdulingList.Min(x => x.EducationMissionClassName); var minSchedulingClassID = classmateSchdulingList.Where(x => x.EducationMissionClassName == minMissionClassName).Select(x => x.EducationSchedulingClassID).FirstOrDefault(); if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID)) { educationSchedulingClassStudentInsert.Add(new StudentsView { UserID = studentSchedulingClass.UserID ?? Guid.Empty, TepTableID = minSchedulingClassID }); } } //情况2:找到同班同学,并且自己学号不是最小,塞第一个自己不是最大的班,如果没有,塞最后一个班 else if (classmateSchdulingList.Count > 0 && studentSchedulingClass.LoginID.CompareTo(classmateSchdulingList.Max(x => x.MinLoginID)) >= 0) { foreach (var classmateScheduling in classmateSchdulingList) { if (studentSchedulingClass.LoginID.CompareTo(classmateScheduling.MaxLoginID) <= 0) { if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID)) { educationSchedulingClassStudentInsert.Add(new StudentsView { UserID = studentSchedulingClass.UserID ?? Guid.Empty, TepTableID = classmateScheduling.EducationSchedulingClassID }); break; } } if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == classmateScheduling.EducationSchedulingClassID)) { educationSchedulingClassStudentInsert.Add(new StudentsView { UserID = studentSchedulingClass.UserID ?? Guid.Empty, TepTableID = classmateScheduling.EducationSchedulingClassID }); } } } //情况3:找不到同班同学,但排课班已经有人,塞顺序下来人最少的班 else if (classmateSchdulingList.Count == 0 && studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0)) { var minStudentCount = studentSchedulingClass.StudentRelateSchedulingClassViewList.Min(x => x.StudentCount); var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList.Where(x => x.StudentCount == minStudentCount) .OrderBy(x => x.EducationMissionClassName) .Select(x => x.EducationSchedulingClassID).FirstOrDefault(); if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID)) { educationSchedulingClassStudentInsert.Add(new StudentsView { UserID = studentSchedulingClass.UserID ?? Guid.Empty, TepTableID = minSchedulingClassID }); } } //情况4:找不到同班同学,而且排课班没人,塞第一个班 else if (classmateSchdulingList.Count == 0 && !studentSchedulingClass.StudentRelateSchedulingClassViewList.Any(x => x.StudentCount > 0)) { var minSchedulingClassID = studentSchedulingClass.StudentRelateSchedulingClassViewList .OrderBy(x => x.EducationMissionClassName) .Select(x => x.EducationSchedulingClassID).FirstOrDefault(); if (!educationSchedulingClassStudentInsert.Any(x => x.UserID == studentSchedulingClass.UserID && x.TepTableID == minSchedulingClassID)) { educationSchedulingClassStudentInsert.Add(new StudentsView { UserID = studentSchedulingClass.UserID ?? Guid.Empty, TepTableID = minSchedulingClassID }); } } } //var educationSchedulingClassStudentInsert = StudentsDAL.Value.GetEducationSchedulingClassStudentInsert(exp).Distinct().ToList(); var educationSchedulingClassIDInsertList = educationSchedulingClassStudentInsert.Select(x => x.TepTableID).Distinct().ToList(); var educationSchedulingClassEntityList = StudentsDAL.Value.EducationSchedulingClassRepository .GetList(x => educationSchedulingClassIDInsertList.Contains(x.EducationSchedulingClassID), (x => x.CF_Student)).ToList(); //批量插入准备 var educationSchedulingClassStudentInsertList = new List(); foreach (var educationScheduling in educationSchedulingClassStudentInsert) { Guid? educationSchedulingClassID = educationScheduling.TepTableID; EM_EducationSchedulingClass educationSchedulingClassEntity = educationSchedulingClassEntityList.Where(x => x.EducationSchedulingClassID == educationSchedulingClassID).FirstOrDefault(); if (educationSchedulingClassEntity != null && educationScheduling.UserID != null) { if (!educationSchedulingClassEntity.CF_Student.Where(x => x.UserID == educationScheduling.UserID).Any()) { //var student = studentEntityList.Where(x => x.UserID == educationScheduling.UserID).FirstOrDefault(); //if(student!=null){ //educationSchedulingClassEntity.CF_Student.Add(student); educationSchedulingClassStudentInsertList.Add(new Relation2KeyTable { Key1 = educationSchedulingClassEntity.EducationSchedulingClassID, Key2 = educationScheduling.UserID }); //} } } } #endregion #region 6.0 考场安排插入异动学生代码段...... //var educationPlanInsertList = StudentsDAL.Value.GetExaminationPlanStudentInsert(educationSchedulingClassStudentInsert).ToList(); //var educationPlanStudentList = educationPlanInsertList.Select(x => x.CF_Student).ToList(); ////批量插入准备 //var educationSchedulingClassStudentList = new List(); ////因为导入学生会有不同的班所以要通过班来循环 //foreach (var classID in classIDs) //{ // foreach (var educationPlanStudent in educationPlanStudentList) // { // //找到考场安排对应的班 // var educationPlanStudentClass = educationPlanStudent.Where(x => x.ClassmajorID == classID); // var educationPlanStudents = educationPlanInsertList.Where(x => x.CF_Student == educationPlanStudentClass); // //找到对应班里的学生 // var studentList=studentEntityList.Where(x=>x.ClassmajorID==classID).ToList(); // //添加学生 // foreach(var student in studentList) // { // educationPlanStudents.ForEach(x => x.CF_Student.Add(student)); // } // } //} // var examinationPlanStudentInsert = DifferentDynamicDAL.GetExaminationPlanStudentInsert(x => x.SchoolyearID == schoolYear).ToList(); //2016年11月8日11:32:50 zhanghl //TODO: 由于考场安排涉及座位安排、暂时不做插入数据处理...... #endregion #region 7.0 成绩管理插入异动学生代码段...... var scoreStudentInsert = StudentsDAL.Value.GetScoreStudentInsert(exp, (x => x.EM_EducationSchedulingClass .Any(w => educationSchedulingClassIDInsertList.Contains(w.EducationSchedulingClassID)))).Distinct().ToList(); var TepTableID = scoreStudentInsert.Select(x => x.TepTableID).Distinct().ToList(); var finalExaminationList = StudentsDAL.Value.FinalExaminationRepository.GetList(x => TepTableID.Contains(x.FinalExaminationID), (x => x.ER_FinalExaminationStudent)).ToList(); var finalExaminationStudentInsertList = new List(); foreach (var scoreStudent in scoreStudentInsert) { ER_FinalExamination finalExaminationEntity = finalExaminationList.Where(x => x.FinalExaminationID == scoreStudent.TepTableID).FirstOrDefault(); if (finalExaminationEntity != null) { if (!finalExaminationEntity.ER_FinalExaminationStudent.Where(x => x.UserID == scoreStudent.UserID).Any()) { var Students = studentEntityList.Where(x => x.UserID == scoreStudent.UserID).FirstOrDefault(); finalExaminationStudentInsertList.Add(new ER_FinalExaminationStudent { FinalExaminationStudentID = Guid.NewGuid(), FinalExaminationID = finalExaminationEntity.FinalExaminationID, SchoolyearNumID = (schoolYear.Value - ((Students.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (Students.CF_Classmajor.CF_Grademajor.SemesterID - 1)) - (schoolYear.SchoolcodeID == Students.CF_Classmajor.CF_Grademajor.SemesterID ? 0 : 1)) / 2 + 1, StarttermID = schoolYear.Value - ((Students.CF_Classmajor.CF_Grademajor.GradeID * 2) - 1 + (Students.CF_Classmajor.CF_Grademajor.SemesterID - 1)) + 1, UserID = scoreStudent.UserID, RecordStatus = (int)SYS_STATUS.USABLE, CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, CreateTime = DateTime.Now, ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, ModifyTime = DateTime.Now }); } } } #endregion #region 8.0 教学评价插入异动学生代码段...... var evaluationSettingStudentInsert = StudentsDAL.Value.GetEvaluationSettingStudentInsert(exp).Distinct().ToList(); var evaluationSettingIDList = evaluationSettingStudentInsert.Select(x => x.TepTableID).Distinct().ToList(); var evaluationSettingStudentID = evaluationSettingStudentInsert.Select(x => x.UserID).Distinct().ToList(); var evaluationSettingEntityList = StudentsDAL.Value.EvaluationSettingRepository .GetList(x => evaluationSettingIDList.Contains(x.EvaluationSettingID) && x.OpenStatus == (int)CF_YesOrNoStatus.No, (x => x.CF_Student)).ToList(); var evaluationSettingStudentInsertList = new List(); foreach (var evaluationSettingID in evaluationSettingIDList) { EM_EvaluationSetting evaluationSettingEntity = evaluationSettingEntityList.Where(x => x.EvaluationSettingID == evaluationSettingID).FirstOrDefault(); if (evaluationSettingEntity != null) { foreach (var student in studentID) { if (evaluationSettingStudentID.Contains(student)) { if (!evaluationSettingEntity.CF_Student.Where(x => x.UserID == student).Any()) { evaluationSettingStudentInsertList.Add(new Relation2KeyTable { Key1 = evaluationSettingEntity.EvaluationSettingID, Key2 = student }); //var Students = studentEntityList.Where(x => x.UserID == student).FirstOrDefault(); //evaluationSettingEntity.CF_Student.Add(Students); } } } } } #endregion #region 9.0学生征订 var studentOrderAddList = StudentsDAL.Value.GetAddStudentsOrder(exp).ToList(); studentOrderAddList.ForEach(x => x.OrderQty++); #endregion #region 10.0学生发放 var studentDistributeAddList = StudentsDAL.Value.GetAddStudentDistribute(exp).ToList(); studentDistributeAddList.ForEach(x => x.DistributeQty++); #endregion UnitOfWork.BulkInsert(educationSchedulingClassStudentInsertList); UnitOfWork.BulkInsert(finalExaminationStudentInsertList); UnitOfWork.BulkInsert(evaluationSettingStudentInsertList); UnitOfWork.Commit(); } /// /// 删除(删除成功后,对相应的录取名单信息进行更新--提交状态) /// /// /// public bool UserDelete(List userIDs) { try { List newStudentUpList = new List(); //查询对应的学生信息List var studentList = StudentsDAL.Value.StudentRepository .GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_User)).ToList(); //对应的身份证号List var iDNumberList = studentList.Where(x => !string.IsNullOrEmpty(x.IDNumber)) .Select(x => x.IDNumber.Trim()).ToList(); //根据身份证号查询对应的录取名单信息List var newStudentList = NewStudentRepository.Value .GetList(x => iDNumberList.Contains(x.IDNumber)).ToList(); foreach (var student in studentList) { var newStudent = newStudentList.Where(x => x.IDNumber == student.IDNumber && x.StudentNo == student.Sys_User.LoginID).SingleOrDefault(); if (newStudent != null) { newStudent.RecordStatus = (int)CF_NewStudentEnterStatus.NotSubmitted; SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); } } UnitOfWork.Remove(x => userIDs.Contains((Guid)x.UserID)); UnitOfWork.Remove(x => userIDs.Contains((Guid)x.UserID)); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); var userList = this.UserRepository.Value.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_Role)).ToList(); userList.ForEach(x => x.Sys_Role = new HashSet()); UnitOfWork.Remove(x => userIDs.Contains(x.UserID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } /// /// Excel导入 /// /// /// public virtual DataTable Import(DataTable dataSource) { var errorSource = dataSource.Clone(); errorSource.Columns.Add("错误信息"); //添加错误并且排除必填字段为空的记录行 var errorList = AddErrorAndExceptEmptyDataRow(dataSource); //添加错误并且排除重复的记录行 errorList.AddRange(AddErrorAndExceptRepetitiveDataRow(dataSource)); //现改为可重复导入学生,并以学号关键字修改学生相关信息表,因此注释掉排除重复学号方法:邓智荣 //添加错误并且排除已存在的记录 //AddErrorAndExceptExistingDataRow(dataSource); var views = MapToStudentsView(dataSource, errorList); errorList.ForEach(x => AddError(errorSource, x.Row, x.Error) ); if (errorSource.Rows.Count == 0) { SaveOrUpdate(views); } return errorSource; } /// /// 添加错误并且排除必填字段为空的记录行 /// /// /// private List AddErrorAndExceptEmptyDataRow(DataTable dataSource) { var dic = new Dictionary { {"学号","学号不能为空"}, {"姓名","姓名不能为空"}, {"性别","性别不能为空"}, {"证件类型","证件类型不能为空"}, {"证件号码","证件号码不能为空"}, {"班级名称","班级名称不能为空"}, {"学籍状态","学籍状态不能为空"}, {"在校状态","在校状态不能为空"}, {"入学学年学期","入学学年学期不能为空"}, }; var errorRowList = (from ds in dataSource.AsEnumerable() from pair in dic where string.IsNullOrEmpty(ds.Field(pair.Key)) group pair by ds into g select new ImportErrorRowView { Row = g.Key, Error = string.Join(",", g.Select(x => x.Value)) }) .ToList(); //foreach (var errorRow in errorRowList) //{ // AddError(errorSource, errorRow.Row, errorRow.Error); // dataSource.Rows.Remove(errorRow.Row); //} return errorRowList; //foreach (var pair in dic) //{ // var query = dataSource.AsEnumerable().Where(w => string.IsNullOrEmpty(w.Field(pair.Key))).ToArray(); // foreach (var dr in query) // { // AddError(errorSource, dr, pair.Value); // dataSource.Rows.Remove(dr); // } //} } /// /// 添加错误并且排除重复的记录行 /// /// /// private List AddErrorAndExceptRepetitiveDataRow(DataTable dataSource) { var query = dataSource.AsEnumerable() .GroupBy(key => key.Field("学号")) .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key)) .SelectMany(s => s) .Select(x => new ImportErrorRowView { Row = x, Error = "学号重复" }).ToList(); //foreach (var dr in query) //{ // AddError(errorSource, dr, "学号重复"); // dataSource.Rows.Remove(dr); //} return query; } /// /// 添加错误并且排除已存在的记录 /// /// /// private List AddErrorAndExceptExistingDataRow(DataTable dataSource) { var loginIDs = dataSource.AsEnumerable().Select(s => s.Field("学号")).ToArray(); var hasLoginIds = UserRepository.Value.GetList(w => loginIDs.Contains(w.LoginID)).Select(s => s.LoginID).ToArray(); var query = dataSource.AsEnumerable().Where(w => hasLoginIds.Contains(w.Field("学号"))) .Select(x => new ImportErrorRowView { Row = x, Error = "该学号已存在" }).ToList(); return query; //foreach (var dr in query) //{ // AddError(errorSource, dr, "该学号已存在"); // dataSource.Rows.Remove(dr); //} } /// /// Excel导入判断 /// /// /// /// private StudentsView[] MapToStudentsView(DataTable dataSource, List errorList) { var views = new List(); var classNames = dataSource.AsEnumerable().Select(s => s.Field("班级名称").Trim()).Distinct().ToArray(); var classes = ClassmajorRepository.Value.GetList(w => classNames.Contains(w.Name.Trim()), i => i.CF_Grademajor.CF_Schoolyear).ToArray(); var schoolYearCodes = dataSource.AsEnumerable().Select(s => s.Field("入学学年学期").Trim()).Distinct().ToArray(); var schoolYears = SchoolyearRepository.Value.GetList(w => schoolYearCodes.Contains(w.Code.Trim())).ToArray(); var dictionarySex = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex); var dictionaryCertificatesType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType); var dictionaryStudentStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StudentStatus); var dictionaryInschoolStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus); var dictionaryStudentType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE); var dictionaryCultureModel = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL); var dictionaryExamineeType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE); var dictionaryEntranceWay = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay); var dictionaryFeatures = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features); var dictionaryTerritorial = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province); var dictionaryNation = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation); var dictionaryHealthy = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState); var dictionaryBloodGroup = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP); var dictionaryPolitics = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics); var dictionaryIsDreamProject = IdNameExt.GetDictionaryItem(DictionaryItem.CF_YesOrNoStatus); DataTimeHelper dth = new DataTimeHelper(); string temp; string isDreamProject; foreach (DataRow dr in dataSource.Rows) { List errorMessageList = new List(); var view = new StudentsView(); view.LoginID = (dr.Field("学号") ?? "").Trim(); view.UserName = (dr.Field("姓名") ?? "").Trim(); view.Career = (dr.Field("在校经历") ?? "").Trim(); #region 性别 var sexField = dr.Field("性别"); if (!string.IsNullOrEmpty(sexField)) { var sex = dictionarySex.SingleOrDefault(w => w.Name.Trim() == sexField.Trim()); if (sex == null) { errorMessageList.Add("性别数据格式不正确"); //AddError(errorSource, dr, "性别数据格式不正确"); //continue; } else { view.SexID = sex.Value; } } #endregion #region 是否是圆梦计划 isDreamProject = (dr.Field("是否是圆梦计划") ?? "").Trim(); if (!string.IsNullOrEmpty(isDreamProject)) { var IsDreamProject = dictionaryIsDreamProject.SingleOrDefault(w => w.Name.Trim() == isDreamProject); if (IsDreamProject == null) { errorMessageList.Add("是否是圆梦计划数据格式不正确"); //AddError(errorSource, dr, "是否是圆梦计划数据格式不正确"); //continue; } else { view.IsDreamProject = IsDreamProject.Value == 0 ? false : true; } } #endregion #region 证件类型 var certificatesTypeField = dr.Field("证件类型"); if (!string.IsNullOrEmpty(certificatesTypeField)) { var certificatesType = dictionaryCertificatesType.SingleOrDefault(w => w.Name.Trim() == certificatesTypeField.Trim()); if (certificatesType == null) { errorMessageList.Add("证件类型数据格式不正确"); //AddError(errorSource, dr, "证件类型数据格式不正确"); //continue; } else { view.CertificatesType = certificatesType.Value; } } #endregion view.IDNumber = (dr.Field("证件号码") ?? ""); #region 班级名称 var classField = dr.Field("班级名称"); if (!string.IsNullOrEmpty(classField)) { var @class = classes.SingleOrDefault(w => w.Name.Trim() == classField.Trim()); if (@class == null) { errorMessageList.Add("班级名称不存在"); //AddError(errorSource, dr, "班级名称不存在"); //continue; } else { view.ClassMajorID = @class.ClassmajorID; view.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(@class.CF_Grademajor.CF_Schoolyear.FirstWeek); //string PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID); //view.PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID);//设置预计毕业时间 } } #endregion #region 学籍状态 var studentStatusField = dr.Field("学籍状态"); if (!string.IsNullOrEmpty(studentStatusField)) { var studentStatus = dictionaryStudentStatus.SingleOrDefault(w => w.Name.Trim() == studentStatusField.Trim()); if (studentStatus == null) { errorMessageList.Add("学籍状态数据格式不正确"); //AddError(errorSource, dr, "学籍状态数据格式不正确"); //continue; } else { view.StudentStatus = studentStatus.Value; } } #endregion #region 在校状态 var inschoolStatusField = dr.Field("在校状态"); if (!string.IsNullOrEmpty(inschoolStatusField)) { var inschoolStatus = dictionaryInschoolStatus.SingleOrDefault(w => w.Name.Trim() == inschoolStatusField.Trim()); if (inschoolStatus == null) { errorMessageList.Add("在校状态数据格式不正确"); //AddError(errorSource, dr, "在校状态数据格式不正确"); //continue; } else { view.InSchoolStatusID = inschoolStatus.Value; } } #endregion #region 入学学年学期 var schoolYearField = dr.Field("入学学年学期"); if (!string.IsNullOrEmpty(schoolYearField)) { var schoolYear = schoolYears.SingleOrDefault(w => w.Code.Trim() == schoolYearField.Trim()); if (schoolYear == null) { errorMessageList.Add("入学学年学期不存在"); //AddError(errorSource, dr, "入学学年学期不存在"); //continue; } else { view.EnteringSchoolYearID = schoolYear.SchoolyearID; } } #endregion #region 学生类别 temp = (dr.Field("学生类别") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryStudentType.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("学生类别不存在"); //AddError(errorSource, dr, "学生类别不存在"); //continue; } else { view.StudentType = ent.Value; } } #endregion #region 培养方式 temp = (dr.Field("培养方式") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryCultureModel.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("培养方式不存在"); //AddError(errorSource, dr, "培养方式不存在"); //continue; } else { view.CultureModel = ent.Value; } } #endregion view.StudentCardNo = (dr.Field("学籍卡编号") ?? "").Trim(); view.GraduateCardNo = (dr.Field("毕结业证书编号") ?? "").Trim(); view.ExamineeNum = (dr.Field("教育部考生号") ?? "").Trim(); #region 考生类别 temp = (dr.Field("考生类别") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryExamineeType.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("考生类别不存在"); //AddError(errorSource, dr, "考生类别不存在"); //continue; } else { view.ExamineeType = ent.Value; } } #endregion #region 入学日期 temp = (dr.Field("入学日期") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { DateTime dt; if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt)) { if (!DateTime.TryParse(temp, out dt)) { errorMessageList.Add("入学日期数据格式不正确"); //AddError(errorSource, dr, "入学日期数据格式不正确"); //continue; } else { view.EntranceDate = dt; } } else { view.EntranceDate = dt; } } #endregion #region 入学方式 temp = (dr.Field("入学方式") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryEntranceWay.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("入学方式不存在"); //AddError(errorSource, dr, "入学方式不存在"); //continue; } else { view.EntranceWay = ent.Value; } } #endregion view.Placebirth = (dr.Field("出生地") ?? "").Trim(); #region 考生特征 temp = (dr.Field("考生特征") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryFeatures.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("考生特征不存在"); //AddError(errorSource, dr, "考生特征不存在"); //continue; } else { view.Features = ent.Value; } } #endregion #region 高考总分 temp = (dr.Field("高考总分") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { decimal d; if (!decimal.TryParse(temp, out d)) { errorMessageList.Add("高考总分数据格式不正确"); //AddError(errorSource, dr, "高考总分数据格式不正确"); //continue; } else { view.Score = d; } } #endregion #region 生源所属地 temp = (dr.Field("生源所属地") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryTerritorial.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("生源所属地不存在"); //AddError(errorSource, dr, "生源所属地不存在"); //continue; } else { view.Territorial = ent.Value; } } #endregion view.Area = (dr.Field("来源地区") ?? "").Trim(); view.UsedName = (dr.Field("曾用名") ?? "").Trim(); view.DirectorName = (dr.Field("导师姓名") ?? "").Trim(); #region 出生日期 temp = (dr.Field("出生日期") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { DateTime dt; if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt)) { if (!DateTime.TryParse(temp, out dt)) { errorMessageList.Add("出生日期数据格式不正确"); //AddError(errorSource, dr, "出生日期数据格式不正确"); //continue; } else { view.BirthDate = dt; } } else { view.BirthDate = dt; } } #endregion view.Country = (dr.Field("国籍") ?? "").Trim(); // view.Politics = (dr.Field("政治面貌") ?? "").Trim(); #region 政治面貌 temp = (dr.Field("政治面貌") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var politics = dictionaryPolitics.SingleOrDefault(w => w.Name.Trim() == temp); if (politics == null) { errorMessageList.Add("政治面貌不存在"); //AddError(errorSource, dr, "政治面貌不存在"); //continue; } else { view.Politics = politics.Value; } } #endregion #region 民族 temp = (dr.Field("民族") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryNation.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("民族不存在"); //AddError(errorSource, dr, "民族不存在"); //continue; } else { view.Nation = ent.Value; } } #endregion view.Place = (dr.Field("籍贯") ?? "").Trim(); #region 健康状态 temp = (dr.Field("健康状态") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryHealthy.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("健康状态不存在"); //AddError(errorSource, dr, "健康状态不存在"); //continue; } else { view.Healthy = ent.Value; } } #endregion #region 血型 temp = (dr.Field("血型") ?? "").Trim(); if (!string.IsNullOrEmpty(temp)) { var ent = dictionaryBloodGroup.SingleOrDefault(w => w.Name.Trim() == temp); if (ent == null) { errorMessageList.Add("血型不存在"); //AddError(errorSource, dr, "血型不存在"); //continue; } else { view.BloodGroup = ent.Value; } } #endregion view.Specialty = (dr.Field("特长") ?? "").Trim(); view.Height = (dr.Field("身高") ?? "").Trim(); view.Weight = (dr.Field("体重") ?? "").Trim(); view.Remarks = (dr.Field("备注") ?? "").Trim(); view.CardNo = (dr.Field("银行卡号") ?? "").Trim(); view.BankName = (dr.Field("开户银行") ?? "").Trim(); view.Email = (dr.Field("电子邮件") ?? "").Trim(); view.QQ = (dr.Field("QQ") ?? "").Trim(); view.Mobile = (dr.Field("移动电话") ?? "").Trim(); view.Telephone = (dr.Field("固定电话") ?? "").Trim(); view.MicroMsgNo = (dr.Field("微信号") ?? "").Trim(); view.ZipCode = (dr.Field("邮编") ?? "").Trim(); view.Address = (dr.Field("通信地址") ?? "").Trim(); view.WorkUnit = (dr.Field("工作单位") ?? "").Trim(); view.HomeAddress = (dr.Field("家庭地址") ?? "").Trim(); view.Recipient = (dr.Field("收件人") ?? "").Trim(); view.Dormitory = (dr.Field("宿舍编号") ?? "").Trim(); if (errorMessageList.Count > 0) { if (errorList.Any(x => x.Row == dr)) { var errorRow = errorList.First(x => x.Row == dr); errorRow.Error += "," + string.Join(",", errorMessageList); } else { errorList.Add(new ImportErrorRowView { Row = dr, Error = string.Join(",", errorMessageList) }); } } else if (!errorList.Any(x => x.Row == dr)) { views.Add(view); } } return views.ToArray(); } /// /// /// /// /// /// private void AddError(DataTable dtError, DataRow dataRow, string message) { var dr = dtError.NewRow(); if (dataRow != null) { dr.ItemArray = dataRow.ItemArray; } dr["错误信息"] = message; dtError.Rows.Add(dr); } /// /// 新增、修改 /// /// private void SaveOrUpdate(params StudentsView[] studentsViews) { var loginIDList = studentsViews.Select(x => x.LoginID).ToList(); var existsStudentViewList = StudentsDAL.Value.StudentRepository.GetList(x => loginIDList.Contains(x.Sys_User.LoginID), (x => x.Sys_User.Sys_Role), (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount), (x => x.CF_Recruitstudents)).ToList(); var needAddList = existsStudentViewList.Select(x => x.Sys_User.LoginID).ToList(); var addStudentsViews = studentsViews.Where(x => !needAddList.Contains(x.LoginID)).ToList(); var parameter = ParameterDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword); var roleList = RoleDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList(); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null) throw new Exception("请先设置配置文件的预计毕业月份(春季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null) throw new Exception("请先设置配置文件的预计毕业日期(春季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null) throw new Exception("请先设置配置文件的预计毕业月份(秋季入学)。"); if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null) throw new Exception("请先设置配置文件的预计毕业日期(秋季入学)。"); SaveInternalForImport(addStudentsViews, null, parameter, roleList); UnitOfWork.Delete(existsStudentViewList.Select(x => x.Sys_User).ToList(), (x => x.Sys_Role)); foreach (var item in studentsViews) { var student = existsStudentViewList.FirstOrDefault(x => x.Sys_User.LoginID == item.LoginID); if (student != null) { UpdateInternalForImport(item, student, parameter, roleList); } } UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.Sys_User).ToList()); UnitOfWork.BatchUpdate(existsStudentViewList); UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentProfile).ToList()); UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentContact).ToList()); UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentAccount).ToList()); UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_Recruitstudents).ToList()); UnitOfWork.BulkInsert(existsStudentViewList.Select(x => x.Sys_User).ToList(), (x => x.Sys_Role)); //UnitOfWork.Commit(); } public void GraduationPicImport(IList photoPaths) { var map = photoPaths .Select(s => new { IDNum = Path.GetFileNameWithoutExtension(s).Trim(), PhotoPath = s, }) .ToArray(); var idNums = map.Select(s => s.IDNum).Distinct().ToArray(); var studentList = StudentsDAL.Value.StudentRepository.GetList(w => idNums.Contains(w.IDNumber), (x => x.CF_StudentProfile)).ToList(); foreach (var idNum in idNums) { var student = studentList.FirstOrDefault(w => w.IDNumber == idNum); if (student == null) { throw new Exception("导入照片中存在无法匹对信息,请检查文件名是否正确。"); } } foreach (var m in map) { var student = studentList.FirstOrDefault(w => w.IDNumber == m.IDNum); if (student != null) { student.GraduationPictureUrl = m.PhotoPath; } } UnitOfWork.Commit(); } public virtual void PicImport(IList photoPaths) { var map = photoPaths .Select(s => new { LoginID = Path.GetFileNameWithoutExtension(s).Trim(), PhotoPath = s, }) .ToArray(); var loginIds = map.Select(s => s.LoginID).Distinct().ToArray(); var users = UserRepository.Value.GetList(w => loginIds.Contains(w.LoginID), i => i.CF_Student).ToList(); foreach (var loginId in loginIds) { var user = users.FirstOrDefault(w => w.LoginID == loginId); if (user == null) { throw new Exception("导入照片中存在无法匹对信息,请检查文件名是否正确。"); } } foreach (var m in map) { var user = users.FirstOrDefault(w => w.LoginID == m.LoginID); if (user != null) { user.CF_Student.PhotoUrl = m.PhotoPath; } } UnitOfWork.Commit(); } public DateTime? ReckonPlanningGraduateDate(Guid GrademajorID) { //由于LINQ不识别方法的系统的时间 ToDateTime(系统,字符串)的方法、将计算时间移至外围 StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduateDate(GrademajorID); return studentsEntity.PlanningGraduateDate.Value.AddDays(studentsEntity.WeeksNum); } //private DateTime GetPlanningGraduate(DateTime firstWeek) //{ // if (firstWeek.Month >= 1 && firstWeek.Month <= 6) // { // return new DateTime(firstWeek.Year, 6, 30); // } // else // { // return new DateTime((firstWeek.Year + 1), 1, 31); // } //} public string GetPlanningGraduate(Guid GrademajorID) { var graduationSchoolyear = this.SchoolyearRepository.Value.GetSingle(x => x.CF_Grademajor.Any(w => w.GrademajorID == GrademajorID)); var date = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduationSchoolyear.FirstWeek); return date.ToString("yyyy-MM-dd"); //return GetPlanningGraduate(graduationSchoolyear.FirstWeek).ToString("yyyy-MM-dd"); //StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduate(GrademajorID); //int PlanningGraduate = (int)studentsEntity.Years; //try //{ // string SetPlanningGraduate; // if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Spring) // { // SetPlanningGraduate = studentsEntity.PlanningGraduateYear.ToString() + "-06-30"; // } // else if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Autumn) // { //因秋季是跨年,毕业年份需要+1年 // SetPlanningGraduate = (studentsEntity.PlanningGraduateYear + 1).ToString() + "-01-31"; // } // else // throw new Exception("学期设置有问题,请核查"); // return SetPlanningGraduate; //} //catch //{ // return ""; //} //预计毕业时间,原来逻辑有问题,默认值为2016-01-31+30个月也就是2018-07-31,当学制不为3或2.5时,返回2018-07-31+学制年数:邓智荣 //DateTime SetPlanningGraduate = Convert.ToDateTime("2016-01-31").AddMonths(30); //DateTime SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate.ToString() + "-06-30"); //if (studentsEntity.LearnSystem == 3) //{ // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30"); // // SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem); //} //if (studentsEntity.LearnSystem == (Decimal)2.5) //{ // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31"); // // SetPlanningGraduate.AddMonths((int)studentsEntity.LearnSystem * 12); //} ////原逻辑只有学制2.5和3的判断,现加上2和4 //if (studentsEntity.LearnSystem == 2 || studentsEntity.LearnSystem == 4) //{ // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30"); //} //if (Convert.ToInt32(studentsEntity.LearnSystem) == studentsEntity.LearnSystem) //{ //2、3或4年制 // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30"); //} //else //{ //2.5或3.5年制 // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31"); //} //return SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem);//2.5 转int 2 } public void ClearPhotoUrl(IList studentIDList) { this.UnitOfWork.Update((x => new CF_Student { PhotoUrl = null }), (x => studentIDList.Contains(x.UserID))); } public virtual int? GetDefaultLearnformForList() { return null; } /// /// /// /// public int GetDataRange() { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var curUserID = curUser.UserID; if (curUser.IsStudent) { return 6; } var menuNo = HttpHelper.GetMenuNo(); if (string.IsNullOrEmpty(menuNo)) { menuNo = HttpContext.Current.Request.UrlReferrer.GetQueryStringByPath("FromMNU"); } SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(curUser.RoleID, menuNo); switch (dataRange) { case SYS_DataRange.All: default: return (int)SYS_DataRange.All; case SYS_DataRange.Campus: return (int)SYS_DataRange.Campus; case SYS_DataRange.College: return (int)SYS_DataRange.College; case SYS_DataRange.Department: return (int)SYS_DataRange.Department; case SYS_DataRange.Teacher: return (int)SYS_DataRange.Teacher; case SYS_DataRange.Assistant: return (int)SYS_DataRange.Assistant; } } } }