Esempio n. 1
0
        /// <summary>
        /// Проверить возможность отправки задания подписания на доработку.
        /// </summary>
        /// <param name="assignment">Задание.</param>
        /// <param name="errorMessage">Сообщение об ошибке.</param>
        /// <param name="eventArgs">Аргумент обработчика вызова.</param>
        /// <returns>True - разрешить отправку, иначе false.</returns>
        public static bool ValidateBeforeRework(IAssignment assignment, string errorMessage, Sungero.Domain.Client.ExecuteActionArgs eventArgs)
        {
            if (string.IsNullOrEmpty(assignment.ActiveText))
            {
                eventArgs.AddError(errorMessage);
                return(false);
            }

            return(true);
        }
        public virtual void CreateCoverLetter(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            Functions.ApprovalSendingAssignment.CreateCoverLetter(_obj.DocumentGroup.OfficialDocuments.FirstOrDefault(), _obj.OtherGroup);
        }
Esempio n. 3
0
        public override void AssignNumber(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (_obj.IsManyAddressees == true && !_obj.Addressees.Any())
            {
                e.AddError(OutgoingDocumentBases.Resources.NeedFillAddressee);
                return;
            }

            base.AssignNumber(e);
        }
Esempio n. 4
0
        public virtual void ApprovalForm(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(_obj))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            Docflow.Functions.Module.RunApprovalSheetReport(_obj.DocumentGroup.OfficialDocuments.Single());
        }
Esempio n. 5
0
        /// <summary>
        /// Проверить возможность отправки задания подписания на доработку.
        /// </summary>
        /// <param name="assignment">Задание.</param>
        /// <param name="errorMessage">Сообщение об ошибке.</param>
        /// <param name="eventArgs">Аргумент обработчика вызова.</param>
        /// <returns>True - разрешить отправку, иначе false.</returns>
        public static bool ValidateBeforeRework(IAssignment assignment, string errorMessage, Sungero.Domain.Client.ExecuteActionArgs eventArgs)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(assignment.Task)))
            {
                eventArgs.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return(false);
            }
            if (string.IsNullOrWhiteSpace(assignment.ActiveText))
            {
                eventArgs.AddError(errorMessage);
                return(false);
            }

            if (!eventArgs.Validate())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        public virtual void SendViaExchangeService(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            var document = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();

            Functions.ApprovalSendingAssignment.SendToCounterparty(document, _obj.Task);
        }
Esempio n. 7
0
        public virtual void ExtendDeadline(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            var task = Docflow.PublicFunctions.DeadlineExtensionTask.Remote.GetDeadlineExtension(_obj);

            task.Show();
        }
        public virtual void AddApprover(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            var dialog   = Dialogs.CreateInputDialog(FreeApprovalTasks.Resources.AddApprover);
            var employee = dialog.AddSelect <Sungero.Company.IEmployee>(FreeApprovalTasks.Resources.Approver, true, null)
                           .Where(x => x.Status != Company.Employee.Status.Closed);
            var addButton = dialog.Buttons.AddCustom(FreeApprovalTasks.Resources.Add);

            dialog.Buttons.AddCancel();
            dialog.SetOnButtonClick(a =>
            {
                if (a.IsValid && a.Button == addButton)
                {
                    if (Functions.ApprovalAssignment.Remote.CanForwardTo(_obj, employee.Value))
                    {
                        // Довыдаем права новому согласующему на вложения.
                        if (Functions.Module.ShowDialogGrantAccessRights(_obj,
                                                                         _obj.OtherGroup.All.ToList(),
                                                                         new List <IRecipient>()
                        {
                            employee.Value
                        }) == false)
                        {
                            a.CloseAfterExecute = false;
                            return;
                        }

                        Docflow.Functions.Module.Remote.AddApprover(_obj, employee.Value);
                        _obj.State.Controls.Control.Refresh();
                        var employeeNameInDative = Company.PublicFunctions.Employee.GetShortName(employee.Value, DeclensionCase.Dative, false);
                        if (_obj.Stage.Sequence == ApprovalStage.Sequence.Parallel)
                        {
                            Dialogs.NotifyMessage(FreeApprovalTasks.Resources.SendedToFormat(employeeNameInDative));
                        }
                        else
                        {
                            Dialogs.NotifyMessage(ApprovalTasks.Resources.TaskWillBeSendedFormat(employeeNameInDative));
                        }
                    }
                    else
                    {
                        a.AddError(FreeApprovalAssignments.Resources.ApproverAlreadyExistsFormat(employee.Value.Person.ShortName));
                    }
                }
            });
            var result = dialog.Show();
        }
        public virtual void CheckConnection(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            // Проверка адреса сервиса Ario.
            var arioUrlValidationMessage = Functions.SmartProcessingSetting.ValidateArioUrl(_obj);

            if (arioUrlValidationMessage != null)
            {
                if (arioUrlValidationMessage.Type == MessageTypes.Error)
                {
                    e.AddError(arioUrlValidationMessage.Text);
                }

                if (arioUrlValidationMessage.Type == MessageTypes.SoftError)
                {
                    e.AddWarning(arioUrlValidationMessage.Text);
                }

                return;
            }

            // Проверка логина и пароля.
            var loginResult = Functions.SmartProcessingSetting.Remote.Login(_obj, _obj.Password, true);

            if (!string.IsNullOrEmpty(loginResult.Error))
            {
                e.AddError(loginResult.Error);
                return;
            }

            Dialogs.NotifyMessage(SmartProcessingSettings.Resources.ArioConnectionEstablished);

            // Проверка классификаторов.
            var classifiersValidationMessage = Functions.SmartProcessingSetting.ValidateClassifiers(_obj);

            if (classifiersValidationMessage != null)
            {
                e.AddWarning(classifiersValidationMessage.Text);
            }
        }
