コード例 #1
0
        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));
        }
コード例 #2
0
        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 }));
        }