public IHttpActionResult GetTaskItemsCount(string eid) { TaskItemsCountModel model = new TaskItemsCountModel(); try { //解密eid eid = Cryptography.Decrypt(eid, DateTime.Now.ToString("yyyyMMdd"), "oms"); //获取代办任务数量 IQueryable <TaskWork> result = TaskWork.GetUseableTaskWork(); if (string.IsNullOrEmpty(eid) || string.IsNullOrWhiteSpace(eid)) { model.Successfull = false; model.Message = "PMT调用获取任务数量的接口错误:传递的EID为空!"; Log4netHelper.WriteErrorLog(model.Message); } result = result.Where(c => (c.Status == TaskWorkStatus.UnFinish) && c.ReceiverAccount == eid.Trim()); model.TaskCount = result.Count(); //获取Notice 数量的接口 model.NoticeCount = ModNotices.GetNotifyCountByEid(eid); //获取Reminder 数量的接口 model.ReminderCount = Remind.Count(c => c.ReceiverAccount == eid.Trim() && !c.IsReaded); model.Successfull = true; model.Message = "接口调用成功!"; } catch (Exception ex) { model.Successfull = false; model.Message = ex.Message; Log4netHelper.Log4netWriteErrorLog(model.Message, ex); } return(Ok(model)); }
public IHttpActionResult GetTaskReminders() { TaskCountModel result = new TaskCountModel(); result.TaskCount = TaskWork.GetUseableTaskWork().Count(c => c.ReceiverAccount == ClientCookie.UserCode && c.Status == TaskWorkStatus.UnFinish); result.ReminderCount = Remind.Count(c => c.ReceiverAccount == ClientCookie.UserCode && !c.IsReaded); result.NoticeCount = Notification.Count(ClientCookie.UserCode); //获取PMT任务数量 string encryptUserCode = Cryptography.Encrypt(ClientCookie.UserCode, DateTime.Now.ToString("yyyyMMdd"), "oms"); string redirectUrl = string.Format(Constants.AM_To_PMT_RedirectUrl, "&eid=" + encryptUserCode); string callPMTTaskUrl = string.Format(Constants.Get_PMT_TaskUrl, encryptUserCode); if (Constants.GetPMTTask) { var pmtTaskResult = ApiProxy.Call <PMTTaskCountModel>(callPMTTaskUrl); if (pmtTaskResult != null) { result.PMT_ApproveCount = pmtTaskResult.ApproveCount; result.PMT_DealCount = pmtTaskResult.DealCount; result.PMT_NotifyCount = pmtTaskResult.NotifyCount; result.PMT_RemindCount = pmtTaskResult.RemindCount; result.PMT_Total = pmtTaskResult.Total; } } result.PMT_URL = redirectUrl; return(Ok(result)); }
public IHttpActionResult GetTaskReminders(int pageSize = 5) { ProjectReminder reminder = new ProjectReminder(); reminder.TaskCount = TaskWork.GetUseableTaskWork().Count(c => c.ReceiverAccount == ClientCookie.UserCode && c.Status == 0 && c.ActionName != ProjectAction.Pending); reminder.Tasks = TaskWork.GetUseableTaskWork().Where(c => c.ReceiverAccount == ClientCookie.UserCode && c.Status == TaskWorkStatus.UnFinish) .OrderByDescending(c => c.CreateTime).Take(pageSize).ToList(); reminder.RemindCount = Remind.Count(c => c.ReceiverAccount == ClientCookie.UserCode && !c.IsReaded); reminder.Reminds = Remind.Search(c => c.ReceiverAccount == ClientCookie.UserCode && !c.IsReaded) .OrderByDescending(c => c.CreateTime).Take(pageSize).ToList(); return(Ok(reminder)); }
public IHttpActionResult GetTaskWorks(int pageIndex, int pageSize, string userCode) { try { var queryString = HttpContext.Current.Request.QueryString; IQueryable <TaskWork> result = TaskWork.GetUseableTaskWork(); if (queryString["Status"] != null) { var status = (TaskWorkStatus)int.Parse(queryString["Status"]); if (status == TaskWorkStatus.Finished) { result = result.Where(c => (c.Status == status || c.Status == TaskWorkStatus.K2ProcessApproved || c.Status == TaskWorkStatus.K2ProcessDeclined) && c.ReceiverAccount == userCode); } else { result = result.Where(c => (c.Status == status) && c.ReceiverAccount == userCode); result = ClosureTool.FilterTaskWork(result); } } var skipSize = pageSize * (pageIndex - 1); string title = queryString["Title"]; if (!string.IsNullOrEmpty(title)) { result = result.Where(c => c.Title.Contains(title)); } string sourceCode = queryString["SourceCode"]; if (!string.IsNullOrEmpty(sourceCode)) { result = result.Where(c => c.SourceCode == sourceCode); } var storeCode = queryString["StoreCode"]; if (!string.IsNullOrEmpty(storeCode)) { result = result.Where(e => e.StoreCode == storeCode); } var storeName = queryString["StoreName"]; if (!string.IsNullOrEmpty(storeName)) { var storeList = StoreBasicInfo.Search(e => e.NameENUS.Contains(storeName) || e.NameZHCN.Contains(storeName)) .Select(e => e.StoreCode).ToList(); if (storeList.Any()) { result = result.Where(e => storeList.Contains(e.StoreCode)); } } int totalItems = result.Count(); var list = new List <TaskWork>(); if (queryString["Status"] != null && queryString["Status"] == "2") { list = result.OrderByDescending(c => c.FinishTime).Skip(skipSize) .Take(pageSize).ToList(); } else { list = result.OrderByDescending(c => c.CreateTime).Skip(skipSize) .Take(pageSize).ToList(); } foreach (var taskWork in list) { var operators = TaskWork.GetOperators(taskWork.TypeCode, taskWork.RefID); var taskWorkOperator = operators.FirstOrDefault(e => e.Code == ClientCookie.UserCode); taskWork.OperateMsg = taskWorkOperator != null ? taskWorkOperator.OperateMsgZHCN : string.Empty; if (taskWork.ProcInstID.HasValue && !string.IsNullOrEmpty(taskWork.RefID) && taskWork.Url.ToLower().IndexOf(taskWork.RefID.ToLower()) < 0) { taskWork.Url = string.Format("{0}&projectId={1}", taskWork.Url, taskWork.RefID); } } return(Ok(new PagedDataSource(totalItems, list.ToArray()))); } catch (Exception ex) { Log4netHelper.WriteError(JsonConvert.SerializeObject(ex)); throw ex; } }