예제 #1
0
        public virtual void DocumentForReviewGroupAdded(Sungero.Workflow.Interfaces.AttachmentAddedEventArgs e)
        {
            var document = OfficialDocuments.As(e.Attachment);

            // Задать тему.
            using (TenantInfo.Culture.SwitchTo())
                _obj.Subject = Docflow.PublicFunctions.Module.TrimSpecialSymbols(DocumentReviewTasks.Resources.Consideration, document.Name);

            // Задать адресата.
            if (IncomingDocumentBases.Is(document))
            {
                _obj.Addressee = IncomingDocumentBases.As(document).Addressee;
            }
            if (Memos.Is(document))
            {
                _obj.Addressee = Memos.As(document).Addressee;
            }

            // Задать срок рассмотрения.
            var addressee = _obj.Addressee ?? Users.Current;

            _obj.Deadline = Docflow.PublicFunctions.DocumentKind.GetConsiderationDate(document.DocumentKind, addressee) ??
                            Calendar.Now.AddWorkingDays(addressee, Functions.Module.Remote.GetDocumentReviewDefaultDays());
            if (!_obj.State.IsCopied)
            {
                Docflow.PublicFunctions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault());
            }

            Docflow.PublicFunctions.OfficialDocument.DocumentAttachedInMainGroup(document, _obj);

            // Добавить вложения.
            Docflow.PublicFunctions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(document, _obj.OtherGroup);
        }
        /// <summary>
        /// Обновить доступность полей карточки задачи.
        /// </summary>
        public virtual void UpdatePropertiesEnableState()
        {
            var document          = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();
            var refreshParameters = Functions.ApprovalTask.Remote.GetStagesInfoForRefresh(ApprovalTasks.As(_obj.Task));

            if (_obj.ForwardPerformer == null)
            {
                if (_obj.Status.Value == Workflow.AssignmentBase.Status.InProcess)
                {
                    _obj.State.Properties.Signatory.IsEnabled       = true;
                    _obj.State.Properties.Addressee.IsEnabled       = true;
                    _obj.State.Properties.DeliveryMethod.IsEnabled  = true;
                    _obj.State.Properties.ExchangeService.IsEnabled = true;
                    _obj.State.Properties.Approvers.IsEnabled       = true;
                }

                // Не давать менять адресата в согласовании служебных записок.
                if (Memos.Is(document))
                {
                    _obj.State.Properties.Addressee.IsEnabled = false;
                }

                Functions.ApprovalReworkAssignment.UpdateDeliveryMethod(_obj);
            }
            else
            {
                _obj.State.Properties.Signatory.IsEnabled       = false;
                _obj.State.Properties.Addressee.IsEnabled       = false;
                _obj.State.Properties.DeliveryMethod.IsEnabled  = false;
                _obj.State.Properties.ExchangeService.IsEnabled = false;
                _obj.State.Properties.Approvers.IsEnabled       = false;
            }
        }
        public override void Refresh(Sungero.Presentation.FormRefreshEventArgs e)
        {
            var document = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();

            var refreshParameters = Functions.ApprovalTask.Remote.GetStagesInfoForRefresh(ApprovalTasks.As(_obj.Task));

            _obj.State.Properties.Addressee.IsVisible  = refreshParameters.AddresseeIsVisible;
            _obj.State.Properties.Addressee.IsRequired = refreshParameters.AddresseeIsRequired;

            // Не давать менять адресата в согласовании служебных записок.
            if (Memos.Is(document))
            {
                _obj.State.Properties.Addressee.IsEnabled = false;
            }

            _obj.State.Properties.Signatory.IsVisible       = refreshParameters.SignatoryIsVisible;
            _obj.State.Properties.Signatory.IsRequired      = refreshParameters.SignatoryIsRequired;
            _obj.State.Properties.AddApprovers.IsVisible    = refreshParameters.AddApproversIsVisible;
            _obj.State.Properties.DeliveryMethod.IsVisible  = refreshParameters.DeliveryMethodIsVisible;
            _obj.State.Properties.ExchangeService.IsVisible = refreshParameters.ExchangeServiceIsVisible;

            Functions.ApprovalManagerAssignment.UpdateDeliveryMethod(_obj);

            _obj.State.Properties.Signatory.IsEnabled = _obj.ApprovalRule == null ? false : refreshParameters.SignatoryIsVisible && _obj.Status.Value == Workflow.AssignmentBase.Status.InProcess;

            if (_obj.Status == Status.InProcess && !Functions.Module.IsLockedByOther(_obj) && _obj.AccessRights.CanUpdate())
            {
                Functions.ApprovalTask.ShowExchangeHint(ApprovalTasks.As(_obj.Task), _obj.State.Properties.DeliveryMethod, _obj.Info.Properties.DeliveryMethod, _obj.DeliveryMethod, e);
            }

            if (!_obj.DocumentGroup.OfficialDocuments.Any())
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
            }

            // Скрывать контрол состояния со сводкой, если сводка пустая.
            var needViewDocumentSummary = Functions.ApprovalManagerAssignment.NeedViewDocumentSummary(_obj);

            _obj.State.Controls.DocumentSummary.IsVisible = needViewDocumentSummary;

            bool canAddApprovers;

            if (e.Params.TryGetValue(Constants.ApprovalManagerAssignment.CanAddApprovers, out canAddApprovers))
            {
                _obj.State.Properties.AddApprovers.IsEnabled = canAddApprovers;
            }

            var reworkParameters = Functions.ApprovalTask.Remote.GetReworkParameters(ApprovalTasks.As(_obj.Task), _obj.StageNumber.Value);

            _obj.State.Properties.ReworkPerformer.IsEnabled = reworkParameters.AllowChangeReworkPerformer;
            _obj.State.Properties.ReworkPerformer.IsVisible = reworkParameters.AllowViewReworkPerformer;
        }
