/// <summary> /// Get the workflow result. Status, Output parameters,... /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <returns>Workflow result</returns> public WorkflowResultInfo GetWorkflowResult(Guid workflowOid) { WorkflowDefinition wfd; using (var uofw = new FlowTasksUnitOfWork()) { wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid, w => w.WorkflowStatus); } var resultInfo = new WorkflowResultInfo { WorkflowOid = wfd.WorkflowOid, Status = wfd.WorkflowStatus.Status, CompletedOn = wfd.CompletedOn.HasValue ? wfd.CompletedOn.Value : DateTime.MinValue, OutParameters = new PropertyInfos(GetWorkflowOutParameters(workflowOid)), Result = string.Empty }; // Get the result from Trace table. Only for completed workflows var traces = _tracer.GetTraceForWorkflow(new[] { workflowOid }, TraceEventType.Activity); foreach (var t in traces) { if (t.Action == ActionTrace.WorkflowCompleted.ToString()) { resultInfo.Result = t.Result; break; } } return(resultInfo); }
/// <summary> /// Trace /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <param name="action">Action</param> /// <param name="code">Code</param> /// <param name="result">Result</param> /// <param name="user">User</param> /// <param name="msg">Msg</param> /// <param name="type">Type</param> public void Trace(Guid workflowOid, ActionTrace action, string code, string result, string user, string msg, TraceEventType type) { using (var uofw = new FlowTasksUnitOfWork()) { var wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid); var eventType = type.ToString(); var tre = uofw.TraceEvents.First(e => e.Type == eventType); var t = new WorkflowTrace { Message = msg.Substring(0, Math.Min(msg.Length, 500)), TraceEvent = tre, User = string.IsNullOrWhiteSpace(user) ? string.Empty : user, When = DateTime.Now, WorkflowDefinition = wfd, Action = action.ToString(), Code = code, Result = result }; uofw.WorkflowTraces.Insert(t); uofw.Commit(); } }
/// <summary> /// Get Tasks Completed /// </summary> /// <param name="user"></param> /// <param name="total"></param> /// <returns>list of TasksOn</returns> public IEnumerable <TasksOn> GetTasksCompleted(string user, out int total) { var results = new List <TasksOn>(); using (var uofw = new FlowTasksUnitOfWork()) { var action = ActionTrace.TaskCompleted.ToString(); var last = DateTime.Now.AddDays(-7); var taskDone = uofw.WorkflowTraces.Find(t => t.User.Equals(user, StringComparison.OrdinalIgnoreCase) && t.Action == action && t.When >= last).ToList(); if (taskDone.Any()) { results = (from t in taskDone group t.Code by t.When.ToString("ddd d MMM") into g select new TasksOn { Date = g.Key, Counter = g.Count() }).ToList(); } total = taskDone.Count; } return(results); }
/// <summary> /// Create Message /// </summary> /// <param name="uofw">FlowTasksUnitOfWork</param> /// <param name="topic">Topic</param> /// <param name="isTopic">Is Topic</param> /// <param name="message">Message</param> /// <param name="from">From</param> /// <param name="to">To</param> /// <param name="attachments">Attachments</param> /// <param name="usersToCopy">Users To Copy</param> private static void CreateMessage(FlowTasksUnitOfWork uofw, Core.Topic topic, bool isTopic, string message, string from, string to, IEnumerable <TopicAttachmentInfo> attachments, IEnumerable <string> usersToCopy) { var newMessage = new TopicMessage { Message = message, IsTopic = isTopic, From = from, To = to, When = DateTime.Now, Topic = topic }; uofw.TopicMessages.Insert(newMessage); var statusNewStr = TopicStatusType.New.ToString(); var statusReadStr = TopicStatusType.Read.ToString(); var statusNew = uofw.TopicStatuses.First(s => s.Status == statusNewStr); var statusRead = uofw.TopicStatuses.First(s => s.Status == statusReadStr); foreach (var u in usersToCopy) { var status = string.Equals(u, from, StringComparison.OrdinalIgnoreCase) ? statusRead : statusNew; uofw.TopicUsers.Insert(new TopicUser { TopicMessage = newMessage, User = u, TopicStatus = status }); } if (attachments != null) { foreach (var a in attachments) { uofw.TopicAttachments.Insert(new TopicAttachment { FileName = a.FileName, OidDocument = a.DocumentOid, TopicMessage = newMessage }); } } }
/// <summary> /// Get Hand Over Users For Task /// </summary> /// <param name="taskOid">Task Oid</param> /// <returns>List of user name</returns> public IEnumerable <string> GetHandOverUsersForTask(Guid taskOid) { using (var uofw = new FlowTasksUnitOfWork()) { var tkd = uofw.TaskDefinitions.First(t => t.TaskOid == taskOid); if (string.IsNullOrWhiteSpace(tkd.HandedOverStatus) || tkd.HandedOverStatus == HandOverStatus.None.ToString()) { var tku = uofw.TaskUserHandOvers.Find(u => u.TaskDefinitionId == tkd.TaskDefinitionId); foreach (var u in tku) { yield return(u.User); } } else if (tkd.HandedOverStatus == HandOverStatus.HandedBack.ToString()) { var tku = uofw.TaskUserHandOvers.Find(u => u.TaskDefinitionId == tkd.TaskDefinitionId); foreach (var u in tku) { yield return(u.User); } } else if (tkd.HandedOverStatus == HandOverStatus.HandedOver.ToString()) { var tku = uofw.TaskUsers.Find(u => u.TaskDefinitionId == tkd.TaskDefinitionId && u.InUse); foreach (var u in tku) { yield return(u.User); } } } }
/// <summary> /// Get Next Tasks For User. /// </summary> /// <param name="user">User</param> /// <param name="workflowOid">Workflow Oid</param> /// <param name="domain">Domain</param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="searchFor"></param> /// <returns>List of TaskInfo</returns> public IEnumerable <TaskInfo> GetNextTasksForUser(string user, Guid workflowOid, string domain, int pageIndex, int pageSize, string searchFor) { // TODO: hotfix to be removed if (pageSize == 0) { pageSize = 10; } IEnumerable <TaskInfo> taskInfos; using (var uofw = new FlowTasksUnitOfWork()) { taskInfos = NextTasksForUserQuery(uofw, user, workflowOid, domain, searchFor) .Select(t => new TaskInfo { WorkflowOid = t.WorkflowDefinition.WorkflowOid, DefaultResult = t.DefaultResult, UiCode = t.UiCode, ExpiryDate = t.ExpiryDate, TaskCode = t.TaskCode, TaskOid = t.TaskOid, Title = t.Title, Description = t.Description, TaskCorrelationId = t.TaskCorrelationId, AcceptedBy = t.AcceptedBy }).ToList(); } var skip = pageIndex * pageSize; var tasks = taskInfos; var tasksForPage = tasks.Skip(skip).Take(pageSize).ToList(); return(tasksForPage); }
/// <summary> /// Update Holiday /// </summary> /// <param name="user">User</param> /// <param name="id"></param> /// <param name="status"></param> /// <param name="holiday">Holiday</param> public void UpdateHoliday(string user, int id, HolidayStatus status, IEnumerable <string> holiday) { using (var uofw = new FlowTasksUnitOfWork()) { var hday = uofw.Holidays.Find(h => h.HolidayId == id).FirstOrDefault(); if (hday == null) { return; } hday.Status = status.ToString(); if (holiday != null) { var holidayList = holiday as IList <string> ?? holiday.ToList(); hday.Year = GetYearFromDate(holidayList.FirstOrDefault()); if (holidayList.Any()) { hday.Dates = String.Join(",", holidayList); } } uofw.Commit(); } }
/// <summary> /// Get Topics For User /// </summary> /// <param name="user">User</param> /// <param name="topicId"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="title"></param> /// <param name="status"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="withReplies"></param> /// <returns>List of topics</returns> public IEnumerable <TopicInfo> GetTopicsForUser(string user, int topicId, DateTime start, DateTime end, string title, string status, int pageIndex, int pageSize, bool withReplies) { var topicInfo = new List <TopicInfo>(); using (var uofw = new FlowTasksUnitOfWork()) { var userTopics = TopicsForUser(uofw, user, topicId, title, string.Empty, false); var skip = pageIndex * pageSize; var topicsinPage = userTopics.OrderByDescending(tu => tu.TopicMessage.Topic.LastChanged).Skip(skip).Take(pageSize).ToList(); var statusNewStr = TopicStatusType.New.ToString(); var statusReadStr = TopicStatusType.Read.ToString(); var statusRead = uofw.TopicStatuses.First(s => s.Status == statusReadStr); foreach (var tu in topicsinPage) { var ti = CreateTopicInfo(tu, uofw, 20, end.AddDays(-1), end, status, withReplies); topicInfo.Add(ti); if (tu.TopicStatus.Status == statusNewStr) { tu.TopicStatus = statusRead; } } uofw.Commit(); } return(topicInfo); }
/// <summary> /// Get Next Tasks For Workflow /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <returns>Task Info</returns> public IEnumerable <TaskInfo> GetNextTasksForWorkflow(Guid workflowOid) { var inProgress = WorkflowStatusType.InProgress.ToString(); using (var uofw = new FlowTasksUnitOfWork()) { var taskInfos = uofw.TaskDefinitions.Find(t => (t.WorkflowDefinition.WorkflowOid == workflowOid && t.WorkflowDefinition.WorkflowStatus.Status == inProgress) || (t.WorkflowDefinition.WorkflowParentDefinition.WorkflowOid == workflowOid && t.WorkflowDefinition.WorkflowParentDefinition.WorkflowStatus.Status == inProgress), t => t.WorkflowDefinition) .Select(t => new TaskInfo { WorkflowOid = t.WorkflowDefinition.WorkflowOid, DefaultResult = t.DefaultResult, UiCode = t.UiCode, ExpiryDate = t.ExpiryDate, TaskCode = t.TaskCode, TaskOid = t.TaskOid, Title = t.Title, Description = t.Description, TaskCorrelationId = t.TaskCorrelationId, AcceptedBy = t.AcceptedBy }).ToList(); return(taskInfos); } }
/// <summary> /// Get workflow configuration /// </summary> /// <param name="workflowCodeOrId">Workflow Code or Workflow Oid</param> /// <param name="effectiveDate">Effective date</param> /// <returns>Workflow Configuration</returns> public WorkflowConfigurationInfo GetWorkflowConfiguration(string workflowCodeOrId, DateTime effectiveDate) { using (var uofw = new FlowTasksUnitOfWork()) { Guid oid; bool isId = Guid.TryParse(workflowCodeOrId, out oid); string workflowCode; // we got an oid if (isId) { workflowCode = uofw.WorkflowDefinitions.First(wfd => wfd.WorkflowOid == oid, wfd => wfd.WorkflowCode).WorkflowCode.Code; } else { workflowCode = workflowCodeOrId; } var wfc = uofw.WorkflowConfigurations.Find(c => c.WorkflowCode.Code == workflowCode && c.EffectiveDate <= effectiveDate && (!c.ExpiryDate.HasValue || c.ExpiryDate > effectiveDate)).Select(ci => new WorkflowConfigurationInfo { ServiceEndPoint = ci.ServiceEndpoint, ServiceUrl = ci.ServiceUrl, BindingConfiguration = ci.BindingConfiguration, ServiceDefinition = ci.ServiceDefinition }).First(); return(wfc); } }
/// <summary> /// Give Back Task /// </summary> /// <param name="taskOid">Task Oid</param> public void GiveBackTask(Guid taskOid) { TaskDefinition tkd; using (var uofw = new FlowTasksUnitOfWork()) { tkd = uofw.TaskDefinitions.First(t => t.TaskOid == taskOid, t => t.WorkflowDefinition); tkd.HandedOverStatus = HandOverStatus.None.ToString(); var tku = uofw.TaskUsers.FirstOrDefault(u => u.TaskDefinitionId == tkd.TaskDefinitionId && u.User == tkd.AcceptedBy); if (tku != null) { tku.InUse = false; } else { var tkuh = uofw.TaskUserHandOvers.FirstOrDefault(u => u.TaskDefinitionId == tkd.TaskDefinitionId && u.User == tkd.AcceptedBy); if (tkuh != null) { tkuh.InUse = false; } } tkd.AcceptedBy = string.Empty; tkd.AcceptedOn = null; uofw.Commit(); } _tracer.Trace(tkd.WorkflowDefinition.WorkflowOid, ActionTrace.TaskGaveBack, tkd.TaskCode, string.Format(Properties.Resources.TK_GAVEBACK, tkd.TaskCode), TraceEventType.Activity); }
/// <summary> /// Get Parameters For Task /// </summary> /// <param name="taskOid">Task Oid</param> /// <returns>List of property</returns> public IEnumerable <PropertyInfo> GetTaskParameters(Guid taskOid) { using (var uofw = new FlowTasksUnitOfWork()) { return(GetTaskParameters(uofw, taskOid)); } }
/// <summary> /// Update Workflow Parameters /// </summary> /// <param name="workflowOid">WorkflowOid</param> /// <param name="taskOid">TaskOid</param> /// <param name="properties">Properties</param> public void UpdateWorkflowParameters(Guid workflowOid, Guid taskOid, IEnumerable <PropertyInfo> properties) { using (var uofw = new FlowTasksUnitOfWork()) { WorkflowDefinition wfd = null; if (workflowOid != Guid.Empty) { wfd = uofw.WorkflowDefinitions.FirstOrDefault(w => w.WorkflowOid == workflowOid); } else if (taskOid != Guid.Empty) { wfd = uofw.TaskDefinitions.Find(t => t.TaskOid == taskOid, t => t.WorkflowDefinition).Select(t => t.WorkflowDefinition).FirstOrDefault(); } if (wfd != null) { var parms = uofw.WorkflowInParameters.Find(p => p.WorkflowDefinitionId == wfd.WorkflowDefinitionId, p => p.Property); var propertyInfos = properties as IList <PropertyInfo> ?? properties.ToList(); foreach (var p in parms) { foreach (var newp in propertyInfos) { if (p.Property.Name == newp.Name) { p.Property.Value = newp.Value; } } } uofw.Commit(); } } }
/// <summary> /// Add Workflow /// </summary> /// <param name="workflowCode">WorkflowCode</param> /// <param name="serviceUrl">ServiceUrl</param> /// <param name="bindingConfiguration">BindingConfiguration</param> /// <param name="serviceEndpoint">ServiceEndpoint</param> public void AddWorkflow(string workflowCode, string serviceUrl, string bindingConfiguration, string serviceEndpoint) { using (var uofw = new FlowTasksUnitOfWork()) { var wfc = uofw.WorkflowCodes.FirstOrDefault(wc => wc.Code == workflowCode); if (wfc == null) { wfc = new WorkflowCode { Code = workflowCode, Description = "Added by Skecth" }; uofw.WorkflowCodes.Insert(wfc); } else { var wfcfg = uofw.WorkflowConfigurations.FirstOrDefault(w => w.WorkflowCode.Code == wfc.Code && w.ExpiryDate == null, w => w.WorkflowCode); if (wfcfg != null) { wfcfg.ExpiryDate = DateTime.Now; } } var newcfg = new WorkflowConfiguration { WorkflowCode = wfc, ServiceUrl = serviceUrl, BindingConfiguration = bindingConfiguration, ServiceEndpoint = serviceEndpoint, EffectiveDate = DateTime.Now }; uofw.WorkflowConfigurations.Insert(newcfg); uofw.Commit(); } }
/// <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(); } }
/// <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); } }
/// <summary> /// Search For Topics /// </summary> /// <param name="user">User</param> /// <param name="pattern">Pattern</param> /// <returns>List of topics that match pattern</returns> public IEnumerable <SearchInfo> SearchForTopics(string user, string pattern) { using (var uofw = new FlowTasksUnitOfWork()) { return(uofw.TopicUsers.ExecuteStoreQuery <SearchInfo>("select [TopicId], [Message], [Rank] from SearchTopicForUser(@p0, @p1)", user, ConvertPatternFullTextSearch(pattern)).OrderByDescending(t => t.Rank).ToList()); } }
/// <summary> /// Get Task Count /// </summary> /// <param name="user"></param> /// <returns>Number of tasks for user</returns> public int GetTaskCount(string user) { using (var uofw = new FlowTasksUnitOfWork()) { var q = NextTasksForUserQuery(uofw, user, Guid.Empty, string.Empty, string.Empty); return(q.Count()); } }
/// <summary> /// Complete Notification /// </summary> /// <param name="taskOid">Task Oid</param> public void CompleteNotification(Guid taskOid) { using (var uofw = new FlowTasksUnitOfWork()) { var tkd = uofw.TaskDefinitions.First(t => t.TaskOid == taskOid, t => t.WorkflowDefinition); uofw.TaskDefinitions.Delete(tkd); uofw.Commit(); } }
/// <summary> /// Delete Workflow /// </summary> /// <param name="uofw">Unit of Work</param> /// <param name="wfd">Workflow Definition</param> private void DeleteWorkflow(FlowTasksUnitOfWork uofw, WorkflowDefinition wfd) { if (wfd == null) { return; } uofw.WorkflowDefinitions.Delete(wfd); }
/// <summary> /// Report User Task Count /// </summary> /// <returns>List of Task/Duration</returns> public IEnumerable <ReportUserTaskCountInfo> ReportUserTaskCount(DateTime?start, DateTime?end, IEnumerable <string> users, IEnumerable <string> tasks) { using (var uofw = new FlowTasksUnitOfWork()) { return(uofw.WorkflowTraces.ExecuteStoreQuery <ReportUserTaskCountInfo>("exec ReportUserTaskCount @p0, @p1", start, end) .Where(q => (tasks == null || !tasks.Any() || tasks.Contains(q.Task)) && (users == null || !users.Any() || users.Contains(q.User))) .ToList()); } }
/// <summary> /// Check workflow is active /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <returns>True if workflow is active</returns> public bool IsWorkflowInProgress(Guid workflowOid) { using (var uofw = new FlowTasksUnitOfWork()) { var wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid, w => w.WorkflowStatus); return(wfd.WorkflowStatus.Status == WorkflowStatusType.InProgress.ToString()); } }
/// <summary> /// Report Workflow Time /// </summary> /// <returns>List of Task/Duration</returns> public IEnumerable <ReportWorkflowTimeInfo> ReportWorkflowTime(DateTime?start, DateTime?end, IEnumerable <string> workflows) { using (var uofw = new FlowTasksUnitOfWork()) { return(uofw.WorkflowTraces.ExecuteStoreQuery <ReportWorkflowTimeInfo>("exec ReportWorkflowTime @p0, @p1", start, end) .Where(q => workflows == null || !workflows.Any() || workflows.Contains(q.Workflow)) .ToList()); } }
/// <summary> /// Get Topic Count /// </summary> /// <param name="user">User</param> /// <returns>Number of topic unread</returns> public int GetTopicCount(string user) { var statusNewStr = TopicStatusType.New.ToString(); using (var uofw = new FlowTasksUnitOfWork()) { var userTopics = TopicsForUser(uofw, user, 0, string.Empty, statusNewStr, true); return(userTopics.Count()); } }
/// <summary> /// Create TopicInfo /// </summary> /// <param name="user">TopicUser</param> /// <param name="uofw">FlowTasksUnitOfWork</param> /// <param name="num">Number of records to return</param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="status"></param> /// <param name="withReplies"></param> /// <returns>TopicInfo</returns> private TopicInfo CreateTopicInfo(TopicUser user, FlowTasksUnitOfWork uofw, int num, DateTime start, DateTime end, string status, bool withReplies) { var replies = new List <TopicMessageInfo>(); var statusNewStr = TopicStatusType.New.ToString(); var statusReadStr = TopicStatusType.Read.ToString(); var statusRead = uofw.TopicStatuses.First(s => s.Status == statusReadStr); var globalTopicStatus = CreateStatusType(user); IEnumerable <TopicUser> userTopics; if (withReplies) { userTopics = uofw.TopicUsers.Find( tu => !tu.TopicMessage.IsTopic && tu.TopicMessage.TopicId == user.TopicMessage.TopicId && tu.User == user.User && (string.IsNullOrEmpty(status) || tu.TopicStatus.Status == status), tu => tu.TopicMessage, tu => tu.TopicMessage.Topic, tu => tu.TopicStatus).ToList(); } else { // If we don't need the replyes, just load the new topics because we want to change the status userTopics = uofw.TopicUsers.Find( tu => !tu.TopicMessage.IsTopic && tu.TopicMessage.TopicId == user.TopicMessage.TopicId && tu.User == user.User && tu.TopicStatus.Status.Equals(statusNewStr), tu => tu.TopicMessage, tu => tu.TopicMessage.Topic, tu => tu.TopicStatus).ToList(); } var users = new Dictionary <string, string>(); foreach (var r in userTopics) { if (withReplies) { replies.Add(CreateMessageInfo(r, uofw, users)); } if (r.TopicStatus.Status == statusNewStr) { globalTopicStatus = TopicStatusType.New; r.TopicStatus = statusRead; } } var ti = new TopicInfo { TopicId = user.TopicMessage.TopicId, Title = user.TopicMessage.Topic.Title, Status = globalTopicStatus, Message = CreateMessageInfo(user, uofw, users), Replies = replies.ToArray() }; return(ti); }
/// <summary> /// Create Documents /// </summary> /// <param name="m">TopicMessage</param> /// <param name="uofw">FlowTasksUnitOfWork</param> /// <returns>List of TopicAttachmentInfo</returns> private IEnumerable <TopicAttachmentInfo> CreateDocuments(TopicMessage m, FlowTasksUnitOfWork uofw) { var documents = new List <TopicAttachmentInfo>(); foreach (var d in uofw.TopicAttachments.Find(a => a.TopicMessageId == m.TopicMessageId)) { documents.Add(new TopicAttachmentInfo { FileName = d.FileName, DocumentOid = d.OidDocument }); } return(documents); }
/// <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); } } }
/// <summary> /// Get workflow children /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <returns>List of oid</returns> public IEnumerable <Guid> GetWorkflowChildren(Guid workflowOid) { using (var uofw = new FlowTasksUnitOfWork()) { var wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid); var wfdChilds = uofw.WorkflowDefinitions.Find(w => w.WorkflowParentDefinitionId == wfd.WorkflowDefinitionId) .Select(w => w.WorkflowOid); return(wfdChilds.ToList()); } }
/// <summary> /// Check if task is a notification. /// </summary> /// <param name="taskOid"></param> /// <returns>Return true if Task is a notification</returns> public bool IsTaskNotification(Guid taskOid) { using (var uofw = new FlowTasksUnitOfWork()) { var tkd = uofw.TaskDefinitions.First(t => t.TaskOid == taskOid, t => t.WorkflowDefinition); if (tkd.TaskCode == NotificationCode) { return(true); } } return(false); }
/// <summary> /// Get Workflow output parameters /// </summary> /// <param name="workflowOid">Workflow Oid</param> /// <returns>List of properties</returns> public IEnumerable <PropertyInfo> GetWorkflowOutParameters(Guid workflowOid) { using (var uofw = new FlowTasksUnitOfWork()) { var wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid); var wfParam = uofw.WorkflowOutParameters.Find(p => p.WorkflowDefinitionId == wfd.WorkflowDefinitionId, p => p.Property) .Select(p => p.Property); return(wfParam.Select(wp => new PropertyInfo { Name = wp.Name, Value = wp.Value, Type = wp.Type }).ToList()); } }