Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        public String getStateBody(T_Task task, string baseURL, string templatepath)
        {
            this.templatepath = templatepath;
            this.task = task;
            this.baseURL = baseURL;

            if (task.Type.Equals("F"))
            {
                return getFunctionStateBody();
            }

            if (task.Type.Equals("S"))
            {
                return getSendStateBody();
            }
            return null;
        }
Ejemplo n.º 3
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);
            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());

        }
Ejemplo n.º 4
0
        public String getReceiveStateBody(M_Message message, T_Task task, string baseURL, string templatepath)
        {
            this.templatepath = templatepath;
            this.baseURL = baseURL;
            try
            {

                StreamReader reader = new StreamReader(templatepath);
                String body = reader.ReadToEnd();

                String tmp = "";

                tmp += "<h3>" + task.Name + "</h3>";
                tmp += "<h2>" + message.Message_Type + " from " + message.Sender_Username + "</h2>";
                tmp += "Platzhalter Prozessinfo";


                body = body.Replace("#CONTENT#", tmp);


                string Link = createURL(task.Id);
                body = body.Replace("#LINK#", Link);

                return body;
            }
            catch (Exception e)
            {
                String body = message.Message_Type;

                return body;
            }
        }
Ejemplo n.º 5
0
 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 }
                 }
     });
 }
Ejemplo n.º 6
0
        public T_Task addTask(T_Task newTask)
        {

            db.T_Tasks.Add(newTask);
            db.SaveChanges();

            return newTask;
        }
Ejemplo n.º 7
0
        protected override void Execute(CodeActivityContext context)
        {
            string editableparameters = context.GetValue(EditableParameters);
            string log = "";
            try
            {

                bool toMultiSubject = false;

                ITaskStore taskStore = StoreHandler.getTaskStore(context.GetValue(cfgSQLConnectionString));

                IProcessStore processStore = StoreHandler.getProcessStore(context.GetValue(cfgSQLConnectionString));
                P_WorkflowInstance creatorinstance = null;
                int timer = 1;
                do
                {
                    try
                    {
                        creatorinstance = processStore.getWorkflowInstance(context.GetValue(WFId));
                    }
                    catch (Exception e)
                    {
                        log = log + "[" + timer + ": " + e.Message + "]";
                        creatorinstance = null;
                        System.Threading.Thread.Sleep(500 * timer);
                        timer++;
                    }
                } while (creatorinstance == null && timer < 20);
                log = log + "(Timer: " + timer + ")";

                string taskProperties = context.GetValue(TaskProperties);
                string subjectname = taskProperties.Split('|')[0];

                //check if the task is a send-task
                if (context.GetValue(Type).Equals("S"))
                {

                    P_ProcessSubject creatorSubject = processStore.getProcessSubjectForWFId(context.GetValue(WFId));

                    P_ProcessSubject recipientSubjet = processStore.getProcessSubject(creatorSubject.Process_Id, subjectname);

                    P_WorkflowInstance recipientInstance = processStore.getWorkflowInstance(recipientSubjet.Id, creatorinstance.ProcessInstance_Id, null);

                    if (recipientSubjet.MultiSubject)
                    {
                        toMultiSubject = true;
                    }

                    //Check if Recipientinstance already Exists
                    if (recipientInstance != null)
                    {
                        //Check if recipient is a multisubject
                        if (recipientSubjet.MultiSubject)
                        {
                            //Multisubject
                            List<string> users = processStore.getWorkflowInstanceOwnersForMultisubjects(recipientInstance.ProcessSubject_Id, recipientInstance.ProcessInstance_Id);
                            users.ForEach(user => taskProperties = taskProperties + "," + subjectname + "|" + user);
                        }
                        else
                        {
                            //Normal Subject
                            if (recipientInstance.Owner != null)
                            {
                                if (recipientInstance.Owner.Length > 0)
                                {
                                    taskProperties = subjectname + "|" + recipientInstance.Owner;
                                }
                            }
                        }
                    }
                    else
                    {
                        //If instance doesn't exist
                        IUserStore userStore = StoreHandler.getUserStore(context.GetValue(cfgSQLConnectionString));
                        //List<string> username = subjectStore.getUsernamesForSubjectName(taskProperties.Split('|')[0]);
                        List<string> username = userStore.getUsernamesForRole(recipientSubjet.U_Role_Id);

                        username.ForEach(user => taskProperties = taskProperties + "," + subjectname + "|" + user);
                    }
                }
                if (context.GetValue(Type).Equals("S") || context.GetValue(Type).Equals("F"))
                {
                    if (editableparameters.Length > 0)
                    {
                        IDictionary<string, dynamic> ob = Newtonsoft.Json.JsonConvert.DeserializeObject<IDictionary<string, dynamic>>(editableparameters);

                        foreach (KeyValuePair<string, dynamic> i in ob)
                        {
                            if (ob[i.Key].Type.Value.Equals("bobasic"))
                            {
                                dynamic boconf = ob[i.Key].Value;
                                if (boconf.boi < 0)
                                {
                                    int id = (int)boconf.bo.Value;

                                    int newid = InitializeBO.initializeBO(id, context.GetValue(cfgSQLConnectionString));
                                    ob[i.Key].Value.boi = newid;
                                }
                            }
                        }
                        editableparameters = Newtonsoft.Json.JsonConvert.SerializeObject(ob);
                    }
                }

                //store task
                T_Task newTask = new T_Task(context.GetValue(Type), context.GetValue(WFId), context.GetValue(Name), context.GetValue(Done), false, context.GetValue(IsEndState), context.GetValue(ReadableParameters), editableparameters, taskProperties, context.GetValue(InternalOrderId));//, creatorinstance.ProcessSubject_Id, creatorinstance.Id);
                newTask.ToMultiSubject = toMultiSubject;
                newTask.P_ProcessInstance_Id = creatorinstance.ProcessInstance_Id;
                newTask.P_ProcessSubject_Id = creatorinstance.ProcessSubject_Id;
                var createdTask = taskStore.addTask(newTask);

                context.SetValue(TaskId, createdTask.Id);

            }catch (Exception e)
                {
                    string message = "[ cfgSQLConnectionString: " + context.GetValue(cfgSQLConnectionString);
                    message = message + "| WFId: " + context.GetValue(WFId) + "][" + log + "]";

                    message = message + e.Message;

                    throw new Exception(message);
                }
        }
Ejemplo n.º 8
0
        private void createReceiveNotification(M_Message message, T_Task task)
        {

            if (message.Notified == false)
            {
                helper = new MailBodyHelper();
                string content = helper.getReceiveStateBody(message, task, baseURL, templatepath);

                List<string> recipients = new List<string>();

                if (String.IsNullOrEmpty(instance.Owner))
                {
                    var subject = processStore.getProcessSubjectForWFId(task.WFId);
                    userStore = StoreHandler.getUserStore(cfgSQLConnectionString);
                    recipients.AddRange(userStore.getUsernamesForRole(subject.U_Role_Id));
                }
                else
                {
                    recipients.Add(instance.Owner);
                }

                foreach (string user in recipients)
                {
                    mail.sendMail(user, "InFlow: " + task.Name + " #" + task.Id + "|" + message.Id, content);
                }

                messageStore.markMessageAsNotified(message.Id);
            }
        }