Example #1
0
        /// <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);
            }
        }
Example #2
0
 /// <summary>
 /// Describes an object capable of managing <see cref="Process"/> and <see cref="ActorAction"/> resources.
 /// </summary>
 public ProcessFacade(ILogger <ProcessFacade> logger, IProcessStore processStore, IApprovalsLegacyStore approvalsLegacyStore, ISecurityStore securityStore)
 {
     _logger               = logger ?? throw new ArgumentNullException(nameof(logger));
     _processStore         = processStore ?? throw new ArgumentNullException(nameof(processStore));
     _approvalsLegacyStore = approvalsLegacyStore ?? throw new ArgumentNullException(nameof(approvalsLegacyStore));
     _securityStore        = securityStore ?? throw new ArgumentNullException(nameof(securityStore));
 }
Example #3
0
        public List <M_Message> getMessagesForReceiveStateTask(string workflowInstanceGuid, List <string> messageTypes)
        {
            List <M_Message> tmp          = new List <M_Message>();
            IProcessStore    processStore = StoreHandler.getProcessStore(connectionString);

            //string wfOwner = processStore.getWorkflowInstance(workflowInstanceGuid).Owner;

            var query = from m in db.M_Messages
                        where m.Recipient_WF_Id == workflowInstanceGuid & m.Received == false
                        select m;

            foreach (var item in query)
            {
                foreach (String s in messageTypes)
                {
                    String[] sa = s.Split('|');
                    String   possibleFromSubject = sa[0];
                    String   possibleMessageType = sa[1];


                    if (item.Message_Type.Equals(possibleMessageType) &&
                        item.Sender_SubjectName.Equals(possibleFromSubject))
                    {
                        tmp.Add(item);
                    }
                }
            }


            return(tmp);
        }
Example #4
0
        protected override void Execute(CodeActivityContext context)
        {
            IProcessStore      processStore    = StoreHandler.getProcessStore(context.GetValue(cfgSQLConnectionString));
            ITaskStore         taskStore       = StoreHandler.getTaskStore(context.GetValue(cfgSQLConnectionString));
            P_WorkflowInstance creatorinstance = processStore.getWorkflowInstance(context.GetValue(WFId));

            processStore.updateWorkflowInstanceEndState(creatorinstance.Id, context.GetValue(IsEndState));

            if (processStore.hasProcessEnded(creatorinstance.ProcessInstance_Id))
            {
                processStore.markProcessInstanceAsEnded(creatorinstance.ProcessInstance_Id, creatorinstance.ProcessSubject_Id, creatorinstance.Owner);
                taskStore.setAllTasksForProcessInstanceAsDone(creatorinstance.ProcessInstance_Id);

                var           instances = processStore.getWFInstanceIdsForProcessInstance(creatorinstance.ProcessInstance_Id);
                CoreFunctions c         = new CoreFunctions(context.GetValue(cfgWFMBaseAddress), context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword), context.GetValue(cfgSQLConnectionString));
                foreach (var i in instances)
                {
                    try
                    {
                        c.terminateSubjectInstance(i);
                    }
                    catch (Exception e)
                    { }
                }
            }
        }
 /// <summary>
 /// Describes an object capable of managing <see cref="Activity"/> and <see cref="ActorAction"/> resources.
 /// </summary>
 public ActivityFacade(ILogger <ActivityFacade> logger, IActivityStore activityStore, IProcessStore processStore, IApprovalsLegacyStore approvalsLegacyStore, IPersonIdentificationStore personIdentificationStore, ISecurityStore securityStore)
 {
     _logger                    = logger ?? throw new ArgumentNullException(nameof(logger));
     _processStore              = processStore ?? throw new ArgumentNullException(nameof(processStore));
     _activityStore             = activityStore ?? throw new ArgumentNullException(nameof(activityStore));
     _approvalsLegacyStore      = approvalsLegacyStore ?? throw new ArgumentNullException(nameof(approvalsLegacyStore));
     _personIdentificationStore = personIdentificationStore ?? throw new ArgumentNullException(nameof(personIdentificationStore));
     _securityStore             = securityStore ?? throw new ArgumentNullException(nameof(securityStore));
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PublishMessagesMiddleware{TState, TProcessHandler}"/> class.
 /// </summary>
 /// <param name="commandBus">Command bus.</param>
 /// <param name="notificationBus">Notification bus.</param>
 /// <param name="store">Process manager command store.</param>
 public PublishMessagesMiddleware(
     ICommandBus <DefaultCommandBusOptions> commandBus,
     INotificationBus notificationBus,
     IProcessStore <TProcessHandler> store)
 {
     this.commandBus      = commandBus;
     this.notificationBus = notificationBus;
     this.store           = store;
 }
        public void createNotificationForTask(int TaskId, string cfgSQLConnectionString)
        {
            this.cfgSQLConnectionString = cfgSQLConnectionString;
            configStore  = StoreHandler.getConfigStore(cfgSQLConnectionString);
            baseURL      = configStore.getString(BaseURL);
            templatepath = configStore.getString(Email_NotificationTemplate);

            taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString);
            T_Task task = taskStore.getTaskById(TaskId);

            helper       = new MailBodyHelper();
            processStore = StoreHandler.getProcessStore(cfgSQLConnectionString);
            instance     = processStore.getWorkflowInstance(task.WFId);
            mail         = new SmtpUtils(configStore);
            if (task.Type.Equals("F") || task.Type.Equals("S"))
            {
                if (configStore.getBool(Email_Notifications_Tasks))
                {
                    string content = helper.getStateBody(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, content);
                    }
                }
            }
            if (task.Type.Equals("R"))
            {
                if (configStore.getBool(Email_Notifications_Messages))
                {
                    messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString);
                    var messages = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString());

                    foreach (var i in messages)
                    {
                        createReceiveNotification(i, task);
                    }
                }
            }
        }
        public void createNotificationForTask(int TaskId, string cfgSQLConnectionString)
        {
            this.cfgSQLConnectionString = cfgSQLConnectionString;
            configStore = StoreHandler.getConfigStore(cfgSQLConnectionString);
            baseURL = configStore.getString(BaseURL);
            templatepath = configStore.getString(Email_NotificationTemplate);

            taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString);
            T_Task task = taskStore.getTaskById(TaskId);
            helper = new MailBodyHelper();
            processStore = StoreHandler.getProcessStore(cfgSQLConnectionString);
            instance = processStore.getWorkflowInstance(task.WFId);
            mail = new SmtpUtils(configStore);
            if (task.Type.Equals("F") || task.Type.Equals("S"))
            {
                if (configStore.getBool(Email_Notifications_Tasks))
                {
                    string content = helper.getStateBody(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, content);
                    }
                }
            }
            if (task.Type.Equals("R"))
            {
                if (configStore.getBool(Email_Notifications_Messages))
                {
                    messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString);
                    var messages = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString());

                    foreach (var i in messages)
                    {
                        createReceiveNotification(i, task);
                    }
                }
            }

        }
