public async Task <IActionResult> Edit(string id, CancellationToken cancellationToken) { var workflowDefinition = await publisher.GetDraftAsync(id, cancellationToken); if (workflowDefinition == null) { return(NotFound()); } var workflowModel = new WorkflowModel { Activities = workflowDefinition.Activities.Select(x => new ActivityModel(x)).ToList(), Connections = workflowDefinition.Connections.Select(x => new ConnectionModel(x)).ToList() }; var model = new WorkflowDefinitionEditModel { Id = workflowDefinition.DefinitionId, Name = workflowDefinition.Name, Json = serializer.Serialize(workflowModel, JsonTokenFormatter.FormatName), Description = workflowDefinition.Description, IsSingleton = workflowDefinition.IsSingleton, IsDisabled = workflowDefinition.IsDisabled, ActivityDefinitions = options.Value.ActivityDefinitions.ToArray(), WorkflowModel = workflowModel }; return(View(model)); }
public async Task <AWFDefinitionDetailResponse> GetDetailDefinitionAsync(string id, CancellationToken cancellationToken) { var workflowDefinition = await _publisher.GetDraftAsync(id, cancellationToken); if (workflowDefinition == null) { throw new ErrorException(StatusCodes.Status404NotFound, $"Can't not found workflow definition with {id}"); } var workflowModel = new WorkflowModel { Activities = workflowDefinition.Activities.Select(x => new ActivityModel(x)).ToList(), Connections = workflowDefinition.Connections.Select(x => new ConnectionModel(x)).ToList() }; var model = new WorkflowDefinitionEditModel { Id = workflowDefinition.DefinitionId, Name = workflowDefinition.Name, Json = _serializer.Serialize(workflowModel, JsonTokenFormatter.FormatName), Description = workflowDefinition.Description, IsSingleton = workflowDefinition.IsSingleton, IsDisabled = workflowDefinition.IsDisabled, ActivityDefinitions = _options.Value.ActivityDefinitions.ToArray(), WorkflowModel = workflowModel }; return(_mapper.Map <AWFDefinitionDetailResponse>(model)); }
public async Task <AWFDefinitionCreateResponse> CreateDefinitionAsync(WorkflowDefinitionEditModel model, CancellationToken cancellationToken) { var workflow = new WorkflowDefinitionVersion(); var postedWorkflow = _serializer.Deserialize <WorkflowModel>(model.Json, JsonTokenFormatter.FormatName); workflow.Activities = postedWorkflow.Activities .Select(x => new ActivityDefinition(x.Id, x.Type, x.State, x.Left, x.Top)) .ToList(); workflow.Connections = postedWorkflow.Connections.Select( x => new ConnectionDefinition(x.SourceActivityId, x.DestinationActivityId, x.Outcome)).ToList(); workflow.Description = model.Description; workflow.Name = model.Name; workflow.IsDisabled = model.IsDisabled; workflow.IsSingleton = model.IsSingleton; var publish = model.SubmitAction == "publish"; if (publish) { workflow = await _publisher.PublishAsync(workflow, cancellationToken); } else { workflow = await _publisher.SaveDraftAsync(workflow, cancellationToken); } return(_mapper.Map <AWFDefinitionCreateResponse>(workflow)); }
public async Task <IActionResult> Edit( string id, WorkflowDefinitionEditModel model, CancellationToken cancellationToken) { var workflow = await workflowDefinitionStore.GetByIdAsync(id, VersionOptions.Latest, cancellationToken); return(await SaveAsync(model, workflow, cancellationToken)); }
public async Task <IActionResult> EditWorkflowDefinition(string id, WorkflowDefinitionEditModel model, CancellationToken cancellationToken) { if (ModelState.IsValid) { var response = await _workflowDefinitionService.EditDefinitionAsync(id, model, cancellationToken); return(Ok(response)); } else { return(ThrowModelErrorsException()); } }
public ViewResult Create() { var workflowDefinition = publisher.New(); var model = new WorkflowDefinitionEditModel { Name = workflowDefinition.Name, Json = serializer.Serialize(workflowDefinition, JsonTokenFormatter.FormatName), ActivityDefinitions = options.Value.ActivityDefinitions.ToArray(), IsSingleton = workflowDefinition.IsSingleton, IsDisabled = workflowDefinition.IsDisabled, Description = workflowDefinition.Description }; return(View(model)); }
private async Task <IActionResult> SaveAsync( WorkflowDefinitionEditModel model, WorkflowDefinitionVersion workflow, CancellationToken cancellationToken) { var postedWorkflow = serializer.Deserialize <WorkflowModel>(model.Json, JsonTokenFormatter.FormatName); workflow.Activities = postedWorkflow.Activities .Select(x => new ActivityDefinition(x.Id, x.Type, x.State, x.Left, x.Top)) .ToList(); workflow.Connections = postedWorkflow.Connections.Select( x => new ConnectionDefinition(x.SourceActivityId, x.DestinationActivityId, x.Outcome)).ToList(); workflow.Description = model.Description; workflow.Name = model.Name; workflow.IsDisabled = model.IsDisabled; workflow.IsSingleton = model.IsSingleton; workflow.UserId = ""; var a = (((System.Security.Claims.ClaimsIdentity)HttpContext.User.Identity).Claims); if (HttpContext.User.Identity != null && a.Count() > 0) { var w = a.ToList(); var e = w[0]; workflow.UserId = e.Value; } var publish = model.SubmitAction == "publish"; if (publish) { workflow = await publisher.PublishAsync(workflow, cancellationToken); notifier.Notify("Workflow successfully published.", NotificationType.Success); } else { workflow = await publisher.SaveDraftAsync(workflow, cancellationToken); notifier.Notify("Workflow successfully saved as a draft.", NotificationType.Success); } return(RedirectToRoute("EditWorkflowDefinition", new { id = workflow.DefinitionId })); }
public async Task <AWFDefinitionEditResponse> EditDefinitionAsync(string id, WorkflowDefinitionEditModel request, CancellationToken cancellationToken) { var workflow = await _workflowDefinitionStore.GetByIdAsync(id, VersionOptions.Latest, cancellationToken); if (workflow == null) { throw new ErrorException(StatusCodes.Status404NotFound, $"Can't not found workflow definition with {id}"); } var postedWorkflow = _serializer.Deserialize <WorkflowModel>(request.Json, JsonTokenFormatter.FormatName); workflow.Activities = postedWorkflow.Activities .Select(x => new ActivityDefinition(x.Id, x.Type, x.State, x.Left, x.Top)) .ToList(); workflow.Connections = postedWorkflow.Connections.Select( x => new ConnectionDefinition(x.SourceActivityId, x.DestinationActivityId, x.Outcome)).ToList(); workflow.Description = request.Description; workflow.Name = request.Name; workflow.IsDisabled = request.IsDisabled; workflow.IsSingleton = request.IsSingleton; var publish = request.SubmitAction == Constants.PublishVersion; if (publish) { workflow = await _publisher.PublishAsync(workflow, cancellationToken); } else { workflow = await _publisher.SaveDraftAsync(workflow, cancellationToken); } return(_mapper.Map <AWFDefinitionEditResponse>(workflow)); }
public async Task <IActionResult> Create(WorkflowDefinitionEditModel model, CancellationToken cancellationToken) { var workflow = new WorkflowDefinitionVersion(); return(await SaveAsync(model, workflow, cancellationToken)); }