Esempio n. 10
0
        public override bool ValidateTinTrrcBeforeExchange(Sungero.Domain.Client.ExecuteActionArgs args)
        {
            var based = base.ValidateTinTrrcBeforeExchange(args);

            if (based)
            {
                if (_obj.TIN != null && _obj.TIN.Length == 10 && string.IsNullOrWhiteSpace(_obj.TRRC))
                {
                    if (args.Action.Name == _obj.Info.Actions.SendInvitation.Name)
                    {
                        args.AddError(CompanyBases.Resources.NeedFillTinAndTrrcForSendInvitation);
                        based = false;
                    }
                    if (args.Action.Name == _obj.Info.Actions.CanExchange.Name)
                    {
                        args.AddError(CompanyBases.Resources.NeedFillTinAndTrrcForCanExchange);
                        based = false;
                    }
                }
            }
            return(based);
        }
Esempio n. 11
0
        public virtual void SendForReview(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            // Проверить заполненность обязательных полей во всех документах комплекта.
            var attachments = _obj.AllAttachments.Select(a => Content.ElectronicDocuments.As(a)).Distinct().ToList();

            if (attachments.Cast <Docflow.IOfficialDocument>().Any(x => Sungero.Docflow.PublicFunctions.OfficialDocument.HasEmptyRequiredProperties(x)))
            {
                e.AddError(VerificationAssignments.Resources.InvalidDocumentWhenSendInWork,
                           _obj.Info.Actions.ShowInvalidDocuments);
                return;
            }

            // Определить главный документ.
            var suitableDocuments = Docflow.PublicFunctions.OfficialDocument.GetSuitableDocuments(attachments,
                                                                                                  Docflow.OfficialDocuments.Info.Actions.SendForReview);
            var probablyMainDocument = Content.ElectronicDocuments.As(Functions.Module.GetLeadingDocument(suitableDocuments.Cast <Docflow.IOfficialDocument>().ToList()));
            var mainDocument         = Docflow.PublicFunctions.OfficialDocument.ChooseMainDocument(suitableDocuments,
                                                                                                   new List <Content.IElectronicDocument> {
                probablyMainDocument
            });

            if (mainDocument == null)
            {
                return;
            }
            var mainOfficialDocument = Docflow.OfficialDocuments.As(mainDocument);

            // Если по главному документу ранее были запущены задачи, то вывести соответствующий диалог.
            if (!Docflow.PublicFunctions.OfficialDocument.NeedCreateReviewTask(mainOfficialDocument))
            {
                return;
            }

            var task       = RecordManagement.PublicFunctions.Module.Remote.CreateDocumentReview(mainOfficialDocument);
            var reviewTask = RecordManagement.DocumentReviewTasks.As(task);

            // Добавить вложения.
            foreach (var attachment in attachments.Where(att => !Equals(att, mainDocument)))
            {
                if (!Docflow.PublicFunctions.OfficialDocument.NeedToAttachDocument(attachment, mainOfficialDocument))
                {
                    continue;
                }
                else
                {
                    reviewTask.OtherGroup.All.Add(attachment);
                }
            }

            reviewTask.Show();
        }
