Example #1
0
        public virtual bool Decision17Result()
        {
            var addressee      = Employees.As(_obj.Addressee);
            var lastAssignment = Assignments.GetAll(x => Equals(x.MainTask, _obj)).ToList().LastOrDefault();
            var isForwarded    = lastAssignment != null && lastAssignment.Result == Sungero.RecordManagement.ReviewManagerAssignment.Result.Forward;

            return(Docflow.PublicFunctions.Module.GetSecretaries(addressee).Any(x => x.PreparesResolution == true && Equals(x.Assistant, _obj.StartedBy)) && !isForwarded);
        }
Example #2
0
 /// <summary>
 /// Получить задание на подготовку проекта резолюции.
 /// </summary>
 /// <param name="startDate">Дата начала текущей итерации рассмотрения.</param>
 /// <returns>Задание на подготовку проекта резолюции.</returns>
 private IAssignment GetPreparingDraftResolutionAssignment(DateTime startDate)
 {
     return(Assignments.GetAll()
            .Where(a => Equals(a.Task, _obj))
            .Where(a => a.Created >= startDate)
            .Where(a => PreparingDraftResolutionAssignments.Is(a))
            .OrderByDescending(a => a.Created)
            .FirstOrDefault());
 }
Example #3
0
        /// <summary>
        /// Получить результат выполнения задания руководителю с последней итерации.
        /// </summary>
        /// <param name="task">Задача "рассмотрение входящего".</param>
        /// <returns>Результат задания руководителю.</returns>
        public static Enumeration?GetLastAssignmentResult(IDocumentReviewTask task)
        {
            var lastAssignments = Assignments.GetAll(c => Equals(c.Task, task) && c.Status == Sungero.Workflow.Assignment.Status.Completed)
                                  .OrderByDescending(c => c.Completed);

            if (!lastAssignments.Any())
            {
                return(null);
            }
            else
            {
                return(lastAssignments.First().Result.Value);
            }
        }
Example #4
0
        public virtual void StartBlock11(Sungero.RecordManagement.Server.PreparingDraftResolutionAssignmentArguments e)
        {
            var addressee = Employees.As(_obj.Addressee);
            var assistant = Docflow.PublicFunctions.Module.GetSecretary(addressee);

            // Добавить адресата в качестве исполнителя.
            e.Block.Performers.Add(assistant);

            // Вычислить дедлайн задания.
            // На подготовку проекта резолюции 4 часа.
            e.Block.RelativeDeadlineHours = 4;

            // Проставляем признак того, что задание для доработки.
            var lastReview = Assignments
                             .GetAll(a => Equals(a.Task, _obj) && Equals(a.TaskStartId, _obj.StartId))
                             .OrderByDescending(a => a.Created)
                             .FirstOrDefault();

            if (lastReview != null && ReviewDraftResolutionAssignments.Is(lastReview) &&
                lastReview.Result == RecordManagement.ReviewDraftResolutionAssignment.Result.AddResolution)
            {
                e.Block.IsRework = true;
            }

            var document = _obj.DocumentForReviewGroup.OfficialDocuments.First();

            var result = Functions.DocumentReviewTask.GetLastAssignmentResult(_obj);

            if (result != RecordManagement.ReviewDraftResolutionAssignment.Result.AddResolution)
            {
                e.Block.Subject = Docflow.PublicFunctions.Module.TrimSpecialSymbols(DocumentReviewTasks.Resources.PrepareDraftResolution, document.Name);
            }
            else
            {
                e.Block.Subject = Docflow.PublicFunctions.Module.TrimSpecialSymbols(DocumentReviewTasks.Resources.ReworkPrepareDraftResolution, document.Name);
            }

            Docflow.PublicFunctions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document);

            // Выдать исполнителю права на вложения.
            Functions.DocumentReviewTask.GrantRightForAttachmentsToAssignees(_obj, e.Block.Performers.ToList());
        }
Example #5
0
        /// <summary>
        /// Получить дату начала текущей итерации рассмотрения.
        /// </summary>
        /// <returns>Дата начала текущей итерации рассмотрения.</returns>
        private DateTime GetIterationStartDate()
        {
            if (!_obj.Started.HasValue)
            {
                return(_obj.Created.Value);
            }

            var startDate        = _obj.Started.Value;
            var lastForwardedAsg = Assignments.GetAll()
                                   .Where(a => Equals(a.Task, _obj))
                                   .Where(a => a.Created >= startDate)
                                   .Where(a => a.Status == Workflow.AssignmentBase.Status.Completed)
                                   .Where(a => a.Result == RecordManagement.ReviewManagerAssignment.Result.Forward)
                                   .OrderByDescending(a => a.Completed.Value)
                                   .FirstOrDefault();

            if (lastForwardedAsg != null)
            {
                startDate = lastForwardedAsg.Completed.Value;
            }

            return(startDate);
        }
Example #6
0
        public virtual bool Decision12Result()
        {
            var currentTaskStartId = _obj.StartId;
            var minAssignmentDate  = Assignments.GetAll(a => Equals(a.Task, _obj) && a.TaskStartId == currentTaskStartId).Min(a => a.Created);
            var reworkAssignments  = FreeApprovalReworkAssignments.GetAll(a => Equals(a.Task, _obj) && a.TaskStartId == currentTaskStartId);

            DateTime lastIterationDate;

            if (reworkAssignments.Any())
            {
                var maxCreated = reworkAssignments.Max(a => a.Created);
                lastIterationDate = maxCreated > minAssignmentDate ? maxCreated.Value : minAssignmentDate.Value;
            }
            else
            {
                lastIterationDate = minAssignmentDate.Value;
            }

            var needRework          = false;
            var approvalAssignments = FreeApprovalAssignments.GetAll()
                                      .Where(a => Equals(a.Task, _obj) && a.Created >= lastIterationDate)
                                      .ToList();

            foreach (var assignment in approvalAssignments.Where(a => a.Result == Docflow.FreeApprovalAssignment.Result.ForRework))
            {
                var hasApprovedAssignment = approvalAssignments.Any(a => Equals(a.Performer, assignment.Performer) &&
                                                                    a.Modified > assignment.Modified &&
                                                                    Equals(a.Result, Docflow.FreeApprovalAssignment.Result.Approved));
                if (!hasApprovedAssignment)
                {
                    needRework = true;
                    break;
                }
            }
            return(needRework);
        }
