private ITaskVO UpdateTask(ITaskVO task) { task.LastUpdateDate = DateTime.Now; CurrentSession.SaveOrUpdate(task); return(task); }
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); }
private ITaskVO CreateTask(ITaskVO task) { // LastUpdateBy will be set in the controller using the login user; hence, just copy. task.CreateBy = task.LastUpdateBy; task.CreationDate = DateTime.Now; task.LastUpdateDate = DateTime.Now; CurrentSession.SaveOrUpdate(task); return(task); }
public virtual ITaskVO SaveTask(ITaskVO task) { if (task.Id == 0) { return(CreateTask(task)); } else { return(UpdateTask(task)); } }
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); }
public abstract ITaskVO ExecuteWorkflow(ITaskVO task, IUserVO nextOwner);