예제 #4
0
        /// <summary>
        /// Проверить адресата.
        /// </summary>
        /// <param name="document">Документ.</param>
        /// <param name="task">Задача на согласование.</param>
        /// <returns>True, если адресат совпадает.</returns>
        private Structures.ConditionBase.ConditionResult CheckAddressee(IOfficialDocument document, IApprovalTask task)
        {
            if (Memos.Is(document))
            {
                var addressee = Memos.As(document).Addressee;
                if (addressee != null)
                {
                    return(Structures.ConditionBase.ConditionResult.Create(_obj.Addressees.Any(c => Equals(c.Addressee, addressee)), string.Empty));
                }
                else
                {
                    return(Structures.ConditionBase.ConditionResult.Create(null, Conditions.Resources.MemoAddresseeIsEmpty));
                }
            }

            return(Structures.ConditionBase.ConditionResult.Create(null, Conditions.Resources.CheckAddresseePossibleOnlyToMemo));
        }
        /// <summary>
        /// Установить доступность свойств.
        /// </summary>
        /// <param name="refreshParameters">Информация по этапам для обновления формы задачи на согласование по регламенту.</param>
        public virtual void SetEnabledProperties(Structures.ApprovalTask.RefreshParameters refreshParameters)
        {
            var taskProperties = _obj.State.Properties;

            taskProperties.Addressee.IsEnabled    = false;
            taskProperties.ReqApprovers.IsEnabled = false;

            if (_obj.ApprovalRule != null)
            {
                taskProperties.Addressee.IsEnabled = refreshParameters.AddresseeIsEnabled;
            }

            var isExchange = _obj.DeliveryMethod != null && _obj.DeliveryMethod.Sid == Constants.MailDeliveryMethod.Exchange;

            taskProperties.ExchangeService.IsEnabled = refreshParameters.ExchangeServiceIsEnabled;
            var document = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();

            if (isExchange && OfficialDocuments.Is(document))
            {
                if (document.Versions.Any())
                {
                    var isIncomingDocument   = Docflow.PublicFunctions.OfficialDocument.Remote.CanSendAnswer(document);
                    var isFormalizedDocument = Docflow.AccountingDocumentBases.Is(document) && Docflow.AccountingDocumentBases.As(document).IsFormalized == true;
                    taskProperties.DeliveryMethod.IsEnabled  = refreshParameters.DeliveryMethodIsEnabled;
                    taskProperties.ExchangeService.IsEnabled = refreshParameters.ExchangeServiceIsEnabled;
                }
            }

            // Не давать менять адресата в согласовании служебных записок.
            if (Memos.Is(document))
            {
                taskProperties.Addressee.IsEnabled = false;
            }

            // Не давать изменять способ доставки для исходящих писем на несколько адресатов.
            if (OutgoingDocumentBases.Is(document) && OutgoingDocumentBases.As(document).IsManyAddressees == true)
            {
                taskProperties.DeliveryMethod.IsEnabled = false;
            }
        }