123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.SupervisionManage;
- using EMIS.ViewModel.SupervisionManage;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.SystemServices;
- using System.Web;
- namespace EMIS.CommonLogic.SupervisionManage
- {
- public class LessonRecordServices : BaseServices, ILessonRecordServices, IFileUploadServices
- {
- public LessonRecordDAL LessonRecordDAL { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public IGridResultSet<LessonRecordView> GetLessonRecordViewGrid(ConfiguretView conditionView, Guid? schoolyearID, Guid? collegeID,
- Guid? supervisionCollegeID, DateTime? startDate, DateTime? endDate, int? pageIndex = null, int? pageSize = null)
- {
- Expression<Func<SUP_LessonRecord, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Staff, bool>> supervisorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- supervisorExp = supervisorExp.And(x => x.CollegeID == collegeID);
- }
- if (supervisionCollegeID.HasValue)
- {
- exp = exp.And(x => x.SupervisionCollegeID == supervisionCollegeID);
- }
- if (startDate.HasValue)
- {
- exp = exp.And(x => x.LessonDate >= startDate);
- }
- if (endDate.HasValue)
- {
- var correctEndDate = endDate.Value.Date.AddDays(1);
- exp = exp.And(x => x.LessonDate < correctEndDate);
- }
- var query = LessonRecordDAL.GetLessonRecordViewQueryable(exp, supervisorExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue))
- {
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue);
- }
- query = this.GetQueryByDataRange(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.LessonDate)
- .ThenBy(x => x.StartTimes);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<LessonRecordView> GetLessonRecordViewList(ConfiguretView conditionView, Guid? schoolyearID, Guid? collegeID,
- Guid? supervisionCollegeID, DateTime? startDate, DateTime? endDate)
- {
- return GetLessonRecordViewGrid(conditionView, schoolyearID, collegeID, supervisionCollegeID, startDate, endDate).rows;
- }
- public LessonRecordView GetLessonRecordView(Guid lessonRecordID)
- {
- return LessonRecordDAL.GetLessonRecordViewQueryable(x => x.LessonRecordID == lessonRecordID, (x => true)).FirstOrDefault();
- }
- public void Save(LessonRecordView lessonRecordView, IList<FileUploadView> attachmentList)
- {
- var lessonRecord = new SUP_LessonRecord();
- if (lessonRecordView.LessonRecordID != Guid.Empty)
- {
- lessonRecord = this.LessonRecordDAL.LessonRecordRepository.GetSingle(x => x.LessonRecordID == lessonRecordView.LessonRecordID,
- (x => x.SUP_LessonRecordAttachment));
- this.SetModifyStatus(lessonRecord);
- }
- else
- {
- lessonRecord.LessonRecordID = Guid.NewGuid();
- //lessonRecord.SchoolyearID = SchoolYearServices.Value.GetCurrentSchoolYear().SchoolYearID;
- this.SetNewStatus(lessonRecord);
- this.UnitOfWork.Add(lessonRecord);
- }
- lessonRecord.SchoolyearID = lessonRecordView.SchoolyearID;
- lessonRecord.LessonDate = lessonRecordView.LessonDate;
- lessonRecord.Location = lessonRecordView.Location;
- lessonRecord.SupervisionCollegeID = lessonRecordView.SupervisionCollegeID;
- lessonRecord.UserID = lessonRecordView.UserID;
- lessonRecord.ClassmajorID = lessonRecordView.ClassmajorID;
- lessonRecord.CoursematerialID = lessonRecordView.CoursematerialID;
- lessonRecord.Weekday = lessonRecordView.Weekday;
- lessonRecord.CoursesTimeID = lessonRecordView.CoursesTimeID;
- lessonRecord.TotalScore = lessonRecordView.TotalScore;
- lessonRecord.Content = HttpUtility.HtmlDecode(lessonRecordView.Content);
- //lessonRecordView.Content.Replace("<", "<").Replace(">", ">").Replace("&", "&").Replace(""", "\"").Replace("&apos", "'");
- //System.Text.RegularExpressions.Regex.Unescape(lessonRecordView.Content);
- lessonRecord.Record = HttpUtility.HtmlDecode(lessonRecordView.Record);
- //System.Text.RegularExpressions.Regex.Unescape(lessonRecordView.Record);
- lessonRecord.SUP_LessonRecordAttachment = new HashSet<SUP_LessonRecordAttachment>();
- if (attachmentList!=null)
- {
- attachmentList.ToList().ForEach(x =>
- {
- var attachment = new SUP_LessonRecordAttachment();
- attachment.LessonRecordAttachmentID = Guid.NewGuid();
- attachment.LessonRecordID = lessonRecord.LessonRecordID;
- attachment.Name = x.FileName;
- attachment.Url = x.FileUrl;
- this.SetNewStatus(attachment);
- UnitOfWork.Add(attachment);
- });
- }
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> lessonRecordIDList)
- {
- UnitOfWork.Delete<SUP_LessonRecordAttachment>(x => lessonRecordIDList.Contains(x.LessonRecordID));
- UnitOfWork.Delete<SUP_LessonRecord>(x => lessonRecordIDList.Contains(x.LessonRecordID));
- }
- public List<FileUploadView> GetFileList(Guid? formID)
- {
- return LessonRecordDAL.GetLessonRecordAttachmentQueryable(x => x.LessonRecordID == formID).ToList();
- }
- }
- }
|