public async Task <IActionResult> Post(WorkFlowProcessedModel model) { if (ModelState.IsValid) { if (model.ProcessState == WorkFlowProcessState.UnPassed && model.Description.IsEmpty()) { return(JError(T["workflow_unpassed_needreason"])); } var processInfo = _workFlowProcessFinder.FindById(model.WorkFlowProcessId); if (processInfo == null) { return(NotFound()); } if (processInfo.StateCode != WorkFlowProcessState.Processing) { return(JError(T["workflow_alreadyhandled"])); } if (processInfo.HandlerId != CurrentUser.SystemUserId) { return(JError(T["workflow_youarenothandler"])); } var instance = _workFlowInstanceService.FindById(processInfo.WorkFlowInstanceId); if (instance == null) { return(NotFound()); } var entityMeta = _entityFinder.FindById(instance.EntityId); if (entityMeta == null) { return(NotFound()); } //执行工作流 var result = await _workFlowExecuter.ExecuteAsync(new WorkFlowExecutionContext() { Attachments = model.Attachments != null ? model.Attachments.Count() : 0 , AttachmentFiles = model.Attachments , Description = model.Description , ProcessInfo = processInfo , InstanceInfo = instance , EntityMetaData = entityMeta , ProcessState = model.ProcessState }).ConfigureAwait(false); if (!result.IsSuccess) { return(JError(result.Message)); } return(JOk(T["operation_success"])); } return(JError(T["operation_error"] + ": " + GetModelErrors(ModelState))); }
public IActionResult WorkFlowProcess(WorkFlowProcessModel model) { if (model.WorkFlowInstanceId.Equals(Guid.Empty)) { return(NotFound()); } if (!model.IsSortBySeted) { model.SortBy = "steporder"; model.SortDirection = 0; } model.InstanceInfo = _workFlowInstanceService.FindById(model.WorkFlowInstanceId); model.FlowInfo = _workFlowFinder.FindById(model.InstanceInfo.WorkFlowId); FilterContainer <WorkFlowProcess> filter = FilterContainerBuilder.Build <WorkFlowProcess>(); filter.And(n => n.WorkFlowInstanceId == model.WorkFlowInstanceId); if (model.GetAll) { List <WorkFlowProcess> result = _workFlowProcessFinder.Query(x => x .Page(model.Page, model.PageSize) .Where(filter) .Sort(n => n.OnFile(model.SortBy).ByDirection(model.SortDirection)) ); model.Items = result; model.TotalItems = result.Count; } else { PagedList <WorkFlowProcess> result = _workFlowProcessFinder.QueryPaged(x => x .Page(model.Page, model.PageSize) .Where(filter) .Sort(n => n.OnFile(model.SortBy).ByDirection(model.SortDirection)) ); model.Items = result.Items; model.TotalItems = result.TotalItems; } return(DynamicResult(model)); }
public IActionResult AssignHandler(Guid processId, string userName) { //查找用户 var query = new QueryExpression("systemuser", CurrentUser.UserSettings.LanguageId); query.ColumnSet.AddColumns("systemuserid", "name"); query.Criteria.FilterOperator = LogicalOperator.Or; query.Criteria.AddCondition("loginname", ConditionOperator.Equal, userName); query.Criteria.AddCondition("usernumber", ConditionOperator.Equal, userName); var user = _dataFinder.Retrieve(query); if (user == null || user.Count == 0) { return(JError(T["workflow_nomatchuser"])); } Guid handlerId = user.GetIdValue(); //当前步骤 var processInfo = _workFlowProcessFinder.FindById(processId); if (processInfo == null) { return(NotFound()); } if (handlerId == CurrentUser.SystemUserId) { return(JError(T["workflow_notallowtome"])); } var instance = _workFlowInstanceService.FindById(processInfo.WorkFlowInstanceId); if (handlerId == instance.ApplicantId) { return(JError(T["workflow_notallowtoapplier"])); } //验证是否有移交权限 //... var log = new WorkFlowProcessLog(); log.CreatedOn = DateTime.Now; log.OperatorId = CurrentUser.SystemUserId; log.Title = T["workflow_assignto"]; log.WorkFlowProcessId = Guid.Empty; log.WorkFlowProcessLogId = Guid.NewGuid(); log.WorkFlowInstanceId = Guid.Empty; _workFlowProcessLogService.Create(log); return(JOk(T["operation_success"])); }
public IActionResult Post([FromRoute] WorkFlowInstanceCancleModel model) { var flowInstance = _workFlowInstanceService.FindById(model.Id); if (flowInstance == null) { return(NotFound()); } WorkFlowCancellationContext context = new WorkFlowCancellationContext { EntityMetaData = _entityFinder.FindById(flowInstance.EntityId) , ObjectId = flowInstance.ObjectId }; var result = _workFlowCanceller.Cancel(context); if (result.IsSuccess) { return(JOk(T["operation_success"])); } return(JError(result.Message)); }
public IActionResult Cancel(Guid id) { var instance = _workFlowInstanceService.FindById(id); if (instance != null) { WorkFlowCancellationContext context = new WorkFlowCancellationContext { EntityMetaData = _entityFinder.FindById(instance.EntityId) , ObjectId = instance.ObjectId }; var flag = _workFlowCanceller.Cancel(context); if (flag.IsSuccess) { return(JOk(T["operation_success"])); } else { return(JError(flag.Message)); } } return(JError(T["operation_error"])); }