Esempio n. 12
0
        public virtual void Login(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            var errors = Functions.BusinessUnitBox.Remote.CheckProperties(_obj);

            foreach (var error in errors)
            {
                e.AddError(error);
            }

            if (errors.Any())
            {
                return;
            }

            var dialog   = Dialogs.CreateInputDialog(BusinessUnitBoxes.Resources.LoginActionTitle);
            var password = dialog.AddPasswordString(_obj.Info.Properties.Password.LocalizedName, true);

            password.MaxLength(Constants.BusinessUnitBox.PasswordMaxLength);
            dialog.Buttons.AddOkCancel();
            dialog.Buttons.Default = DialogButtons.Ok;

            dialog.SetOnButtonClick(
                x =>
            {
                if (x.Button == DialogButtons.Ok && x.IsValid)
                {
                    var loginResult = Functions.BusinessUnitBox.Remote.Login(_obj, password.Value);
                    if (loginResult != string.Empty)
                    {
                        x.AddError(loginResult);
                    }
                    else
                    {
                        Dialogs.NotifyMessage(BusinessUnitBoxes.Resources.ConnectionEstablished);
                        Functions.BusinessUnitBox.Remote.UpdateExchangeServiceCertificates(_obj);
                    }

                    if (!Functions.BusinessUnitBox.Remote.CheckAllResponsibleCertificates(_obj, _obj.Responsible))
                    {
                        e.AddWarning(BusinessUnitBoxes.Resources.CertificateNotFound);
                    }
                }
            });
            dialog.Show();
        }
Esempio n. 13
0
        /// <summary>
        /// Перейти на сайт.
        /// </summary>
        /// <param name="website">Адрес сайта.</param>
        /// <param name="e">Аргумент события.</param>
        public static void GoToWebsite(string website, Sungero.Domain.Client.ExecuteActionArgs e)
        {
            website = website.ToLower();
            if (!(website.StartsWith("http://") || website.StartsWith("https://")))
            {
                website = "http://" + website;
            }

            try
            {
                Hyperlinks.Open(website);
            }
            catch
            {
                e.AddError(Resources.WrongWebsite);
            }
        }
Esempio n. 14
0
        public virtual void ExtendDeadline(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            var newDeadline = Functions.ApprovalTask.GetNewDeadline(_obj.Deadline);

            if (newDeadline != null)
            {
                _obj.Deadline = newDeadline.Value;
                _obj.Save();
                Dialogs.NotifyMessage(Docflow.Resources.CurrentAssignmentNewDeadline);
            }
        }
Esempio n. 15
0
        public virtual void CreateAcquaintance(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            _obj.Save();
            var document = _obj.DocumentGroup.OfficialDocuments.First();

            var subTask = RecordManagement.PublicFunctions.Module.Remote.CreateAcquaintanceTaskAsSubTask(document, _obj);

            if (subTask != null)
            {
                subTask.ShowModal();
            }
        }
Esempio n. 16
0
        public override void Abort(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            var error = Docflow.PublicFunctions.Module.Remote.GetTaskAbortingError(_obj, Docflow.PublicConstants.Module.TaskMainGroup.DocumentReviewTask.ToString());

            if (!string.IsNullOrWhiteSpace(error))
            {
                e.AddError(error);
            }
            else
            {
                if (!Docflow.PublicFunctions.Module.ShowConfirmationDialog(e.Action.ConfirmationMessage, null, null, Constants.DocumentReviewTask.AbortConfirmDialogID))
                {
                    return;
                }

                base.Abort(e);
            }
        }
Esempio n. 17
0
        public virtual void CreateActionItem(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(ApprovalTasks.As(_obj.Task)))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            _obj.Save();
            var parentAssignmentId = _obj.Id;
            var document           = _obj.DocumentGroup.OfficialDocuments.First();
            var assignedBy         = ApprovalTasks.As(_obj.Task).Addressee;
            var hackTask           = Functions.Module.CreateActionItemExecutionWithResolution(document, parentAssignmentId, _obj.ActiveText, assignedBy);

            if (hackTask != null)
            {
                hackTask.ShowModal();
            }
        }