Example #9
0
        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");
        }
Example #10
0
        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);
        }
Example #11
0
        /// <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);
        }
Example #12
0
        protected override void Execute(CodeActivityContext context)
        {
            IProcessStore      processStore         = StoreHandler.getProcessStore(context.GetValue(cfgSQLConnectionString));
            P_WorkflowInstance senderInstance       = processStore.getWorkflowInstance(context.GetValue(SenderId));
            P_ProcessSubject   senderProcessSubject = processStore.getProcessSubject(senderInstance.ProcessSubject_Id);
            P_Process          process = processStore.getProcess(senderProcessSubject.Process_Id);
            P_ProcessSubject   recipientProcessSubject = processStore.getProcessSubject(senderProcessSubject.Process_Id, context.GetValue(RecipientSubject));

            //check if message is for internal subject
            if (recipientProcessSubject.WFM_WFName != null)
            {
                string recipientuser = context.GetValue(RecipientUsername);
                if (recipientuser != null)
                {
                    if (recipientuser.Length == 0)
                    {
                        recipientuser = null;
                    }
                }

                P_WorkflowInstance recipientInstance = processStore.getWorkflowInstance(recipientProcessSubject.Id, senderInstance.ProcessInstance_Id, recipientuser);
                if (recipientInstance != null)
                {
                    //update recipient workflow id
                    context.SetValue(RecipientId, recipientInstance.Id);
                }
                //message is for internal subject
                context.SetValue(IsMessageForExternalSubject, false);
                //update recipient processsubjectId
                context.SetValue(RecipientProcessSubjectId, recipientProcessSubject.Id);
            }
            else
            {
                //message is for external subject
                context.SetValue(IsMessageForExternalSubject, true);
            }


            context.SetValue(GlobalProcessName, process.GlobalProcessName);
            context.SetValue(ProcessInstanceId, senderInstance.ProcessInstance_Id);
            context.SetValue(SenderSubject, senderProcessSubject.Name);
            context.SetValue(SenderUsername, senderInstance.Owner);
            context.SetValue(Recipient_Role_Id, recipientProcessSubject.U_Role_Id);
        }
Example #13
0
        private void initService()
        {
            if (connectionString == null)
            {
                connectionString = ConfigurationSettings.AppSettings["repositoryConnectionString"].ToString();

                wfmBaseAddress = ConfigurationSettings.AppSettings["wfmBaseAddress"].ToString();
                wfmUsername    = ConfigurationSettings.AppSettings["wfmUsername"].ToString();

                wfmPassword = ConfigurationSettings.AppSettings["wfmPassword"].ToString();

                taskStore    = StoreHandler.getTaskStore(connectionString);
                processStore = StoreHandler.getProcessStore(connectionString);
                userStore    = StoreHandler.getUserStore(connectionString);
                messageStore = StoreHandler.getMessageStore(connectionString);

                _db = new InFlowDb();
            }
        }
