public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Task.ParentAssignment.Status != Workflow.AssignmentBase.Status.InProcess)
            {
                // Добавить автотекст.
                e.Result = DeadlineExtensionAssignments.Resources.Complete;
                return;
            }

            if (_obj.Result.Value == Result.ForRework)
            {
                // Проверить заполненность причины отказа.
                if (_obj.Texts.Last().IsAutoGenerated ?? false)
                {
                    e.AddError(DeadlineExtensionAssignments.Resources.RefusalReasonNotFilled);
                }

                // Добавить автотекст.
                e.Result = DeadlineExtensionAssignments.Resources.Denied;
            }
            else
            {
                // Новый срок должен быть больше старого.
                if (!Functions.Module.CheckDeadline(_obj.Task.Author, _obj.NewDeadline, _obj.ScheduledDate))
                {
                    e.AddError(_obj.Info.Properties.NewDeadline, DeadlineExtensionTasks.Resources.DesiredDeadlineIsNotCorrect);
                }

                // Добавить автотекст.
                var desiredDeadlineLabel = Functions.DeadlineExtensionTask.GetDesiredDeadlineLabel(_obj.NewDeadline.Value);
                e.Result = DeadlineExtensionAssignments.Resources.DeadlineExtendedFormat(desiredDeadlineLabel);
            }
        }
Example #2
0
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Result.Value == Result.ForRework)
            {
                // Проверить заполненность причины отказа.
                if (_obj.Texts.Last().IsAutoGenerated ?? false)
                {
                    e.AddError(DeadlineExtensionAssignments.Resources.RefusalReasonNotFilled);
                }

                // Добавить автотекст.
                e.Result = DeadlineExtensionAssignments.Resources.Denied;
            }
            else
            {
                // Новый срок поручения должен быть больше старого.
                if (_obj.NewDeadline <= _obj.ScheduledDate)
                {
                    e.AddError(_obj.Info.Properties.NewDeadline, DeadlineExtensionTasks.Resources.DesiredDeadlineIsNotCorrect, new[] { _obj.Info.Properties.NewDeadline });
                }

                // Добавить автотекст.
                var desiredDeadlineLabel = Functions.DeadlineExtensionTask.GetDesiredDeadlineLabel(_obj.NewDeadline.Value);
                e.Result = DeadlineExtensionAssignments.Resources.DeadlineExtendedFormat(desiredDeadlineLabel);
            }
        }
Example #3
0
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Result.Value == Result.AddResolution && (_obj.Texts.Last().IsAutoGenerated ?? false))
            {
                e.AddError(ApprovalReviewAssignments.Resources.ResolutionTextNeeded);
            }

            // Проверить зарегистрированность документа, если схлопнуто с этапом регистрации.
            if ((_obj.Result.Value == Result.AddActionItem || _obj.Result.Value == Result.AddResolution || _obj.Result.Value == Result.Informed) &&
                Functions.ApprovalTask.CurrentStageCollapsedWithSpecificStage(ApprovalTasks.As(_obj.Task), _obj.StageNumber, Docflow.ApprovalStage.StageType.Register))
            {
                var registrationState = _obj.DocumentGroup.OfficialDocuments.First().RegistrationState;
                if (registrationState == null || registrationState != Docflow.OfficialDocument.RegistrationState.Registered)
                {
                    e.AddError(ApprovalTasks.Resources.ToPerformNeedRegisterDocument);
                }
            }

            // Добавить автотекст.
            if (_obj.Result == Result.ForRework)
            {
                e.Result = ApprovalTasks.Resources.ForRework;
            }
            else
            {
                e.Result = Functions.ApprovalTask.GetCollapsedResult(ApprovalTasks.As(_obj.Task), _obj.Result);
            }
        }
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Task.SchemeVersion > 2)
            {
                if (!Functions.Module.CheckDeadline(_obj.Addressee ?? Users.Current, _obj.AddresseeDeadline, Calendar.Now))
                {
                    e.AddError(_obj.Info.Properties.AddresseeDeadline, FreeApprovalTasks.Resources.ImpossibleSpecifyDeadlineLessThanToday);
                }

                if (!Functions.FreeApprovalAssignment.CanForwardTo(_obj, _obj.Addressee))
                {
                    e.AddError(_obj.Info.Properties.Addressee, FreeApprovalAssignments.Resources.ApproverAlreadyExistsFormat(_obj.Addressee.Person.ShortName));
                }
            }

            if (_obj.Result == Result.Approved)
            {
                e.Result = Docflow.FreeApprovalTasks.Resources.Approved;
            }
            else if (_obj.Result == Result.Forward)
            {
                e.Result = FreeApprovalTasks.Resources.ForwardedFormat(Company.PublicFunctions.Employee.GetShortName(_obj.Addressee, DeclensionCase.Dative, true));
            }
            else
            {
                e.Result = Docflow.FreeApprovalTasks.Resources.ForRework;
            }
        }
