public async Task <IActionResult> Create(string activityName, ActivityEditViewModel model) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageWorkflows)) { return(Forbid()); } var workflowType = await _session.GetAsync <WorkflowType>(model.WorkflowTypeId); var activity = _activityLibrary.InstantiateActivity(activityName); var activityEditor = await _activityDisplayManager.UpdateEditorAsync(activity, _updateModelAccessor.ModelUpdater, isNew : true); if (!ModelState.IsValid) { activityEditor.Metadata.Type = "Activity_Edit"; model.Activity = activity; model.ActivityEditor = activityEditor; return(View(model)); } var activityRecord = new ActivityRecord { ActivityId = model.ActivityId, Name = activity.Name, Properties = activity.Properties, }; workflowType.Activities.Add(activityRecord); _session.Save(workflowType); _notifier.Success(H["Activity added successfully."]); return(Url.IsLocalUrl(model.ReturnUrl) ? (IActionResult)Redirect(model.ReturnUrl) : RedirectToAction("Edit", "WorkflowType", new { id = model.WorkflowTypeId })); }
public async Task <IActionResult> Create(string activityName, ActivityEditViewModel model, string workflowsnippetname) { if (!await _authorizationService.AuthorizeAsync(User, OrchardCore.Workflows.Snippets.Permissions.ManageWorkflowSnippets)) { return(Forbid()); } // var workflowType = await _session.GetAsync<WorkflowType>(model.WorkflowTypeId); var workflowSnippet = await GetWorkFlowSnippet(workflowsnippetname); var activity = _activityLibrary.InstantiateActivity(activityName); var activityEditor = await _activityDisplayManager.UpdateEditorAsync(activity, _updateModelAccessor.ModelUpdater, isNew : true); if (!ModelState.IsValid) { activityEditor.Metadata.Type = "ActivityWorkflowSnippets_Edit"; ((dynamic)activityEditor).WorkflowSnippetName = workflowsnippetname; model.Activity = activity; model.ActivityEditor = activityEditor; return(View(model)); } var activityRecord = new ActivityRecord { ActivityId = model.ActivityId, Name = activity.Name, Properties = activity.Properties, }; workflowSnippet.WorkFlowType.Activities.Add(activityRecord); await UpdateWorkFlowSnippet(workflowsnippetname, workflowSnippet); // _session.Save(workflowType); _notifier.Success(H["Activity added successfully"]); return(Url.IsLocalUrl(model.ReturnUrl) ? (IActionResult)Redirect(model.ReturnUrl) : RedirectToAction("Edit", "WorkflowSnippetsAdmin", new { sourcename = workflowsnippetname })); }
public async Task <IActionResult> Update(string activityName, [FromForm] ActivityEditorUpdateModel model, CancellationToken cancellationToken) { var activity = await workflowTokenizer.DetokenizeActivityAsync(JToken.Parse(model.ActivityJson ?? "{}"), cancellationToken); var editorShape = await displayManager.UpdateEditorAsync(activity, this, false); if (!ModelState.IsValid) { return(View("Edit", new ActivityEditorEditViewModel { ActivityJson = JsonConvert.SerializeObject(activity), ActivityEditorShape = editorShape })); } dynamic designShape = await activityShapeFactory.BuildDesignShapeAsync(activity, cancellationToken); return(View("Display", designShape)); }