public QueryListResultBase <MyTaskDto> GetTaskList(QueryCriteriaBase <MyTaskCriteria> queryPara, string apiKey)
        {
            Cat.GetProducer().NewTransaction("URL-WebService", "GetTaskList");
            var a = Cat.GetManager().PeekTransaction;
            QueryListResultBase <MyTaskDto> result = null;

            try
            {
                if (APIKeyUtility.IsRightAPIKey(apiKey))
                {
                    result = WorkFlowTaskService.GetMyTaskList(queryPara);
                }
                else
                {
                    result = new QueryListResultBase <MyTaskDto>();
                }
                a.Status = "0";
            }
            catch (Exception ex)
            {
                Cat.GetProducer().LogError(ex);
                a.SetStatus(ex);
                throw ex;
            }
            finally
            {
                a.Complete();
            }
            return(result);
        }
Esempio n. 2
0
        public void GetMyTaskListTest()
        {
            var mock = new Mock <WorkFlowTaskService>()
            {
                CallBase = true
            };

            mock.Setup(_ => _.ProcessInfoDomain.GetByProcessCode(It.IsAny <IList <string> >())).Returns(WorkFlowTaskServiceTestMock.processInfoList);
            mock.Setup(_ => _.MyTaskDomain.GetMyTaskList(It.IsAny <QueryCriteriaBase <QueryWorkList> >())).Returns(WorkFlowTaskServiceTestMock.MyTaskDdo);
            mock.Setup(_ => _.WorklistHeaderRepositories.GetListBySnList(It.IsAny <List <string> >())).Returns(WorkFlowTaskServiceTestMock.WorkListHeader);
            var query = new QueryCriteriaBase <MyTaskCriteria>()
            {
                PagingInfo = new PaginationModel()
            };
            var actual = mock.Object.GetMyTaskList(null);

            Assert.AreEqual(0, actual.ResultList.Count);
            query.QueryCriteria = new MyTaskCriteria()
            {
                Folio            = "",
                ProcessStartDate = new DatePeriodModel
                {
                    DateFrom = DateTime.Now,
                    DateTo   = DateTime.Now,
                }
            };
            Assert.AreEqual(0, actual.ResultList.Count);

            query.QueryCriteria.ProcessCode = null;
            var actual2 = mock.Object.GetMyTaskList(query);

            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcessCode = new List <string>()
            {
            };
            actual2 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcessCode = new List <string>()
            {
                "aaa"
            };
            actual2 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);

            query.QueryCriteria.ProcInstId = null;
            var actual3 = mock.Object.GetMyTaskList(query);

            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcInstId = new List <int>()
            {
            };
            actual3 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcInstId = new List <int>()
            {
                12345
            };
            actual3 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
        }
