123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.CalendarManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.ViewModel.CalendarManage;
- namespace EMIS.CommonLogic.CalendarManage
- {
- public class SCalendarServices : BaseServices, ISCalendarServices
- {
- public SCalendarDAL scalendarDAL { get; set; }
- /// <summary>
- /// 查询校历信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="activitiesType">活动类型</param>
- /// <param name="timesSegment">时间段</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<SCalendarView> GetSCalendarViewGrid(ConfiguretView configuretView, int? activitiesType, int? timesSegment, int pageIndex, int pageSize)
- {
- var query = scalendarDAL.GetSCalendarQueryable(x => true);
- if (activitiesType.HasValue && activitiesType != -1)
- query = query.Where(x => x.ActivitiesType == activitiesType);
- if (timesSegment.HasValue && timesSegment != -1)
- query = query.Where(x => x.TimesSegment == timesSegment);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue)
- .OrderByDescending(x => x.ActivitiesTime).ThenBy(x => x.TimesSegment).ToGridResultSet<SCalendarView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.ActivitiesTime).ThenBy(x => x.TimesSegment).ToGridResultSet<SCalendarView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询校历信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="activitiesType">活动类型</param>
- /// <param name="timesSegment">时间段</param>
- /// <returns></returns>
- public List<SCalendarView> GetSCalendarViewList(ConfiguretView configuretView, int? activitiesType, int? timesSegment)
- {
- var query = scalendarDAL.GetSCalendarQueryable(x => true);
- if (activitiesType.HasValue && activitiesType != -1)
- query = query.Where(x => x.ActivitiesType == activitiesType);
- if (timesSegment.HasValue && timesSegment != -1)
- query = query.Where(x => x.TimesSegment == timesSegment);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue)
- .OrderByDescending(x => x.ActivitiesTime).ThenBy(x => x.TimesSegment).ToList();
- return query.OrderByDescending(x => x.ActivitiesTime).ThenBy(x => x.TimesSegment).ToList();
- }
- /// <summary>
- /// 获取校历信息
- /// </summary>
- /// <param name="activitiesID">主键ID</param>
- /// <returns></returns>
- public CF_SCalendar GetSCalendar(Guid? activitiesID)
- {
- //查询条件
- Expression<Func<CF_SCalendar, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.ActivitiesID == activitiesID);
- return scalendarDAL.scalendarRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取校历信息
- /// </summary>
- /// <param name="Name">活动名称</param>
- /// <returns></returns>
- public CF_SCalendar GetSCalendar(string Name)
- {
- //查询条件
- Expression<Func<CF_SCalendar, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.Name == Name);
- return scalendarDAL.scalendarRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取校历信息
- /// </summary>
- /// <param name="activitiesID">主键ID</param>
- /// <returns></returns>
- public SCalendarView GetSCalendarView(Guid? activitiesID)
- {
- SCalendarView scalendarView = new SCalendarView();
- if (activitiesID.HasValue)
- scalendarView = scalendarDAL.GetSCalendarQueryable(x => true).Where(x => x.ActivitiesID == activitiesID).FirstOrDefault();
- return scalendarView;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="scalendar">实体</param>
- /// <returns></returns>
- public bool SCalendarAdd(SCalendarView scalendarView)
- {
- try
- {
- if (this.scalendarDAL.scalendarRepository
- .GetList(x => x.Name == scalendarView.Name && x.ActivitiesTime == scalendarView.ActivitiesTime
- && x.TimesSegment == scalendarView.TimesSegment).Count() > 0)
- {
- throw new Exception("已存在相同的数据,请重新输入!");
- }
- CF_SCalendar scalendar = new CF_SCalendar();
- scalendar.ActivitiesID = Guid.NewGuid();
- scalendar.Name = scalendarView.Name;
- scalendar.ActivitiesTime = scalendarView.ActivitiesTime.Value;
- scalendar.TimesSegment = scalendarView.TimesSegment.Value;
- scalendar.ActivitiesContent = scalendarView.ActivitiesContent;
- scalendar.ActivitiesType = scalendarView.ActivitiesType;
- this.SetNewStatus(scalendar);
- UnitOfWork.Add(scalendar);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="scalendar">实体</param>
- /// <returns></returns>
- public bool SCalendarUpdate(SCalendarView scalendarView)
- {
- try
- {
- if (this.scalendarDAL.scalendarRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.Name == scalendarView.Name && x.ActivitiesTime == scalendarView.ActivitiesTime
- && x.TimesSegment == scalendarView.TimesSegment && x.ActivitiesID != scalendarView.ActivitiesID).Count() > 0)
- {
- throw new Exception("活动名称已存在,请重新输入!");
- }
- var scalendar = GetSCalendar(scalendarView.ActivitiesID);
- if (scalendar == null)
- {
- throw new Exception("未能找到相对应的数据!");
- }
- scalendar.Name = scalendarView.Name;
- scalendar.ActivitiesTime = scalendarView.ActivitiesTime.Value;
- scalendar.TimesSegment = scalendarView.TimesSegment.Value;
- scalendar.ActivitiesContent = scalendarView.ActivitiesContent;
- scalendar.ActivitiesType = scalendarView.ActivitiesType;
- this.SetModifyStatus(scalendar);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="activitiesIDs"></param>
- /// <returns></returns>
- public bool SCalendarDelete(List<Guid> activitiesIDs)
- {
- try
- {
- UnitOfWork.Delete<CF_SCalendar>(x => activitiesIDs.Contains(x.ActivitiesID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|