123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.Common.CalendarManage;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.CalendarManage
- {
- public class ArrangementServices : BaseServices, IArrangementServices
- {
- public ArrangementDAL ArrangementDAL { get; set; }
- public List<ViewModel.CalendarManage.ArrangementView> GetArrangementViewList(ViewModel.ConfiguretView configuretView)
- {
- var query = ArrangementDAL.GetArrangementView(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return query.OrderBy(x => x.Weekday).ThenBy(x => x.StartTimes).ToList();
- }
- /// <summary>
- /// 周工作时间安排表
- /// </summary>
- /// <returns></returns>
- public IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid()
- {
- var resultSet = ArrangementDAL.GetArrangementViewQueryable().OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
- return resultSet;
- }
- /// <summary>
- /// 新增周工作时间
- /// </summary>
- /// <param name="listArrangement"></param>
- public void ArrangementAdd(List<ArrangementView> listArrangement)
- {
- try
- {
- var courseTimeIDList = listArrangement.Select(x => x.CoursesTimeID).ToList();
- var courseTimeList = ArrangementDAL.coursesTimeRepository.GetList(x => courseTimeIDList.Contains(x.CoursesTimeID), (y => y.CF_Arrangements));
- foreach (var arrangementView in listArrangement)
- {
- EM_CoursesTime coursesTime = courseTimeList.Where(x => x.CoursesTimeID == arrangementView.CoursesTimeID)
- .FirstOrDefault();
- if (coursesTime != null)
- {
- UnitOfWork.Remove<CF_Arrangements>(x => x.CoursesTimeID == coursesTime.CoursesTimeID);
- bool? IsOnWork = false;
- for (int i = 0; i < 7; i++)
- {
- if (i == (int)DayOfWeek.Monday)
- IsOnWork = arrangementView.MondayIsOnWork;
- if (i == (int)DayOfWeek.Tuesday)
- IsOnWork = arrangementView.TuesdayIsOnWork;
- if (i == (int)DayOfWeek.Wednesday)
- IsOnWork = arrangementView.WednesdayIsOnWork;
- if (i == (int)DayOfWeek.Thursday)
- IsOnWork = arrangementView.ThursdayIsOnWork;
- if (i == (int)DayOfWeek.Friday)
- IsOnWork = arrangementView.FridayIsOnWork;
- if (i == (int)DayOfWeek.Saturday)
- IsOnWork = arrangementView.SaturdayIsOnWork;
- if (i == (int)DayOfWeek.Sunday)
- IsOnWork = arrangementView.SundayIsOnWork;
- CF_Arrangements arrangements = new CF_Arrangements();
- arrangements.ArrangementsID = Guid.NewGuid();
- arrangements.CoursesTimeID = coursesTime.CoursesTimeID;
- arrangements.Weekday = i;
- arrangements.IsOnWork = IsOnWork;
- SetNewStatus(arrangements);
- UnitOfWork.Add(arrangements);
- }
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- public bool IsOnWork(int weekday, Guid courseTimeID)
- {
- var isOnWork = ArrangementDAL.ArrangementsRepository.GetList(x => x.Weekday == weekday && x.CoursesTimeID == courseTimeID && x.IsOnWork == true);
- return isOnWork.Count() > 0;
- }
- }
- }
|