public async Task <ActionResult> ProvisionWorkflowPost() { var token = await O365Util.GetAccessToken(ServiceResources.Dashboard); var suiteLevelWebAppUrl = Regex.Match(Request.Url.AbsoluteUri, "https?://[^/]+?(?=/)", RegexOptions.Compiled).Value; using (var clientContext = TokenHelper.GetClientContextWithAccessToken(DemoSiteCollectionUrl, token)) { var service = new WorkflowProvisionService(clientContext); var incidentsList = CSOMUtil.getListByTitle(clientContext, "Incidents"); service.Unsubscribe(incidentsList.Id, "Incident"); service.DeleteDefinitions("Incident"); service.DeleteList("Incident Workflow Tasks"); service.DeleteList("Incident Workflow History"); var workflow = System.IO.File.ReadAllText(Server.MapPath("~/Workflows/Incident.xaml")); workflow = workflow.Replace("(SuiteLevelWebAppUrlPlaceholder)", suiteLevelWebAppUrl) .Replace("(dispatcherPlaceHolder)", ConfigurationManager.AppSettings["DispatcherName"]); workflow = WorkflowUtil.TranslateWorkflow(workflow); var definitionId = service.SaveDefinitionAndPublish("Incident", workflow); var taskListId = service.CreateTaskList("Incident Workflow Tasks"); var historyListId = service.CreateHistoryList("Incident Workflow History"); service.Subscribe("Incident Workflow", definitionId, incidentsList.Id, WorkflowSubscritpionEventType.ItemAdded, taskListId, historyListId); ViewBag.Message = "Incident Workflow, Incident Workflow Tasks list and Incident Workflow History list have been created successfully. Click the Create Sample Data menu item to proceed."; } return(View()); }
public void RemoveIncidentWorkflowAndRelatedLists() { var incidentsList = CSOMUtil.GetListByTitle(clientContext, "Incidents"); var service = new WorkflowProvisionService(clientContext); service.Unsubscribe(incidentsList.Id, "Incident"); service.DeleteDefinitions("Incident"); service.DeleteList("Incident Workflow Tasks"); service.DeleteList("Incident Workflow History"); }