public void PopulateWorkflows() { Collection <WorkflowDescription> workflowsCollection = null; try { if (this.Uri != null) { WorkflowManagementClient client = new WorkflowManagementClient(this.Uri, this.context.ClientSettings); workflowsCollection = client.Workflows.Get(0, 100, null); } } catch (WorkflowManagementException e) { Trace.TraceError("Exception occured while fetching workflows: {0}", e); } if (workflowsCollection != null) { foreach (WorkflowDescription workflow in workflowsCollection.OrderBy(workflow => - workflow.LastModified.Ticks)) { this.Workflows.Add(new WorkflowViewModel(this.ParentScope, workflow, this.context)); } } }
public void PopulateActivities() { this.Activities.Clear(); WorkflowManagementClient client = new WorkflowManagementClient(this.Uri, this.context.ClientSettings); Task <Collection <ActivityDescription> > getActivitiesTask = client.Activities.GetAsync(0, 500, includeXaml: true); getActivitiesTask.OnSuccess( delegate(Collection <ActivityDescription> activities) { foreach (ActivityDescription activity in activities) { this.Activities.Add(new ActivityViewModel(activity)); } }); getActivitiesTask.OnFaulted( delegate(Exception exception) { Trace.TraceError("Failed to get activities: {0}", exception); }); getActivitiesTask.OnCanceled( delegate() { Trace.TraceWarning("Activity fetching was canceled."); }); }
public string deleteProcess(int P_ProcessId, bool deleteDBEntries) { InFlowDb _db = new InFlowDb(cfgSQLConnectionString); var p_Process = _db.P_Processes.Find(P_ProcessId); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + p_Process.WFM_RootScope + p_Process.WFM_ProcessScope + "/"), credentials); client.CleanUp(); if (deleteDBEntries) { var p_ProcessInstances = _db.P_ProcessInstance.Where(result => result.P_Process_Id == p_Process.Id).ToList(); foreach (var i in p_ProcessInstances) { _db.T_Tasks.RemoveRange(_db.T_Tasks.Where(result => result.P_ProcessInstance_Id == i.Id)); _db.M_Messages.RemoveRange(_db.M_Messages.Where(result => result.ProcessInstance_Id == i.Id)); } _db.P_ProcessInstance.RemoveRange(p_ProcessInstances); var p_ProcessSubjects = _db.P_ProcessSubjects.Where(result => result.Process_Id == p_Process.Id).ToList(); foreach (var ps in p_ProcessSubjects) { _db.P_WorkflowInstances.RemoveRange(_db.P_WorkflowInstances.Where(result => result.ProcessSubject_Id == ps.Id)); } _db.P_ProcessSubjects.RemoveRange(p_ProcessSubjects); _db.P_Processes.Remove(p_Process); _db.SaveChanges(); } return(p_Process.WFM_RootScope + p_Process.WFM_ProcessScope); }
/// <summary> /// create process-scope with configuration /// </summary> /// <param name="companyScopeName"></param> /// <param name="processScopeName"></param> /// <returns></returns> private string createProcessScope(string companyScopeName, string processScopeName) { IDictionary <string, string> configValues = new Dictionary <string, string> { { "cfgManagementScopeAddress", cfgWFMBaseAddress + companyScopeName + "/" + managementScopeName + "/" }, { "cfgProcessScopeAddress", cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/" }, { "cfgWFMBaseAddress", cfgWFMBaseAddress }, { "cfgWFMUsername", cfgWFMUsername }, { "cfgWFMPassword", cfgWFMPassword }, { "cfgSQLConnectionString", cfgSQLConnectionString } }; WorkflowConfiguration Configuration = new WorkflowConfiguration(); configValues.ToList().ForEach(c => Configuration.AppSettings.Add(c)); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/"), credentials); client = client.CurrentScope.PublishChildScope(processScopeName, new ScopeDescription() { UserComments = processScopeName, DefaultWorkflowConfiguration = Configuration }); string scope = client.ScopeUri.ToString(); return(scope); }
/// <summary> /// Create a new company-scope (no support for external input-pools) /// </summary> /// <param name="companyScopeName">name of the new company-scope</param> /// <param name="workflow_TaskTier_Path">filepath of the task-handler workflow</param> /// <returns></returns> public string addCompanyScope(string companyScopeName, string workflow_TaskTier_Path) { WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress), credentials); client = client.CurrentScope.PublishChildScope(companyScopeName, new ScopeDescription() { UserComments = companyScopeName }); //create management Scope createProcessScope(companyScopeName, managementScopeName); //init Task Tier client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + managementScopeName + "/"), credentials); //Console.Write("Publishing TaskTier..."); client.PublishWorkflow(workflow_TaskTier_Name, workflow_TaskTier_Path, new MatchAllSubscriptionFilter() //Filter { Matches = { { "NotificationType", "NewTask" } } }); return(client.ScopeUri.ToString()); }
public static void PublishActivity(this WorkflowManagementClient client, string name, string xamlFilePath) { client.Activities.Publish( new ActivityDescription(WorkflowUtils.Translate(xamlFilePath)) { Name = name }); }
/// <summary> /// delete an existing process/process-scope /// </summary> /// <param name="companyScopeName">name of the company-scope</param> /// <param name="processScopeName">name of the process-scope</param> /// <param name="deleteDBEntries">delete database entries?</param> /// <returns></returns> public string deleteProcess(string companyScopeName, string processScopeName) { WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/"), credentials); client.CleanUp(); return(companyScopeName + "/" + processScopeName); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); T_Task newTask = new T_Task("R", context.GetValue(globalWFId), context.GetValue(Name), false, false, context.GetValue(isEndState), "", "", context.GetValue(messages), context.GetValue(OrderId));//,0,""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); T_Task newTask = new T_Task("R", context.GetValue(globalWFId), context.GetValue(Name), false, false, context.GetValue(isEndState), "", "", context.GetValue(messages), context.GetValue(OrderId));//,0,""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
public static WorkflowManagementClient CreateForSample(string rootScope, string scopeName) { var rootClient = new WorkflowManagementClient(new Uri(rootScope)); return(rootClient.CurrentScope.PublishChildScope(scopeName, new ScopeDescription() { UserComments = string.Format("For {0} sample only", scopeName) })); }
public void terminateSubjectInstance(string workFlowId) { IProcessStore processStore = StoreHandler.getProcessStore(connectionString); var instance = processStore.getWorkflowInstance(workFlowId); var subject = instance.ProcessSubject; var process = subject.Process; WorkflowManagementClient client = new WorkflowManagementClient(new Uri(baseAddress + process.WFM_RootScope + process.WFM_ProcessScope), credentials); client.Instances.Terminate(subject.WFM_WFName, workFlowId, "ProcessEnd"); }
public void terminateSubjectInstance(string workFlowId) { IProcessStore processStore = StoreHandler.getProcessStore(connectionString); var instance = processStore.getWorkflowInstance(workFlowId); var subject = instance.ProcessSubject; var process = subject.Process; WorkflowManagementClient client = new WorkflowManagementClient(new Uri(baseAddress + process.WFM_RootScope + process.WFM_ProcessScope), credentials); client.Instances.Terminate(subject.WFM_WFName, workFlowId, "ProcessEnd"); }
/// <summary> /// List child-scopes of a given scope /// </summary> /// <param name="scope">scope</param> /// <returns>list of child-scopes</returns> private List<string> listScopes(string scope) { List<string> scopes = new List<string>(); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + scope), credentials); foreach (var i in client.CurrentScope.GetChildScopes()) { scopes.Add(i.Path.TrimStart('/')); } return scopes; }
public static WorkflowManagementClient CreateForSample(string rootScope, string scopeName, System.Net.NetworkCredential credential) { var rootClient = new WorkflowManagementClient(new Uri(rootScope), credential); return rootClient.CurrentScope.PublishChildScope(scopeName, new ScopeDescription() { UserComments = string.Format("For {0} sample only", scopeName) }); }
public string addProcess(string companyScopeName, string processScopeName, string workflow_MessageTier_Path, List <SubjectConfig> processSubjects, bool createDBEntries, string startSubjectname, int WS_Project_Id, int WS_Project_Version, string processInfo) { string scope = createProcessScope(companyScopeName, processScopeName); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/"), credentials); client.PublishWorkflow(workflow_MessageTier_Name, workflow_MessageTier_Path, new MatchAllSubscriptionFilter() //Filter { Matches = { { "NotificationType", "NewMessage" } } }); foreach (SubjectConfig process in processSubjects) { if (process.Xaml != null) { client.PublishWorkflowString(process.Name, process.Xaml); } } if (createDBEntries) { IProcessStore processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); P_Process newProcess = new P_Process(processScopeName); newProcess.WS_ProjectId = WS_Project_Id; newProcess.WS_Project_Version = WS_Project_Version; newProcess.WFM_ProcessScope = processScopeName; newProcess.ProcessInfo = processInfo; newProcess.WFM_RootScope = companyScopeName + "/"; newProcess.ProcessSubjects = new List <P_ProcessSubject>(); foreach (SubjectConfig process in processSubjects) { if (process.Xaml != null) { newProcess.ProcessSubjects.Add(new P_ProcessSubject(process.Name, process.Name.Equals(startSubjectname), process.Name, process.Role_Id, process.MultiSubject)); } else { newProcess.ProcessSubjects.Add(new P_ProcessSubject(process.Name, process.Name.Equals(startSubjectname), null, process.Role_Id, process.MultiSubject)); } } processStore.addNewProcess(newProcess); } return(scope); }
internal static Task <ServiceContext> ConnectAsync(Uri serviceUri, ClientSettings settings) { Trace.TraceInformation("Attempting to fetch the scope from {0}...", serviceUri); WorkflowManagementClient client = new WorkflowManagementClient(serviceUri, settings); TaskCompletionSource <ServiceContext> completionSource = new TaskCompletionSource <ServiceContext>(); Task <ScopeDescription> getScopeTask = client.CurrentScope.GetAsync(); getScopeTask.OnSuccess(rootScope => completionSource.SetResult(new ServiceContext(serviceUri, settings, rootScope))); getScopeTask.OnFaulted(exception => completionSource.SetException(exception)); getScopeTask.OnCanceled(() => completionSource.SetCanceled()); return(completionSource.Task); }
/// <summary> /// List child-scopes of a given scope /// </summary> /// <param name="scope">scope</param> /// <returns>list of child-scopes</returns> private List <string> listScopes(string scope) { List <string> scopes = new List <string>(); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + scope), credentials); foreach (var i in client.CurrentScope.GetChildScopes()) { scopes.Add(i.Path.TrimStart('/')); } return(scopes); }
/// <summary> /// Create a new company-scope (supporting external input-pools) /// </summary> /// <param name="companyScopeName">name of the new company-scope</param> /// <param name="workflow_TaskTier_Path">filepath of the task-handler workflow</param> /// <param name="workflow_SBMessageTier_Path">filepath of the SBMessage-handler workflow</param> /// <returns></returns> public string addCompanyScope(string companyScopeName, string workflow_TaskTier_Path, string workflow_SBMessageTier_Path) { string output = addCompanyScope(companyScopeName, workflow_TaskTier_Path); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + managementScopeName + "/"), credentials); client.PublishWorkflow(workflow_SBMessageTier_Name, workflow_SBMessageTier_Path); string guid = client.Workflows.Start(workflow_SBMessageTier_Name); return(guid); }
static void Main(string[] args) { // The following code allows a client to use a non-fully qualified name and resolves https issues such as: // System.Net.WebException: The underlying connection was closed: Could not establish trust // relationship for the SSL/TLS secure channel // NOT for production, only for limited local development. //System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate (object sender, // System.Security.Cryptography.X509Certificates.X509Certificate certificate, // System.Security.Cryptography.X509Certificates.X509Chain chain, // System.Net.Security.SslPolicyErrors sslPolicyErrors) //{ // return true; //}; Console.Write("Setting up scope..."); WorkflowManagementClient client = WorkflowUtils.CreateForSample(baseAddress, "WFMgrGettingStarted"); WorkflowUtils.PrintDone(); Console.Write("Publishing GetProducts activity..."); client.PublishActivity("GetProducts", @"..\..\..\GetProductsActivities\GetProducts.xaml"); WorkflowUtils.PrintDone(); Console.Write("Publishing Workflow..."); client.PublishWorkflow(workflowName, @"..\..\..\GetProductsActivities\GetProductsWorkflow.xaml"); WorkflowUtils.PrintDone(); Console.Write("Enter a search keyword: "); string SearchKeyword = Console.ReadLine(); Console.Write("Starting workflow instance..."); WorkflowStartParameters startParameters = new WorkflowStartParameters(); startParameters.Content.Add("SearchKeyword", SearchKeyword); string instanceId = client.Workflows.Start(workflowName, startParameters); WorkflowUtils.PrintDone(); Console.WriteLine("\nPolling UserStatus...\n"); string finalUserStatus = client.WaitForWorkflowCompletion(workflowName, instanceId); WorkflowUtils.Print("Completed with status: " + finalUserStatus, ConsoleColor.Green); Console.WriteLine("Press any key to clean up scope."); Console.ReadKey(); client.CleanUp(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
/// <summary> /// Delete entire company-scope /// </summary> /// <param name="companyScopeName">company-scope name</param> /// <param name="deleteDBEntries">delete database entries?</param> /// <returns></returns> public string deleteCompanyScope(string companyScopeName) { /*if (deleteDBEntries) * { * IProcessStore processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); * * processStore.deleteCompany(companyScopeName); * }*/ WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/"), credentials); client.CleanUp(); return(companyScopeName); }
static void Main(string[] args) { // Check test settings - you can deploy to the test host to attach visual studio to it. bool test = false; Console.WriteLine("Press t to deploy to test host"); test = Console.ReadLine().ToLower() == "t"; string baseAddress = string.Format("https://{0}:12290/", machineName); if (test) { baseAddress = string.Format("http://{0}:12292/", machineName); } // Create scope Console.Write("Setting up scope..."); WorkflowManagementClient client = WorkflowUtils.CreateForSample(baseAddress, scopeName); WorkflowUtils.PrintDone(); // Deploy all activities Console.Write("Publishing Phone activities..."); client.PublishActivity("ReceiveCallerInput", @"..\..\..\PhoneMenuWorkflows\ReceiveCallerInput.xaml"); client.PublishActivity("RetrieveUserFlights", @"..\..\..\PhoneMenuWorkflows\RetrieveUserFlights.xaml"); client.PublishActivity("SetNextOptions", @"..\..\..\PhoneMenuWorkflows\SetNextOptions.xaml"); client.PublishActivity("SayGoodbye", @"..\..\..\PhoneMenuWorkflows\SayGoodbye.xaml"); WorkflowUtils.PrintDone(); // Deploy actual workflow, by specifying the external variables Console.Write("Publishing Workflow..."); Collection <ExternalVariable> externalVariables = new Collection <ExternalVariable> { new ExternalVariable <string> { Name = "UserOptions", Default = "", Modifiers = VariableModifiers.Mapped }, new ExternalVariable <string> { Name = "PhoneNr", Default = "", Modifiers = VariableModifiers.Mapped }, new ExternalVariable <string> { Name = "GoodbyeStatement", Default = "", Modifiers = VariableModifiers.Mapped } }; client.PublishWorkflow(workflowName, @"..\..\..\PhoneMenuWorkflows\FlightMenuStateMachine.xaml", externalVariables); WorkflowUtils.PrintDone(); }
/// <summary> /// start a new instance of a processsubject with an existing processinstanceid /// </summary> /// <param name="processInstanceId">existing processinstanceid</param> /// <param name="subjectProcessId">id of the processsubject</param> /// <param name="username">owner of the new processsubject instance</param> /// <returns>id of the new workflow instance</returns> public string startNewSubjectProcess(string processInstanceId, int subjectProcessId, string username) { IProcessStore processStore = StoreHandler.getProcessStore(connectionString); Console.WriteLine("start2 " + subjectProcessId + " " + username); P_ProcessSubject subject = processStore.getProcessSubject(subjectProcessId); P_Process process = processStore.getProcess(subject.Process_Id); string adress = baseAddress + process.WFM_RootScope + process.WFM_ProcessScope; WorkflowManagementClient client = new WorkflowManagementClient(new Uri(adress), credentials); string guid = client.Workflows.Start(subject.WFM_WFName); processStore.addWorkflowInstance(subject.Id, processInstanceId, guid, username); Console.WriteLine(guid, ConsoleColor.Blue); return(guid); }
/// <summary> /// start a new instance of a processsubject with an existing processinstanceid /// </summary> /// <param name="processInstanceId">existing processinstanceid</param> /// <param name="subjectProcessId">id of the processsubject</param> /// <param name="username">owner of the new processsubject instance</param> /// <returns>id of the new workflow instance</returns> public string startNewSubjectProcess(string processInstanceId, int subjectProcessId, string username) { IProcessStore processStore = StoreHandler.getProcessStore(connectionString); Console.WriteLine("start2 " + subjectProcessId + " " + username); P_ProcessSubject subject = processStore.getProcessSubject(subjectProcessId); P_Process process = processStore.getProcess(subject.Process_Id); string adress = baseAddress + process.WFM_RootScope + process.WFM_ProcessScope; WorkflowManagementClient client = new WorkflowManagementClient(new Uri(adress), credentials); string guid = client.Workflows.Start(subject.WFM_WFName); processStore.addWorkflowInstance(subject.Id, processInstanceId, guid, username); Console.WriteLine(guid, ConsoleColor.Blue); return guid; }
public static void PublishWorkflowString(this WorkflowManagementClient client, string workflowName, string xamlFile, Collection <ExternalVariable> externalVariables, IDictionary <string, string> configValues, SubscriptionFilter activationFilter = null) { // publish the activity description related with the workflow client.Activities.Publish( new ActivityDescription(WorkflowUtils.TranslateString(xamlFile)) { Name = workflowName }, true, true); // now, publish the workflow description WorkflowDescription description = new WorkflowDescription { Name = workflowName, ActivityPath = workflowName, }; // add external variables if (externalVariables != null) { externalVariables .ToList() .ForEach(ev => description.ExternalVariables.Add(ev)); } // add config if (configValues != null) { description.Configuration = new WorkflowConfiguration(); configValues .ToList() .ForEach(c => description.Configuration.AppSettings.Add(c)); } // add activation filter if (activationFilter != null) { description.ActivationDescription = new SubscriptionActivationDescription { Filter = activationFilter }; } // publish! client.Workflows.Publish(description); }
public void PopulateInstances() { if (this.instances == null) { this.instances = new ObservableCollection <InstanceViewModel>(); } else { this.instances.Clear(); } this.instanceCount = 0; this.instances.Add(new InstanceFetchMessage("Loading...")); WorkflowManagementClient client = new WorkflowManagementClient(this.ParentScope.Uri, this.context.ClientSettings); Task <Collection <WorkflowInstanceInfo> > getInstancesTask = client.Instances.GetAsync(0, 500, this.currentWorkflow.Name); getInstancesTask.OnSuccess( delegate(Collection <WorkflowInstanceInfo> instances) { this.instanceCount = instances.Count; Trace.TraceInformation("Fetched {0} instances for workflow named '{1}'", this.instanceCount, this.currentWorkflow.Name); this.instances.Clear(); foreach (WorkflowInstanceInfo instance in instances) { InstanceViewModel instanceViewModel = new InstanceViewModel(instance); this.instances.Add(instanceViewModel); } this.RaisePropertyChanged("InstanceCount"); }); getInstancesTask.OnCanceled( delegate() { Trace.TraceError("Failed to fetch instances for workflow named '{0}' due to a timeout.", this.currentWorkflow.Name); this.instances.Clear(); this.instances.Add(new InstanceFetchMessage("Timed out while querying for instances.")); }); getInstancesTask.OnFaulted( delegate(Exception e) { Trace.TraceError("Failed to fetch instances for workflow named '{0}'", this.currentWorkflow.Name); }); }
private void submitTaskAnswer(DynamicValue val, P_Process process, T_Task openTask) { //create and publish notification WorkflowManagementClient client = new WorkflowManagementClient(new Uri(baseAddress + process.WFM_RootScope + process.WFM_ProcessScope), credentials); client.PublishNotification(new WorkflowNotification() { Properties = { { "NotificationType", "taskAnswer" }, { "wfID", openTask.WFId }, { "OrderId", openTask.InternalOrderId } }, Content = new Dictionary <string, object>() { { "data", val } } }); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); DynamicValue dvReadableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(readableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvReadableParameters.Add(i, value); } } DynamicValue dvEditableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(editableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvEditableParameters.Add(i, value); } else { DynamicValue val = new DynamicValue(); val.Add("Type", "string"); val.Add("Value", ""); dvEditableParameters.Add(i, val); } } T_Task newTask = new T_Task("S", context.GetValue(globalWFId), context.GetValue(Name), false, false, context.GetValue(isEndState), dvReadableParameters.ToString(), dvEditableParameters.ToString(), context.GetValue(toSubject), context.GetValue(OrderId));//, 0, ""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); DynamicValue dvReadableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(readableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvReadableParameters.Add(i, value); } } DynamicValue dvEditableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(editableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvEditableParameters.Add(i, value); } else { DynamicValue val = new DynamicValue(); val.Add("Type", "string"); val.Add("Value", ""); dvEditableParameters.Add(i, val); } } T_Task newTask = new T_Task("S", context.GetValue(globalWFId), context.GetValue(Name),false, false, context.GetValue(isEndState), dvReadableParameters.ToString(), dvEditableParameters.ToString(), context.GetValue(toSubject), context.GetValue(OrderId));//, 0, ""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
public static string WaitForWorkflowCompletion(this WorkflowManagementClient client, string workflowName, string instanceId, int pollingInterval = 0) { string currentStatus = string.Empty; string lastStatus = string.Empty; WorkflowInstanceInfo instanceInfo = client.Instances.Get(workflowName, instanceId); while (true) { instanceInfo = client.Instances.Get(workflowName, instanceId); currentStatus = instanceInfo.UserStatus; if (currentStatus != lastStatus && !string.IsNullOrWhiteSpace(currentStatus)) { Console.Write(" Current Status: "); WorkflowUtils.Print(currentStatus, ConsoleColor.Cyan); lastStatus = currentStatus; } if (instanceInfo.WorkflowStatus == WorkflowInstanceStatus.Started || instanceInfo.WorkflowStatus == WorkflowInstanceStatus.NotStarted) { Thread.Sleep(pollingInterval); continue; } if (instanceInfo.WorkflowStatus == WorkflowInstanceStatus.Completed) { Console.WriteLine("\nWorkflow instance completed"); } break; } return(instanceInfo.UserStatus); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); //set message data DynamicValue data = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(parameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); data.Add(i, value); } } List <string> recipients = new List <string>(context.GetValue(recipient).Split(',')); List <M_Message> messages = new List <M_Message>(); if (recipients.Count == 1) { List <string> usernames = new List <string>(); IUserStore userStore = StoreHandler.getUserStore(context.GetValue(cfgSQLConnectionString)); string[] recipientArray = recipients[0].Split('|'); string recipientSubject = recipientArray[0]; IProcessStore processStore = StoreHandler.getProcessStore(context.GetValue(cfgSQLConnectionString)); P_ProcessSubject senderSubject = processStore.getProcessSubjectForWFId(context.GetValue(globalWFId)); P_WorkflowInstance senderinstance = processStore.getWorkflowInstance(context.GetValue(globalWFId)); P_ProcessSubject recipientSubjet = processStore.getProcessSubject(senderSubject.Process_Id, recipientSubject); if (recipientSubjet.MultiSubject && recipientArray.Length == 1)//If multisubject { P_WorkflowInstance recipientInstance = processStore.getWorkflowInstance(recipientSubjet.Id, senderinstance.ProcessInstance_Id, null); //Check if Recipientinstance already Exists if (recipientInstance != null) { //recipients are only existing processsubjectinstances usernames = processStore.getWorkflowInstanceOwnersForMultisubjects(recipientInstance.ProcessSubject_Id, recipientInstance.ProcessInstance_Id); } else { //recipients are all users who represent the processsubject // usernames = subjectStore.getUsernamesForSubjectName(recipientArray[0]); usernames = userStore.getUsernamesForRole(recipientSubjet.U_Role_Id); } foreach (string user in usernames) { M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, user, context.GetValue(type), data.ToString()); messages.Add(m); } } else { //simple Subject string recipientUsername = ""; if (recipientArray.Length > 1) { recipientUsername = recipientArray[1]; } M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, recipientUsername, context.GetValue(type), data.ToString()); messages.Add(m); } } else //multisubject { foreach (string rec in recipients) { string[] recipientArray = rec.Split('|'); string recipientSubject = recipientArray[0]; string recipientUsername = ""; if (recipientArray.Length > 1) { recipientUsername = recipientArray[1]; } M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, recipientUsername, context.GetValue(type), data.ToString()); messages.Add(m); } } WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgProcessScopeAddress)), credentials); messages.ForEach(m => client.PublishNotification(m.toWorkflowNotification())); }
/// <summary> /// Create a new company-scope (no support for external input-pools) /// </summary> /// <param name="companyScopeName">name of the new company-scope</param> /// <param name="workflow_TaskTier_Path">filepath of the task-handler workflow</param> /// <returns></returns> public string addCompanyScope(string companyScopeName, string workflow_TaskTier_Path) { WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress), credentials); client = client.CurrentScope.PublishChildScope(companyScopeName, new ScopeDescription() { UserComments = companyScopeName }); //create management Scope createProcessScope(companyScopeName, managementScopeName); //init Task Tier client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + managementScopeName + "/"), credentials); //Console.Write("Publishing TaskTier..."); client.PublishWorkflow(workflow_TaskTier_Name, workflow_TaskTier_Path, new MatchAllSubscriptionFilter() //Filter { Matches = { { "NotificationType" , "NewTask" } } }); return client.ScopeUri.ToString(); }
/// <summary> /// Delete entire company-scope /// </summary> /// <param name="companyScopeName">company-scope name</param> /// <param name="deleteDBEntries">delete database entries?</param> /// <returns></returns> public string deleteCompanyScope(string companyScopeName) { /*if (deleteDBEntries) { IProcessStore processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); processStore.deleteCompany(companyScopeName); }*/ WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/"), credentials); client.CleanUp(); return companyScopeName; }
/// <summary> /// create process-scope with configuration /// </summary> /// <param name="companyScopeName"></param> /// <param name="processScopeName"></param> /// <returns></returns> private string createProcessScope(string companyScopeName, string processScopeName) { IDictionary<string, string> configValues = new Dictionary<string, string> { { "cfgManagementScopeAddress", cfgWFMBaseAddress + companyScopeName + "/"+managementScopeName+"/" }, { "cfgProcessScopeAddress", cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/" }, { "cfgWFMBaseAddress" , cfgWFMBaseAddress}, { "cfgWFMUsername", cfgWFMUsername }, { "cfgWFMPassword", cfgWFMPassword}, { "cfgSQLConnectionString", cfgSQLConnectionString } }; WorkflowConfiguration Configuration = new WorkflowConfiguration(); configValues.ToList().ForEach(c => Configuration.AppSettings.Add(c)); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/"), credentials); client = client.CurrentScope.PublishChildScope(processScopeName, new ScopeDescription() { UserComments = processScopeName, DefaultWorkflowConfiguration = Configuration }); string scope = client.ScopeUri.ToString(); return scope; }
private void submitTaskAnswer(DynamicValue val, P_Process process, T_Task openTask) { //create and publish notification WorkflowManagementClient client = new WorkflowManagementClient(new Uri(baseAddress + process.WFM_RootScope + process.WFM_ProcessScope), credentials); client.PublishNotification(new WorkflowNotification() { Properties = { { "NotificationType", "taskAnswer" }, { "wfID", openTask.WFId }, { "OrderId", openTask.InternalOrderId } }, Content = new Dictionary<string, object>() { { "data", val } } }); }
/// <summary> /// delete an existing process/process-scope /// </summary> /// <param name="companyScopeName">name of the company-scope</param> /// <param name="processScopeName">name of the process-scope</param> /// <param name="deleteDBEntries">delete database entries?</param> /// <returns></returns> public string deleteProcess(string companyScopeName, string processScopeName) { WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/"), credentials); client.CleanUp(); return companyScopeName + "/" + processScopeName; }
public string deleteProcess(int P_ProcessId, bool deleteDBEntries) { InFlowDb _db = new InFlowDb(cfgSQLConnectionString); var p_Process = _db.P_Processes.Find(P_ProcessId); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + p_Process.WFM_RootScope + p_Process.WFM_ProcessScope + "/"), credentials); client.CleanUp(); if (deleteDBEntries) { var p_ProcessInstances = _db.P_ProcessInstance.Where(result => result.P_Process_Id == p_Process.Id).ToList(); foreach(var i in p_ProcessInstances) { _db.T_Tasks.RemoveRange(_db.T_Tasks.Where(result => result.P_ProcessInstance_Id == i.Id)); _db.M_Messages.RemoveRange(_db.M_Messages.Where(result => result.ProcessInstance_Id == i.Id)); } _db.P_ProcessInstance.RemoveRange(p_ProcessInstances); var p_ProcessSubjects = _db.P_ProcessSubjects.Where(result => result.Process_Id == p_Process.Id).ToList(); foreach(var ps in p_ProcessSubjects) { _db.P_WorkflowInstances.RemoveRange(_db.P_WorkflowInstances.Where(result => result.ProcessSubject_Id == ps.Id)); } _db.P_ProcessSubjects.RemoveRange(p_ProcessSubjects); _db.P_Processes.Remove(p_Process); _db.SaveChanges(); } return p_Process.WFM_RootScope + p_Process.WFM_ProcessScope; }
public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, IDictionary <string, string> configValues, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, xamlFilePath, null, configValues, activationFilter); }
public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, Collection <ExternalVariable> externalVariables, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, xamlFilePath, externalVariables, null, activationFilter); }
public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string XamlFile, SubscriptionFilter activationFilter = null) { PublishWorkflow(client, workflowName, XamlFile, null, null, activationFilter); }
public static void PublishWorkflowString(this WorkflowManagementClient client, string workflowName, string xamlFilePath, SubscriptionFilter activationFilter = null) { PublishWorkflowString(client, workflowName, xamlFilePath, null, null, activationFilter); }
public string addProcess(string companyScopeName, string processScopeName, string workflow_MessageTier_Path, List<SubjectConfig> processSubjects, bool createDBEntries, string startSubjectname, int WS_Project_Id, int WS_Project_Version, string processInfo) { string scope = createProcessScope(companyScopeName, processScopeName); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + processScopeName + "/"), credentials); client.PublishWorkflow(workflow_MessageTier_Name, workflow_MessageTier_Path, new MatchAllSubscriptionFilter() //Filter { Matches = { { "NotificationType" , "NewMessage" } } }); foreach (SubjectConfig process in processSubjects) { if (process.Xaml != null) { client.PublishWorkflowString(process.Name, process.Xaml); } } if (createDBEntries) { IProcessStore processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); P_Process newProcess = new P_Process(processScopeName); newProcess.WS_ProjectId = WS_Project_Id; newProcess.WS_Project_Version = WS_Project_Version; newProcess.WFM_ProcessScope = processScopeName; newProcess.ProcessInfo = processInfo; newProcess.WFM_RootScope = companyScopeName + "/"; newProcess.ProcessSubjects = new List<P_ProcessSubject>(); foreach (SubjectConfig process in processSubjects) { if (process.Xaml != null) newProcess.ProcessSubjects.Add(new P_ProcessSubject(process.Name, process.Name.Equals(startSubjectname), process.Name, process.Role_Id, process.MultiSubject)); else newProcess.ProcessSubjects.Add(new P_ProcessSubject(process.Name, process.Name.Equals(startSubjectname), null, process.Role_Id, process.MultiSubject)); } processStore.addNewProcess(newProcess); } return scope; }
public static void CleanUp(this WorkflowManagementClient client) { client.CurrentScope.Delete(); }
/// <summary> /// Create a new company-scope (supporting external input-pools) /// </summary> /// <param name="companyScopeName">name of the new company-scope</param> /// <param name="workflow_TaskTier_Path">filepath of the task-handler workflow</param> /// <param name="workflow_SBMessageTier_Path">filepath of the SBMessage-handler workflow</param> /// <returns></returns> public string addCompanyScope(string companyScopeName, string workflow_TaskTier_Path, string workflow_SBMessageTier_Path) { string output = addCompanyScope(companyScopeName, workflow_TaskTier_Path); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(cfgWFMBaseAddress + companyScopeName + "/" + managementScopeName + "/"), credentials); client.PublishWorkflow(workflow_SBMessageTier_Name, workflow_SBMessageTier_Path); string guid = client.Workflows.Start(workflow_SBMessageTier_Name); return guid; }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); //set message data DynamicValue data = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(parameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); data.Add(i, value); } } List<string> recipients = new List<string>(context.GetValue(recipient).Split(',')); List<M_Message> messages = new List<M_Message>(); if (recipients.Count == 1) { List<string> usernames = new List<string>(); IUserStore userStore = StoreHandler.getUserStore(context.GetValue(cfgSQLConnectionString)); string[] recipientArray = recipients[0].Split('|'); string recipientSubject = recipientArray[0]; IProcessStore processStore = StoreHandler.getProcessStore(context.GetValue(cfgSQLConnectionString)); P_ProcessSubject senderSubject = processStore.getProcessSubjectForWFId(context.GetValue(globalWFId)); P_WorkflowInstance senderinstance = processStore.getWorkflowInstance(context.GetValue(globalWFId)); P_ProcessSubject recipientSubjet = processStore.getProcessSubject(senderSubject.Process_Id, recipientSubject); if (recipientSubjet.MultiSubject && recipientArray.Length == 1)//If multisubject { P_WorkflowInstance recipientInstance = processStore.getWorkflowInstance(recipientSubjet.Id, senderinstance.ProcessInstance_Id, null); //Check if Recipientinstance already Exists if (recipientInstance != null) { //recipients are only existing processsubjectinstances usernames = processStore.getWorkflowInstanceOwnersForMultisubjects(recipientInstance.ProcessSubject_Id, recipientInstance.ProcessInstance_Id); } else { //recipients are all users who represent the processsubject // usernames = subjectStore.getUsernamesForSubjectName(recipientArray[0]); usernames = userStore.getUsernamesForRole(recipientSubjet.U_Role_Id); } foreach (string user in usernames) { M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, user, context.GetValue(type), data.ToString()); messages.Add(m); } } else { //simple Subject string recipientUsername = ""; if (recipientArray.Length > 1) { recipientUsername = recipientArray[1]; } M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, recipientUsername, context.GetValue(type), data.ToString()); messages.Add(m); } } else //multisubject { foreach (string rec in recipients) { string[] recipientArray = rec.Split('|'); string recipientSubject = recipientArray[0]; string recipientUsername = ""; if (recipientArray.Length > 1) { recipientUsername = recipientArray[1]; } M_Message m = new M_Message(context.GetValue(globalWFId), recipientSubject, recipientUsername, context.GetValue(type), data.ToString()); messages.Add(m); } } WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgProcessScopeAddress)), credentials); messages.ForEach(m => client.PublishNotification(m.toWorkflowNotification())); }