/// <summary> /// Получить нестандартных исполнителей задачи. /// </summary> /// <returns>Исполнители.</returns> public virtual List <IRecipient> GetTaskAdditionalAssignees() { var assignees = new List <IRecipient>(); var documentReview = DocumentReviewTasks.As(_obj); if (documentReview == null) { return(assignees); } var recipient = documentReview.Addressee; if (recipient != null) { assignees.Add(recipient); var secretary = Docflow.PublicFunctions.Module.GetSecretary(recipient); var document = documentReview.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault(); secretary = secretary ?? Docflow.PublicFunctions.Module.Remote.GetClerk(document); assignees.Add(secretary ?? documentReview.Author); } assignees.AddRange(documentReview.ResolutionObservers.Where(o => o.Observer != null).Select(o => o.Observer)); return(assignees.Distinct().ToList()); }
public virtual void AddAssignment(Sungero.Workflow.Client.ExecuteResultActionArgs e) { if (!_obj.ResolutionGroup.ActionItemExecutionTasks.Any(t => t.Status == ActionItemExecutionTask.Status.Draft)) { var confirmationAccepted = Functions.Module.ShowConfirmationDialogCreationActionItem(_obj, _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault(), e); var dialogID = Constants.DocumentReviewTask.PreparingDraftResolutionAssignmentConfirmDialogID.AddAssignment; if (Docflow.PublicFunctions.Module.ShowDialogGrantAccessRightsWithConfirmationDialog(_obj, _obj.OtherGroup.All.ToList(), confirmationAccepted ? null : e.Action, dialogID) == false) { e.Cancel(); } } else { Functions.DocumentReviewTask.CheckOverdueActionItemExecutionTasks(DocumentReviewTasks.As(_obj.Task), e); var giveRights = Docflow.PublicFunctions.Module.ShowDialogGrantAccessRights(_obj, _obj.OtherGroup.All.ToList(), null); if (giveRights == false) { e.Cancel(); } if (giveRights == null && Functions.PreparingDraftResolutionAssignment.ShowConfirmationDialogStartDraftResolution(_obj, e) == false) { e.Cancel(); } RecordManagement.Functions.DocumentReviewTask.Remote.StartActionItemsForDraftResolution(DocumentReviewTasks.As(_obj.Task), _obj); } }
public virtual void PrintResolution(Sungero.Domain.Client.ExecuteActionArgs e) { _obj.Save(); var report = RecordManagement.Reports.GetDraftResolutionReport(); var actionItems = _obj.ResolutionGroup.ActionItemExecutionTasks; report.Resolution.AddRange(actionItems); report.TextResolution = _obj.ActiveText; report.Document = _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault(); report.Author = DocumentReviewTasks.As(_obj.Task).Addressee; report.Open(); }
/// <summary> /// Показать диалог подтверждения выполнения без создания поручений. /// </summary> /// <param name="assignment">Задание, которое выполняется.</param> /// <param name="document">Документ.</param> /// <param name="e">Аргументы.</param> /// <returns>True, если диалог был, иначе false.</returns> public static bool ShowConfirmationDialogCreationActionItem(IAssignment assignment, IOfficialDocument document, Sungero.Workflow.Client.ExecuteResultActionArgs e) { var reviewTask = DocumentReviewTasks.As(assignment.Task); var hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee); if (hasSubActionItem) { return(false); } var dialogText = ReviewResolutionAssignments.Is(assignment) ? Docflow.Resources.ExecuteWithoutCreatingActionItemFromAddressee : Docflow.Resources.ExecuteWithoutCreatingActionItem; var dialog = Dialogs.CreateTaskDialog(dialogText, MessageType.Question); dialog.Buttons.AddYes(); dialog.Buttons.Default = DialogButtons.Yes; var createActionItemButton = dialog.Buttons.AddCustom(Docflow.Resources.CreateActionItem); dialog.Buttons.AddNo(); var result = dialog.Show(); if (result == DialogButtons.Yes) { return(true); } if (result == DialogButtons.Cancel || result == DialogButtons.No) { e.Cancel(); } assignment.Save(); var assignedBy = reviewTask.Addressee; var resolution = ReviewResolutionAssignments.Is(assignment) ? ReviewResolutionAssignments.As(assignment).ResolutionText : assignment.ActiveText; var actionItem = Functions.Module.Remote.CreateActionItemExecutionWithResolution(document, assignment.Id, resolution, assignedBy); actionItem.IsDraftResolution = false; actionItem.ShowModal(); hasSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.InProcess, reviewTask.Addressee); if (hasSubActionItem) { return(true); } var hasDraftSubActionItem = Functions.ActionItemExecutionTask.Remote.HasSubActionItems(assignment.Task, Workflow.Task.Status.Draft, reviewTask.Addressee); e.AddError(hasDraftSubActionItem ? Docflow.Resources.AllCreatedActionItemsShouldBeStarted : Docflow.Resources.CreatedActionItemExecutionNeeded); e.Cancel(); return(true); }
public virtual void CreateActionItem(Sungero.Domain.Client.ExecuteActionArgs e) { _obj.Save(); var task = Functions.DocumentReviewTask.CreateActionItemExecution(_obj, DocumentReviewTasks.As(_obj.MainTask), _obj.ActiveText); var documentReview = DocumentReviewTasks.As(_obj.Task); if (documentReview.Addressee.Status == Sungero.CoreEntities.DatabookEntry.Status.Closed) { task.AssignedBy = null; } else { task.AssignedBy = Docflow.PublicFunctions.Module.Remote.IsUsersCanBeResolutionAuthor(task.DocumentsGroup.OfficialDocuments.SingleOrDefault(), documentReview.Addressee) ? documentReview.Addressee : null; } task.ShowModal(); }
public virtual void AddResolution(Sungero.Domain.Client.ExecuteActionArgs e) { _obj.Save(); var document = _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault(); var task = Functions.Module.Remote.CreateActionItemExecution(document); var assignee = task.Assignee ?? Users.Current; task.MaxDeadline = _obj.Deadline.HasValue ? _obj.Deadline.Value : Calendar.Today.AddWorkingDays(assignee, 2); task.IsDraftResolution = true; var assignedBy = DocumentReviewTasks.As(_obj.Task).Addressee; task.AssignedBy = Docflow.PublicFunctions.Module.Remote.IsUsersCanBeResolutionAuthor(document, assignedBy) ? assignedBy : null; foreach (var otherGroupAttachment in _obj.OtherGroup.All) { task.OtherGroup.All.Add(otherGroupAttachment); } task.ShowModal(); if (!task.State.IsInserted) { _obj.ResolutionGroup.ActionItemExecutionTasks.Add(task); _obj.Save(); } }
public virtual void ForExecution(Sungero.Workflow.Client.ExecuteResultActionArgs e) { // В качестве проектов резолюции нельзя отправить поручения-непроекты. if (_obj.ResolutionGroup.ActionItemExecutionTasks.Any(a => a.IsDraftResolution != true)) { e.AddError(DocumentReviewTasks.Resources.FindNotDraftResolution); e.Cancel(); } Functions.DocumentReviewTask.CheckOverdueActionItemExecutionTasks(DocumentReviewTasks.As(_obj.Task), e); // Замена стандартного диалога подтверждения выполнения действия. var dialogID = Constants.DocumentReviewTask.ReviewDraftResolutionAssignmentConfirmDialogID.ForExecution; if (!Docflow.PublicFunctions.Module.ShowDialogGrantAccessRightsWithConfirmationDialog(_obj, _obj.OtherGroup.All.ToList(), e.Action, dialogID)) { e.Cancel(); } RecordManagement.Functions.DocumentReviewTask.Remote.StartActionItemsForDraftResolution(DocumentReviewTasks.As(_obj.Task), _obj); }
/// <summary> /// Добавить блок информации о рассмотрении документа руководителем. /// </summary> /// <param name="stateView">Схема представления.</param> /// <param name="startDate">Дата начала текущей итерации рассмотрения.</param> /// <returns>Полученный блок.</returns> private StateBlock AddReviewManagerBlock(StateView stateView, DateTime startDate) { var managerAssignment = this.GetManagerAssignment(startDate); var resolutionAssignment = this.GetPreparingDraftResolutionAssignment(startDate); var author = managerAssignment != null? Docflow.PublicFunctions.OfficialDocument.GetAuthor(managerAssignment.Performer, managerAssignment.CompletedBy) : Docflow.PublicFunctions.OfficialDocument.GetAuthor(_obj.Addressee, _obj.Addressee); var actionItems = ActionItemExecutionTasks.GetAll() .Where(t => (t.ParentAssignment != null && (Equals(t.ParentAssignment.Task, _obj) || Equals(t.ParentAssignment, managerAssignment))) && t.Status != Workflow.Task.Status.Draft && Equals(t.AssignedBy, DocumentReviewTasks.As(_obj).Addressee)) .OrderBy(t => t.Started); var isCompleted = (managerAssignment != null && managerAssignment.Status == Workflow.AssignmentBase.Status.Completed) || (resolutionAssignment != null && resolutionAssignment.Result == RecordManagement.PreparingDraftResolutionAssignment.Result.AddAssignment); var isReworkresolution = managerAssignment != null && ReviewDraftResolutionAssignments.Is(managerAssignment) && managerAssignment.Result == RecordManagement.ReviewDraftResolutionAssignment.Result.AddResolution && !(resolutionAssignment != null && resolutionAssignment.Result == RecordManagement.PreparingDraftResolutionAssignment.Result.AddAssignment); var isDraft = _obj.Status == Workflow.Task.Status.Draft; var headerStyle = Docflow.PublicFunctions.Module.CreateHeaderStyle(isDraft); var performerStyle = Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle(isDraft); var labelStyle = Docflow.PublicFunctions.Module.CreateStyle(false, isDraft, false); var separatorStyle = Docflow.PublicFunctions.Module.CreateSeparatorStyle(); // Добавить блок. Установить иконку и сущность. var block = stateView.AddBlock(); block.Entity = _obj; if (isCompleted && !isReworkresolution) { block.AssignIcon(ReviewManagerAssignments.Info.Actions.AddResolution, StateBlockIconSize.Large); } else { block.AssignIcon(StateBlockIconType.OfEntity, StateBlockIconSize.Large); } // Рассмотрение руководителем ещё в работе. if (!isCompleted || isReworkresolution) { // Добавить заголовок. block.AddLabel(Docflow.Resources.StateViewDocumentReview, headerStyle); block.AddLineBreak(); if (managerAssignment != null && !isReworkresolution) { if (managerAssignment.Status == Workflow.AssignmentBase.Status.Aborted) { Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewAborted); } else if (managerAssignment.IsRead == false) { Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewUnRead); } else { this.AddAssignmentStatusInfoToRight(block, labelStyle, managerAssignment); } } else if (_obj.Status == Workflow.Task.Status.Completed) { Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewCompleted); } else if (_obj.Status == Workflow.Task.Status.Aborted) { Docflow.PublicFunctions.Module.AddInfoToRightContent(block, Docflow.ApprovalTasks.Resources.StateViewAborted); } // Адресат. block.AddLabel(string.Format("{0}: {1}", Docflow.Resources.StateViewAddressee, Company.PublicFunctions.Employee.GetShortName(_obj.Addressee, false)), performerStyle); var deadline = managerAssignment != null && !isReworkresolution ? managerAssignment.Deadline : _obj.MaxDeadline; var deadlineString = deadline.HasValue ? Docflow.PublicFunctions.Module.ToShortDateShortTime(deadline.Value.ToUserTime()) : Docflow.OfficialDocuments.Resources.StateViewWithoutTerm; block.AddLabel(string.Format("{0}: {1}", Docflow.OfficialDocuments.Resources.StateViewDeadline, deadlineString), performerStyle); if (!isReworkresolution && managerAssignment != null && managerAssignment.Deadline.HasValue) { Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, managerAssignment.Deadline.Value, managerAssignment.Performer); } else if (resolutionAssignment != null && resolutionAssignment.Deadline.HasValue) { Docflow.PublicFunctions.OfficialDocument.AddDeadlineHeaderToRight(block, resolutionAssignment.Deadline.Value, resolutionAssignment.Performer); } } else if (managerAssignment != null || resolutionAssignment != null) { // Рассмотрение завершено. // Добавить заголовок. var completionDate = managerAssignment == null?resolutionAssignment.Completed.Value.ToUserTime() : managerAssignment.Completed.Value.ToUserTime(); var resolutionDate = Docflow.PublicFunctions.Module.ToShortDateShortTime(completionDate); block.AddLabel(Docflow.Resources.StateViewResolution, headerStyle); block.AddLineBreak(); block.AddLabel(string.Format("{0}: {1} {2}: {3}", DocumentReviewTasks.Resources.StateViewAuthor, author, Docflow.OfficialDocuments.Resources.StateViewDate, resolutionDate), performerStyle); block.AddLineBreak(); block.AddLabel(Docflow.Constants.Module.SeparatorText, separatorStyle); block.AddLineBreak(); block.AddEmptyLine(Docflow.Constants.Module.EmptyLineMargin); // Если поручения не созданы, или рассмотрение выполнено с результатом "Вынести резолюцию" или "Принято к сведению" и помощник сам не отправлял поручения в работу. // В старых задачах поручение и рассмотрение не связаны, поэтому обрабатываем такие случаи как резолюцию. if (!actionItems.Any() || (managerAssignment != null && managerAssignment.Result != RecordManagement.ReviewManagerAssignment.Result.AddAssignment && managerAssignment.Result != RecordManagement.ReviewDraftResolutionAssignment.Result.ForExecution && !(resolutionAssignment != null && resolutionAssignment.Result == RecordManagement.PreparingDraftResolutionAssignment.Result.AddAssignment))) { var comment = resolutionAssignment != null && resolutionAssignment.Result == RecordManagement.PreparingDraftResolutionAssignment.Result.AddAssignment ? Docflow.PublicFunctions.Module.GetFormatedUserText(resolutionAssignment.Texts.Last().Body) : Docflow.PublicFunctions.Module.GetFormatedUserText(managerAssignment.Texts.Last().Body); block.AddLabel(comment); block.AddLineBreak(); } else { // Добавить информацию по каждому поручению. foreach (var actionItem in actionItems) { if (actionItem.IsCompoundActionItem == true) { foreach (var item in actionItem.ActionItemParts) { if (item.ActionItemPartExecutionTask != null) { Functions.ActionItemExecutionTask.AddActionItemInfo(block, item.ActionItemPartExecutionTask, author); } } } else { Functions.ActionItemExecutionTask.AddActionItemInfo(block, actionItem, author); } } } } return(block); }