예제 #1
0
        public virtual void StartBlock7(Sungero.Docflow.Server.FreeApprovalNotificationArguments e)
        {
            // Синхронизировать группу приложений документа.
            var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault();

            Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document);
            if (OfficialDocuments.Is(document))
            {
                Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup);
            }

            e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.NewApprovalLapSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name);

            var approvalReworkAssignments = FreeApprovalReworkAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId);

            if (approvalReworkAssignments.Any())
            {
                var lastApprovalReworkAssignments = approvalReworkAssignments.OrderByDescending(asg => asg.Created).First();

                foreach (var recipient in lastApprovalReworkAssignments.Approvers.Where(apr => apr.Action == Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendNotice))
                {
                    e.Block.Performers.Add(recipient.Approver);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Получить нестандартных исполнитлей задачи.
        /// </summary>
        /// <returns>Исполнители.</returns>
        public virtual List <IRecipient> GetTaskAdditionalAssignees()
        {
            var assignees = new List <IRecipient>();

            var freeApprovalTask = FreeApprovalTasks.As(_obj);

            if (freeApprovalTask == null)
            {
                return(assignees);
            }

            assignees.AddRange(freeApprovalTask.Approvers.Where(a => a.Approver != null).Select(a => a.Approver));

            var reworkAssignment = FreeApprovalReworkAssignments
                                   .GetAll(asg => Equals(asg.Task, _obj) && asg.TaskStartId == _obj.StartId)
                                   .OrderByDescending(asg => asg.Created)
                                   .FirstOrDefault();

            if (reworkAssignment != null)
            {
                assignees.AddRange(reworkAssignment.Approvers.Where(a => a.Approver != null).Select(a => a.Approver));
            }

            assignees.AddRange(freeApprovalTask.Observers.Where(a => a.Observer != null).Select(a => a.Observer));

            return(assignees.Distinct().ToList());
        }
예제 #3
0
        public virtual void StartBlock2(Sungero.Docflow.Server.FreeApprovalAssignmentArguments e)
        {
            e.Block.IsParallel = true;
            e.Block.Subject    = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.ApproversAsgSubject,
                                                                     _obj.ForApprovalGroup.ElectronicDocuments.First().Name);

            var reworkAssignments = FreeApprovalReworkAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId);

            // Если заданий на доработку нет, то заполняем согласующих из задачи, если есть - то из последнего задания на доработку.
            if (!reworkAssignments.Any())
            {
                if (_obj.MaxDeadline.HasValue)
                {
                    e.Block.AbsoluteDeadline = _obj.MaxDeadline.Value;
                }
                foreach (var recipient in _obj.Approvers.OrderBy(apr => apr.Id))
                {
                    var approversList = Functions.FreeApprovalTask.GetUsersFromGroups(recipient.Approver);
                    foreach (var groupRecipient in approversList)
                    {
                        if (!e.Block.Performers.Contains(groupRecipient))
                        {
                            e.Block.Performers.Add(groupRecipient);
                        }
                    }
                }
                // Выдать права на документы всем согласующим, включая группы.
                Functions.FreeApprovalTask.GrantRightForAttachmentsToPerformers(_obj, _obj.Approvers.Select(apr => apr.Approver).ToList());
            }
            else
            {
                var lastReworkAssignment = reworkAssignments.OrderByDescending(asg => asg.Created).First();
                if (lastReworkAssignment.NewDeadline.HasValue)
                {
                    e.Block.AbsoluteDeadline = lastReworkAssignment.NewDeadline.Value;
                }
                _obj.MaxDeadline = lastReworkAssignment.NewDeadline;

                foreach (var element in lastReworkAssignment.Approvers.Where(asg => asg.Action == Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendForApproval))
                {
                    e.Block.Performers.Add(element.Approver);
                }
                // Выдать права на документы всем согласующим сотрудникам.
                Functions.FreeApprovalTask.GrantRightForAttachmentsToPerformers(_obj, e.Block.Performers.ToList());
            }
        }
예제 #4
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);
        }
예제 #5
0
        public virtual void StartBlock3(Sungero.Docflow.Server.FreeApprovalReworkAssignmentArguments e)
        {
            // Синхронизировать группу приложений документа.
            var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault();

            Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document);
            if (OfficialDocuments.Is(document))
            {
                Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup);
            }

            e.Block.Performers.Add(_obj.Author);
            e.Block.RelativeDeadlineDays = 3;
            e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.RevisionAsgSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name);
            if (_obj.MaxDeadline.HasValue)
            {
                e.Block.NewDeadline = _obj.MaxDeadline;
            }

            var approvalAssignments = FreeApprovalAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId);
            var reworkAssignments   = FreeApprovalReworkAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId);
            var lastIterationId     = Functions.FreeApprovalTask.GetApprovalAssignmentLastIterationId(_obj);

            // Если заданий на доработку не было, то заполняем всю таблицу из заданий по задаче,
            // если были - то исполнителей берем из последнего задания на доработку, а результат и действие заполняем по последним заданиям на согласование.
            if (!reworkAssignments.Any())
            {
                foreach (var aprAssignment in approvalAssignments.Where(asg => asg.IterationId == lastIterationId).OrderBy(i => i.Created))
                {
                    Functions.FreeApprovalTask.AddToReworkAssigneeNewApprover(e, aprAssignment);
                }
            }
            else
            {
                var approvalReworkAssignmentFromLastIteration = reworkAssignments.OrderByDescending(asg => asg.Created).First();
                foreach (var asgApprover in approvalReworkAssignmentFromLastIteration.Approvers.OrderBy(asg => asg.Id))
                {
                    // Копируем все значения.
                    var newApprover = e.Block.Approvers.FirstOrDefault(a => Equals(a.Approver, asgApprover.Approver)) ?? e.Block.Approvers.AddNew();
                    newApprover.Approver = asgApprover.Approver;
                    newApprover.Approved = asgApprover.Approved;
                    newApprover.Action   = asgApprover.Action;

                    // Если результат согласования изменился \ согласование не было выполнено - перебиваем данные.
                    var lastApprovalAsg = approvalAssignments.Where(asg => asg.Performer.Equals(asgApprover.Approver)).OrderByDescending(asg => asg.IterationId).ThenByDescending(asg => asg.Modified).FirstOrDefault();
                    if (lastApprovalAsg != null)
                    {
                        if (lastApprovalAsg.Result == Sungero.Docflow.FreeApprovalAssignment.Result.Approved)
                        {
                            newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.IsApproved;
                            newApprover.Action   = newApprover.Action == Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendForApproval ?
                                                   Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendNotice : Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.DoNotSend;
                        }
                        else if (lastApprovalAsg.Result == Sungero.Docflow.FreeApprovalAssignment.Result.Forward)
                        {
                            newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.NotApproved;
                            newApprover.Action   = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.DoNotSend;
                        }
                        else
                        {
                            newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.NotApproved;
                            newApprover.Action   = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendForApproval;
                        }
                    }
                }
                foreach (var newApproval in approvalAssignments.Where(a => a.IterationId == lastIterationId).OrderBy(i => i.Created))
                {
                    Functions.FreeApprovalTask.AddToReworkAssigneeNewApprover(e, newApproval);
                }
            }
        }