Example #1
0
        protected override void Execute(CodeActivityContext context)
        {
            IMessageStore messageStore = StoreHandler.getMessageStore(context.GetValue(cfgSQLConnectionString));

            M_Message m = new M_Message(context.GetValue(SenderId), context.GetValue(RecipientSubject), context.GetValue(RecipientUsername), context.GetValue(Type), context.GetValue(Data));
            m.GlobalProcessName = context.GetValue(GlobalProcessName);
            m.ProcessInstance_Id = context.GetValue(ProcessInstanceId);
            m.Sender_SubjectName = context.GetValue(SenderSubject); 
            m.Sender_Username = context.GetValue(SenderUsername);
            m.Recipient_WF_Id = context.GetValue(RecipientId);
            m.Recipient_Role_Id = context.GetValue(Recipient_Role_Id);
            m.Received = false;
            m.Notified = false;

            int id = messageStore.addMessage(m);

            context.SetValue(MessageId, id);
        }
Example #2
0
 public int addMessage(M_Message message)
 {
     db.M_Messages.Add(message);
     db.SaveChanges();
     return message.Id;
 }
Example #3
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;
            }
        }
Example #4
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()));
        }
        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);
            }
        }