Ejemplo n.º 1
0
        public virtual void StartAssignment2(Sungero.Docflow.IFreeApprovalAssignment assignment, Sungero.Docflow.Server.FreeApprovalAssignmentArguments e)
        {
            // Обновляем вложения - актуально для согласующих, добавленных в середине процесса.
            Functions.FreeApprovalTask.SynchronizeAddendaAndAttachmentsGroup(_obj);

            // Дополнительно выдаем права на случай переадресации.
            Functions.FreeApprovalTask.GrantRightForAttachmentsToPerformers(_obj, new List <IRecipient> {
                assignment.Performer
            });

            var task = FreeApprovalTasks.As(assignment.Task);

            if (!task.Approvers.Select(x => x.Approver).Contains(assignment.Performer))
            {
                var approver = task.Approvers.AddNew();
                approver.Approver = assignment.Performer;
                task.Save();
            }
        }
Ejemplo n.º 2
0
        public virtual void CompleteAssignment2(Sungero.Docflow.IFreeApprovalAssignment assignment, Sungero.Docflow.Server.FreeApprovalAssignmentArguments e)
        {
            Functions.FreeApprovalTask.SynchronizeAddendaAndAttachmentsGroup(_obj);

            // Выдать права на приложения.
            var recipientsToGrantRights = Functions.Module.GetTaskAssignees(_obj);

            Functions.FreeApprovalTask.GrantRightForAttachmentsToPerformers(_obj, recipientsToGrantRights);

            var assignmentsInWork = FreeApprovalAssignments.GetAll(asg => asg.Task.Equals(_obj) &&
                                                                   asg.TaskStartId == _obj.StartId &&
                                                                   asg.Status == Sungero.Workflow.AssignmentBase.Status.InProcess);

            if (assignment.Result == Sungero.Docflow.FreeApprovalAssignment.Result.ForRework && _obj.ReceiveNotice == true &&
                _schemeVersion >= SchemeVersions.V2 && assignmentsInWork.Any())
            {
                var notice = FreeApprovalNotifications.Create(_obj);
                notice.Performer = _obj.Author;
                var lastIterationId         = Functions.FreeApprovalTask.GetApprovalAssignmentLastIterationId(_obj);
                var firstApprovalAssignment = Functions.FreeApprovalTask.GetLastAssignmentWithoutNotice(_obj, lastIterationId).First();
                notice.LinkedFreeApprovalAssignment = firstApprovalAssignment;
                notice.Author = firstApprovalAssignment.Performer;
                var subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.ReworkNoticeSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name);
                notice.Subject = subject.Length > FreeApprovalNotifications.Info.Properties.Subject.Length ?
                                 subject.Substring(0, FreeApprovalNotifications.Info.Properties.Subject.Length) :
                                 subject;
            }

            if (assignment.Result == Sungero.Docflow.FreeApprovalAssignment.Result.Forward)
            {
                assignment.Forward(assignment.Addressee, ForwardingLocation.Next, assignment.AddresseeDeadline);
                var approver = _obj.Approvers.Where(x => Equals(x.Approver, assignment.Performer)).FirstOrDefault();
                _obj.Approvers.Remove(approver);

                var newApprover = _obj.Approvers.AddNew();
                newApprover.Approver = assignment.Addressee;
            }
        }