public async Task <IActionResult> Create(string activityName, int workflowTypeId, string returnUrl)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows))
            {
                return(Forbid());
            }

            var activity       = _activityLibrary.InstantiateActivity(activityName);
            var activityId     = _activityIdGenerator.GenerateUniqueId(new ActivityRecord());
            var activityEditor = await _activityDisplayManager.BuildEditorAsync(activity, _updateModelAccessor.ModelUpdater, isNew : true);

            activityEditor.Metadata.Type = "Activity_Edit";

            var viewModel = new ActivityEditViewModel
            {
                Activity       = activity,
                ActivityId     = activityId,
                ActivityEditor = activityEditor,
                WorkflowTypeId = workflowTypeId,
                ReturnUrl      = returnUrl
            };

            if (!activity.HasEditor)
            {
                // No editor to show; short-circuit to the "POST" action.
                return(await Create(activityName, viewModel));
            }

            return(View(viewModel));
        }
예제 #2
0
        public async Task <IActionResult> Create(string activityName, [FromBody] JToken json, CancellationToken cancellationToken)
        {
            var activityDescriptor = await activityLibrary.GetByNameAsync(activityName, cancellationToken);

            var activity = activityDescriptor.InstantiateActivity(json);

            activity.Id = Guid.NewGuid().ToString().Replace("-", "");

            var editorShape = await displayManager.BuildEditorAsync(activity, this, false);

            var activityToken = await workflowTokenizer.TokenizeActivityAsync(activity, cancellationToken);

            var model = new ActivityEditorEditViewModel
            {
                ActivityJson        = activityToken.ToString(),
                ActivityEditorShape = editorShape,
            };

            return(View("Edit", model));
        }