public virtual IList <ITask> FindTasksAndVariablesByQueryCriteria(ITaskQuery taskQuery)
        {
            const string  query        = "selectTaskWithVariablesByQueryCriteria";
            TaskQueryImpl taskQueyImpl = taskQuery as TaskQueryImpl;

            // paging doesn't work for combining task instances and variables due to
            // an outer join, so doing it in-memory
            if (taskQueyImpl.FirstResult < 0 || taskQueyImpl.MaxResults <= 0)
            {
                return(new List <ITask>());
            }

            int firstResult = taskQueyImpl.FirstResult;
            int maxResults  = taskQueyImpl.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (taskQueyImpl.TaskVariablesLimit != null)
            {
                taskQueyImpl.MaxResults = taskQueyImpl.TaskVariablesLimit.GetValueOrDefault();
            }
            else
            {
                taskQueyImpl.MaxResults = ProcessEngineConfiguration.TaskQueryLimit;
            }
            taskQueyImpl.FirstResult = 0;

            IList <ITask> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <TaskEntityImpl, ITask>(query, taskQueyImpl, taskQueyImpl.FirstResult, taskQueyImpl.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <ITask>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }
            return(new List <ITask>());
        }
示例#2
0
        public virtual IList <IHistoricTaskInstance> FindHistoricTaskInstancesAndVariablesByQueryCriteria(IHistoricTaskInstanceQuery historicTaskInstanceQuery)
        {
            var query = historicTaskInstanceQuery as HistoricTaskInstanceQueryImpl;

            // paging doesn't work for combining task instances and variables
            // due to an outer join, so doing it in-memory
            if (query.FirstResult < 0 || query.MaxResults <= 0)
            {
                return(new List <IHistoricTaskInstance>());
            }

            int firstResult = query.FirstResult;
            int maxResults  = query.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (query.TaskVariablesLimit != null)
            {
                query.MaxResults = query.TaskVariablesLimit.GetValueOrDefault();
            }
            else
            {
                query.MaxResults = ProcessEngineConfiguration.HistoricTaskQueryLimit;
            }
            query.FirstResult = 0;

            IList <IHistoricTaskInstance> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <HistoricTaskInstanceEntityImpl, IHistoricTaskInstance>("selectHistoricTaskInstancesWithVariablesByQueryCriteria", historicTaskInstanceQuery, query.FirstResult, query.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <IHistoricTaskInstance>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }

            return(instanceList);
        }
示例#3
0
        public virtual IList <IProcessInstance> FindProcessInstanceAndVariablesByQueryCriteria(IProcessInstanceQuery query)
        {
            ProcessInstanceQueryImpl executionQuery = query as ProcessInstanceQueryImpl;

            // paging doesn't work for combining process instances and variables due
            // to an outer join, so doing it in-memory
            if (executionQuery.FirstResult < 0 || executionQuery.MaxResults <= 0)
            {
                return(new List <IProcessInstance>());
            }

            int firstResult = executionQuery.FirstResult;
            int maxResults  = executionQuery.MaxResults;

            // setting max results, limit to 20000 results for performance reasons
            if (executionQuery.ProcessInstanceVariablesLimit != null)
            {
                executionQuery.MaxResults = executionQuery.ProcessInstanceVariablesLimit.GetValueOrDefault();
            }
            else
            {
                executionQuery.MaxResults = ProcessEngineConfiguration.ExecutionQueryLimit;
            }
            executionQuery.FirstResult = 0;

            IList <IProcessInstance> instanceList = DbSqlSession.SelectListWithRawParameterWithoutFilter <ExecutionEntityImpl, IProcessInstance>("selectProcessInstanceWithVariablesByQueryCriteria", executionQuery, executionQuery.FirstResult, executionQuery.MaxResults);

            if (instanceList != null && instanceList.Count > 0)
            {
                if (firstResult > 0)
                {
                    if (firstResult <= instanceList.Count)
                    {
                        int toIndex = firstResult + Math.Min(maxResults, instanceList.Count - firstResult);
                        return(instanceList.Skip(firstResult).Take(toIndex).ToList());
                    }
                    else
                    {
                        return(new List <IProcessInstance>());
                    }
                }
                else
                {
                    int toIndex = Math.Min(maxResults, instanceList.Count);
                    return(instanceList.Skip(0).Take(toIndex).ToList());
                }
            }
            return(new List <IProcessInstance>());
        }