123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.ProjectShareManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.ProjectShareManage;
- using System;
- using System.Collections.Generic;
- using Bowin.Common.Linq;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.ViewModel.SystemView;
- namespace EMIS.CommonLogic.ProjectShareManage
- {
- public class ShareRecordServices : BaseServices, IShareRecordServices
- {
- public ShareRecordDAL shareRecordDAL { get; set; }
- public UserDAL UserDAL { get; set; }
- public AnnouncementDAL AnnouncementDAL { get; set; }
- public IGridResultSet<ShareRecordView> GetShareRecordViewGrid(ConfiguretView configuretView, DateTime? startTime, DateTime? endTime, string title, Guid? userID, int pageIndex, int pageSize)
- {
- Expression<Func<Sys_ShareRecord, bool>> exp = (x => true);
- if (startTime.HasValue)
- {
- exp = exp.And(x => x.DateTime >= startTime);
- }
- if (endTime.HasValue)
- {
- exp = exp.And(x => x.DateTime <= endTime);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
- var query = shareRecordDAL.GetShareRecordView(exp);
- if (title != "" && title != null)
- {
- query.Where(x => x.Title.Contains(title));
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return query.OrderBy(x => x.Title).ThenBy(x => x.ClassmajorID).ThenBy(x => x.UserID).ToGridResultSet<ShareRecordView>(pageIndex, pageSize);
- }
- public List<ShareRecordView> GetShareRecordViewList(ConfiguretView configuretView, DateTime? startTime, DateTime? endTime, string title, Guid? userID, List<Guid> idList = null)
- {
- Expression<Func<Sys_ShareRecord, bool>> exp = (x => true);
- if (startTime.HasValue)
- {
- exp = exp.And(x => x.DateTime >= startTime);
- }
- if (endTime.HasValue)
- {
- exp = exp.And(x => x.DateTime <= endTime);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.UserID == userID);
- }
- if (idList != null && idList.Count() > 0)
- {
- exp = exp.And(x => idList.Contains(x.ShareRecordID));
- }
- var query = shareRecordDAL.GetShareRecordView(exp);
- if (title != "" && title != null)
- {
- query.Where(x => x.Title.Contains(title));
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return query.OrderBy(x => x.Title).ThenBy(x => x.ClassmajorID).ThenBy(x => x.UserID).ToList();
- }
- public void CheckAndRecordScore(Guid? announcementID, string loginID, string openID)
- {
- try
- {
- Sys_ShareRecord sys_ShareRecord = new Sys_ShareRecord();
- var user = UserDAL.GetStudentUserView(x => x.LoginID == loginID, y => true).FirstOrDefault();
- Expression<Func<Sys_ShareRecord, bool>> exp = (x => true);
- List<ShareRecordView> ShareRecordViewList = shareRecordDAL.GetShareRecordView(exp).ToList();
- List<AnnouncementTypeView> typeList = AnnouncementDAL.GetAnnouncementTypeView(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).OrderBy(x => x.Name).ToList();
- var type = typeList.Where(x => x.No == "05").FirstOrDefault();
- var wechatSubscribe = shareRecordDAL.wechatSubscribeRepository.Entities.Where(x => x.UserID == user.UserID).FirstOrDefault();
- var announcement = shareRecordDAL.announcementRepository.Entities.Where(x => x.AnnouncementID == announcementID).FirstOrDefault();
- var ShareRecordView = ShareRecordViewList.Where(x => x.UserID == user.UserID && x.AnnouncementID == announcementID && x.OpenID == openID).FirstOrDefault();
- if (announcement.AnnouncementTypeID == type.AnnouncementTypeID && ShareRecordView == null && wechatSubscribe.OpenID != openID)
- {
- sys_ShareRecord.ShareRecordID = Guid.NewGuid();
- sys_ShareRecord.AnnouncementID = announcementID;
- sys_ShareRecord.UserID = user.UserID;
- sys_ShareRecord.OpenID = openID;
- sys_ShareRecord.RecordStatus = 1;
- sys_ShareRecord.DateTime = DateTime.Now;
- sys_ShareRecord.CreateTime = DateTime.Now;
- sys_ShareRecord.CreateUserID = user.UserID;
- sys_ShareRecord.ModifyTime = DateTime.Now;
- sys_ShareRecord.ModifyUserID = user.UserID;
- UnitOfWork.Add(sys_ShareRecord);
- }
- else
- {
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|