1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350 |
- 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.Common.AdministrativeOrgan;
- using EMIS.DataLogic.Common.Students;
- using EMIS.ViewModel;
- using System.Data;
- using EMIS.ViewModel.Cache;
- 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;
- using EMIS.DataLogic.ExaminationApply;
- namespace EMIS.CommonLogic.Students
- {
- public class StudentsServices : BaseServices, IStudentsServices
- {
- public Lazy<StudentsDAL> StudentsDAL { get; set; }
- public Lazy<RoleDAL> RoleDAL { get; set; }
- public Lazy<InSchoolSettingRepository> InSchoolSettingRepository { get; set; }
- public Lazy<StudentProfileRepository> StudentProfileRepository { get; set; }
- public Lazy<StudentContactRepository> StudentContactRepository { get; set; }
- public Lazy<UserRepository> UserRepository { get; set; }
- public Lazy<RecruitstudentsRepository> RecruitstudentsRepository { get; set; }
- public Lazy<StudentAccountRepository> StudentAccountRepository { get; set; }
- public Lazy<ClassmajorRepository> ClassmajorRepository { get; set; }
- public Lazy<SchoolyearRepository> SchoolyearRepository { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public ParameterDAL ParameterDAL { get; set; }
- public InSchoolStatusSettingDAL InSchoolStatusSettingDAL { get; set; }
- public DataRangeDAL DataRangeDAL { get; set; }
- public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
- public AnnouncementDAL AnnouncementDAL { get; set; }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID">校区ID</param>
- /// <param name="collegeID">院系所ID</param>
- /// <param name="educationID">培养层次ID</param>
- /// <param name="years">学年</param>
- /// <param name="standardID">招生专业ID</param>
- /// <param name="learnFormID">学习形式ID</param>
- /// <param name="classMajorID">班级ID</param>
- /// <param name="Shoolstatu">在校状态ID</param>
- /// <param name="isPhotos">是否有照片</param>
- /// <param name="graduationtmentDropdown">是否毕业学生</param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<StudentsView> GetStudentUserViewList(ViewModel.ConfiguretView configuretView,
- int? 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<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
- Expression<Func<CF_Grademajor, bool>> 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.SchoolAreaID == campusID);
- if (collegeID.HasValue)
- gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
- if (years.HasValue)
- gradeexp = gradeexp.And(x => x.SchoolyearID == 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.IsDreamProject != null);
- }
- else
- {
- exp=exp.And(x=>x.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).ToGridResultSet<StudentsView>(pageIndex, pageSize);
-
- }
- public IList<StudentsView> GetStudentViewList(ViewModel.ConfiguretView configuretView,
- int? 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<Guid?> UserIDsIDList)
- {
- Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
- Expression<Func<CF_Grademajor, bool>> 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.SchoolAreaID == campusID);
- if (collegeID.HasValue)
- gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
- if (years.HasValue)
- gradeexp = gradeexp.And(x => x.SchoolyearID == 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.IsDreamProject != null);
- }
- else
- {
- exp = exp.And(x => x.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();
- }
- /// <summary>
- /// 导出excel和dbf
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="years"></param>
- /// <param name="standardID"></param>
- /// <param name="learningformID"></param>
- /// <param name="classmajorID"></param>
- /// <param name="IsGraduation"></param>
- /// <param name="inSchoolStatusID"></param>
- /// <param name="isPhotos"></param>
- /// <param name="isDream"></param>
- /// <param name="planningGraduateDate"></param>
- /// <param name="LearnSystem"></param>
- /// <param name="education"></param>
- /// <param name="reportStatusID"></param>
- /// <returns></returns>
- public IList<StudentsView> GetStudentExportList(ViewModel.ConfiguretView configuretView,
- int? 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<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
- Expression<Func<CF_Grademajor, bool>> 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.SchoolAreaID == campusID);
- if (collegeID.HasValue)
- gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
- if (years.HasValue)
- gradeexp = gradeexp.And(x => x.SchoolyearID == 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.IsDreamProject != null);
- }
- else
- {
- exp = exp.And(x => x.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();
- }
- /// <summary>
- /// 将数据表写入到DBF文件中
- /// </summary>
- /// <param name="dt"></param>
- public void WriteToDbf(DataTable dt, List<string> colList)
- {
- //连接字符串
- string sConn =
- "Provider=Microsoft.Jet.OLEDB.4.0; " +
- "Data Source=" + System.IO.Directory.GetCurrentDirectory() + "; " +
- "Extended Properties=dBASE IV;";
- OleDbConnection conn = new OleDbConnection(sConn);
- conn.Open();
- try
- {
- //如果存在同名文件则先删除
- if (File.Exists(dt.TableName + ".dbf"))
- {
- File.Delete(dt.TableName + ".dbf");
- }
- OleDbCommand cmd;
- //建立新表
- StringBuilder sbCreate = new StringBuilder();
- sbCreate.Append("CREATE TABLE " + dt.TableName + ".dbf (");
- for (int i = 0; i < colList.Count; i++)
- {
- sbCreate.Append(colList[i]);
- sbCreate.Append(" char(25)");
- if (i != colList.Count - 1)
- {
- sbCreate.Append(", ");
- }
- else
- {
- sbCreate.Append(')');
- }
- }
- cmd = new OleDbCommand(sbCreate.ToString(), conn);
- cmd.ExecuteNonQuery();
- //插入各行
- StringBuilder sbInsert = new StringBuilder();
- foreach (DataRow dr in dt.Rows)
- {
- sbInsert.Clear();
- sbInsert.Append("INSERT INTO " + dt.TableName + ".dbf (");
- 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;
-
- }
- public IList<StudentsView> GetStudentViewListByIDList(IList<Guid?> studentUserIDList)
- {
- return StudentsDAL.Value.GetStudentQueryable(x => studentUserIDList.Contains(x.UserID)).ToList();
- }
- /// <summary>
- /// 获取可进行异动申请的学生。
- /// </summary>
- /// <returns></returns>
- public IGridResultSet<StudentsView> GetAbleDifferentDynamicApplyStudentList(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> 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);
- }
- /// <summary>
- /// 查询用户ID
- /// </summary>
- /// <param name="userId"></param>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="studentfileView"></param>
- 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)ViewModel.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();
- }
- public void StudentDelete(List<Guid> userIDs)
- {
- try
- {
- var registrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => userIDs.Contains(x.UserID.Value)).ToList();
- if (registrationList != null && registrationList.Count() > 0)
- {
- throw new Exception("要删除的学生中存在已报名的数据,无法删除");
- }
- else
- {
- //List<Guid> dbuserID = new List<Guid>();
- using (TransactionScope ts = new TransactionScope())
- {
- var announcementList = AnnouncementDAL.AnnouncementRepository.GetList(x => x.Sys_User.Any(y => userIDs.Contains(y.UserID)), (x => x.Sys_Role), (x => x.Sys_User)).ToList();
- announcementList.ForEach(x => {
- x.Sys_User.RemoveWhere(y => userIDs.Contains(y.UserID));
- });
- UnitOfWork.Commit();
- //UnitOfWork.BatchUpdate
- UnitOfWork.Remove<CF_StudentContact>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StudentAccount>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_Recruitstudents>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StudentProfile>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_Student>(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<Sys_Role>());
- UnitOfWork.Remove<Sys_User>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Commit();
- ts.Complete();
- }
-
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取信息
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.Sys_User GetUser(Guid? userID)
- {
- //查询条件
- Expression<Func<Sys_User, bool>> expression = x => x.UserID == userID;
- return UserRepository.Value.GetSingle(expression, (x => x.Sys_Role));
- }
- /// <summary>
- /// 获取学生扩展表信息
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.CF_StudentProfile GetProfile(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_StudentProfile, bool>> expression = x => x.UserID == userID;
- return StudentProfileRepository.Value.GetSingle(expression);
- }
- /// <summary>
- /// 获取学生信息
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.CF_Student GetStudent(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_Student, bool>> expression = x => x.UserID == userID;
- return StudentsDAL.Value.StudentRepository.GetSingle(expression);
- }
- /// <summary>
- /// 高考招生表
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.CF_Recruitstudents GetRecruit(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_Recruitstudents, bool>> expression = x => x.UserID == userID;
- return RecruitstudentsRepository.Value.GetSingle(expression);
- }
- /// <summary>
- /// 学生缴费表
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.CF_StudentAccount GetAccount(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_StudentAccount, bool>> expression = x => x.UserID == userID;
- return StudentAccountRepository.Value.GetSingle(expression);
- }
- /// <summary>
- /// 学生联系表
- /// </summary>
- /// <param name="userID">用户ID</param>
- /// <returns></returns>
- public Entities.CF_StudentContact GetContact(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_StudentContact, bool>> expression = x => x.UserID == userID;
- return StudentContactRepository.Value.GetSingle(expression);
- }
- /// <summary>
- /// 获取学生表列表信息
- /// </summary>
- /// <returns></returns>
- public Entities.CF_Student GetStudenter(Guid? userID)
- {
- //查询条件
- Expression<Func<CF_Student, bool>> expression = x => x.UserID == userID;
- return StudentsDAL.Value.StudentRepository.GetSingle(expression);
- }
- public CF_Student GetReplaceGraduateNo(string ReplaceGraduateNo,Guid? userID)
- {
- //查询条件
- Expression<Func<CF_Student, bool>> 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<Func<Sys_User, bool>> user = p => p.UserID == userid;
- return UserRepository.Value.GetSingle(user);
- }
- private void SaveOrUpdate(params StudentsView[] studentsViews)
- {
- var IDNumberList = studentsViews.Select(x => x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")).ToList();
- var existsStudentViewList = StudentsDAL.Value.StudentRepository.GetList(x => IDNumberList.Contains(x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")) || IDNumberList.Contains(x.Sys_User.LoginID.Trim().ToLower().Replace(")", ")").Replace("(", "(")),
- (x => x.Sys_User.Sys_Role),
- (x => x.CF_StudentProfile),
- (x => x.CF_StudentContact),
- (x => x.CF_StudentAccount),
- (x => x.CF_Recruitstudents)).ToList();
- var existsStudentList = existsStudentViewList.Select(x=>x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")).ToList();
- var addStudentsViews = studentsViews.Where(x => !existsStudentList.Contains(x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "("))).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.IDNumber == item.IDNumber);
- if (student != null)
- {
- UpdateInternalForImport(item, student, parameter, roleList);
- student.Sys_User.LoginID = item.IDNumber;
- }
- }
- 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 DataTable Import(DataTable dataSource)
- {
- var errorSource = dataSource.Clone();
- errorSource.Columns.Add("错误信息");
- //添加错误并且排除必填字段为空的记录行
- var errorList = AddErrorAndExceptEmptyDataRow(dataSource);
- //添加错误并且排除重复的记录行
- errorList.AddRange(AddErrorAndExceptRepetitiveDataRow(dataSource));
- //现改为可重复导入学生,并以学号关键字修改学生相关信息表,因此注释掉排除重复学号方法:邓智荣
- //添加错误并且排除已存在的记录
- //AddErrorAndExceptExistingDataRow(dataSource, errorSource);
- var views = MapToStudentsView(dataSource, errorList);
- errorList.ForEach(x =>
- AddError(errorSource, x.Row, x.Error)
- );
- if (errorSource.Rows.Count == 0)
- {
- SaveOrUpdate(views);
- }
- return errorSource;
- }
- public void GraduationPicImport(IList<string> 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.CF_StudentProfile.GraduationPictureUrl = m.PhotoPath;
- }
- }
- UnitOfWork.Commit();
- }
- public virtual DataTable PicImport(IList<string> photoPaths)
- {
- //var errorWebPath = "";
- var dt = new DataTable();
- var map = photoPaths
- .Select(s => new
- {
- IDNumber = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- })
- .ToArray();
- var IDNumbers = map.Select(s => s.IDNumber).Distinct().ToArray();
- var userIDList = StudentsDAL.Value.StudentRepository.Entities.Where(x => IDNumbers.Contains(x.IDNumber)).Select(x => x.UserID).ToList();
- var users = UserRepository.Value.GetList(w => userIDList.Contains(w.UserID), i => i.CF_Student).ToList();
- var idList = new List<string>();
- //var importIDList = new List<>
- foreach (var idNumber in IDNumbers)
- {
- var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(idNumber, StringComparison.OrdinalIgnoreCase));
- if (user == null)
- {
- idList.Add(idNumber);
- }
- else {
-
- }
- }
- foreach (var m in map)
- {
- var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(m.IDNumber, StringComparison.InvariantCultureIgnoreCase));
- if (user != null)
- {
- user.CF_Student.PhotoUrl = m.PhotoPath;
- }
-
- }
- UnitOfWork.Commit();
- if (idList.Count() > 0)
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- dt.Columns.Add("证件号码", Type.GetType("System.String"));
- dt.Columns.Add("错误原因", Type.GetType("System.String"));
- foreach (var id in idList)
- {
- DataRow row = dt.NewRow();
- row["证件号码"] = id.ToString();
- row["错误原因"] = "系统不存在该学生";
- dt.Rows.Add(row);
- }
- }
- return dt;
-
- }
- private StudentsView[] MapToStudentsView(DataTable dataSource, List<ImportErrorRowView> errorList)
- {
- var views = new List<StudentsView>();
- var classNames = dataSource.AsEnumerable().Select(s => s.Field<string>("班级名称").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<string>("入学学年学期").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<string> errorMessageList = new List<string>();
- var view = new StudentsView();
- view.LoginID = (dr.Field<string>("学号") ?? "").Trim();
- view.UserName = (dr.Field<string>("姓名") ?? "").Trim();
- view.Career = (dr.Field<string>("在校经历") ?? "").Trim();
- #region 性别
- var sexField = dr.Field<string>("性别");
- 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.Sex = sex.Value;
- }
- }
- #endregion
- #region 是否是圆梦计划
- isDreamProject = (dr.Field<string>("是否是圆梦计划")??"").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<string>("证件类型");
- 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<string>("证件号码") ?? "").Trim();
- #region 班级名称
- var classField = dr.Field<string>("班级名称");
- 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<string>("学籍状态");
- 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<string>("在校状态");
- 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<string>("入学学年学期");
- 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<string>("学生类别") ?? "").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<string>("培养方式") ?? "").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<string>("学号") ?? "").Trim();//岭南报名系统学号存在学籍卡号字段
- //(dr.Field<string>("学籍卡编号") ?? "").Trim();
- view.GraduateCardNo = (dr.Field<string>("毕结业证书编号") ?? "").Trim();
- view.ExamineeNum = (dr.Field<string>("教育部考生号") ?? "").Trim();
- #region 考生类别
- temp = (dr.Field<string>("考生类别") ?? "").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<string>("入学日期") ?? "").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<string>("入学方式") ?? "").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<string>("出生地") ?? "").Trim();
- #region 考生特征
- temp = (dr.Field<string>("考生特征") ?? "").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<string>("高考总分") ?? "").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<string>("生源所属地") ?? "").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<string>("来源地区") ?? "").Trim();
- view.UsedName = (dr.Field<string>("曾用名") ?? "").Trim();
- view.DirectorName = (dr.Field<string>("导师姓名") ?? "").Trim();
- #region 出生日期
- temp = (dr.Field<string>("出生日期") ?? "").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<string>("国籍") ?? "").Trim();
- // view.Politics = (dr.Field<string>("政治面貌") ?? "").Trim();
- #region 政治面貌
- temp = (dr.Field<string>("政治面貌") ?? "").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<string>("民族") ?? "").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<string>("籍贯") ?? "").Trim();
- #region 健康状态
- temp = (dr.Field<string>("健康状态") ?? "").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<string>("血型") ?? "").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<string>("特长") ?? "").Trim();
- view.Height = (dr.Field<string>("身高") ?? "").Trim();
- view.Weight = (dr.Field<string>("体重") ?? "").Trim();
- view.Remarks = (dr.Field<string>("备注") ?? "").Trim();
- view.CardNo = (dr.Field<string>("银行卡号") ?? "").Trim();
- view.BankName = (dr.Field<string>("开户银行") ?? "").Trim();
- view.Email = (dr.Field<string>("电子邮件") ?? "").Trim();
- view.QQ = (dr.Field<string>("QQ") ?? "").Trim();
- view.Mobile = (dr.Field<string>("移动电话") ?? "").Trim();
- view.Telephone = (dr.Field<string>("固定电话") ?? "").Trim();
- view.MicroMsgNo = (dr.Field<string>("微信号") ?? "").Trim();
- view.ZipCode = (dr.Field<string>("邮编") ?? "").Trim();
- view.Address = (dr.Field<string>("通信地址") ?? "").Trim();
- view.WorkUnit = (dr.Field<string>("工作单位") ?? "").Trim();
- view.HomeAddress = (dr.Field<string>("家庭地址") ?? "").Trim();
- view.Recipient = (dr.Field<string>("收件人") ?? "").Trim();
- view.Dormitory = (dr.Field<string>("宿舍编号") ?? "").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 List<ImportErrorRowView> AddErrorAndExceptEmptyDataRow(DataTable dataSource)
- {
- var dic = new Dictionary<string, string>
- {
- {"学号","学号不能为空"},
- {"姓名","姓名不能为空"},
- {"性别","性别不能为空"},
- {"证件类型","证件类型不能为空"},
- {"证件号码","证件号码不能为空"},
- {"班级名称","班级名称不能为空"},
- {"学籍状态","学籍状态不能为空"},
- {"在校状态","在校状态不能为空"},
- {"入学学年学期","入学学年学期不能为空"},
- };
- var errorRowList = (from ds in dataSource.AsEnumerable()
- from pair in dic
- where string.IsNullOrEmpty(ds.Field<string>(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<string>(pair.Key))).ToArray();
- // foreach (var dr in query)
- // {
- // AddError(errorSource, dr, pair.Value);
- // dataSource.Rows.Remove(dr);
- // }
- //}
- }
- private List<ImportErrorRowView> AddErrorAndExceptExistingDataRow(DataTable dataSource)
- {
- var loginIDs = dataSource.AsEnumerable().Select(s => s.Field<string>("学号")).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<string>("学号")))
- .Select(x => new ImportErrorRowView { Row = x, Error = "该学号已存在" }).ToList();
- return query;
- //foreach (var dr in query)
- //{
- // AddError(errorSource, dr, "该学号已存在");
- // dataSource.Rows.Remove(dr);
- //}
- }
- private List<ImportErrorRowView> AddErrorAndExceptRepetitiveDataRow(DataTable dataSource)
- {
- var query = dataSource.AsEnumerable()
- .GroupBy(key => key.Field<string>("学号").ToLower().Replace(")", ")").Replace("(", "("))
- .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key))
- .SelectMany(s => s)
- .Select(x => new ImportErrorRowView { Row = x, Error = "学号重复" }).ToList();
- var idNumber = dataSource.AsEnumerable()
- .GroupBy(key => key.Field<string>("证件号码").ToLower().Replace(")", ")").Replace("(", "("))
- .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);
- //}
- if (query.Count > 0)
- {
- return query;
- }
- if (idNumber.Count > 0)
- {
- return idNumber;
- }
- return query;
- }
- 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 SaveOrUpdateInternal(StudentsView studentfileView, BaseStudentView tempView, CF_Parameter parameter,
- IList<Sys_Role> roleList)
- {
- Sys_User user;
- CF_Student student; //获取学生信息
- CF_StudentProfile studentProfile;
- CF_StudentContact studentContact;
- CF_StudentAccount studentAccount;
- CF_Recruitstudents recruitstudents;
- List<Guid> StudentID = new List<Guid>();
- //以导入信息中的学号查找学生,当没有该学生时新增,否则修改学生信息
- if (tempView == null) //studentfileView.UserID == Guid.Empty
- {
- if (!string.IsNullOrEmpty(studentfileView.IDNumber) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.IDNumber == studentfileView.IDNumber))
- {
- throw new Exception("已存在相同证件号码的学生");
- }
- if (!string.IsNullOrEmpty(studentfileView.StudentNo) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.StudentCardNo == studentfileView.StudentNo))
- {
- throw new Exception("已存在相同学号的学生");
- }
- user = new Sys_User();
- user.UserID = Guid.NewGuid();
- StudentID.Add(user.UserID);
- if (parameter == null)
- {
- //密码默认为6个8
- user.Password = ("888888").MD5();
- }
- else
- {
- if (parameter.Value != null)
- {
- user.Password = parameter.Value;
- }
- else
- {
- //密码默认为6个8
- user.Password = ("888888").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.IDNumber;//岭南登录号用身份证号
- if (!string.IsNullOrEmpty(studentfileView.UserName))
- user.Name = studentfileView.UserName;
- if (studentfileView.ClassMajorID != null)
- student.ClassmajorID = studentfileView.ClassMajorID;
- if (studentfileView.Sex != null)
- student.Sex = (int)studentfileView.Sex;
- if (studentfileView.CertificatesType != null)
- student.CertificatesType = studentfileView.CertificatesType;
- if (!string.IsNullOrEmpty(studentfileView.IDNumber))
- student.IDNumber = studentfileView.IDNumber;
- if (studentfileView.IsDreamProject)
- student.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.StudentNo;
- //毕、结业证书编号
- student.GraduateCardNo = studentfileView.GraduateCardNo;
- student.CultureModel = 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<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList();
- roleList.ForEach(x => user.Sys_Role.Add(x));
- if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl))
- {
- studentProfile.GraduationPictureUrl = studentfileView.GraduationPictureUrl;
- }
- studentProfile.UsedName = studentfileView.UsedName;
- studentProfile.DirectorName = studentfileView.DirectorName;
- studentProfile.BirthDate = studentfileView.BirthDate;
- studentProfile.Country = studentfileView.Country;
- if (studentfileView.Politics != null)
- studentProfile.Politics = studentfileView.Politics;
- studentProfile.Nation = studentfileView.Nation;
- studentProfile.Place = studentfileView.Place;
- studentProfile.Healthy = studentfileView.Healthy;
- studentProfile.BloodGroup = studentfileView.BloodGroup;
- //studentProfile.BornPlace = studentfileView.BornPlace;
- studentProfile.Specialty = studentfileView.Specialty;
- studentProfile.Height = studentfileView.Height;
- studentProfile.Weight = studentfileView.Weight;
- studentProfile.Remarks = studentfileView.Remarks;
- studentContact.Email = studentfileView.Email;
- studentContact.QQ = studentfileView.QQ;
- studentContact.Mobile = studentfileView.Mobile;
- studentContact.Telephone = studentfileView.Telephone;
- studentContact.MicroMsgNo = 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.EntranceWay = studentfileView.EntranceWay;
- recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
- recruitstudents.PlaceBirth = studentfileView.Placebirth;
- recruitstudents.ExamineeType = studentfileView.ExamineeType;
- recruitstudents.Features = studentfileView.Features;
- recruitstudents.Score = studentfileView.Score;
- recruitstudents.Territorial = studentfileView.Territorial;
- recruitstudents.Area = studentfileView.Area;
- recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 导入更新
- /// </summary>
- /// <param name="studentfileView"></param>
- /// <param name="student"></param>
- /// <param name="parameter"></param>
- /// <param name="roleList"></param>
- private void UpdateInternalForImport(StudentsView studentfileView, CF_Student student, CF_Parameter parameter,
- IList<Sys_Role> 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.IDNumber;//岭南LoginID为证件号码
- if (!string.IsNullOrEmpty(studentfileView.UserName))
- student.Sys_User.Name = studentfileView.UserName;
- if (studentfileView.ClassMajorID != null)
- student.ClassmajorID = student.ClassmajorID;
- if (studentfileView.Sex != null)
- student.Sex = (int)studentfileView.Sex;
- if (studentfileView.CertificatesType != null)
- student.CertificatesType = studentfileView.CertificatesType;
- if (!string.IsNullOrEmpty(studentfileView.IDNumber))
- student.IDNumber = studentfileView.IDNumber;
- if (studentfileView.IsDreamProject)
- student.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.CultureModel = 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<Sys_Role>();
- 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.CF_StudentProfile.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.CF_StudentProfile.BirthDate = studentfileView.BirthDate;
- if (!string.IsNullOrEmpty(studentfileView.Country))
- student.CF_StudentProfile.Country = studentfileView.Country;
- if (studentfileView.Politics != null)
- student.CF_StudentProfile.Politics = studentfileView.Politics;
- if (studentfileView.Nation != null)
- student.CF_StudentProfile.Nation = studentfileView.Nation;
- if (!string.IsNullOrEmpty(studentfileView.Place))
- student.CF_StudentProfile.Place = studentfileView.Place;
- if (studentfileView.Healthy != null)
- student.CF_StudentProfile.Healthy = 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.CF_StudentProfile.Remarks = 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.MicroMsgNo = 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.EntranceWay = studentfileView.EntranceWay;
- if (!string.IsNullOrEmpty(studentfileView.ExamineeNum))
- student.CF_Recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
- if (!string.IsNullOrEmpty(studentfileView.Placebirth))
- student.CF_Recruitstudents.PlaceBirth = studentfileView.Placebirth;
- if (studentfileView.ExamineeType != null)
- student.CF_Recruitstudents.ExamineeType = studentfileView.ExamineeType;
- if (studentfileView.Features != null)
- student.CF_Recruitstudents.Features = studentfileView.Features;
- if (studentfileView.Score != null)
- student.CF_Recruitstudents.Score = studentfileView.Score;
- if (studentfileView.Territorial != null)
- student.CF_Recruitstudents.Territorial = studentfileView.Territorial;
- if (!string.IsNullOrEmpty(studentfileView.Area))
- student.CF_Recruitstudents.Area = studentfileView.Area;
- if (studentfileView.EnteringSchoolYearID != null)
- student.CF_Recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
- }
- /// <summary>
- /// 导入新增
- /// </summary>
- /// <param name="studentfileView"></param>
- /// <param name="tempView"></param>
- /// <param name="parameter"></param>
- /// <param name="roleList"></param>
- private void SaveInternalForImport(List<StudentsView> studentfileView, BaseStudentView tempView, CF_Parameter parameter,
- IList<Sys_Role> roleList)
- {
- List<Guid> StudentID=new List<Guid>();
- List<Sys_User> userList=new List<Sys_User>();
- List<CF_Student> studentList=new List<CF_Student>(); //获取学生信息
- List<CF_StudentProfile> studentProfileList = new List<CF_StudentProfile>();
- List<CF_StudentContact> studentContactList= new List<CF_StudentContact>();
- List<CF_StudentAccount> studentAccountList =new List<CF_StudentAccount>();
- List<CF_Recruitstudents> recruitstudentsList = new List<CF_Recruitstudents>();
- for (int i = 0; i < studentfileView.Count(); i++)
- {
- var pwd="";
- if (parameter == null)
- {
- pwd = ("888888").MD5();
- }
- else
- {
- if (parameter.Value != null)
- {
- pwd = parameter.Value;
- }
- else
- {
- pwd = ("888888").MD5();
- }
- }
- Sys_User user=new Sys_User();
- int? tpye=null;
- user.LoginID=studentfileView[i].IDNumber;//岭南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<Sys_Role>();
- 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].Sex != null)
- students.Sex = (int)studentfileView[i].Sex;
- if (studentfileView[i].CertificatesType != null)
- students.CertificatesType = studentfileView[i].CertificatesType;
- if (!string.IsNullOrEmpty(studentfileView[i].IDNumber))
- students.IDNumber = studentfileView[i].IDNumber;
- if (studentfileView[i].IsDreamProject)
- students.IsDreamProject = studentfileView[i].IsDreamProject;
- 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].CultureModel != null)
- students.CultureModel = studentfileView[i].CultureModel;
- 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,
- Sex = students.Sex,
- 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 (!string.IsNullOrEmpty(studentfileView[i].GraduationPictureUrl))
- {
- studentProfile.GraduationPictureUrl = studentfileView[i].GraduationPictureUrl;
- }
- if (!string.IsNullOrEmpty(studentfileView[i].UsedName))
- studentProfile.UsedName = studentfileView[i].UsedName;
- if (!string.IsNullOrEmpty(studentfileView[i].DirectorName))
- studentProfile.DirectorName = studentfileView[i].DirectorName;
- if (studentfileView[i].BirthDate != null)
- studentProfile.BirthDate = studentfileView[i].BirthDate;
- if (!string.IsNullOrEmpty(studentfileView[i].Country))
- studentProfile.Country = studentfileView[i].Country;
- if (studentfileView[i].Politics != null)
- studentProfile.Politics = studentfileView[i].Politics;
- if (studentfileView[i].Nation != null)
- studentProfile.Nation = studentfileView[i].Nation;
- if (!string.IsNullOrEmpty(studentfileView[i].Place))
- studentProfile.Place = studentfileView[i].Place;
- if (studentfileView[i].Healthy != null)
- studentProfile.Healthy = 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))
- studentProfile.Remarks = 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,
- Healthy=studentProfile.Healthy,
- 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.MicroMsgNo = 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,
- MicroMsgNo=studentContact.MicroMsgNo,
- 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.EntranceWay = 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.Features = studentfileView[i].Features;
- if (studentfileView[i].Score != null)
- recruitstudents.Score = studentfileView[i].Score;
- if (studentfileView[i].Territorial != null)
- recruitstudents.Territorial = 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,
- EntranceWay=recruitstudents.EntranceWay,
- ExamineeNum=recruitstudents.ExamineeNum,
- PlaceBirth=recruitstudents.PlaceBirth,
- ExamineeType=recruitstudents.ExamineeType,
- Features=recruitstudents.Features,
- Score=recruitstudents.Score,
- Territorial=recruitstudents.Territorial,
- 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);
- }
- public IGridResultSet<BaseStudentView> GetBaseStudentView(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? grademajorID, Guid? classmajorID, Guid? userID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> 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 query
- .OrderByDescending(x => x.LoginID.Length).ThenBy(x => x.LoginID)
- .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
- .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
- }
- 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));
- if (graduationSchoolyear != null)
- {
- var date = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduationSchoolyear.FirstWeek);
- return date.ToString("yyyy-MM-dd");
- }
- else
- {
- return null;
- }
- //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 IGridResultSet<StudentsView> GetPlanningGraduateList()
- {
- Dictionary<int, DateTime?> diction = new Dictionary<int, DateTime?>();
- //int key = 0;
- var query = StudentsDAL.Value.GetPlanningGraduateDictionary().Where(x => x.PlanningGraduateDate != null);
- List<DateTime?> list = query.Select(x => x.PlanningGraduateDate).OrderBy(x => x.Value).ToList();
- List<StudentsView> stulist = query.OrderBy(x => x.PlanningGraduateDate).ToList();
- List<string> datestr = new List<string>();
- for (int i = 0; i < stulist.Count; i++)
- {
- stulist[i].PlanningGraduateStr = list[i].Value.ToString("yyyyMMdd");
- }
- //List<string> dictionList = query.Select(x => x.PlanningGraduateStr).ToList();
- //foreach(DateTime date in dictionList)
- //{
- // diction.Add(key, date);
- // key++;
- //}
- return stulist.AsQueryable().ToGridResultSet<StudentsView>();
- }
- public void ClearPhotoUrl(IList<Guid> studentIDList)
- {
- this.UnitOfWork.Update<CF_Student>((x => new CF_Student { PhotoUrl = null }), (x => studentIDList.Contains(x.UserID)));
- }
- public virtual int? GetDefaultLearnformForList()
- {
- return null;
- }
- 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;
- }
- 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;
- }
- }
- public IGridResultSet<BaseStudentView> GetStudentOnlyInSchool(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.InSchoolStatusID == (int)CF_InschoolStatus.InSchool);
- Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeexp = (x => 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<BaseStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID">校区ID</param>
- /// <param name="collegeID">院系所ID</param>
- /// <param name="educationID">培养层次ID</param>
- /// <param name="years">学年</param>
- /// <param name="standardID">招生专业ID</param>
- /// <param name="learnFormID">学习形式ID</param>
- /// <param name="classMajorID">班级ID</param>
- /// <param name="Shoolstatu">在校状态ID</param>
- /// <param name="isPhotos">是否有照片</param>
- /// <param name="graduationtmentDropdown">是否毕业学生</param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentsView> GetStudentUserViewList(ConfiguretView configuretView,
- int? 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<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && inschoolStatusList.Contains(x.InSchoolStatusID));
- Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
- if (campusID.HasValue)
- {
- gradeexp = gradeexp.And(x => x.SchoolAreaID == 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.SchoolyearID == 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.GraduatingSemesterID == 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);
- 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<StudentsView>(pageIndex, pageSize);
- }
- public RegistView GetRegistViewByUserID(Guid userID)
- {
- var registView = StudentsDAL.Value.GetRegustViewQueryable(x => x.UserID == userID).FirstOrDefault();
- return registView;
- }
- public bool CheckNecessary(Guid userID)
- {
- var registView = this.GetRegistViewByUserID(userID);
- if (registView == null)
- {
- return false;
- }
- if (string.IsNullOrEmpty(registView.LoginID))
- {
- return false;
- }
- if (!registView.CertificatesType.HasValue)
- {
- return false;
- }
- if (string.IsNullOrEmpty(registView.UserName))
- {
- return false;
- }
- if (string.IsNullOrEmpty(registView.Mobile))
- {
- return false;
- }
- if (string.IsNullOrEmpty(registView.Email))
- {
- return false;
- }
- if (string.IsNullOrEmpty(registView.PhotoUrl))
- {
- return false;
- }
- if (!registView.Sex.HasValue)
- {
- return false;
- }
- if (!registView.BirthDate.HasValue)
- {
- return false;
- }
- return true;
- }
- }
- }
|