Esempio n. 18
0
 public virtual void OpenInExchangeService(Sungero.Domain.Client.ExecuteActionArgs e)
 {
     try
     {
         var hyperlink = Sungero.Exchange.PublicFunctions.Module.Remote.GetDocumentHyperlink(_obj);
         if (string.IsNullOrWhiteSpace(hyperlink))
         {
             e.AddInformation(OfficialDocuments.Resources.DocumentNotInService);
         }
         else
         {
             Hyperlinks.Open(hyperlink);
         }
     }
     catch (AppliedCodeException ex)
     {
         e.AddError(ex.Message);
     }
 }
Esempio n. 19
0
        public override void Abort(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            var error = _obj.Status == Status.Draft ? string.Empty : Functions.Module.Remote.GetTaskAbortingError(_obj, Constants.Module.TaskMainGroup.ApprovalTask.ToString());

            if (!string.IsNullOrWhiteSpace(error))
            {
                e.AddError(error);
            }
            else if (Functions.ApprovalTask.GetReasonBeforeAbort(_obj, null))
            {
                base.Abort(e);
            }
            _obj.Save();
        }
        public virtual void Login(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!PublicFunctions.SmartProcessingSetting.Remote.CheckConnection(_obj))
            {
                e.AddError(SmartProcessingSettings.Resources.ArioConnectionError);
                return;
            }

            var dialog   = Dialogs.CreateInputDialog(SmartProcessingSettings.Resources.LoginActionTitle);
            var password = dialog.AddPasswordString(_obj.Info.Properties.Password.LocalizedName, true);

            password.MaxLength(Constants.SmartProcessingSetting.PasswordMaxLength);
            dialog.Buttons.AddOkCancel();
            dialog.Buttons.Default = DialogButtons.Ok;

            dialog.SetOnButtonClick(
                x =>
            {
                if (x.Button == DialogButtons.Ok && x.IsValid)
                {
                    var loginResult = Functions.SmartProcessingSetting.Remote.Login(_obj, password.Value, false);
                    if (!string.IsNullOrEmpty(loginResult.Error))
                    {
                        x.AddError(loginResult.Error);
                    }
                    else
                    {
                        _obj.Password = loginResult.EncryptedPassword;
                        Dialogs.NotifyMessage(SmartProcessingSettings.Resources.ArioConnectionEstablished);
                    }
                }
            });

            dialog.Show();
        }
Esempio n. 21
0
        public virtual void DoActive(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (Functions.ApprovalRuleBase.Remote.GetDoubleRules(_obj).Any())
            {
                e.AddError(ApprovalRuleBases.Resources.DuplicateDetected, _obj.Info.Actions.ShowDuplicate);
                return;
            }

            var    message     = e.Action.ConfirmationMessage;
            string description = ((Domain.Shared.IInternalActionInfo)e.Action).ActionMetadata.GetConfirmationDescription();

            var prevRule = Functions.ApprovalRuleBase.Remote.GetPreviousActiveRule(_obj);

            if (prevRule != null)
            {
                description = string.Format("{0}{1}{2}", description, Environment.NewLine, ApprovalRuleBases.Resources.ClosePreviousRule);
            }

            var dialog = Dialogs.CreateTaskDialog(message, string.IsNullOrEmpty(description) ? null : description, MessageType.Question);

            dialog.Buttons.AddYesNo();
            dialog.Buttons.Default = DialogButtons.Yes;

            if (dialog.Show() == DialogButtons.Yes)
            {
                var prevStatus = _obj.Status;
                _obj.Status = Status.Active;
                try
                {
                    _obj.Save();
                }
                catch
                {
                    _obj.Status = prevStatus;
                    throw;
                }
                Dialogs.NotifyMessage(ApprovalRuleBases.Resources.ApprovalRuleSetActive);
            }
        }
Esempio n. 22
0
 /// <summary>
 /// Показать ошибку в хинте с требованием усиленной подписи.
 /// </summary>
 /// <param name="assignment">Задание, в котором показывается хинт.</param>
 /// <param name="e">Аргументы действия.</param>
 public static void ShowStrongSignErrorHint(IAssignment assignment, Sungero.Domain.Client.ExecuteActionArgs e)
 {
     e.AddError(ApprovalTasks.Resources.CertificateNeeded);
 }
