123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- 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 ActivitieServices : BaseServices, IActivitieServices
- {
- public ActivitieDAL activitieDAL { 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<ActivitieView> GetActivitieViewGrid(ConfiguretView configuretView, int? activitiesType, int? timesSegment, int pageIndex, int pageSize)
- {
- var query = activitieDAL.GetActivitiesQueryable(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)
- .OrderBy(x => x.ActivitiesTimeMonth).ThenBy(x => x.ActivitiesTimeDay).ThenBy(x => x.TimesSegment).ToGridResultSet<ActivitieView>(pageIndex, pageSize);
- return query.OrderBy(x => x.ActivitiesTimeMonth).ThenBy(x => x.ActivitiesTimeDay).ThenBy(x => x.TimesSegment).ToGridResultSet<ActivitieView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询固定活动信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="activitiesType">活动类型</param>
- /// <param name="timesSegment">时间段</param>
- /// <returns></returns>
- public List<ActivitieView> GetActivitieViewList(ConfiguretView configuretView, int? activitiesType, int? timesSegment)
- {
- var query = activitieDAL.GetActivitiesQueryable(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)
- .OrderBy(x => x.ActivitiesTimeMonth).ThenBy(x => x.ActivitiesTimeDay).ThenBy(x => x.TimesSegment).ToList();
- return query.OrderBy(x => x.ActivitiesTimeMonth).ThenBy(x => x.ActivitiesTimeDay).ThenBy(x => x.TimesSegment).ToList();
- }
- /// <summary>
- /// 获取固定活动信息
- /// </summary>
- /// <param name="activitiesID">主键ID</param>
- /// <returns></returns>
- public CF_ActivitiesSets GetActivitie(Guid? activitiesID)
- {
- //查询条件
- Expression<Func<CF_ActivitiesSets, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.ActivitiesID == activitiesID);
- return activitieDAL.activitiesSetsRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取固定活动信息
- /// </summary>
- /// <param name="Name">活动名称</param>
- /// <returns></returns>
- public CF_ActivitiesSets GetActivitie(string Name)
- {
- //查询条件
- Expression<Func<CF_ActivitiesSets, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.Name == Name);
- return activitieDAL.activitiesSetsRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取固定活动信息
- /// </summary>
- /// <param name="activitiesID">主键ID</param>
- /// <returns></returns>
- public ActivitieView GetActivitieView(Guid? activitiesID)
- {
- ActivitieView activitieView = new ActivitieView();
- if (activitiesID.HasValue)
- activitieView = activitieDAL.GetActivitiesQueryable(x => true).Where(x => x.ActivitiesID == activitiesID).FirstOrDefault();
- return activitieView;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="activitiesSets">实体</param>
- /// <returns></returns>
- public bool ActivitiesAdd(ActivitieView activitieView)
- {
- try
- {
- if (this.activitieDAL.activitiesSetsRepository
- .GetList(x => x.Name == activitieView.Name&&x.ActivitiesTimeMonth==activitieView.ActivitiesTimeMonth
- && x.ActivitiesTimeDay == activitieView.ActivitiesTimeDay && x.TimesSegment == activitieView.TimesSegment).Count() > 0)
- {
- throw new Exception("已存在相同的数据,请重新输入!");
- }
- CF_ActivitiesSets activitiesSets = new CF_ActivitiesSets();
- activitiesSets.ActivitiesID = Guid.NewGuid();
- activitiesSets.Name = activitieView.Name;
- activitiesSets.ActivitiesTimeMonth = activitieView.ActivitiesTimeMonth.Value;
- activitiesSets.ActivitiesTimeDay = activitieView.ActivitiesTimeDay.Value;
- activitiesSets.TimesSegment = activitieView.TimesSegment.Value;
- activitiesSets.ActivitiesContent = activitieView.ActivitiesContent;
- activitiesSets.ActivitiesType = activitieView.ActivitiesType;
- this.SetNewStatus(activitiesSets);
- UnitOfWork.Add(activitiesSets);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="activitiesSets">实体</param>
- /// <returns></returns>
- public bool ActivitiesUpdate(ActivitieView activitieView)
- {
- try
- {
- CF_ActivitiesSets activitiesSets = GetActivitie(activitieView.ActivitiesID);
- if (activitiesSets == null)
- {
- throw new Exception("保存失败,未能找到相对应的数据!");
- }
- activitiesSets.Name = activitieView.Name;
- activitiesSets.ActivitiesTimeMonth = activitieView.ActivitiesTimeMonth.Value;
- activitiesSets.ActivitiesTimeDay = activitieView.ActivitiesTimeDay.Value;
- activitiesSets.TimesSegment = activitieView.TimesSegment.Value;
- activitiesSets.ActivitiesContent = activitieView.ActivitiesContent;
- activitiesSets.ActivitiesType = activitieView.ActivitiesType;
- this.SetModifyStatus(activitiesSets);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="activitiesIDs"></param>
- /// <returns></returns>
- public bool ActivitiesDelete(List<Guid> activitiesIDs)
- {
- try
- {
- UnitOfWork.Delete<CF_ActivitiesSets>(x => activitiesIDs.Contains(x.ActivitiesID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|