/// <summary> /// Выполнить задание. /// </summary> /// <param name="assignment">Задание.</param> /// <param name="resultComplete">Результат выполнения задания.</param> /// <param name="activeText">Текст задания.</param> private void ExecuteAssigment(Sungero.Workflow.IAssignment assignment, string resultComplete, string activeText) { assignment.ActiveText = activeText; // Выполнение простого задания. Т.к. он платформенный, то выполняется таким образом. if (Sungero.Workflow.SimpleAssignments.Is(assignment) && resultComplete == "Complete") { assignment.Complete(null); } else { if (this.CheckAssignmentType(assignment.Info.Name)) { assignment.Complete(new Enumeration(resultComplete)); } } }
public virtual void TrySendAssignmentMessage(Sungero.Workflow.IAssignment assignment) { var chatBotUser = DirRX.ChatBotInfrastructure.ChatBotUsers.Null; var employee = Sungero.Company.Employees.As(assignment.Performer); if (employee != null) { chatBotUser = DirRX.ChatBotInfrastructure.ChatBotUsers.GetAll(u => u.Person != null && Equals(u.Person, employee.Person)).FirstOrDefault(); } if (this.CheckAssignmentType(assignment.Info.Name) && chatBotUser != null) { SendAssignmentMessage(assignment, chatBotUser); Logger.DebugFormat("Sending assignment type: {0}", assignment.Info.Name); } }
public static IDeadlineExtensionTask GetDeadlineExtension(Sungero.Workflow.IAssignment assignment) { // Проверить наличие старой задачи на продление срока. var oldTask = Docflow.DeadlineExtensionTasks.GetAll() .Where(j => Equals(j.ParentAssignment, assignment)) .Where(j => j.Status == Workflow.Task.Status.InProcess || j.Status == Workflow.Task.Status.Draft) .FirstOrDefault(); if (oldTask != null) { return(oldTask); } var task = Docflow.DeadlineExtensionTasks.CreateAsSubtask(assignment); task.MaxDeadline = (assignment.Deadline < Calendar.Today) ? Calendar.Today : assignment.Deadline; task.NeedsReview = false; task.Subject = Sungero.Docflow.Functions.DeadlineExtensionTask.GetDeadlineExtensionSubject(task, DeadlineExtensionTasks.Resources.ExtendDeadlineTaskSubject); // Определить исполнителя. if (Sungero.RecordManagement.ActionItemExecutionAssignments.Is(assignment)) { var actionItem = RecordManagement.ActionItemExecutionAssignments.As(assignment); task.Assignee = Functions.DeadlineExtensionTask.GetAssigneesForActionItemExecutionTask(actionItem).Assignees.FirstOrDefault(); } else if (Sungero.Docflow.ApprovalManagerAssignments.Is(assignment) || Sungero.RecordManagement.ReportRequestAssignments.Is(assignment)) { task.Assignee = assignment.Author; } else { task.Assignee = assignment.Author; if (Equals(assignment.Author, assignment.Performer)) { var author = Company.Employees.As(assignment.Author); if (author != null && author.Department.Manager != null) { task.Assignee = author.Department.Manager; } } } task.CurrentDeadline = assignment.Deadline; task.Author = assignment.Performer; return(task); }
public virtual void SendAssignmentMessage(Sungero.Workflow.IAssignment assignment, DirRX.ChatBotInfrastructure.IChatBotUser chatBotUser) { var documents = GetAttachements(assignment); var processAssignmentType = GetChatBotProcessAssignmentType(assignment); var message = processAssignmentType.IncomingInstructionText; Logger.DebugFormat("message: {0}", message); var actions = GetResultVariants(assignment); Logger.DebugFormat("action: {0}", actions[0].ResultLocale); var chatBotProcessAssignment = DirRX.ChatBotTask.ChatBotProcessAssignments.Create(); chatBotProcessAssignment.AssignmentId = assignment.Id; chatBotProcessAssignment.ChatBotProcess = DirRX.ChatBotInfrastructure.PublicFunctions.Module.StartProcess(processAssignmentType.AssignmentType, chatBotUser); chatBotProcessAssignment.Save(); Logger.DebugFormat("Send assignment: {0}", assignment.Id); bool isError = false; try { DirRX.ChatBotInfrastructure.PublicFunctions.Module.SendAttachmentsMessage( message, new List <DirRX.ChatBotInfrastructure.IChatBotUser> { chatBotUser }, chatBotProcessAssignment.ChatBotProcess, processAssignmentType.AssignmentType, !string.IsNullOrEmpty(actions[0].ResultLocale) ? DirRX.ChatBotInfrastructure.PublicFunctions.Module.CreateSimpleAction(actions[0].ResultLocale) : string.Empty, !string.IsNullOrEmpty(actions[1].ResultLocale) ? DirRX.ChatBotInfrastructure.PublicFunctions.Module.CreateSimpleAction(actions[1].ResultLocale) : string.Empty, !string.IsNullOrEmpty(actions[2].ResultLocale) ? DirRX.ChatBotInfrastructure.PublicFunctions.Module.CreateSimpleAction(actions[2].ResultLocale) : string.Empty, !string.IsNullOrEmpty(actions[3].ResultLocale) ? DirRX.ChatBotInfrastructure.PublicFunctions.Module.CreateSimpleAction(actions[3].ResultLocale) : string.Empty, !string.IsNullOrEmpty(actions[4].ResultLocale) ? DirRX.ChatBotInfrastructure.PublicFunctions.Module.CreateSimpleAction(actions[4].ResultLocale) : string.Empty, documents[0], documents[1], documents[2], documents[3], documents[3] ); } catch (Exception ex) { Logger.ErrorFormat("Message sending failed. Error: {0}", ex.Message); isError = true; } if (!isError) { chatBotProcessAssignment.Status = DirRX.ChatBotTask.ChatBotProcessAssignment.Status.Closed; chatBotProcessAssignment.Save(); } }
public void CompleteAssigment(Sungero.Workflow.IAssignment assignment, string assignmentResult, string activeText) { // Выполнить задание. this.ExecuteAssigment(assignment, assignmentResult, activeText); }