Пример #1
0
        public ICallReportVO ProcessCallReport(ICallReportVO callReport, string action)
        {
            IUserVO loginUser = UserDAO.RetrieveUserByLoginId(callReport.LastUpdateBy);

            if (callReport.Id == 0)
            {
                callReport.Owner = loginUser;
            }
            CallReportDAO.SaveCallReport(callReport);

            ITaskVO task = TaskDAO.RetrieveTaskByRefIdAndFlowType(callReport.Id, WORKFLOW_TYPE);

            if (task == null)
            {
                task = new TaskVO()
                {
                    ReferenceId = callReport.Id, WorkflowType = WORKFLOW_TYPE
                };
                task.LastUpdateBy = callReport.LastUpdateBy;
                task.Initiator    = loginUser;
            }

            task.PreviousOwner = loginUser;
            task.TaskAction    = action;

            task = WorkflowManager.ExecuteWorkflow(task, callReport.Reviewer);
            TaskDAO.SaveTask(task);

            callReport.Status            = task.TaskStatus;
            callReport.WorkflowProcessId = task.WorkflowProcessId;
            callReport.TaskStatus        = task.TaskStatus;
            callReport.CurrentRecipient  = UserDAO.RetrieveUserById(task.CurrentOwner.Id);

            return(callReport);
        }
        public override ITaskVO ExecuteWorkflow(ITaskVO task, IUserVO nextOwner)
        {
            if (task.WorkflowProcessId == null)
            {
                task.WorkflowProcessId = Guid.NewGuid();
            }

            Guid processId = (task.WorkflowProcessId ?? Guid.Empty);

            CreateWorkflowIfNotExists(processId, task.WorkflowType);

            ProcessDefinition processDefinition = WorkflowInit.Runtime.GetProcessScheme(processId);

            WorkflowCommand command = WorkflowInit.Runtime.GetAvailableCommands(
                (task.WorkflowProcessId ?? Guid.Empty), string.Empty)
                                      .Where(c => c.CommandName.Trim() == task.TaskAction).FirstOrDefault();

            if (command != null)
            {
                WorkflowInit.Runtime.ExecuteCommand(command, string.Empty, string.Empty);

                if (nextOwner != null)
                {
                    // Always assume first that it is for Submit.
                    task.CurrentOwner = nextOwner;
                }

                var commands = WorkflowInit.Runtime.GetAvailableCommands(processId, string.Empty);
                if (commands == null || commands.Count() == 0)
                {
                    // For end-states.
                    task.TaskStatus   = Constants.GetEnumDescription <TaskStatus>(TaskStatus.COMPLETED);
                    task.CurrentOwner = task.Initiator;
                }
                else
                {
                    ActivityDefinition definition = processDefinition.InitialActivity;
                    WorkflowState      state      = WorkflowInit.Runtime.GetCurrentState(processId);
                    if (definition.State == state.Name)
                    {
                        // For Draft.
                        task.TaskStatus   = Constants.GetEnumDescription <TaskStatus>(TaskStatus.IN_PROGRESS);
                        task.CurrentOwner = task.Initiator;
                    }
                }
            }

            task.Status = WorkflowInit.Runtime.GetCurrentState(processId).Name;
            task.WorkflowDefinitionId = processDefinition.Id;

            return(task);
        }
Пример #3
0
        public IList <ICallReportVO> RetrieveCallReportTaskList(string loginId, bool isInitiator)
        {
            IUserVO loginUser = UserDAO.RetrieveUserByLoginId(loginId);

            return(TaskADO.RetrieveCallReportTaskList(loginUser.Id, isInitiator));
        }
Пример #4
0
        public int RetrieveCallReportTaskListCount(string loginId)
        {
            IUserVO loginUser = UserDAO.RetrieveUserByLoginId(loginId);

            return(TaskADO.RetrieveCallReportTaskListCount(loginUser.Id));
        }
Пример #5
0
 public abstract ITaskVO ExecuteWorkflow(ITaskVO task, IUserVO nextOwner);