123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using EMIS.DataLogic.EducationManage;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EducationManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using System.Transactions;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.SystemView;
- using EMIS.DataLogic.ExaminationApply;
- namespace EMIS.CommonLogic.EducationManage
- {
- public class ExaminationMessageServices : BaseServices, IExaminationMessageServices
- {
- public ExaminationMessageDAL ExaminationMessageDAL { get; set; }
- public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
- public Lazy<IAnnouncementServices> AnnouncementServices { get; set; }
- public IGridResultSet<ExaminationMessageView> GetExaminationMessageViewGrid(ConfiguretView conditionView, Guid? schoolyearID, Guid? examinationBatchID,
- Guid? examinationTypeID, Guid? examinationProjectID, int? schoolAreaID, Guid? collegeID, int? year, Guid? classmajorID, int? pageIndex, int? pageSize)
- {
- Expression<Func<EX_ExaminationBatch, bool>> batchExp = (x => true);
- Expression<Func<EX_ExaminationProject, bool>> projectExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> facultyExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Classmajor, bool>> classExp = (x => true);
- if (schoolyearID.HasValue)
- {
- batchExp = batchExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationBatchID.HasValue)
- {
- batchExp = batchExp.And(x => x.ExaminationBatchID == examinationBatchID);
- }
- if (examinationTypeID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- projectExp = projectExp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (schoolAreaID.HasValue)
- {
- gradeExp = gradeExp.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (collegeID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- gradeExp = gradeExp.And(x => x.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- classExp = classExp.And(x => x.ClassmajorID == classmajorID);
- }
- var query = ExaminationMessageDAL.GetExaminationMessageViewQueryable(batchExp, projectExp, facultyExp, gradeExp, classExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue) && !string.IsNullOrEmpty(conditionView.Attribute))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- return query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationBatchName)
- .ThenBy(x => x.ExaminationTypeName)
- .ThenBy(x => x.ExaminationProjectName)
- .ThenBy(x => x.ClassmajorName)
- .ThenByDescending(x => x.UserName)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public List<ExaminationMessageAnnounceView> Save(ExaminationMessageSaveView examinationMessageSaveView)
- {
- var dbExaminationMessageList = ExaminationMessageDAL.ExaminationMessageRepository
- .GetList(x => examinationMessageSaveView.ExaminationRegistrationIDList.Contains(x.ExaminationRegistrationID)).ToList();
- var registList = ExaminationSubjectDAL.GetStudentListView(x => examinationMessageSaveView.ExaminationRegistrationIDList.Contains(x.ExaminationRegistrationID),
- (x => true), (x => true), (x => true)).ToList();
- var userIDList = registList.Select(x => x.UserID).Distinct().ToList();
- var resultView = registList.GroupBy(x => new { x.ExaminationProjectID, x.ExaminationProjectName })
- .Select(x => new ExaminationMessageAnnounceView
- {
- ExaminationProjectID = x.Key.ExaminationProjectID,
- ExaminationProjectName = x.Key.ExaminationProjectName,
- ExaminationTime = examinationMessageSaveView.ExaminationTime,
- Remark = examinationMessageSaveView.Remark,
- UserIDList = x.Select(w => w.UserID).ToList()
- }).ToList();
- var insertList = examinationMessageSaveView.ExaminationRegistrationIDList.Where(x => !dbExaminationMessageList.Any(w => w.ExaminationRegistrationID == x))
- .Select(x => new EM_ExaminationMessage
- {
- ExaminationRegistrationID = x,
- ExaminationTime = examinationMessageSaveView.ExaminationTime,
- Remark = examinationMessageSaveView.Remark
- }).ToList();
- insertList.ForEach(x => this.SetNewStatus(x));
- var updateList = examinationMessageSaveView.ExaminationRegistrationIDList.Join(dbExaminationMessageList, (x => x), (x => x.ExaminationRegistrationID),
- ((x, y) => new EM_ExaminationMessage
- {
- ExaminationRegistrationID = y.ExaminationRegistrationID,
- ExaminationTime = examinationMessageSaveView.ExaminationTime,
- Remark = examinationMessageSaveView.Remark
- })).ToList();
- updateList.ForEach(x => this.SetModifyStatus(x));
- //HttpUtility.HtmlDecode(
- var announcementView = new AnnouncementView()
- {
- Title = "考试通知",
- Content = "<span style=\"font-weight:bold\">考试时间:" + examinationMessageSaveView.ExaminationTime.Value.ToString() + "</span><br/><span>" + examinationMessageSaveView.Remark + "</span>",
- StartTime = null,
- EndTime = null,
- IsTop = false
- };
- using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
- {
- UnitOfWork.BulkInsert(insertList);
- UnitOfWork.BatchUpdate(updateList);
- this.AnnouncementServices.Value.Save(announcementView, new List<Guid?>(), userIDList);
- scope.Complete();
- }
- return resultView;
- }
- }
- }
|