Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
        /// <summary>
        /// Set taskanswer for a receive-task
        /// </summary>
        /// <param name="taskId">Id of the task</param>
        /// <param name="messageInstanceId">Id of the choosen message</param>
        /// <param name="username">username</param>
        public void submitReceiveTaskAnswer(int taskId, string messageInstanceId, string username)
        {
            IProcessStore processStore = StoreHandler.getProcessStore(connectionString);
            ITaskStore    taskStore    = StoreHandler.getTaskStore(connectionString);

            T_Task openTask = taskStore.getTaskById(taskId);

            //check if task isn't already answered
            if (openTask.Done == false && openTask.Type.Equals("R"))
            {
                P_ProcessSubject processSubject = processStore.getProcessSubjectForWFId(openTask.WFId);
                P_Process        process        = processStore.getProcess(processSubject.Process_Id);

                DynamicValue val = new DynamicValue();
                val.Add("MessageId", new DynamicValue(messageInstanceId));

                submitTaskAnswer(val, process, openTask);

                //set task as answered
                //taskStore.setTaskStatus(taskId, true);
                taskStore.setTaskStatus(taskId, username, "", messageInstanceId);

                //set the owner of the task recipient instance to the user who submitted the taskanswer
                processStore.setWorkflowInstanceOwner(openTask.WFId, username);
            }
        }
        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());

        }
        /// <summary>
        /// Set taskanswer for a send-state task
        /// </summary>
        /// <param name="taskId">Id of the task</param>
        /// <param name="recipientName">choosen recipient/s</param>
        /// <param name="editableParameters">edited parameters</param>
        public void submitSendTaskAnswer(int taskId, string recipientName, string editableParameters, string username)
        {
            IProcessStore processStore = StoreHandler.getProcessStore(connectionString);
            ITaskStore    taskStore    = StoreHandler.getTaskStore(connectionString);

            T_Task openTask = taskStore.getTaskById(taskId);

            //check if task isn't already answered
            if (openTask.Done == false && openTask.Type.Equals("S"))
            {
                P_ProcessSubject processSubject = processStore.getProcessSubjectForWFId(openTask.WFId);
                P_Process        process        = processStore.getProcess(processSubject.Process_Id);

                DynamicValue val = DynamicValue.Parse(editableParameters);
                val.Add("recipient", new DynamicValue(recipientName));

                submitTaskAnswer(val, process, openTask);

                //set task as answered
                //taskStore.setTaskStatus(taskId, true);
                taskStore.setTaskStatus(taskId, username, editableParameters, recipientName);
            }
        }
Exemple #7
0
        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>
        /// Set taskanswer for a receive-task
        /// </summary>
        /// <param name="taskId">Id of the task</param>
        /// <param name="messageInstanceId">Id of the choosen message</param>
        /// <param name="username">username</param>
        public void submitReceiveTaskAnswer(int taskId, string messageInstanceId, string username)
        {
            IProcessStore processStore = StoreHandler.getProcessStore(connectionString);
            ITaskStore taskStore = StoreHandler.getTaskStore(connectionString);

            T_Task openTask = taskStore.getTaskById(taskId);

            //check if task isn't already answered
            if (openTask.Done == false && openTask.Type.Equals("R"))
            {
                P_ProcessSubject processSubject = processStore.getProcessSubjectForWFId(openTask.WFId);
                P_Process process = processStore.getProcess(processSubject.Process_Id);

                DynamicValue val = new DynamicValue();
                val.Add("MessageId", new DynamicValue(messageInstanceId));

                submitTaskAnswer(val, process, openTask);

                //set task as answered
                //taskStore.setTaskStatus(taskId, true);
                taskStore.setTaskStatus(taskId, username, "", messageInstanceId);

                //set the owner of the task recipient instance to the user who submitted the taskanswer
                processStore.setWorkflowInstanceOwner(openTask.WFId, username);
            }
        }
        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()));
        }