123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.DataLogic.ExaminationApply;
- using EMIS.ViewModel.ExaminationApply;
- using EMIS.ViewModel.Students;
- using EMIS.DataLogic.Common.Students;
- using Spire.Barcode;
- using System.Drawing;
- using EMIS.Utility;
- using System.Web;
- using System.IO;
- using System.Text;
- using Bowin.Common.Utility;
- using System.Web.Mvc;
- using EMIS.DataLogic.ExamManage;
- using System.Data;
- using EMIS.ViewModel.SystemView;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.ExaminationApply
- {
- public class ExaminationSubjectServices : BaseServices, IExaminationSubjectServices
- {
- public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
- public StudentsDAL studentsDAL { get; set; }
- public ProjectFeeDAL ProjectFeeDAL { get; set; }
- public ExaminationBatchDAL ExaminationBatchDAL { get; set; }
- public Lazy<ISerialNumberServices> SerialNumberServices { get; set; }
- public IGridResultSet<StudentListView> GetStudentListViewGrid(ConfiguretView examinationSubjectView, Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, Guid? classmajorID, int? recordStatus, int? isConfirm, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationRegistration, bool>> erexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp = x => true;
- Expression<Func<CF_Student, bool>> stuexp = x => true;
- if (schoolYearID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.EX_ExaminationBatch.SchoolyearID == schoolYearID);
- }
- if (examinationBatchID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (campusID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolAreaID == campusID);
- }
- if (collegeID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- stuexp = stuexp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- erexp = erexp.And(x => x.RecordStatus == recordStatus);
- }
-
- var q = ExaminationSubjectDAL.GetStudentListView(erexp, epexp, ebpexp, stuexp);
- if (isConfirm.HasValue)
- {
- q = q.Where(x => isConfirm == 1 ? (x.ExaminationRegistrationConfirmID != null) : (x.ExaminationRegistrationConfirmID == null));
- }
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.FeeTypeID).ThenBy(x => x.UserName).ToGridResultSet<StudentListView>(pageIndex, pageSize);
- }
- public IGridResultSet<StudentListView> GetMyexamListView(ConfiguretView examinationSubjectView,Guid UserID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationRegistration, bool>> erexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp = x => true;
- Expression<Func<CF_Student, bool>> stuexp = x => true;
- erexp = erexp.And(x => x.UserID == UserID);
- var q = ExaminationSubjectDAL.GetStudentListView(erexp, epexp, ebpexp, stuexp);
-
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.FeeTypeID).
- ThenBy(x => x.ClassmajorName).ThenByDescending(x => x.StudentNo).ToGridResultSet<StudentListView>(pageIndex, pageSize);
- }
- public List<StudentListView> GetStudentListViewForExport(ConfiguretView examinationSubjectView, Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, Guid? classmajorID, int? recordStatus, int? isConfirm, List<Guid?> idList)
- {
- Expression<Func<EX_ExaminationRegistration, bool>> erexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp = x => true;
- Expression<Func<CF_Student, bool>> stuexp = x => true;
- if (schoolYearID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.EX_ExaminationBatch.SchoolyearID == schoolYearID);
- }
- if (examinationBatchID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (campusID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolAreaID == campusID);
- }
- if (collegeID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- stuexp = stuexp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- erexp = erexp.And(x => x.RecordStatus == recordStatus);
- }
- if (idList.Count > 0)
- {
- erexp = erexp.And(x => idList.Contains(x.ExaminationRegistrationID));
- }
- var q = ExaminationSubjectDAL.GetStudentListView(erexp, epexp, ebpexp, stuexp);
- if (isConfirm.HasValue)
- {
- q = q.Where(x => isConfirm == 1 ? (x.ExaminationRegistrationConfirmID != null) : (x.ExaminationRegistrationConfirmID == null));
- }
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.ExaminationTypeName).ThenBy(x => x.FeeTypeID).
- ThenBy(x => x.ClassmajorName).ThenByDescending(x => x.StudentNo).ToList();
- }
- public StudentListView GetStudentListView(Guid? examinationRegistrationID)
- {
- try
- {
- var studentListView = ExaminationSubjectDAL.GetStudentListView(x => x.ExaminationRegistrationID == examinationRegistrationID, x => true, x => true, x => true)
- .SingleOrDefault();
- return studentListView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public void AddSave(StudentListView studentListView, List<StudentsView> studentsViewList)
- {
- try
- {
-
- var ExaminationProjectFeeType = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetSingle(x => x.ExaminationProjectFeeID == studentListView.ExaminationProjectFeeID && x.FeeTypeID == studentListView.FeeTypeID);
- if (ExaminationProjectFeeType == null)
- {
- throw new Exception("找不到收费标准对应的收费项,请先设置。");
- }
- List<EX_ExaminationRegistration> RegistrationList = new List<EX_ExaminationRegistration>();
- var ExaminationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.GetList(x => x.ExaminationProjectID == studentListView.ExaminationProjectID && x.ExaminationBatchID == studentListView.ExaminationBatchID).FirstOrDefault();
- var userIDList = studentsViewList.Select(x => x.UserID).ToList();
- var dbstudentRegistration = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => x.ExaminationProjectFeeTypeID == ExaminationProjectFeeType.ExaminationProjectFeeTypeID && x.ExaminationBatchProjectID == ExaminationBatchProject.ExaminationBatchProjectID && userIDList.Contains(x.UserID.Value) && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Refunded).FirstOrDefault();
- if (dbstudentRegistration != null)
- {
- throw new Exception("添加的学生中有已报名的学生。");
- }
- foreach (var student in studentsViewList)
- {
- EX_ExaminationRegistration examinationRegistration = new EX_ExaminationRegistration();
- examinationRegistration.ExaminationBatchProjectID = ExaminationBatchProject.ExaminationBatchProjectID;
- examinationRegistration.ExaminationProjectFeeTypeID = ExaminationProjectFeeType.ExaminationProjectFeeTypeID;
- examinationRegistration.ExaminationRegistrationConfirmID = studentListView.ExaminationRegistrationConfirmID;
- //examinationRegistration.SchoolyearID = studentListView.SchoolyearID;
- examinationRegistration.Fee = ExaminationProjectFeeType.Fee;
- examinationRegistration.Remark = studentListView.Remark;
- examinationRegistration.ExaminationRegistrationID = Guid.NewGuid();
- examinationRegistration.UserID = student.UserID;
- this.SetNewStatus(examinationRegistration);
- RegistrationList.Add(examinationRegistration);
- }
- UnitOfWork.BulkInsert(RegistrationList);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void EditSave(StudentListView studentListView)
- {
- var ExaminationProjectFeeType = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetSingle(x => x.ExaminationProjectFeeID == studentListView.ExaminationProjectFeeID && x.FeeTypeID == studentListView.FeeTypeID);
- if (ExaminationProjectFeeType == null)
- {
- throw new Exception("找不到收费标准对应的收费项,请先设置。");
- }
- var dbstudentRegistration = ExaminationSubjectDAL.examinationRegistrationRepository.GetSingle(x => x.ExaminationRegistrationID == studentListView.ExaminationRegistrationID);
- if (dbstudentRegistration == null)
- {
- throw new Exception("该报名信息不存在。");
- }
- else {
- dbstudentRegistration.ExaminationProjectFeeTypeID = ExaminationProjectFeeType.ExaminationProjectFeeTypeID;
- dbstudentRegistration.Fee = ExaminationProjectFeeType.Fee;
- dbstudentRegistration.Remark = studentListView.Remark;
- }
- UnitOfWork.Commit();
- }
- public IGridResultSet<StudentListView> GetStudentViewList(ConfiguretView examinationSubjectView, Guid? examinationRegistrationID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> filter = x => true;
- var inSchoolStatusIDList = studentsDAL.InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();
- filter = filter.And(x => inSchoolStatusIDList.Contains(x.InSchoolStatusID));
- var query = ExaminationSubjectDAL.GetStudentListView(x => x.ExaminationRegistrationID == examinationRegistrationID, x => true, x => true, x => true);
- return query.OrderByDescending(x => x.StudentNo).ToGridResultSet<StudentListView>(pageIndex, pageSize);
- }
- public IGridResultSet<BaseStudentView> GetStudentListForSelect(ConfiguretView configuretView, Guid? examinationRegistrationID, Guid? examinationBatchID, Guid? examinationProjectID, int? campusID, Guid? collegeID, Guid? grademajorID, int? year, int? standardID, Guid? classmajorID, int pageIndex, int pageSize)
- {
- var examinationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationBatchID && x.ExaminationProjectID == examinationProjectID).FirstOrDefault();
- List<Guid?> studentUserIDList = new List<Guid?>();
- if (examinationBatchProject != null)
- {
- var dbStudentList = ExaminationSubjectDAL.examinationRegistrationRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Refunded).ToList();
- studentUserIDList = dbStudentList.Select(x => x.UserID).ToList();
- }
- Expression<Func<CF_Student, bool>> exp = x => true;
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolAreaID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (grademajorID.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.GrademajorID == grademajorID);
- }
- if(year.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- exp = exp.And(x => x.ClassmajorID == classmajorID);
- }
- //if (studentUserIDList.Count > 0)
- //{
- // exp = exp.And(x => !studentUserIDList.Contains(x.UserID));
- //}
- var query = studentsDAL.GetInSchoolStudentViewQueryable(exp);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = query.ToList();
- if (studentUserIDList.Count > 0)
- {
- result = query.ToList().Where(x => !studentUserIDList.Contains(x.UserID)).ToList();
- }
- return result.AsQueryable<BaseStudentView>().OrderBy(x => x.CollegeName).ThenByDescending(x => x.Years).ThenBy(x => x.ClassmajorName).ThenBy(x => x.UserName).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
- //return null;
- }
- public void Delete(List<Guid> examinationRegistrationIDLsit)
- {
- try
- {
- var dbExaminationRegistrationList = ExaminationSubjectDAL.GetStudentListView(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID), x => true, x => true, x => true).ToList();
- if (dbExaminationRegistrationList.Any(x => x.RecordStatus > (int)EX_ExaminationRegistrationStatus.ForPay))
- {
- throw new Exception("不是“待缴费”状态的数据不能删除");
- }
- if (dbExaminationRegistrationList.Any(x => x.ExaminationRegistrationConfirmID != null))
- {
- throw new Exception("已确认的数据不能删除");
- }
- UnitOfWork.Delete<EX_ExaminationRegistration>(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public void ChangeFee(List<Guid> examinationRegistrationIDLsit, decimal? Fee, string Remark)
- {
- try
- {
- var examinationRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID)).ToList();
- examinationRegistrationList.ForEach(x =>
- {
- if (x.RecordStatus != (int)EX_ExaminationRegistrationStatus.ForPay)
- {
- throw new Exception("只有待缴费的数据才能调整费用");
- }
- });
- examinationRegistrationList.ForEach(x => {
- x.Fee = Fee;
- x.Remark = Remark;
- });
- UnitOfWork.BatchUpdate(examinationRegistrationList);
- }
- catch (Exception)
- {
- throw;
- }
- }
- public Guid? Confirm(List<Guid> examinationRegistrationIDLsit, string filePathUrl)
- {
- try
- {
- var dbExaminationRegistrationList = ExaminationSubjectDAL.GetStudentListView(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID), x => true, x => true, x => true).ToList();
- if (dbExaminationRegistrationList.Any(x => x.RecordStatus != (int)EX_ExaminationRegistrationStatus.ForPay))
- {
- throw new Exception("只能选择待缴费状态的数据进行打包");
- }
- if (dbExaminationRegistrationList.Any(x => x.ExaminationRegistrationConfirmID != null))
- {
- throw new Exception("选择的数据存在已确认数据,如需要重新打包请先取消打包");
- }
- //var confirmNo = DateTime.Now.ToString("yyyyMMdd");
- //var dbRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => x.ExaminationRegistrationConfirmID != null).ToList();
- //var confirmIDList = dbRegistrationList.Select(x => x.ExaminationRegistrationConfirmID).ToList();
- //var dbConfirmList = ExaminationSubjectDAL.examinationRegistrationConfirmRepository.GetList(x => confirmIDList.Contains(x.ExaminationRegistrationConfirmID));
- //var todayNoList = dbConfirmList.Where(x => x.No.Contains(confirmNo)).Select(x => x.No).ToList();
- //var maxNo = 0;
- //if (todayNoList.Count > 0)
- //{
- // foreach (var noStr in todayNoList)
- // {
- // var no = int.Parse(noStr.Substring(noStr.Length - 4, 4));
- // if (no > maxNo)
- // {
- // maxNo = no;
- // }
- // }
- //}
- //maxNo = maxNo + 1;
- //confirmNo = confirmNo + maxNo.ToString("0000");
- var confirmNo = SerialNumberServices.Value.SetDialySN(Const.EX_REGISTCONFIRM_NO_PREFIX, 4)
- .Replace(Const.EX_REGISTCONFIRM_NO_PREFIX, DateTime.Today.ToString("yyyyMMdd"));
- //string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH;
- //string physicalPath = HttpContext.Current.Server.MapPath(filePath);
- EX_ExaminationRegistrationConfirm confirm = new EX_ExaminationRegistrationConfirm();
- confirm.ExaminationRegistrationConfirmID = Guid.NewGuid();
- confirm.No = confirmNo;
- confirm.BarcodeUrl = GenerateBarCodeByConfirm(confirmNo, filePathUrl);
- SetNewStatus(confirm);
- var examinationRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID)).ToList();
- examinationRegistrationList.ForEach(x =>
- {
- x.ExaminationRegistrationConfirmID = confirm.ExaminationRegistrationConfirmID;
- });
- UnitOfWork.Add(confirm);
- UnitOfWork.Commit();
- UnitOfWork.BatchUpdate(examinationRegistrationList);
-
- return confirm.ExaminationRegistrationConfirmID;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void CancelConfirm(List<Guid> examinationRegistrationIDLsit)
- {
- try
- {
- var registrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => examinationRegistrationIDLsit.Contains(x.ExaminationRegistrationID)).ToList();
- if (registrationList.Where(x => x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid || x.RecordStatus == (int)EX_ExaminationRegistrationStatus.Refunding).Count() > 0)
- {
- throw new Exception("选中的数据有已缴费状态的,无法取消确认");
- }
- var confirmIDList = registrationList.Select(x => x.ExaminationRegistrationConfirmID).ToList();
- var cancelRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => confirmIDList.Contains(x.ExaminationRegistrationConfirmID)).ToList();
- cancelRegistrationList.ForEach(x => x.ExaminationRegistrationConfirmID = null);
- UnitOfWork.BatchUpdate(cancelRegistrationList);
- UnitOfWork.Delete<EX_ExaminationRegistrationConfirm>(x => confirmIDList.Contains(x.ExaminationRegistrationConfirmID));
-
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IList<StudentsView> GetStudentViewListByIDList(IList<Guid?> registrationIDList)
- {
- return ExaminationSubjectDAL.GetStudentQueryableByRegistration(x => registrationIDList.Contains(x.ExaminationRegistrationID)).ToList();
- }
- public IList<StudentsView> GetStudentListByCondition(ConfiguretView configuretView,
- Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, Guid? classmajorID, int? recordStatus, int? isConfirm)
- {
- Expression<Func<EX_ExaminationRegistration, bool>> erexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp = x => true;
- Expression<Func<CF_Student, bool>> stuexp = x => true;
- if (schoolYearID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.EX_ExaminationBatch.SchoolyearID == schoolYearID);
- }
- if (examinationBatchID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (campusID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolAreaID == campusID);
- }
- if (collegeID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- stuexp = stuexp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- erexp = erexp.And(x => x.RecordStatus == recordStatus);
- }
- var q = ExaminationSubjectDAL.GetStudentListView(erexp, epexp, ebpexp, stuexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- q = q.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var idList = q.Select(x => x.ExaminationRegistrationID).ToList();
- return ExaminationSubjectDAL.GetStudentQueryableByRegistration(x => idList.Contains(x.ExaminationRegistrationID)).ToList();
- }
- public string GenerateBarCodeByConfirm(string confirmNo, string filePathUrl) {
- BarcodeSettings bs = new BarcodeSettings()
- {
- Data = confirmNo,
- ShowCheckSumChar = false,
- TopTextColor = Color.Red,
- ShowTopText = false,
- ShowTextOnBottom = true
- };
- BarcodeSettings.ApplyKey("JY1YX-2SPIQ-9H8DV-H2IPO-3RPI2");
- //Generate the barcode based on the this.barCodeControl1
- BarCodeGenerator generator = new BarCodeGenerator(bs);
- Image barcode = generator.GenerateImage();
- string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH.EndsWith("\\") ? Const.LOCAL_SETTING_UPLOAD_FILEPATH : Const.LOCAL_SETTING_UPLOAD_FILEPATH + "\\";
- filePath = filePath + Const.LOCAL_SETTING_BARCODEPATH + "\\";
- string physicalPath = HttpContext.Current.Server.MapPath(filePath);
- if (!Directory.Exists(physicalPath))
- {
- Directory.CreateDirectory(physicalPath);
- }
- string url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority;
- string savePath = url + filePathUrl + "/" + Const.LOCAL_SETTING_BARCODEPATH + "/" + confirmNo + ".png";
- string tagetPhysicalPath = (physicalPath.EndsWith("\\") ? physicalPath : physicalPath + "\\") + confirmNo + ".png";
- //save the barcode as an image
- barcode.Save(@tagetPhysicalPath);
- return savePath;
- }
- public ExcelImportResult StudentImport(Dictionary<string, string> cellheader, out int OkCount, out List<StudentListView> errdataList, out int ErrCount, string sourcePhysicalPath,
- Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? examinationProjectFeeID, int? feeTypeID)
- {
- //获取要报考的批次项目和项目收费标准对应收费项
- var examinationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationBatchID && x.ExaminationProjectID == examinationProjectID).FirstOrDefault();
- //var examinationProjectFeeType = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.Entities.Where(x => x.ExaminationProjectFeeID == examinationProjectFeeID && x.FeeTypeID == feeTypeID).FirstOrDefault();
- //获取要报考的批次项目和项目收费标准对应收费项对应的已报名名单
- var studentRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID).ToList();
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- var result = new ExcelImportResult();
- var excel = new NpoiExcelHelper();
- var errorTable = new DataTable();
- List<StudentListView> errList = new List<StudentListView>();
- cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
- // 1.1解析文件,存放到一个List集合里
- List<StudentListView> enlist =
- NpoiExcelHelper.ExcelToEntityList<StudentListView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- Expression<Func<CF_Student, bool>> filter = x => true;
- List<BaseStudentView> insertList = new List<BaseStudentView>();
- var inSchoolStatusIDList = studentsDAL.InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();
- //filter = filter.And(x => inSchoolStatusIDList.Contains(x.InSchoolStatusID));获取所有学生,不排除是否在校
- var studentList = studentsDAL.GetInSchoolStudentViewQueryable(filter).ToList();
- cellheader.Add("ErrorMessage", "错误信息");//还原字典项
- cellheader.ForEach(x => errorTable.Columns.Add(x.Value));
- if (enlist.Count() <= 0)
- {
- throw new Exception("请填写Excel模板信息数据。");
- }
- for (int i = 0; i < enlist.Count(); i++)
- {
- string errorMsgStr = "第" + (i + 2) + "行数据检测异常:";
- StudentListView en = enlist[i];
- bool isHaveNoInputValue = false;
- en.IsExcelVaildateOK = true;
- #region 检查是否有未填的值
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errorMsgStr += "证件号不能为空;";
- isHaveNoInputValue = true;
- }
- #endregion
- #region 检查数据是否存在
- if (!studentList.Any(x => x.IDNumber == en.IDNumber))
- {
- errorMsgStr += "学生不存在;";
- isHaveNoInputValue = true;
- }
- else {
- var student = studentList.FirstOrDefault(x => x.IDNumber == en.IDNumber);
- if (studentRegistrationList.Any(x => x.UserID == student.UserID))
- {
- errorMsgStr += "学生已报名该科目;";
- isHaveNoInputValue = true;
- }
- }
- #endregion
- if (isHaveNoInputValue)
- {
- en.IsExcelVaildateOK = false;
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- }
- else
- {
- //enlist[i].IsExcelVaildateOK = true;
- var student = studentList.FirstOrDefault(x => x.IDNumber == en.IDNumber);
- if(student != null)
- {
- insertList.Add(student);
- }
-
- }
- }
-
- ErrCount = errList.Distinct().Count();
- errdataList = errList.Distinct().ToList();
- OkCount = enlist.Distinct().Count() - errList.Distinct().Count();
- result.SuccessCount = OkCount;
- result.ErrorCount = ErrCount;
- if (ErrCount > 0)
- {
- errList.ForEach(x => errorTable.Rows.Add(x));
- result.IsAllSuccess = false;
- var errorCellHeader = cellheader;
- result.Data = insertList;
- result.ErrorFilePath = this.WriteErrorFile(excel, cellheader.Values, errorTable);
- result.Message = string.Format("导入失败,详情请点击错误数据下载查看。");
- }
- else
- {
- result.IsAllSuccess = true;
- result.Data = insertList;
- }
- return result;
- }
- private string WriteErrorFile(NpoiExcelHelper excel, IEnumerable<string> errorCellheader, DataTable errorTable)
- {
- var errorExcelBuff = excel.ExportMemoryStream(errorTable, "", errorCellheader.ToArray());
- var logicalPath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString() + ".xls";
- var physicalPath = HttpContext.Current.Server.MapPath(logicalPath);
- var fs = File.Create(physicalPath);
- fs.Write(errorExcelBuff, 0, errorExcelBuff.Length);
- fs.Flush();
- fs.Close();
- return UrlHelper.GenerateContentUrl(logicalPath, HttpContext.Current.Request.RequestContext.HttpContext);
- }
- /// <summary>
- /// 获取项目下拉(根据批次,考试类型)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="examinationBatchID"></param>
- /// <param name="examinationTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ExaminationProjectViewNotSubject> GetExaminationProjectViewGridForComboGrid(ConfiguretView configuretView, Guid? examinationBatchID, Guid? examinationTypeID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationProject, bool>> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (examinationBatchID.HasValue)
- {
- expCampus = expCampus.And(x => x.EX_ExaminationBatchProject.Any(y => y.ExaminationBatchID == examinationBatchID));
- }
- if (examinationTypeID.HasValue)
- {
- expCampus = expCampus.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- var query = ProjectFeeDAL.GetProectListViewGridForSelect(expCampus).Distinct();
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.ExaminationProjectID).ThenBy(x => x.ExaminationLevelID)
- .ToGridResultSet<ExaminationProjectViewNotSubject>(pageIndex, pageSize);
- }
- /// <summary>
- /// 获取项目收费标准下拉(根据项目)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="examinationProjectID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ExaminationProjectFeeView> GetProjectFeeTypeViewForComboGrid(ConfiguretView configuretView, Guid? examinationBatchID, Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationBatchProjectControl, bool>> expebpc = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var ExaminationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationBatchID && x.ExaminationProjectID == examinationProjectID).FirstOrDefault();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (ExaminationBatchProject != null)
- {
- expebpc = expebpc.And(x => x.ExaminationBatchProjectID == ExaminationBatchProject.ExaminationBatchProjectID);
- }
- if (curUser != null && curUser.IsStudent)
- {
- var student = studentsDAL.GetStudentQueryable(x => x.UserID == curUser.UserID, x => true, x => true).FirstOrDefault();
- expebpc = expebpc.And(x => x.SchoolyearID == student.Years && x.StandardID == student.StandardID);
- }
- var query = ProjectFeeDAL.GerProjectFeeByProjectAndYearStandard(expebpc);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.Distinct().OrderBy(x => x.ExaminationProjectID).ToGridResultSet<ExaminationProjectFeeView>(pageIndex, pageSize);
- }
- public IGridResultSet<ExaminationProjectFeeView> GetProjectFeeTypeViewByBaseForComboGrid(ConfiguretView configuretView, Guid? examinationBatchID, Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationProjectFee, bool>> expFee = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var ExaminationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationBatchID && x.ExaminationProjectID == examinationProjectID).FirstOrDefault();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (examinationProjectID.HasValue)
- {
- expFee = expFee.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- var query = ProjectFeeDAL.GetProjectFee(expFee);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.ProjectName).ThenBy(x => x.Name).ToGridResultSet<ExaminationProjectFeeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 获取收费项下拉(根据项目收费标准)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="examinationProjectFeeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<DictionaryItemView> GetFeeTypeViewForComboGrid(ConfiguretView configuretView, Guid? examinationProjectFeeID, int pageIndex, int pageSize)
- {
- var examinationProjectFeeTypeList = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.GetList(x => x.ExaminationProjectFeeID == examinationProjectFeeID && x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- List<int?> feeTypeID = examinationProjectFeeTypeList.Select(x => x.FeeTypeID).Distinct().ToList();
- var query = from a in ExaminationSubjectDAL.dictionaryItemRepository.GetList(x => x.DictionaryCode == "EX_ExaminationProjectFeeType" && feeTypeID.Contains(x.Value))
- from epftr in ExaminationSubjectDAL.examinationProjectFeeTypeRepository.Entities.Where(x => x.ExaminationProjectFeeID == examinationProjectFeeID && x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.FeeTypeID == a.Value).DefaultIfEmpty()
- select new DictionaryItemView
- {
- DictionaryItemID = a.DictionaryItemID,
- DictionaryCode = a.DictionaryCode,
- Code = a.Code,
- DictionaryName = a.Sys_Dictionary.Name,
- Value = a.Value,
- IsEditable = a.IsEditable.Value,
- IsVisible = a.RecordStatus > 0,
- Name = a.Name + "(" + epftr.Fee.ToString() + ")",
- OrderNo = a.OrderNo,
- RecordStatus = a.RecordStatus,
- };
- return query.Distinct().OrderBy(x => x.Value).ToGridResultSet<DictionaryItemView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 获取批次下拉(根据学年学期)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ExaminationBatchView> GetExaminationBatchViewForComboGrid(ConfiguretView configuretView, Guid? schoolyearID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationBatch, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expCampus = expCampus.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = ExaminationBatchDAL.GetBatchList(expCampus);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Name).ToGridResultSet<ExaminationBatchView>(pageIndex, pageSize);
- }
- public List<StudentListForExportView> GetStudentListForExportViewGrid(ConfiguretView examinationSubjectView, Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID,
- Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, Guid? classmajorID, int? recordStatus, int? isConfirm, List<Guid?> ids)
- {
- Expression<Func<EX_ExaminationRegistration, bool>> erexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp = x => true;
- Expression<Func<CF_Student, bool>> stuexp = x => true;
- if (schoolYearID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.EX_ExaminationBatch.SchoolyearID == schoolYearID);
- }
- if (examinationBatchID.HasValue)
- {
- ebpexp = ebpexp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- epexp = epexp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (campusID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolAreaID == campusID);
- }
- if (collegeID.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- stuexp = stuexp.And(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- stuexp = stuexp.And(x => x.ClassmajorID == classmajorID);
- }
- if (recordStatus.HasValue)
- {
- erexp = erexp.And(x => x.RecordStatus == recordStatus);
- }
- var q = ExaminationSubjectDAL.GetStudentListForExport(erexp, epexp, ebpexp, stuexp);
- if (isConfirm.HasValue)
- {
- q = q.Where(x => isConfirm == 1 ? (x.ExaminationRegistrationConfirmID != null) : (x.ExaminationRegistrationConfirmID == null));
- }
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return q.OrderByDescending(x => x.Year).ThenBy(x => x.CollegeID).ThenBy(x => x.StandardID).ThenBy(x => x.StudentNo).ToList();
- }
- public List<BaseStudentView> AddStudentsCheck(List<string> IDList, Guid? schoolYearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID, Guid? examinationProjectFeeID, int? feeTypeID)
- {
- try
- {
- //获取要报考的批次项目和项目收费标准对应收费项
- var examinationBatchProject = ExaminationSubjectDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationBatchID && x.ExaminationProjectID == examinationProjectID).FirstOrDefault();
- //var examinationProjectFeeType = ExaminationSubjectDAL.examinationProjectFeeTypeRepository.Entities.Where(x => x.ExaminationProjectFeeID == examinationProjectFeeID && x.FeeTypeID == feeTypeID).FirstOrDefault();
- //获取要报考的批次项目和项目收费标准对应收费项对应的已报名名单
- var studentRegistrationList = ExaminationSubjectDAL.examinationRegistrationRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID && x.RecordStatus != (int)EX_ExaminationRegistrationStatus.Refunded).ToList();
- var userIDList = studentRegistrationList.Select(x => x.UserID).ToList();
- //获取学生
- Expression<Func<CF_Student, bool>> filter = x => true;
- filter = filter.And(x => IDList.Contains(x.IDNumber));
- var studentList = studentsDAL.GetInSchoolStudentViewQueryable(filter).ToList();
- studentList = studentList.Where(x => !userIDList.Contains(x.UserID)).ToList();
- return studentList;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|