Exemple #1
0
        /// <summary>
        /// Create Reply
        /// </summary>
        /// <param name="topicId">TopicId</param>
        /// <param name="message">Message</param>
        /// <param name="from">From</param>
        /// <param name="to">To</param>
        /// <param name="attachments">Attachments</param>
        public void CreateReply(int topicId, string message, string from, string to, IEnumerable <TopicAttachmentInfo> attachments)
        {
            using (var uofw = new FlowTasksUnitOfWork())
            {
                var topic        = uofw.Topics.First(t => t.TopicId == topicId);
                var topicMessage = uofw.TopicMessages.First(m => m.TopicId == topicId && m.IsTopic);

                if (!string.IsNullOrWhiteSpace(to))
                {
                    to += ";";
                }
                else
                {
                    to = string.Empty;
                }

                if (!to.Contains(topicMessage.To))
                {
                    to += topicMessage.To;
                }
                if (!to.Contains(topicMessage.From))
                {
                    to += ";" + topicMessage.From;
                }

                var usersToCopy = ParseUsers.GetListUsersName(_usersService, to);

                CreateMessage(uofw, topic, false, message, from, to, attachments, usersToCopy);
                topic.LastChanged = DateTime.Now;

                uofw.Commit();
            }
        }
Exemple #2
0
        /// <summary>
        /// Create Topic
        /// </summary>
        /// <param name="title">Title</param>
        /// <param name="message">Message</param>
        /// <param name="from">From</param>
        /// <param name="to">To</param>
        /// <param name="attachments">Attachments</param>
        public int CreateTopic(string title, string message, string from, string to, IEnumerable <TopicAttachmentInfo> attachments)
        {
            // if to is not empty then this is a direct message
            // otherwise get the to users from followers
            if (string.IsNullOrWhiteSpace(to))
            {
                to = GetBroadcastUsers(from);
            }

            var users       = to + ";" + from; // topic visible to sender (from) as well
            var usersToCopy = ParseUsers.GetListUsersName(_usersService, users);

            using (var uofw = new FlowTasksUnitOfWork())
            {
                var topic = new Core.Topic {
                    Title = title, LastChanged = DateTime.Now
                };
                uofw.Topics.Insert(topic);

                CreateMessage(uofw, topic, true, message, from, to, attachments, usersToCopy);

                uofw.Commit();

                return(topic.TopicId);
            }
        }
Exemple #3
0
        /// <summary>
        /// Create Notification
        /// </summary>
        /// <param name="workflowOid">Workflow Oid</param>
        /// <param name="notificationInfo">notification Info</param>
        public void CreateNotification(Guid workflowOid, NotificationInfo notificationInfo)
        {
            using (var uofw = new FlowTasksUnitOfWork())
            {
                WorkflowDefinition wfd = uofw.WorkflowDefinitions.First(d => d.WorkflowOid == workflowOid, d => d.WorkflowCode);

                foreach (var u in ParseUsers.GetListUsersName(_usersService, wfd.Domain, notificationInfo.AssignedToUsers))
                {
                    CreateNotification(uofw, wfd, notificationInfo, u);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Initialize Users
        /// </summary>
        /// <param name="uofw">Unit of Work</param>
        /// <param name="tkd">Task Definition</param>
        /// <param name="taskInfo">Task Info</param>
        /// <param name="domain">Domain</param>
        private void InitializeUsers(IFlowTasksUnitOfWork uofw, TaskDefinition tkd, TaskInfo taskInfo, string domain)
        {
            bool foundUser = false;

            foreach (var u in ParseUsers.GetListUsersName(_usersService, domain, taskInfo.AssignedToUsers))
            {
                uofw.TaskUsers.Insert(CreateTaskUser(tkd, u));
                foundUser = true;
            }

            foreach (var u in ParseUsers.GetListUsersName(_usersService, domain, taskInfo.HandOverUsers))
            {
                uofw.TaskUserHandOvers.Insert(CreateTaskUserHandHover(tkd, u));
                foundUser = true;
            }

            if (!foundUser)
            {
                throw new Exception("No valid user found");
            }
        }