Esempio n. 3
0
        public QueryListResultBase <MyTaskDto> GetMyTaskList(QueryCriteriaBase <MyTaskCriteria> queryPara)
        {
            if (queryPara != null && queryPara.QueryCriteria != null && queryPara.PagingInfo != null)
            {
                var processCode       = new List <string>();
                var procInstIds       = new List <int>();
                var orginatorLoginIds = new List <int>();

                if (queryPara.QueryCriteria.ProcessCode != null && queryPara.QueryCriteria.ProcessCode.Count > 0)
                {
                    processCode = queryPara.QueryCriteria.ProcessCode.Where(_ => _ != string.Empty).ToList();
                }

                if (queryPara.QueryCriteria.ProcInstId != null && queryPara.QueryCriteria.ProcInstId.Count > 0)
                {
                    procInstIds = queryPara.QueryCriteria.ProcInstId.Where(_ => _ != 0).ToList();
                }
                if (queryPara.QueryCriteria.OriginatorLoginId != null && queryPara.QueryCriteria.OriginatorLoginId.Count > 0)
                {
                    orginatorLoginIds = queryPara.QueryCriteria.OriginatorLoginId.Where(_ => _ != 0).ToList();
                }

                var queryWorkList = new QueryCriteriaBase <QueryWorkList>()
                {
                    QueryCriteria = new QueryWorkList()
                    {
                        ProcessCodes = processCode,
                        ProcInstIds  = procInstIds,
                        LoginIds     = new List <int>()
                        {
                            queryPara.QueryCriteria.LoginId
                        },
                        Folio              = queryPara.QueryCriteria.Folio,
                        ProcessStartDate   = queryPara.QueryCriteria.ProcessStartDate,
                        TaskStartDate      = queryPara.QueryCriteria.TaskStartDate,
                        OriginatorLoginIds = orginatorLoginIds
                    },
                    PagingInfo = queryPara.PagingInfo
                };

                var result = Mapper.Map <QueryListResultBase <MyTaskDto> >(MyTaskDomain.GetMyTaskList(queryWorkList));

                MapWorkListURL(result.ResultList);
                return(result);
            }
            else
            {
                return(new QueryListResultBase <MyTaskDto>()
                {
                    PagingInfo = new PaginationModel(),
                    ResultList = new List <MyTaskDto>()
                });
            }
        }
        public void GetMyTaskListTest()
        {
            var mock = new Mock<WorkFlowTaskService>() { CallBase = true };
            mock.Setup(_ => _.ProcessInfoDomain.GetByProcessCode(It.IsAny<IList<string>>())).Returns(WorkFlowTaskServiceTestMock.processInfoList);
            mock.Setup(_ => _.MyTaskDomain.GetMyTaskList(It.IsAny<QueryCriteriaBase<QueryWorkList>>())).Returns(WorkFlowTaskServiceTestMock.MyTaskDdo);
            mock.Setup(_ => _.WorklistHeaderRepositories.GetListBySnList(It.IsAny<List<string>>())).Returns(WorkFlowTaskServiceTestMock.WorkListHeader);
            var query = new QueryCriteriaBase<MyTaskCriteria>()
            {
                PagingInfo = new PaginationModel()
            };
            var actual = mock.Object.GetMyTaskList(null);
            Assert.AreEqual(0, actual.ResultList.Count);
            query.QueryCriteria = new MyTaskCriteria()
            {
                Folio = "",
                ProcessStartDate = new DatePeriodModel
                {
                    DateFrom = DateTime.Now,
                    DateTo = DateTime.Now,
                }
            };
            Assert.AreEqual(0, actual.ResultList.Count);

            query.QueryCriteria.ProcessCode = null;
            var actual2 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcessCode = new List<string>() { };
            actual2 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcessCode = new List<string>() { "aaa" };
            actual2 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual2.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);

            query.QueryCriteria.ProcInstId = null;
            var actual3 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcInstId = new List<int>() { };
            actual3 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
            query.QueryCriteria.ProcInstId = new List<int>() { 12345 };
            actual3 = mock.Object.GetMyTaskList(query);
            Assert.IsTrue(actual3.ResultList.Count == WorkFlowTaskServiceTestMock.MyTaskDto.ResultList.Count);
        }
        public void GetWorkListTest()
        {
            IWorklistRepostories target = new WorklistRepostories();

            QueryCriteriaBase<QueryWorkList> queryCriteriay = new QueryCriteriaBase<QueryWorkList>()
            {
                PagingInfo = new PaginationModel()
                {
                    PageSize = 0,
                    PageCount = 0
                },
                QueryCriteria = new QueryWorkList()
                {
                    ProcessStartDate = new DatePeriodModel
                    {
                        DateFrom = DateTime.Today.AddDays(-30),
                        DateTo = DateTime.Today,
                    },
                    Folio = string.Empty,
                    LoginIds = null,
                    ProcInstIds = null
                }
            };
            var actual = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual.PagingInfo.PageCount == 0);

            queryCriteriay.PagingInfo.PageSize = 3;
            actual = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.LoginIds = new List<int>();
            queryCriteriay.QueryCriteria.ProcInstIds = new List<int>();
            actual = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.ProcInstIds = new List<int> { actual.ResultList[0].ProcInst.ID };
            queryCriteriay.QueryCriteria.Folio = actual.ResultList[0].ProcInst.Folio;
            queryCriteriay.QueryCriteria.LoginIds = new List<int>() { Convert.ToInt32(actual.ResultList[0].Destination.Replace("K2SQL:", "")) };
            var actual2 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual2.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.ProcessCodes = new List<string> { };
            var actual9 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual9.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.ProcessCodes = new List<string> { actual.ResultList[0].ProcInst.proc.ProcSet.Descr };
            var actual10 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual10.ResultList.Count > 0);

            var actual3 = target.GetWorkList(queryCriteriay);
            //Assert.AreEqual(actual2.ResultList.Count, actual3.PagingInfo.ItemCount);
            Assert.IsTrue(queryCriteriay.PagingInfo.PageSize >= actual3.ResultList.Count);
            Assert.IsTrue(actual3.PagingInfo.PageCount > 0);

            queryCriteriay.PagingInfo.SortField = "worklisttime";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Descending;
            var actual4 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual4.ResultList[0].StartDate >= actual4.ResultList[actual4.ResultList.Count - 1].StartDate);

            queryCriteriay.PagingInfo.SortField = "worklisttime";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Ascending;
            var actual5 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual5.ResultList[0].StartDate <= actual5.ResultList[actual5.ResultList.Count - 1].StartDate);

            queryCriteriay.PagingInfo.SortField = "folio";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Unspecified;
            var actual6 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual6.ResultList.Count > 0);

            queryCriteriay.PagingInfo.SortField = "folio";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Descending;
            var actual7 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual7.ResultList.Count > 0);

            queryCriteriay.PagingInfo.PageSize = 2000;
            var actual11 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual11.ResultList.Count <=1000);

            queryCriteriay.PagingInfo.SortField = "";
            queryCriteriay.PagingInfo.PageIndex = queryCriteriay.PagingInfo.ItemCount + 1;
            var actual8 = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual8.ResultList.Count == 0);
        }
        public QueryListResultBase<MyTaskDto> GetMyTaskList(QueryCriteriaBase<MyTaskCriteria> queryPara)
        {
            if (queryPara != null && queryPara.QueryCriteria != null && queryPara.PagingInfo != null)
            {
                var processCode = new List<string>();
                var procInstIds = new List<int>();
                var orginatorLoginIds = new List<int>();

                if (queryPara.QueryCriteria.ProcessCode != null && queryPara.QueryCriteria.ProcessCode.Count > 0)
                {
                    processCode = queryPara.QueryCriteria.ProcessCode.Where(_ => _ != string.Empty).ToList();
                }

                if (queryPara.QueryCriteria.ProcInstId != null && queryPara.QueryCriteria.ProcInstId.Count > 0)
                {
                    procInstIds = queryPara.QueryCriteria.ProcInstId.Where(_ => _ != 0).ToList();
                }
                if (queryPara.QueryCriteria.OriginatorLoginId != null && queryPara.QueryCriteria.OriginatorLoginId.Count > 0)
                {
                    orginatorLoginIds = queryPara.QueryCriteria.OriginatorLoginId.Where(_ => _ != 0).ToList();
                }

                var queryWorkList = new QueryCriteriaBase<QueryWorkList>()
                {
                    QueryCriteria = new QueryWorkList()
                    {
                        ProcessCodes = processCode,
                        ProcInstIds = procInstIds,
                        LoginIds = new List<int>() { queryPara.QueryCriteria.LoginId },
                        Folio = queryPara.QueryCriteria.Folio,
                        ProcessStartDate = queryPara.QueryCriteria.ProcessStartDate,
                        TaskStartDate = queryPara.QueryCriteria.TaskStartDate,
                        OriginatorLoginIds = orginatorLoginIds
                    },
                    PagingInfo = queryPara.PagingInfo
                };

                var result = Mapper.Map<QueryListResultBase<MyTaskDto>>(MyTaskDomain.GetMyTaskList(queryWorkList));

                MapWorkListURL(result.ResultList);
                return result;
            }
            else
            {
                return new QueryListResultBase<MyTaskDto>()
                {
                    PagingInfo = new PaginationModel(),
                    ResultList = new List<MyTaskDto>()
                };
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            Cat.GetProducer().NewTransaction("URL-http", "GetTaskList");
            var a = Cat.GetManager().PeekTransaction;

            context.Response.ContentType = "text/plain";
            QueryListResultBase <MyTaskDto> result = new QueryListResultBase <MyTaskDto>();

            try
            {
                int loginId = 0;
                int.TryParse(context.Request.Params["loginId"], out loginId);
                string     originatorLoginIds = context.Request.Params["originatorLoginIds"];
                List <int> originatorLoginId  = new List <int>();
                if (!string.IsNullOrEmpty(originatorLoginIds))
                {
                    originatorLoginId = originatorLoginIds.Split(new char[] { ',', ';' }).Select(_ => int.Parse(_)).ToList();
                }
                string     procInstIds = context.Request.Params["procInstIds"];
                List <int> procInstId  = new List <int>();
                if (!string.IsNullOrEmpty(procInstIds))
                {
                    procInstId = procInstIds.Split(new char[] { ',', ';' }).Select(_ => int.Parse(_)).ToList();
                }
                string        processCodes = context.Request.Params["processCodes"];
                List <string> processCode  = new List <string>();
                if (!string.IsNullOrEmpty(processCodes))
                {
                    processCode = processCodes.Split(new char[] { ',', ';' }).ToList();
                }
                string folio       = context.Request.Params["folio"];
                string taskFrom    = context.Request.Params["taskFrom"];
                string taskTo      = context.Request.Params["taskTo"];
                string processFrom = context.Request.Params["processFrom"];
                string processTo   = context.Request.Params["processTo"];
                int    pageIndex   = 0;
                int.TryParse(context.Request.Params["pageIndex"], out pageIndex);
                int pageSize = 0;
                int.TryParse(context.Request.Params["pageSize"], out pageSize);
                string sortField = context.Request.Params["sortField"];
                string sortOrder = context.Request.Params["sortOrder"];

                string apiKey = context.Request.Params["apiKey"];

                if (APIKeyUtility.IsRightAPIKey(apiKey))
                {
                    PaginationModel PagingInfo = new PaginationModel()
                    {
                        PageIndex = pageIndex,
                        PageSize  = pageSize
                    };
                    if (!string.IsNullOrEmpty(sortField))
                    {
                        PagingInfo.SortField = sortField;
                    }
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        switch (sortOrder.ToUpper())
                        {
                        case "ASC":
                            PagingInfo.SortOrder = SortOrder.Ascending;
                            break;

                        case "DESC":
                            PagingInfo.SortOrder = SortOrder.Descending;
                            break;

                        default:
                            PagingInfo.SortOrder = SortOrder.Unspecified;
                            break;
                        }
                    }

                    DatePeriodModel processDate = new DatePeriodModel();
                    if (!string.IsNullOrEmpty(processFrom))
                    {
                        processDate.DateFrom = Convert.ToDateTime(processFrom);
                    }
                    if (!string.IsNullOrEmpty(processTo))
                    {
                        processDate.DateTo = Convert.ToDateTime(processTo);
                    }

                    DatePeriodModel taskDate = new DatePeriodModel();
                    if (!string.IsNullOrEmpty(taskFrom))
                    {
                        taskDate.DateFrom = Convert.ToDateTime(taskFrom);
                    }
                    if (!string.IsNullOrEmpty(taskTo))
                    {
                        taskDate.DateTo = Convert.ToDateTime(taskTo);
                    }

                    QueryCriteriaBase <MyTaskCriteria> query = new QueryCriteriaBase <MyTaskCriteria>()
                    {
                        PagingInfo    = PagingInfo,
                        QueryCriteria = new MyTaskCriteria()
                        {
                            Folio             = folio,
                            LoginId           = loginId,
                            OriginatorLoginId = originatorLoginId,
                            ProcInstId        = procInstId,
                            ProcessCode       = processCode,
                            ProcessStartDate  = processDate,
                            TaskStartDate     = taskDate
                        }
                    };

                    result = WorkFlowTaskService.GetMyTaskList(query);
                }
                a.Status = "0";
            }
            catch (Exception ex)
            {
                Cat.GetProducer().LogError(ex);
                a.SetStatus(ex);
                LogHelper.Error("GetTaskList", ex.Message, ex, context.Request.Params.ToString());
                result = new QueryListResultBase <MyTaskDto>();
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            finally
            {
                a.Complete();
            }
            context.Response.Write(JsonConvert.SerializeObject(result, new IsoDateTimeConverter()
            {
                DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fff"
            }));
        }
Esempio n. 8
0
        public void GetWorkListTest()
        {
            IWorklistRepostories target = new WorklistRepostories();

            QueryCriteriaBase <QueryWorkList> queryCriteriay = new QueryCriteriaBase <QueryWorkList>()
            {
                PagingInfo = new PaginationModel()
                {
                    PageSize  = 0,
                    PageCount = 0
                },
                QueryCriteria = new QueryWorkList()
                {
                    ProcessStartDate = new DatePeriodModel
                    {
                        DateFrom = DateTime.Today.AddDays(-30),
                        DateTo   = DateTime.Today,
                    },
                    Folio       = string.Empty,
                    LoginIds    = null,
                    ProcInstIds = null
                }
            };
            var actual = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual.PagingInfo.PageCount == 0);


            queryCriteriay.PagingInfo.PageSize = 3;
            actual = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual.ResultList.Count > 0);



            queryCriteriay.QueryCriteria.LoginIds    = new List <int>();
            queryCriteriay.QueryCriteria.ProcInstIds = new List <int>();
            actual = target.GetWorkList(queryCriteriay);
            Assert.IsTrue(actual.ResultList.Count > 0);


            queryCriteriay.QueryCriteria.ProcInstIds = new List <int> {
                actual.ResultList[0].ProcInst.ID
            };
            queryCriteriay.QueryCriteria.Folio    = actual.ResultList[0].ProcInst.Folio;
            queryCriteriay.QueryCriteria.LoginIds = new List <int>()
            {
                Convert.ToInt32(actual.ResultList[0].Destination.Replace("K2SQL:", ""))
            };
            var actual2 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual2.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.ProcessCodes = new List <string> {
            };
            var actual9 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual9.ResultList.Count > 0);

            queryCriteriay.QueryCriteria.ProcessCodes = new List <string> {
                actual.ResultList[0].ProcInst.proc.ProcSet.Descr
            };
            var actual10 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual10.ResultList.Count > 0);

            var actual3 = target.GetWorkList(queryCriteriay);

            //Assert.AreEqual(actual2.ResultList.Count, actual3.PagingInfo.ItemCount);
            Assert.IsTrue(queryCriteriay.PagingInfo.PageSize >= actual3.ResultList.Count);
            Assert.IsTrue(actual3.PagingInfo.PageCount > 0);

            queryCriteriay.PagingInfo.SortField = "worklisttime";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Descending;
            var actual4 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual4.ResultList[0].StartDate >= actual4.ResultList[actual4.ResultList.Count - 1].StartDate);

            queryCriteriay.PagingInfo.SortField = "worklisttime";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Ascending;
            var actual5 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual5.ResultList[0].StartDate <= actual5.ResultList[actual5.ResultList.Count - 1].StartDate);

            queryCriteriay.PagingInfo.SortField = "folio";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Unspecified;
            var actual6 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual6.ResultList.Count > 0);

            queryCriteriay.PagingInfo.SortField = "folio";
            queryCriteriay.PagingInfo.SortOrder = Common.Enum.SortOrder.Descending;
            var actual7 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual7.ResultList.Count > 0);

            queryCriteriay.PagingInfo.PageSize = 2000;
            var actual11 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual11.ResultList.Count <= 1000);

            queryCriteriay.PagingInfo.SortField = "";
            queryCriteriay.PagingInfo.PageIndex = queryCriteriay.PagingInfo.ItemCount + 1;
            var actual8 = target.GetWorkList(queryCriteriay);

            Assert.IsTrue(actual8.ResultList.Count == 0);
        }
