Exemple #1
0
 public static List <IActionItemExecutionTask> GetSubActionItemExecution(IActionItemExecutionAssignment entity)
 {
     return(ActionItemExecutionTasks
            .GetAll()
            .Where(j => j.Status.Value == Workflow.Task.Status.InProcess)
            .Where(j => j.ActionItemType == ActionItemType.Additional)
            .Where(j => j.ParentAssignment == entity)
            .ToList());
 }
Exemple #2
0
        public virtual bool Monitoring11Result()
        {
            if (_obj.IsCompoundActionItem != true)
            {
                return(true);
            }

            return(!ActionItemExecutionTasks.GetAll(j => Equals(j.ParentTask, _obj) &&
                                                    j.ActionItemType != ActionItemType.Main &&
                                                    j.Status.Value == Workflow.Task.Status.InProcess &&
                                                    j.ParentStartId == _obj.StartId).Any());
        }
Exemple #3
0
        public virtual void Script4Execute()
        {
            var desiredDeadline = _obj.NewDeadline;

            // Обновить срок у задания.
            var actionItemAssignment = ActionItemExecutionAssignments.Get(_obj.ParentAssignment.Id);

            actionItemAssignment.Deadline      = desiredDeadline;
            actionItemAssignment.ScheduledDate = desiredDeadline;
            actionItemAssignment.Save();

            // Обновить срок у задачи.
            var actionItemExecution = ActionItemExecutionTasks.Get(actionItemAssignment.Task.Id);

            actionItemExecution.Deadline    = desiredDeadline;
            actionItemExecution.MaxDeadline = desiredDeadline;

            // Обновить срок у составной задачи.
            if (actionItemExecution.ActionItemType == ActionItemType.Component)
            {
                var component  = ActionItemExecutionTasks.Get(actionItemExecution.ParentTask.Id);
                var actionItem = component.ActionItemParts.FirstOrDefault(j => Equals(j.Assignee, actionItemExecution.Assignee) &&
                                                                          Equals(j.ActionItemPart, actionItemExecution.ActionItem) &&
                                                                          j.Deadline == _obj.CurrentDeadline);
                if (actionItem != null)
                {
                    actionItem.Deadline = desiredDeadline;
                }
            }

            // Продлить сроки соисполнителей.
            foreach (var performer in actionItemExecution.CoAssignees)
            {
                var subTasks = ActionItemExecutionTasks.GetAll(t => Equals(t.MainTask, actionItemExecution) &&
                                                               t.Status == Sungero.Workflow.Task.Status.InProcess &&
                                                               Equals(t.Assignee, performer.Assignee));
                foreach (var subTask in subTasks)
                {
                    subTask.Deadline    = desiredDeadline;
                    subTask.MaxDeadline = desiredDeadline;

                    // Продлить срок у активного задания соисполнителя.
                    var assignment = ActionItemExecutionAssignments.GetAll()
                                     .FirstOrDefault(a => Equals(a.Task, subTask) && a.Status == Sungero.Workflow.AssignmentBase.Status.InProcess);

                    if (assignment != null)
                    {
                        assignment.Deadline      = desiredDeadline;
                        assignment.ScheduledDate = desiredDeadline;
                    }
                }
            }
        }
Exemple #4
0
        public virtual void CompleteAssignment6(Sungero.RecordManagement.IReviewResolutionAssignment assignment, Sungero.RecordManagement.Server.ReviewResolutionAssignmentArguments e)
        {
            var document = _obj.DocumentForReviewGroup.OfficialDocuments.First();

            // Если поручения не созданы, то изменить статус исполнения - не требует исполнения.
            if (!ActionItemExecutionTasks.GetAll(t => t.Status == Workflow.Task.Status.InProcess && Equals(t.ParentAssignment, assignment)).Any())
            {
                document.ExecutionState = ExecutionState.WithoutExecut;
            }
            else
            {
                document.ExecutionState = ExecutionState.OnExecution;
            }
        }
Exemple #5
0
        public virtual void StartBlock2(Sungero.RecordManagement.Server.ActionItemSupervisorNotificationArguments e)
        {
            // Задать тему.
            e.Block.Subject = Functions.ActionItemExecutionTask.GetActionItemExecutionSubject(_obj, ActionItemExecutionTasks.Resources.ControlNoticeSubject);

            // Задать исполнителя.
            if (_obj.Supervisor != null && _obj.Author != _obj.Supervisor && _obj.StartedBy != _obj.Supervisor && (_obj.ActionItemType == ActionItemType.Main))
            {
                e.Block.Performers.Add(_obj.Supervisor);
            }

            Functions.ActionItemExecutionTask.GrantRightsToAttachments(_obj, _obj.DocumentsGroup.All.ToList(), true);
            Functions.ActionItemExecutionTask.GrantRightsToAttachments(_obj, _obj.AddendaGroup.All.ToList(), true);

            var document = _obj.DocumentsGroup.OfficialDocuments.FirstOrDefault();

            if (document != null)
            {
                var documentsGroupGuid    = Docflow.PublicConstants.Module.TaskMainGroup.ActionItemExecutionTask;
                var nonStartedActiveTasks = ActionItemExecutionTasks
                                            .GetAll(t => t.AttachmentDetails.Any(a => a.GroupId == documentsGroupGuid && a.AttachmentId == document.Id) && t.Status == Workflow.Task.Status.InProcess && t.Id != _obj.Id)
                                            .ToList();

                foreach (var task in nonStartedActiveTasks)
                {
                    var hasAssignments = Workflow.Assignments.GetAll(s => Equals(task, s.Task)).Any();
                    var hasSubTasks    = Workflow.Tasks.GetAll(s => Equals(task, s.ParentTask)).Any();
                    if (!hasAssignments && !hasSubTasks)
                    {
                        Logger.DebugFormat("Granting rights for task {0}. Current Task: {1}", task.Id, _obj.Id);
                        Functions.ActionItemExecutionTask.GrantRightsToAttachments(task, task.DocumentsGroup.All.ToList(), true);
                        Functions.ActionItemExecutionTask.GrantRightsToAttachments(task, task.AddendaGroup.All.ToList(), true);
                    }
                }
            }

            Docflow.PublicFunctions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, _obj.DocumentsGroup.OfficialDocuments.FirstOrDefault());

            // Выдача прав соисполнителям и составным, чтобы Script10Execute в цикле не зависал при блокировках документа
            if (document != null)
            {
                var assignees     = _obj.CoAssignees.Select(a => a.Assignee);
                var partAssignees = _obj.ActionItemParts.Select(p => p.Assignee);
                foreach (var assignee in assignees.Concat(partAssignees))
                {
                    if (!document.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.Read, assignee))
                    {
                        document.AccessRights.Grant(assignee, DefaultAccessRightsTypes.Read);
                    }
                }
            }

            // Задать состояние поручения.
            if (_obj.ExecutionState != ExecutionState.OnRework && _obj.Assignee != null)
            {
                _obj.ExecutionState = ExecutionState.OnExecution;
            }

            // Заполнить исполнителя, если это первое поручение по документу.
            if (document != null && document.Assignee == null && document.State.Properties.Assignee.IsVisible)
            {
                document.Assignee = _obj.Assignee;
            }

            // Обновить статус исполнения документа
            Functions.ActionItemExecutionTask.SetDocumentStates(_obj);
        }
Exemple #6
0
        /// <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);
        }