Пример #1
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);
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        public Models.JobsViewModels.ReceiveTaskViewModel getReceiveTask(int id, string username)
        {
            initService();
            if (CanUserAccessTask(id, username))
            {
                var task = taskStore.getTaskById(id);

                if (task.Type.Equals("R"))
                {
                    var  processInstance = _db.P_ProcessInstance.Find(task.P_ProcessInstance_Id);
                    var  process         = _db.P_Processes.Find(processInstance.P_Process_Id);
                    bool tout            = false;
                    if (task.SubmittedTaskProperties != null)
                    {
                        if (task.SubmittedTaskProperties.Equals("TimeOut!"))
                        {
                            tout = true;
                        }
                    }


                    DateTime doneDate = new DateTime();
                    if (task.DateSubmitted != null)
                    {
                        doneDate = task.DateSubmitted.Value;
                    }
                    ReceiveTaskViewModel model = new ReceiveTaskViewModel()
                    {
                        Id = task.Id, Name = task.Name, Done = task.Done, Seen = task.Seen, DoneDate = doneDate, ProcessStartDate = processInstance.DateStarted.Value, StartedByUser = processInstance.StartedByUser, TaskCreatedDate = task.DateCreated.Value, Timedout = tout, Version = process.WS_Project_Version, ProcessName = process.WS_Project.Name
                    };

                    List <M_Message> mlist = new List <M_Message>();
                    if (task.Done)
                    {
                        if (!tout)
                        {
                            try
                            {
                                mlist.Add(messageStore.getMessageBymsgId(int.Parse(task.SubmittedTaskProperties)));
                            }
                            catch (Exception e)
                            {
                            }
                        }
                    }
                    else
                    {
                        //find to the task related messages
                        mlist = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString());
                    }


                    // mlist.ForEach(m => model.Messages.Add(new MessagesViewModel { Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username, Parameters = Json.Decode<Dictionary<string, string>>(m.Data) }));


                    foreach (var m in mlist)
                    {
                        IDictionary <string, dynamic> editableParameters = Newtonsoft.Json.JsonConvert.DeserializeObject <IDictionary <string, dynamic> >(m.Data);
                        MessagesViewModel             mvm = new MessagesViewModel()
                        {
                            Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username
                        };
                        if (editableParameters != null)
                        {
                            foreach (var i in editableParameters)
                            {
                                mvm.Parameters.Add(new TaskParameter(i.Key, i.Value));    // { Name = i.Key, Value = i.Value });
                            }
                        }
                        model.Messages.Add(mvm);
                    }


                    //  mlist.ForEach(m => model.Messages.Add(new MessagesViewModel { Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username, Parameters = new Dictionary<string, string>() }));


                    return(model);
                }
            }

            return(null);
        }
Пример #4
0
        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);
                }
            }
        }