12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339 |
- 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 void PicImport(IList<string> photoPaths)
- {
- 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>();
- foreach (var idNumber in IDNumbers)
- {
- var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(idNumber, StringComparison.OrdinalIgnoreCase));
- if (user == null)
- {
- idList.Add(idNumber);
- }
- }
- if (idList.Count() > 0)
- {
- string idstr = "";
- for (int i = 0; i < (idList.Count() > 5 ? 5 : idList.Count()); i++)
- {
- idstr += idList[i] + ",";
- }
- throw new Exception("导入照片中存在无法匹对信息,照片名字为:" + idstr.Remove(idstr.Length - 1) + "...,请检查系统是否存在对应学生。");
- }
- 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();
- }
- 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;
- }
- }
- }
|