123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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.ViewModel.TerminatePrinter;
- using EMIS.ViewModel;
- using EMIS.DataLogic.TerminatePrinter;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.TerminatePrinter
- {
- public class StudentPrintTimesServices : BaseServices, IStudentPrintTimesServices
- {
- public StudentPrintTimesDAL StudentPrintTimesDAL { get; set; }
- public IGridResultSet<StudentPrintTimesView> GetStudentPrintTimesViewGrid(ConfiguretView conditionView, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? pageIndex, int? pageSize)
- {
- 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 (collegeID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- gradeExp = gradeExp.And(x => x.GradeID == yearID);
- }
- if (standardID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classExp = classExp.And(x => x.ClassmajorID == classmajorID);
- }
- var query = StudentPrintTimesDAL.GetStudentPrintTimesViewQueryable(facultyExp, gradeExp, classExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue))
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue.Trim());
- query = query.OrderByDescending(x => x.YearID)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.StandardID)
- .ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.LoginID);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<StudentPrintTimesView> GetStudentPrintTimesViewGrid(ConfiguretView conditionView, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID)
- {
- 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 (collegeID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.CollegeID == collegeID);
- }
- if (yearID.HasValue)
- {
- gradeExp = gradeExp.And(x => x.GradeID == yearID);
- }
- if (standardID.HasValue)
- {
- facultyExp = facultyExp.And(x => x.StandardID == standardID);
- }
- if (classmajorID.HasValue)
- {
- classExp = classExp.And(x => x.ClassmajorID == classmajorID);
- }
- var query = StudentPrintTimesDAL.GetStudentPrintTimesViewQueryable(facultyExp, gradeExp, classExp);
- if (!string.IsNullOrEmpty(conditionView.ConditionValue))
- query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue.Trim());
- query = query.OrderByDescending(x => x.YearID)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.StandardID)
- .ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.LoginID);
- return query.ToList();
- }
- public StudentPrintMessageView GetStudentPrintMessageView(Guid userID)
- {
- return StudentPrintTimesDAL.GetStudentPrintMessageViewQueryable(x => x.UserID == userID).FirstOrDefault();
- }
- public void Count(Guid userID)
- {
- Tem_StudentPrintTimes printTimes = this.StudentPrintTimesDAL.StudentPrintTimesRepository.GetSingle(x => x.UserID == userID);
- if (printTimes == null)
- {
- printTimes = new Tem_StudentPrintTimes()
- {
- StudentPrintTimesID = Guid.NewGuid(),
- UserID = userID,
- Times = 1,
- RecordStatus = (int)SYS_STATUS.UNUSABLE,
- CreateUserID = userID,
- CreateTime = DateTime.Now,
- };
- this.UnitOfWork.Add(printTimes);
- }
- else
- {
- printTimes.Times++;
- }
- printTimes.ModifyUserID = userID;
- printTimes.ModifyTime = DateTime.Now;
- this.UnitOfWork.Commit();
- }
- public void BatchUpdate(IList<Guid> userIDList, int times)
- {
- var nullableUserIDList = userIDList.Select(x => (Guid?)x).ToList();
- var printTimesList = this.StudentPrintTimesDAL.StudentPrintTimesRepository.GetList(x => nullableUserIDList.Contains(x.UserID)).ToList();
- var updateList = (from printTimes in printTimesList
- from user in userIDList.Where(x => x == printTimes.UserID)
- select printTimes).ToList();
- updateList.ForEach(x =>
- {
- x.Times = times;
- this.SetModifyStatus(x);
- });
- var insertList = (from user in userIDList
- from printTimes in printTimesList.Where(x => x.UserID == user).DefaultIfEmpty()
- where printTimes == null
- select new Tem_StudentPrintTimes
- {
- StudentPrintTimesID = Guid.NewGuid(),
- UserID = user,
- Times = times
- }).ToList();
- insertList.ForEach(x =>
- {
- this.SetNewStatus(x);
- });
- UnitOfWork.BatchUpdate(updateList);
- UnitOfWork.BulkInsert(insertList);
- }
- }
- }
|