Example #14
0
        private void initService()
        {
            if (connectionString == null)
            {
                connectionString = ConfigurationSettings.AppSettings["repositoryConnectionString"].ToString();

                wfmBaseAddress = ConfigurationSettings.AppSettings["wfmBaseAddress"].ToString();
                wfmUsername = ConfigurationSettings.AppSettings["wfmUsername"].ToString();

                wfmPassword = ConfigurationSettings.AppSettings["wfmPassword"].ToString();

                taskStore = StoreHandler.getTaskStore(connectionString);
                processStore = StoreHandler.getProcessStore(connectionString);
                userStore = StoreHandler.getUserStore(connectionString);
                messageStore = StoreHandler.getMessageStore(connectionString);

                _db = new InFlowDb();
            }
        }
        public void createNotificationForMessage(int MessageId, string cfgSQLConnectionString)
        {
            this.cfgSQLConnectionString = cfgSQLConnectionString;
            configStore  = StoreHandler.getConfigStore(cfgSQLConnectionString);
            baseURL      = configStore.getString(BaseURL);
            templatepath = configStore.getString(Email_NotificationTemplate);

            if (configStore.getBool(Email_Notifications_Messages))
            {
                taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString);
                T_Task task = taskStore.getReceiveTaskForMessageId(MessageId);
                if (task != null)
                {
                    messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString);
                    mail         = new SmtpUtils(configStore);
                    processStore = StoreHandler.getProcessStore(cfgSQLConnectionString);
                    instance     = processStore.getWorkflowInstance(task.WFId);
                    M_Message message = messageStore.getMessageBymsgId(MessageId);
                    createReceiveNotification(message, task);
                }
            }
        }
Example #16
0
        /// <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);
            }
        }
Example #17
0
        public List <T_Task> getTasksNotDoneByUsername(string name)
        {
            IProcessStore processStore = StoreHandler.getProcessStore(connectionString);
            IUserStore    userStore    = StoreHandler.getUserStore(connectionString);

            List <T_Task> temp  = new List <T_Task>();
            var           query = from t in db.T_Tasks
                                  where t.Done == false
                                  select t;

            foreach (var item in query)
            {
                P_WorkflowInstance i = processStore.getWorkflowInstance(item.WFId);
                //string subjectname = processStore.getProcessSubject(i.ProcessSubject_Id).Name;
                int roleId = processStore.getProcessSubject(i.ProcessSubject_Id).U_Role_Id;
                if (i.Owner.Length > 0)
                {
                    if (i.Owner.Equals(name))
                    {
                        temp.Add(item);
                    }
                }
                else
                {
                    foreach (string us in userStore.getUsernamesForRole(roleId))
                    {
                        if (us.Equals(name))
                        {
                            temp.Add(item);
                        }
                    }
                }
            }

            return(temp);
        }
Example #18
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()));
        }
Example #19
0
 public KillAllListener(IProcessStore processStore, ILogger <KillAllListener> logger)
 {
     _processStore = processStore;
     _logger       = logger;
 }
Example #20
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);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PrepareMessagesMiddleware{TState, TProcessHandler}"/> class.
 /// </summary>
 /// <param name="store">Process manager store.</param>
 public PrepareMessagesMiddleware(IProcessStore <TProcessHandler> store)
 {
     this.store = store;
 }
        public void createNotificationForMessage(int MessageId, string cfgSQLConnectionString)
        {
            this.cfgSQLConnectionString = cfgSQLConnectionString;
            configStore = StoreHandler.getConfigStore(cfgSQLConnectionString);
            baseURL = configStore.getString(BaseURL);
            templatepath = configStore.getString(Email_NotificationTemplate);

            if (configStore.getBool(Email_Notifications_Messages))
            {
                taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString);
                T_Task task = taskStore.getReceiveTaskForMessageId(MessageId);
                if (task != null)
                {
                    
                    messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString);
                    mail = new SmtpUtils(configStore);
                    processStore = StoreHandler.getProcessStore(cfgSQLConnectionString);
                    instance = processStore.getWorkflowInstance(task.WFId);
                    M_Message message = messageStore.getMessageBymsgId(MessageId);
                    createReceiveNotification(message, task);
                }
            }
        }
Example #23
0
 public ReflectionExecutor(IProcessStore store, ILoggerFactory loggerFactory,
                           IOptions <SwarmClientOptions> options) : base(store, loggerFactory, options)
 {
 }
Example #24
0
 public KillListener(IProcessStore processStore, ILoggerFactory loggerFactory)
 {
     _processStore = processStore;
     _logger       = loggerFactory.CreateLogger <KillAllListener>();
 }
Example #25
0
 protected ExecutorBase(IProcessStore store, ILoggerFactory loggerFactory, IOptions <SwarmClientOptions> options)
 {
     Store   = store;
     Logger  = loggerFactory.CreateLogger <ProcessExecutor>();
     Options = options.Value;
 }