Esempio n. 23
0
        public virtual void CancelRegistration(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            var settingType = Functions.OfficialDocument.GetSettingType(_obj);

            // Можно отменять регистрацию только журналов своей группы регистрации.
            if (!Functions.OfficialDocument.CanChangeRequisitesOrCancelRegistration(_obj))
            {
                e.AddError(settingType == Docflow.RegistrationSetting.SettingType.Registration ?
                           Docflow.Resources.NeedRightOnDocumentRegisterToUnregister :
                           Docflow.Resources.NeedRightOnDocumentRegisterToUnreserve);
                return;
            }

            // Поля будут очищены после отмены, проверять обязательность нет смысла.
            // Обязательность полей будет восстановлена на рефреше.
            _obj.State.Properties.RegistrationNumber.IsRequired = false;
            _obj.State.Properties.RegistrationDate.IsRequired   = false;
            _obj.State.Properties.DocumentRegister.IsRequired   = false;
            if (!e.Validate())
            {
                return;
            }

            var text        = Docflow.Resources.CancelRegistration;
            var description = Docflow.Resources.CancelRegistrationDescription;

            if (settingType == Docflow.RegistrationSetting.SettingType.Reservation)
            {
                text        = Docflow.Resources.CancelReservation;
                description = Docflow.Resources.CancelReservationDescription;
            }
            if (settingType == Docflow.RegistrationSetting.SettingType.Numeration)
            {
                text        = Docflow.Resources.CancelNumbering;
                description = Docflow.Resources.CancelNumberingDescription;
            }

            var dialog = Dialogs.CreateTaskDialog(text, description, MessageType.Warning);
            dialog.Buttons.AddOkCancel();
            dialog.Buttons.Default = DialogButtons.Ok;
            if (dialog.Show()   == DialogButtons.Ok)
            {
                var needSaveDocument = _obj.DocumentKind.NumberingType != Docflow.DocumentKind.NumberingType.Numerable ||
                                       !_obj.DocumentKind.AutoNumbering.Value;

                Functions.OfficialDocument.RegisterDocument(_obj, DocumentRegisters.Null, null, null, false, needSaveDocument);

                // Задизейблить свойства.
                _obj.State.Properties.DocumentRegister.IsEnabled   = false;
                _obj.State.Properties.RegistrationNumber.IsEnabled = false;
                _obj.State.Properties.RegistrationDate.IsEnabled   = false;

                // Не показывать хинт о перерегистрации.
                bool repeatRegister;

                if (e.Params.TryGetValue(Sungero.Docflow.Constants.OfficialDocument.RepeatRegister, out repeatRegister) && repeatRegister)
                {
                    e.Params.Remove(Sungero.Docflow.Constants.OfficialDocument.RepeatRegister);
                }
            }

            // Отменить подсветку рег.номера и даты.
            this._obj.State.Properties.RegistrationNumber.HighlightColor = Sungero.Core.Colors.Empty;
            this._obj.State.Properties.RegistrationDate.HighlightColor   = Sungero.Core.Colors.Empty;
        }