Example #5
0
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Result.Value == Result.ForRework)
            {
                // Проверить заполненность комментария к повторному запросу.
                if (_obj.Texts.Last().IsAutoGenerated ?? false)
                {
                    e.AddError(DeadlineRejectionAssignments.Resources.RequestCommentNotFilled);
                }

                // Новый срок поручения должен быть позже старого.
                if (_obj.NewDeadline <= _obj.CurrentDeadline)
                {
                    e.AddError(_obj.Info.Properties.NewDeadline, DeadlineExtensionTasks.Resources.DesiredDeadlineIsNotCorrect, new[] { _obj.Info.Properties.NewDeadline });
                }

                // Добавить автотекст.
                e.Result = DeadlineRejectionAssignments.Resources.RequestedRepeatedly;
            }
            else
            {
                // Добавить автотекст.
                e.Result = DeadlineRejectionAssignments.Resources.RequestedAccepted;
            }
        }
Example #6
0
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            // Обязательность полей могла измениться.
            var document     = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();
            var stages       = Functions.ApprovalTask.GetStages(ApprovalTasks.As(_obj.Task)).Stages;
            var hasSignStage = Functions.ApprovalRuleBase.HasApprovalStage(_obj.ApprovalRule, Docflow.ApprovalStage.StageType.Sign, document, stages);

            _obj.State.Properties.Signatory.IsVisible  = hasSignStage;
            _obj.State.Properties.Signatory.IsRequired = hasSignStage;

            // Проверить, имеет ли право подписывающий на подпись.
            if (hasSignStage &&
                !Functions.ApprovalTask.CheckSignatory(ApprovalTasks.As(_obj.Task), _obj.Signatory, stages))
            {
                e.AddError(_obj.Info.Properties.Signatory, ApprovalTasks.Resources.IncorrectSignatory);
            }

            if (_obj.Result == Result.ForReapproving)
            {
                e.Result = ApprovalTasks.Resources.ForReapproving;
            }
            else if (_obj.Result == Result.Forward)
            {
                e.Result = FreeApprovalTasks.Resources.ForwardedFormat(Company.PublicFunctions.Employee.GetShortName(_obj.ForwardPerformer, DeclensionCase.Dative, true));
            }
            else
            {
                e.Result = ApprovalTasks.Resources.AbortApproving;
            }
        }
Example #7
0
 public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
 {
     if (!Functions.Module.CheckDeadline(_obj.NewDeadline, Calendar.Now))
     {
         e.AddError(_obj.Info.Properties.NewDeadline, FreeApprovalTasks.Resources.ImpossibleSpecifyDeadlineLessThanToday, new[] { _obj.Info.Properties.NewDeadline });
     }
     else if (_obj.Result == Result.Reworked)
     {
         e.Result = Docflow.FreeApprovalTasks.Resources.ForReapproving;
     }
     else
     {
         e.Result = Docflow.FreeApprovalTasks.Resources.AbortApproving;
     }
 }
Example #8
0
        public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
        {
            if (_obj.Task.SchemeVersion > 1 && !Functions.ApprovalAssignment.CanForwardTo(_obj, _obj.Addressee))
            {
                e.AddError(_obj.Info.Properties.Addressee, FreeApprovalAssignments.Resources.ApproverAlreadyExistsFormat(_obj.Addressee.Person.ShortName));
            }

            if (_obj.Result == Result.Approved)
            {
                e.Result = ApprovalTasks.Resources.Endorsed;
            }
            else if (_obj.Result == Result.Forward)
            {
                e.Result = FreeApprovalTasks.Resources.ForwardedFormat(Company.PublicFunctions.Employee.GetShortName(_obj.Addressee, DeclensionCase.Dative, true));
            }
            else
            {
                e.Result = ApprovalTasks.Resources.ForRework;
            }
        }
 public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
 {
     // Проверить зарегистрированность документа, если схлопнуто с этапом регистрации.
     if (_obj.Result == Result.Complete && Functions.ApprovalTask.CurrentStageCollapsedWithSpecificStage(ApprovalTasks.As(_obj.Task), _obj.StageNumber, Docflow.ApprovalStage.StageType.Register))
     {
         var registrationState = _obj.DocumentGroup.OfficialDocuments.First().RegistrationState;
         if (registrationState == null || registrationState != Docflow.OfficialDocument.RegistrationState.Registered)
         {
             e.AddError(ApprovalTasks.Resources.ToPerformNeedRegisterDocument);
             return;
         }
     }
     if (_obj.Result == Result.ForRevision)
     {
         e.Result = ApprovalTasks.Resources.ForRework;
     }
     else
     {
         e.Result = Functions.ApprovalTask.GetCollapsedResult(ApprovalTasks.As(_obj.Task), _obj.Result);
     }
 }
 public override void BeforeComplete(Sungero.Workflow.Server.BeforeCompleteEventArgs e)
 {
     if (_obj.Result == Result.Execute)
     {
         // Проверить зарегистрированность документа.
         var document          = _obj.DocumentGroup.OfficialDocuments.First();
         var registrationState = document.RegistrationState;
         if (registrationState == null || (Enumeration)registrationState != OfficialDocument.RegistrationState.Registered)
         {
             e.AddError(ApprovalTasks.Resources.ToPerformNeedRegisterDocument);
             return;
         }
     }
     if (_obj.Result == Result.ForRevision)
     {
         e.Result = ApprovalTasks.Resources.ForRework;
     }
     else
     {
         e.Result = Functions.ApprovalTask.GetCollapsedResult(ApprovalTasks.As(_obj.Task), _obj.Result);
     }
 }