protected override void Execute(CodeActivityContext context) { DynamicValue data = context.GetValue(this.Data); //set transition DynamicValue transition = new DynamicValue(); data.TryGetValue("transition", out transition); context.SetValue(GlobalTransition, transition.ToString()); data.Remove("transition"); //write parameters DynamicValue variables = context.GetValue(GlobalVariables); foreach (string i in data.Keys) { DynamicValue value = new DynamicValue(); data.TryGetValue(i, out value); if (variables.ContainsKey(i)) { variables.Remove(i); } variables.Add(i, value); } context.SetValue(GlobalVariables, variables); }
protected override void Execute(CodeActivityContext context) { DynamicValue taskdata = context.GetValue(this.Data); DynamicValue MessageId = new DynamicValue(); taskdata.TryGetValue("MessageId", out MessageId); IMessageStore messageStore = strICT.InFlow.Db.StoreHandler.getMessageStore(context.GetValue(cfgSQLConnectionString)); M_Message message = messageStore.getMessageBymsgId(Convert.ToInt32(MessageId.ToString())); //store message-type in GlobalTransition context.SetValue(GlobalTransition, message.Sender_SubjectName + "|" + message.Message_Type); DynamicValue data = DynamicValue.Parse(message.Data); DynamicValue variables = context.GetValue(GlobalVariables); //write message data to GlobalVariables foreach (string i in data.Keys) { DynamicValue value = new DynamicValue(); data.TryGetValue(i, out value); if (variables.ContainsKey(i)) { variables.Remove(i); } variables.Add(i, value); } context.SetValue(GlobalVariables, variables); //mark message in message-store as received messageStore.markMessageAsReceived(message.Id); }
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); //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())); }