Esempio n. 24
0
        public override void Start(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!Functions.ApprovalTask.Remote.HasDocumentAndCanRead(_obj))
            {
                e.AddError(ApprovalTasks.Resources.NoRightsToDocument);
                return;
            }

            if (!Sungero.Docflow.Functions.ApprovalTask.ValidateApprovalTaskStart(_obj, e))
            {
                return;
            }

            var document = _obj.DocumentGroup.OfficialDocuments.FirstOrDefault();

            if (document != null)
            {
                // Если инициатор указан в этапе согласования, то проверяем наличие сертификата.
                var approvalStage   = Functions.ApprovalTask.Remote.AuthorMustApproveDocument(_obj, _obj.Author, _obj.AddApprovers.Select(app => app.Approver).ToList());
                var documentHasBody = document.Versions.Any();

                if (approvalStage.HasApprovalStage && documentHasBody && approvalStage.NeedStrongSign && !PublicFunctions.Module.Remote.GetCertificates(document).Any())
                {
                    e.AddError(ApprovalTasks.Resources.CertificateNeeded);
                    return;
                }

                var giveRights = Functions.Module.ShowDialogGrantAccessRights(_obj, _obj.OtherGroup.All.ToList(), _obj.AddApprovers.Select(a => a.Approver).ToList());
                if (giveRights == false)
                {
                    return;
                }

                if (!document.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.Change, _obj.Author))
                {
                    Functions.ApprovalTask.Remote.GrantRightsToAuthor(_obj);
                }

                var author = _obj.Author;

                Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document);

                if (giveRights == null)
                {
                    // Запросить подтверждение подписания и отправки.
                    var question = ApprovalTasks.Resources.AreYouSureYouWantSendDocumentForApproval;
                    if (approvalStage.HasApprovalStage)
                    {
                        if (documentHasBody)
                        {
                            question = ApprovalTasks.Resources.AreYouSureYouWantSignAndSendDocumentForApproval;
                        }
                        if (_obj.AddendaGroup.OfficialDocuments.Any())
                        {
                            question = ApprovalTasks.Resources.AreYouSureYouWantSignAndSendDocumentAndAddendaForApproval;
                        }
                    }
                    var dialogResult = Functions.Module.ShowConfirmationDialog(question, null, null, Constants.ApprovalTask.StartConfirmDialogID);
                    if (!dialogResult)
                    {
                        return;
                    }
                }

                if (approvalStage.HasApprovalStage)
                {
                    try
                    {
                        // Если инициатор указан в этапе согласования, то установить его подпись сразу.
                        if (!Functions.Module.EndorseWithAddenda(document, _obj.AddendaGroup.OfficialDocuments.ToList <IElectronicDocument>(), null, author, approvalStage.NeedStrongSign, string.Empty))
                        {
                            e.AddError(ApprovalTasks.Resources.ToStartNeedSignDocument);
                            return;
                        }
                    }
                    catch (CommonLibrary.Exceptions.PlatformException ex)
                    {
                        if (!ex.IsInternal)
                        {
                            var message = string.Format("{0}.", ex.Message.TrimEnd('.'));
                            e.AddError(message);
                            return;
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }

            base.Start(e);
        }
Esempio n. 25
0
        public virtual void FillFromService(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (string.IsNullOrWhiteSpace(_obj.PSRN) && string.IsNullOrWhiteSpace(_obj.TIN) && string.IsNullOrWhiteSpace(_obj.Name))
            {
                e.AddError(CompanyBases.Resources.ErrorNeedFillTinPsrnNameForService);
                return;
            }

            if (!string.IsNullOrEmpty(_obj.PSRN))
            {
                _obj.PSRN = _obj.PSRN.Trim();
            }

            if (!string.IsNullOrEmpty(_obj.TIN))
            {
                _obj.TIN = _obj.TIN.Trim();
            }

            var response = Functions.CompanyBase.Remote.FillFromService(_obj, string.Empty);
            var error    = response.Message;

            var companyDisplayValues = response.CompanyDisplayValues;

            if (companyDisplayValues != null && companyDisplayValues.Count < 1)
            {
                Dialogs.ShowMessage(CompanyBases.Resources.ErrorCompanyNotFoundInService, MessageType.Information);
                return;
            }

            if (!string.IsNullOrWhiteSpace(error))
            {
                Dialogs.ShowMessage(error, CompanyBases.Resources.ContactAdministrator, MessageType.Error);
                return;
            }

            if (response.Amount > 1)
            {
                const int MaxCompaniesCount = 25;
                var       dialogText        = response.Amount > MaxCompaniesCount
          ? CompanyBases.Resources.FoundMoreThanNCompaniesInServiceFormat(MaxCompaniesCount, response.Amount)
          : CompanyBases.Resources.FoundSeveralCompaniesInServiceFormat(response.Amount);

                var dialog = Dialogs.CreateInputDialog(CompanyBases.Resources.ChoseCompanyDialogTitle, dialogText);
                dialog.Buttons.AddOkCancel();
                var companyShortLabels = companyDisplayValues.Select(x => x.DisplayValue).Take(MaxCompaniesCount);
                var companyShortLabel  = dialog.AddSelect(CompanyBases.Resources.FillFrom, true).From(companyShortLabels.ToArray());

                var result = dialog.Show();
                if (result == DialogButtons.Ok)
                {
                    var companyDisplayValue = companyDisplayValues.Where(x => x.DisplayValue == companyShortLabel.Value).First();
                    response = Functions.CompanyBase.Remote.FillFromService(_obj, companyDisplayValue.PSRN);
                    error    = response.Message;
                    if (!string.IsNullOrWhiteSpace(error))
                    {
                        Dialogs.ShowMessage(error, MessageType.Error);
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (string.IsNullOrWhiteSpace(error) &&
                response.CompanyDisplayValues != null)
            {
                Dialogs.NotifyMessage(CompanyBases.Resources.FillFromServiceSuccess);
                if (response.FoundContacts != null)
                {
                    var contacts = string.Join(";", response.FoundContacts.Select(contact => string.Format("{0}|{1}|{2}", contact.FullName, contact.JobTitle, contact.Phone)));
                    e.Params.AddOrUpdate(Constants.CompanyBase.FindedContactsInServiceParamName, contacts);
                }
            }
        }