Example #7
0
        public Sungero.Core.StateView GetStateView()
        {
            // Добавить заголовок.
            var stateView = StateView.Create();

            var taskBeginText = _obj.Texts.OrderBy(t => t.Created).FirstOrDefault();
            var comment       = taskBeginText != null ? taskBeginText.Body : string.Empty;

            comment = comment != FreeApprovalTasks.Resources.ApprovalText ? comment : string.Empty;
            if (_obj.Started.HasValue)
            {
                Docflow.PublicFunctions.OfficialDocument
                .AddUserActionBlock(stateView, _obj.Author, ApprovalTasks.Resources.StateViewDocumentSentForApproval, _obj.Started.Value, _obj, comment, _obj.StartedBy);
            }
            else
            {
                Docflow.PublicFunctions.OfficialDocument
                .AddUserActionBlock(stateView, _obj.Author, ApprovalTasks.Resources.StateViewTaskDrawCreated, _obj.Created.Value, _obj, comment, _obj.Author);
            }

            // Добавить основной блок для задачи.
            var taskBlock = this.AddTaskBlock(stateView);

            // Получить все задания по задаче.
            var taskAssignments = Assignments.GetAll().Where(a => Equals(a.Task, _obj)).ToList();

            // Определить итерации.
            var iterations = Functions.Module.GetIterationDates(_obj);

            // Обработать каждую итерацию.
            foreach (var iteration in iterations)
            {
                var date             = iteration.Date;
                var hasReworkBefore  = iteration.IsRework;
                var hasRestartBefore = iteration.IsRestart;

                var nextIteration = iterations.Where(d => d.Date > date).FirstOrDefault();
                var nextDate      = Calendar.Now;

                if (nextIteration != null)
                {
                    nextDate = nextIteration.Date;
                }

                // Получить задания в рамках круга согласования.
                var assignments = taskAssignments
                                  .Where(a => a.Created >= date && a.Created < nextDate)
                                  .OrderBy(a => a.Created)
                                  .ToList();

                // Если нет заданий, то перейти к следующей итерации.
                if (!assignments.Any())
                {
                    continue;
                }

                // Добавить блок отправки.
                this.AddSendForApprovalBlock(taskBlock, assignments.First(), hasReworkBefore, hasRestartBefore);

                StateBlock parentBlock = null;

                // Выделить этап согласования.
                var approvalAssignments = assignments.Where(a => FreeApprovalAssignments.Is(a));
                if (approvalAssignments.Any())
                {
                    // Вставить блок для группировки этапа согласования.
                    var iterationBlock = taskBlock.AddChildBlock();
                    iterationBlock.NeedGroupChildren = true;
                    iterationBlock.IsExpanded        = approvalAssignments.Any(a => a.Status == Workflow.AssignmentBase.Status.InProcess);

                    // Заголовок блока итерации.
                    iterationBlock.AddLabel(ApprovalTasks.Resources.StateViewApprovalStage, Docflow.PublicFunctions.Module.CreateHeaderStyle());
                    iterationBlock.AddLineBreak();

                    // Добавить информацию по исполнителям группы согласования.
                    var performersLabel = string.Join(", ", approvalAssignments
                                                      .Select(a => a.Performer)
                                                      .Distinct()
                                                      .Select(a => (Sungero.Company.Employees.Is(a) ?
                                                                    Company.PublicFunctions.Employee.GetShortName(Sungero.Company.Employees.As(a), false) :
                                                                    a.Name)));
                    iterationBlock.AddLabel(performersLabel, Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle());

                    parentBlock = iterationBlock;
                }

                // Добавить задания.
                assignments = assignments.OrderByDescending(a => a.Result.HasValue).ThenBy(a => a.Completed).ToList();
                this.AddAssignmentsBlocks(parentBlock, taskBlock, assignments);

                // Установить иконку и статус для группировки этапа согласования.
                var endStatus = string.Empty;
                if (parentBlock != null)
                {
                    // Иконка по умолчанию.
                    parentBlock.AssignIcon(FreeApprovalTasks.Resources.FreeApproveStage, StateBlockIconSize.Large);

                    if (approvalAssignments.Any(a => a.Result == Docflow.FreeApprovalAssignment.Result.ForRework))
                    {
                        parentBlock.AssignIcon(ApprovalTasks.Resources.Notapprove, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewNotApproved;
                    }
                    else if (!approvalAssignments.Any(a => a.Result != Docflow.FreeApprovalAssignment.Result.Approved))
                    {
                        parentBlock.AssignIcon(ApprovalTasks.Resources.Approve, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewEndorsed;
                    }

                    if (assignments.Any(a => a.Status == Workflow.AssignmentBase.Status.Aborted))
                    {
                        parentBlock.AssignIcon(StateBlockIconType.Abort, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewAborted;
                    }

                    Functions.Module.AddInfoToRightContent(parentBlock, parentBlock.IsExpanded ? ApprovalTasks.Resources.StateViewInProcess : endStatus);
                }
            }

            return(stateView);
        }