public IHttpActionResult QueryProjectComments(NotificationSearchCondition searchCondition) { int totalSize; var data = QueryProjectComments(searchCondition, out totalSize); return(Ok(new { data, totalSize })); }
public IHttpActionResult Query(NotificationSearchCondition searchCondition) { searchCondition.ReceiverAccount = ClientCookie.UserCode; int totalSize; var data = Notification.Query(searchCondition, out totalSize).ToList(); return(Ok(new { data, totalSize })); }
public static IQueryable <Notification> Query(NotificationSearchCondition searchCondition, out int totalSize) { var predicate = PredicateBuilder.True <Notification>(); if (!string.IsNullOrEmpty(searchCondition.Title)) { predicate = predicate.And(e => e.Title.Contains(searchCondition.Title)); } if (!string.IsNullOrEmpty(searchCondition.SenderZHCN)) { var employeeList = Employee.Search(e => e.NameZHCN.Contains(searchCondition.SenderZHCN)); var employeeCodeList = employeeList.Select(e => e.Code).ToList(); predicate = predicate.And(e => employeeCodeList.Contains(e.SenderCode)); } if (!string.IsNullOrEmpty(searchCondition.SenderENUS)) { var employeeList = Employee.Search(e => e.NameENUS.Contains(searchCondition.SenderENUS)); var employeeCodeList = employeeList.Select(e => e.Code).ToList(); predicate = predicate.And(e => employeeCodeList.Contains(e.SenderCode)); } if (!string.IsNullOrEmpty(searchCondition.ReceiverAccount)) { predicate = predicate.And(e => e.ReceiverCode == searchCondition.ReceiverAccount); } //从多少页开始取数据 var notificationList = Search(predicate, e => e.CreateTime, searchCondition.PageIndex, searchCondition.PageSize, out totalSize, true); foreach (var notification in notificationList) { var notificationLocal = notification; var sender = Employee.FirstOrDefault(e => e.Code == notificationLocal.SenderCode); var receiver = Employee.FirstOrDefault(e => e.Code == notificationLocal.ReceiverCode); notification.SenderZHCN = sender != null ? sender.NameZHCN : string.Empty; notification.SenderENUS = sender != null ? sender.NameENUS : string.Empty; notification.ReceiverZHCN = receiver != null ? receiver.NameZHCN : string.Empty; notification.ReceiverENUS = receiver != null ? receiver.NameENUS : string.Empty; var message = NotificationMessage.FirstOrDefault(e => e.Id == notificationLocal.ContentId); if (message != null) { notification.Message = message.MessageContent; } } return(notificationList); }
public IHttpActionResult ExportExcel(NotificationSearchCondition searchCondition) { var current = HttpContext.Current; int totalSize; searchCondition.PageSize = 1000000; var data = Notification.GetNotificationList(searchCondition, out totalSize); //if (!string.IsNullOrEmpty(searchCondition.FlowCode)) //{ // var tmpList = GetProjectComments(searchCondition, out totalSize); // if (tmpList != null && tmpList.Count > 0) // { // foreach (var l in tmpList) // { // data.Add(new NotificationDTO() // { // FlowCode = l.SourceCode, // Message = l.Content, // SenderZHCN = l.CreateUserNameZHCN, // SenderENUS = l.CreateUserNameENUS, // CreateTime = l.CreateTime.HasValue ? l.CreateTime.Value : DateTime.Now, // PositionENUS = l.TitleNameENUS, // HasRead = true // }); // } // } //} var siteFilePath = SiteFilePath.CommentsList_Template; var path = string.Format(@"{0}\{1}", SiteFilePath.Template_DIRECTORY, siteFilePath); var fileName = Guid.NewGuid() + ".xlsx"; var tempFilePath = current.Server.MapPath("~/") + "Temp\\" + fileName; File.Copy(path, tempFilePath); var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(tempFilePath), ExcelDataInputType.CommentsList); var dataList = data.Select(e => new ExcelInputDTO() { Form = e.FlowCode, Comments = e.Message, CreateBy = e.SenderZHCN + "(" + e.SenderENUS + ")", CreateDate = e.CreateTime == null?"":e.CreateTime.Value.ToShortDateString(), SendTo = e.ReceiverZHCN + "(" + e.ReceiverENUS + ")", SenderPosition = e.PositionENUS, IsRead = e.HasRead ? "Yes" : "No" }).ToList(); excelOutputDirector.ListInput(dataList); return(Ok(new { fileName = fileName } )); }
public IHttpActionResult Query(NotificationSearchCondition searchCondition) { int totalSize; var data = Notification.GetNotificationList(searchCondition, out totalSize); if (data != null && data.Count < 10) { if (!string.IsNullOrEmpty(searchCondition.FlowCode)) { var tmpCount = 0; var count = searchCondition.PageSize - data.Count; searchCondition.PageIndex = 0; searchCondition.PageSize = count; } } return(Ok(new { data, totalSize })); }
public IHttpActionResult GetMessageList(string userCode, string projectId, string flowCode) { var notifi = new Notification(); var searchCondition = new NotificationSearchCondition(); searchCondition.ProjectId = projectId; searchCondition.FlowCode = flowCode; searchCondition.PageSize = 1000; int totalSize; var result = new { //ReceiveMessageList = notifi.GetNotificationByReceiverCode(userCode, projectId), //SendMessageList = notifi.GetNotificationBySenderCode(userCode, projectId), NotificationList = notifi.GetNotificationByProjectId(projectId, flowCode), ApprovalRecords = QueryProjectComments(searchCondition, out totalSize) }; return(Ok(result)); }
private List <ProjectComment> GetProjectComments(NotificationSearchCondition searchCondition, out int totalSize) { var entity = BaseWFEntity.GetWorkflowEntity(searchCondition.ProjectId, searchCondition.FlowCode); var list = entity == null ? null : entity.GetEntityProjectComment(); if (list != null && list.Count > 0) { var nextDay = searchCondition.CreateDate; if (searchCondition.CreateDate.HasValue) { nextDay = searchCondition.CreateDate.Value.AddDays(1); } var tmpList = list.Where( e => (string.IsNullOrEmpty(searchCondition.Title) || e.Content.Contains(searchCondition.Title)) && (!searchCondition.CreateDate.HasValue || (e.CreateTime > searchCondition.CreateDate.Value && e.CreateTime < nextDay)) && (string.IsNullOrEmpty(searchCondition.SenderCode) || e.CreateUserAccount == searchCondition.SenderCode)).ToList(); totalSize = tmpList.Count; tmpList = tmpList.Skip(searchCondition.PageSize * (searchCondition.PageIndex - 1)) .Take(searchCondition.PageSize) .ToList(); return(tmpList); } else { totalSize = 0; return(null); } }
private List <Notification> QueryProjectComments(NotificationSearchCondition searchCondition, out int totalSize) { var tmpList = GetProjectComments(searchCondition, out totalSize); var data = new List <Notification>(); if (tmpList != null && tmpList.Count > 0) { for (var i = 0; i < tmpList.Count; i++) { var l = tmpList[i]; data.Add(new Notification() { FlowCode = l.SourceCode, Message = l.Content, SenderZHCN = string.IsNullOrEmpty(l.UserNameZHCN)?l.CreateUserNameZHCN:l.UserNameZHCN, SenderENUS = string.IsNullOrEmpty(l.UserNameENUS)?l.CreateUserNameENUS:l.UserNameENUS, CreateTime = l.CreateTime.HasValue ? l.CreateTime.Value : DateTime.Now, PositionENUS = l.TitleNameENUS, HasRead = true }); } } return(data); }
public static List <NotificationDTO> GetNotificationList(NotificationSearchCondition condition, out int totalSize) { var context = PrepareDb(); if (condition == null) { condition = new NotificationSearchCondition(); } var entity = BaseWFEntity.GetWorkflowEntity(condition.ProjectId, condition.FlowCode); Guid? entityId = null; string souceCode = ""; string tableName = ""; if (entity != null) { souceCode = entity.WorkflowCode.Split('_')[0]; entityId = entity.EntityId; } int pageIndex = condition.PageIndex; int pageSize = condition.PageSize; totalSize = 0; var data = (from N in context.Notification join M in context.NotificationMessage on N.ContentId equals M.Id join E in context.Employee on N.SenderCode equals E.Code join R in context.Employee on N.ReceiverCode equals R.Code into TEMPEM from tem in TEMPEM.DefaultIfEmpty() where (string.IsNullOrEmpty(condition.Title) || M.MessageContent.Contains(condition.Title)) && N.ProjectId == condition.ProjectId && N.FlowCode == condition.FlowCode && (string.IsNullOrEmpty(condition.SenderCode) || N.SenderCode == condition.SenderCode) orderby N.CreateTime descending select new NotificationDTO { Id = N.Id, RefId = N.RefId, ProjectId = N.ProjectId, SenderCode = N.SenderCode, ReceiverCode = N.ReceiverCode, CreateTime = N.CreateTime, LastUpdateTime = N.LastUpdateTime, CreateUserAccount = N.CreateUserAccount, IsSendEmail = N.IsSendEmail, HasRead = N.HasRead, FlowCode = N.FlowCode, PositionENUS = E.PositionENUS, PositionZHCN = E.PositionZHCN, SenderENUS = E.NameENUS, SenderZHCN = E.NameZHCN, ReceiverENUS = tem.NameENUS, ReceiverZHCN = tem.NameZHCN, Message = M.MessageContent } ).Union( from PC in context.ProjectComment where PC.Status == ProjectCommentStatus.Submit && entityId != null && PC.RefTableId == entityId && PC.SourceCode == souceCode && (string.IsNullOrEmpty(condition.Title) || PC.Content.Contains(condition.Title)) && (string.IsNullOrEmpty(condition.SenderCode) || PC.CreateUserAccount == condition.SenderCode) orderby PC.CreateTime descending select new NotificationDTO { Id = PC.Num, RefId = PC.RefTableId, ProjectId = condition.ProjectId, SenderCode = PC.CreateUserAccount, ReceiverCode = "", CreateTime = PC.CreateTime, LastUpdateTime = null, CreateUserAccount = PC.CreateUserAccount, IsSendEmail = false, HasRead = true, FlowCode = condition.FlowCode, PositionENUS = "", PositionZHCN = "", SenderENUS = string.IsNullOrEmpty(PC.CreateUserNameENUS)?PC.UserNameENUS:PC.CreateUserNameENUS, SenderZHCN = string.IsNullOrEmpty(PC.CreateUserNameZHCN) ? PC.UserNameZHCN : PC.CreateUserNameZHCN, ReceiverENUS = "", ReceiverZHCN = "", Message = PC.Content } ); IQueryable <NotificationDTO> filterData = null; if (condition.CreateDate.HasValue && condition.EndDate.HasValue) { var endDate = condition.EndDate.Value.AddDays(1); filterData = data.Where( e => e.CreateTime >= condition.CreateDate.Value && e.CreateTime <= endDate); } else { filterData = data; } totalSize = filterData.Count(); var result = filterData .OrderByDescending(e => e.CreateTime) .Skip(pageSize * (pageIndex - 1)) .Take(pageSize) .ToList() .Select(e => new NotificationDTO() { Id = e.Id, RefId = e.RefId, ProjectId = e.ProjectId, SenderCode = e.SenderCode, ReceiverCode = e.ReceiverCode, CreateTime = e.CreateTime, LastUpdateTime = e.LastUpdateTime, CreateUserAccount = e.CreateUserAccount, IsSendEmail = e.IsSendEmail, HasRead = e.HasRead, FlowCode = e.FlowCode, PositionENUS = e.PositionENUS, PositionZHCN = e.PositionZHCN, SenderZHCN = e.SenderZHCN, SenderENUS = e.SenderENUS, ReceiverENUS = e.ReceiverENUS, ReceiverZHCN = e.ReceiverZHCN, Message = e.Message }).ToList(); return(result); }