Esempio n. 9
0
        public void ProcessRequest(HttpContext context)
        {
            Cat.GetProducer().NewTransaction("URL-http", "GetTaskList");
            var a = Cat.GetManager().PeekTransaction;

            context.Response.ContentType = "text/plain";
            QueryListResultBase<MyTaskDto> result = new QueryListResultBase<MyTaskDto>();
            try
            {
                int loginId = 0;
                int.TryParse(context.Request.Params["loginId"], out loginId);
                string originatorLoginIds = context.Request.Params["originatorLoginIds"];
                List<int> originatorLoginId = new List<int>();
                if (!string.IsNullOrEmpty(originatorLoginIds))
                    originatorLoginId = originatorLoginIds.Split(new char[] { ',', ';' }).Select(_ => int.Parse(_)).ToList();
                string procInstIds = context.Request.Params["procInstIds"];
                List<int> procInstId = new List<int>();
                if (!string.IsNullOrEmpty(procInstIds))
                    procInstId = procInstIds.Split(new char[] { ',', ';' }).Select(_ => int.Parse(_)).ToList();
                string processCodes = context.Request.Params["processCodes"];
                List<string> processCode = new List<string>();
                if (!string.IsNullOrEmpty(processCodes))
                    processCode = processCodes.Split(new char[] { ',', ';' }).ToList();
                string folio = context.Request.Params["folio"];
                string taskFrom = context.Request.Params["taskFrom"];
                string taskTo = context.Request.Params["taskTo"];
                string processFrom = context.Request.Params["processFrom"];
                string processTo = context.Request.Params["processTo"];
                int pageIndex = 0;
                int.TryParse(context.Request.Params["pageIndex"], out pageIndex);
                int pageSize = 0;
                int.TryParse(context.Request.Params["pageSize"], out pageSize);
                string sortField = context.Request.Params["sortField"];
                string sortOrder = context.Request.Params["sortOrder"];

                string apiKey = context.Request.Params["apiKey"];

                if (APIKeyUtility.IsRightAPIKey(apiKey))
                {
                    PaginationModel PagingInfo = new PaginationModel()
                    {
                        PageIndex = pageIndex,
                        PageSize = pageSize
                    };
                    if (!string.IsNullOrEmpty(sortField))
                    {
                        PagingInfo.SortField = sortField;
                    }
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        switch (sortOrder.ToUpper())
                        {
                            case "ASC":
                                PagingInfo.SortOrder = SortOrder.Ascending;
                                break;
                            case "DESC":
                                PagingInfo.SortOrder = SortOrder.Descending;
                                break;
                            default:
                                PagingInfo.SortOrder = SortOrder.Unspecified;
                                break;
                        }

                    }

                    DatePeriodModel processDate = new DatePeriodModel();
                    if (!string.IsNullOrEmpty(processFrom))
                        processDate.DateFrom = Convert.ToDateTime(processFrom);
                    if (!string.IsNullOrEmpty(processTo))
                        processDate.DateTo = Convert.ToDateTime(processTo);

                    DatePeriodModel taskDate = new DatePeriodModel();
                    if (!string.IsNullOrEmpty(taskFrom))
                        taskDate.DateFrom = Convert.ToDateTime(taskFrom);
                    if (!string.IsNullOrEmpty(taskTo))
                        taskDate.DateTo = Convert.ToDateTime(taskTo);

                    QueryCriteriaBase<MyTaskCriteria> query = new QueryCriteriaBase<MyTaskCriteria>()
                    {
                        PagingInfo = PagingInfo,
                        QueryCriteria = new MyTaskCriteria()
                        {
                            Folio = folio,
                            LoginId = loginId,
                            OriginatorLoginId = originatorLoginId,
                            ProcInstId = procInstId,
                            ProcessCode = processCode,
                            ProcessStartDate = processDate,
                            TaskStartDate = taskDate
                        }
                    };

                    result = WorkFlowTaskService.GetMyTaskList(query);
                }
                a.Status = "0";

            }
            catch (Exception ex)
            {
                Cat.GetProducer().LogError(ex);
                a.SetStatus(ex);
                LogHelper.Error("GetTaskList", ex.Message, ex, context.Request.Params.ToString());
                result = new QueryListResultBase<MyTaskDto>();
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }
            finally
            {
                a.Complete();
            }
            context.Response.Write(JsonConvert.SerializeObject(result, new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-ddTHH:mm:ss.fff" }));
        }
Esempio n. 10
0
        //public IList<Models.Worklist> GetWorkList(string destination, DateTime startDate, DateTime endDate)
        //{
        //    using (var edm = new Models.DianPingK2ServerLogContext())
        //    {
        //        //return edm.Worklist.Select(_ =>
        //        //    new Models.Worklist
        //        //    {
        //        //        DestType = _.DestType,
        //        //        ProcInst = new Models.ProcInst
        //        //        {
        //        //            Folio = _.ProcInst.Folio
        //        //        }
        //        //    }).Where(_ => _.Destination == destination && _.ProcInst.StartDate > startDate).ToList();
        //        return edm.Worklist.Include("ProcInst")
        //            .Where(_ => _.Destination == destination && _.ProcInst.StartDate > startDate).ToList();
        //    }
        //}
        public QueryListResultBase<Worklist> GetWorkList(QueryCriteriaBase<QueryWorkList> queryPara)
        {
            var result = new QueryListResultBase<Worklist>();

            var transactionOptions = new System.Transactions.TransactionOptions();
            transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;

            var edm = new DianPingK2ServerLogContext();
            //edm.Database.ExecuteSqlCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");

            var query = edm.Worklist.Include("ProcInst").AsQueryable().Where(_ => _.Status == 0);

            if (queryPara != null)
            {
                var criteria = queryPara.QueryCriteria;
                if (criteria != null)
                {
                    //if (criteria.ProcessFullName != null && criteria.ProcessFullName.Count > 0)
                    //{
                    //    query = query.Where(_ => criteria.ProcessFullName.Contains(_.ProcInst.proc.ProcSet.FullName));
                    //}
                    if (criteria.ProcessCodes != null && criteria.ProcessCodes.Count > 0)
                    {
                        query = query.Where(_ => criteria.ProcessCodes.Contains(_.ProcInst.proc.ProcSet.Descr));
                    }
                    if (criteria.LoginIds != null && criteria.LoginIds.Count > 0)
                    {
                        IList<string> loginIdsStr = criteria.LoginIds.Select(_ => string.Format("K2SQL:{0}", _)).ToList();
                        query = query.Where(_ => loginIdsStr.Contains(_.Destination));
                    }
                    if (criteria.OriginatorLoginIds != null && criteria.OriginatorLoginIds.Count > 0)
                    {
                        IList<string> loginIdsStr = criteria.OriginatorLoginIds.Select(_ => string.Format("K2SQL:{0}", _)).ToList();
                        query = query.Where(_ => loginIdsStr.Contains(_.ProcInst.Originator));
                    }
                    if (criteria.ProcInstIds != null && criteria.ProcInstIds.Count > 0)
                    {
                        query = query.Where(_ => criteria.ProcInstIds.Contains(_.ProcInst.ID));
                    }
                    if (!string.IsNullOrEmpty(criteria.Folio))
                    {
                        query = query.Where(_ => _.ProcInst.Folio.StartsWith(criteria.Folio));
                    }
                    if (criteria.TaskStartDate != null)
                    {
                        if (criteria.TaskStartDate.DateFrom.HasValue)
                        {
                            query = query.Where(_ => _.StartDate >= criteria.TaskStartDate.DateFrom.Value);
                        }
                        if (criteria.TaskStartDate.DateTo.HasValue)
                        {
                            query = query.Where(_ => _.StartDate < criteria.TaskStartDate.DateTo.Value);
                        }
                    }
                    if (criteria.ProcessStartDate != null)
                    {
                        if (criteria.ProcessStartDate.DateFrom.HasValue)
                        {
                            query = query.Where(_ => _.ProcInst.StartDate >= criteria.ProcessStartDate.DateFrom.Value);
                        }
                        if (criteria.ProcessStartDate.DateTo.HasValue)
                        {
                            query = query.Where(_ => _.ProcInst.StartDate < criteria.ProcessStartDate.DateTo.Value);
                        }
                    }
                    if (queryPara.PagingInfo != null)
                    {
                        using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
                        {
                            queryPara.PagingInfo.ItemCount = query.Count();
                            transactionScope.Complete();
                        }
                        if (queryPara.PagingInfo.SortField != null)
                        {
                            switch (queryPara.PagingInfo.SortField.ToLower())
                            {
                                case "folio":
                                    if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                    {
                                        query = query.OrderByDescending(_ => _.ProcInst.Folio);
                                    }
                                    else
                                    {
                                        query = query.OrderBy(_ => _.ProcInst.Folio);
                                    }
                                    break;
                                case "worklisttime":
                                    if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                    {
                                        query = query.OrderByDescending(_ => _.StartDate);
                                    }
                                    else
                                    {
                                        query = query.OrderBy(_ => _.StartDate);
                                    }
                                    break;
                                case "procstarttime":
                                    if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                    {
                                        query = query.OrderByDescending(_ => _.ProcInst.StartDate);
                                    }
                                    else
                                    {
                                        query = query.OrderBy(_ => _.ProcInst.StartDate);
                                    }
                                    break;
                                default:
                                    query = query.OrderByDescending(_ => _.StartDate);
                                    break;
                            }
                        }
                        else
                        {
                            query = query.OrderByDescending(_ => _.StartDate);
                        }
                        query = query
                            .Skip(queryPara.PagingInfo.PageIndex == 0 ? 0 : (queryPara.PagingInfo.PageIndex - 1) * queryPara.PagingInfo.PageSize)
                            .Take(queryPara.PagingInfo.PageSize);
                    }
                }
                result.PagingInfo = queryPara.PagingInfo;
            }
            //result.PagingInfo = null;

            using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
            {
                result.ResultList = query.ToList();
                transactionScope.Complete();
            }
            return result;
        }
Esempio n. 11
0
        public QueryListResultBase<MyTaskDto> GetTaskList(QueryCriteriaBase<MyTaskCriteria> queryPara, string apiKey)
        {
            Cat.GetProducer().NewTransaction("URL-WebService", "GetTaskList");
            var a = Cat.GetManager().PeekTransaction;
            QueryListResultBase<MyTaskDto> result = null;

            try
            {
                if (APIKeyUtility.IsRightAPIKey(apiKey))
                {
                    result = WorkFlowTaskService.GetMyTaskList(queryPara);
                }
                else
                {
                    result = new QueryListResultBase<MyTaskDto>();
                }
                a.Status = "0";
            }
            catch (Exception ex)
            {
                Cat.GetProducer().LogError(ex);
                a.SetStatus(ex);
                throw ex;
            }
            finally
            {
                a.Complete();
            }
            return result;
        }
Esempio n. 12
0
 public QueryListResultBase<MyTaskDdo> GetMyTaskList(QueryCriteriaBase<QueryWorkList> queryPara)
 {
     var sourceResult = WorklistRepostories.GetWorkList(queryPara);
     return Mapper.Map<QueryListResultBase<MyTaskDdo>>(sourceResult);
 }
Esempio n. 13
0
        public QueryListResultBase <MyTaskDdo> GetMyTaskList(QueryCriteriaBase <QueryWorkList> queryPara)
        {
            var sourceResult = WorklistRepostories.GetWorkList(queryPara);

            return(Mapper.Map <QueryListResultBase <MyTaskDdo> >(sourceResult));
        }
Esempio n. 14
0
        //public IList<Models.Worklist> GetWorkList(string destination, DateTime startDate, DateTime endDate)
        //{
        //    using (var edm = new Models.DianPingK2ServerLogContext())
        //    {
        //        //return edm.Worklist.Select(_ =>
        //        //    new Models.Worklist
        //        //    {
        //        //        DestType = _.DestType,
        //        //        ProcInst = new Models.ProcInst
        //        //        {
        //        //            Folio = _.ProcInst.Folio
        //        //        }
        //        //    }).Where(_ => _.Destination == destination && _.ProcInst.StartDate > startDate).ToList();
        //        return edm.Worklist.Include("ProcInst")
        //            .Where(_ => _.Destination == destination && _.ProcInst.StartDate > startDate).ToList();
        //    }

        //}

        public QueryListResultBase <Worklist> GetWorkList(QueryCriteriaBase <QueryWorkList> queryPara)
        {
            var result = new QueryListResultBase <Worklist>();

            var transactionOptions = new System.Transactions.TransactionOptions();

            transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;

            var edm = new DianPingK2ServerLogContext();
            //edm.Database.ExecuteSqlCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");

            var query = edm.Worklist.Include("ProcInst").AsQueryable().Where(_ => _.Status == 0);

            if (queryPara != null)
            {
                var criteria = queryPara.QueryCriteria;
                if (criteria != null)
                {
                    //if (criteria.ProcessFullName != null && criteria.ProcessFullName.Count > 0)
                    //{
                    //    query = query.Where(_ => criteria.ProcessFullName.Contains(_.ProcInst.proc.ProcSet.FullName));
                    //}
                    if (criteria.ProcessCodes != null && criteria.ProcessCodes.Count > 0)
                    {
                        query = query.Where(_ => criteria.ProcessCodes.Contains(_.ProcInst.proc.ProcSet.Descr));
                    }
                    if (criteria.LoginIds != null && criteria.LoginIds.Count > 0)
                    {
                        IList <string> loginIdsStr = criteria.LoginIds.Select(_ => string.Format("K2SQL:{0}", _)).ToList();
                        query = query.Where(_ => loginIdsStr.Contains(_.Destination));
                    }
                    if (criteria.OriginatorLoginIds != null && criteria.OriginatorLoginIds.Count > 0)
                    {
                        IList <string> loginIdsStr = criteria.OriginatorLoginIds.Select(_ => string.Format("K2SQL:{0}", _)).ToList();
                        query = query.Where(_ => loginIdsStr.Contains(_.ProcInst.Originator));
                    }
                    if (criteria.ProcInstIds != null && criteria.ProcInstIds.Count > 0)
                    {
                        query = query.Where(_ => criteria.ProcInstIds.Contains(_.ProcInst.ID));
                    }
                    if (!string.IsNullOrEmpty(criteria.Folio))
                    {
                        query = query.Where(_ => _.ProcInst.Folio.StartsWith(criteria.Folio));
                    }
                    if (criteria.TaskStartDate != null)
                    {
                        if (criteria.TaskStartDate.DateFrom.HasValue)
                        {
                            query = query.Where(_ => _.StartDate >= criteria.TaskStartDate.DateFrom.Value);
                        }
                        if (criteria.TaskStartDate.DateTo.HasValue)
                        {
                            query = query.Where(_ => _.StartDate < criteria.TaskStartDate.DateTo.Value);
                        }
                    }
                    if (criteria.ProcessStartDate != null)
                    {
                        if (criteria.ProcessStartDate.DateFrom.HasValue)
                        {
                            query = query.Where(_ => _.ProcInst.StartDate >= criteria.ProcessStartDate.DateFrom.Value);
                        }
                        if (criteria.ProcessStartDate.DateTo.HasValue)
                        {
                            query = query.Where(_ => _.ProcInst.StartDate < criteria.ProcessStartDate.DateTo.Value);
                        }
                    }
                    if (queryPara.PagingInfo != null)
                    {
                        using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
                        {
                            queryPara.PagingInfo.ItemCount = query.Count();
                            transactionScope.Complete();
                        }
                        if (queryPara.PagingInfo.SortField != null)
                        {
                            switch (queryPara.PagingInfo.SortField.ToLower())
                            {
                            case "folio":
                                if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                {
                                    query = query.OrderByDescending(_ => _.ProcInst.Folio);
                                }
                                else
                                {
                                    query = query.OrderBy(_ => _.ProcInst.Folio);
                                }
                                break;

                            case "worklisttime":
                                if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                {
                                    query = query.OrderByDescending(_ => _.StartDate);
                                }
                                else
                                {
                                    query = query.OrderBy(_ => _.StartDate);
                                }
                                break;

                            case "procstarttime":
                                if (queryPara.PagingInfo.SortOrder == Common.Enum.SortOrder.Descending)
                                {
                                    query = query.OrderByDescending(_ => _.ProcInst.StartDate);
                                }
                                else
                                {
                                    query = query.OrderBy(_ => _.ProcInst.StartDate);
                                }
                                break;

                            default:
                                query = query.OrderByDescending(_ => _.StartDate);
                                break;
                            }
                        }
                        else
                        {
                            query = query.OrderByDescending(_ => _.StartDate);
                        }
                        query = query
                                .Skip(queryPara.PagingInfo.PageIndex == 0 ? 0 : (queryPara.PagingInfo.PageIndex - 1) * queryPara.PagingInfo.PageSize)
                                .Take(queryPara.PagingInfo.PageSize);
                    }
                }
                result.PagingInfo = queryPara.PagingInfo;
            }
            //result.PagingInfo = null;

            using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
            {
                result.ResultList = query.ToList();
                transactionScope.Complete();
            }
            return(result);
        }