Esempio n. 1
0
        public virtual void AddResolution(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            var document = _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault();
            var task     = (document == null) ? Functions.Module.Remote.CreateActionItemExecution() : Functions.Module.Remote.CreateActionItemExecution(document);
            var assignee = task.Assignee ?? Users.Current;

            task.MaxDeadline       = _obj.Deadline ?? Calendar.Today.AddWorkingDays(assignee, 2);
            task.IsDraftResolution = true;
            foreach (var otherGroupAttachment in _obj.OtherGroup.All)
            {
                task.OtherGroup.All.Add(otherGroupAttachment);
            }
            task.ShowModal();
            if (!task.State.IsInserted)
            {
                var draftActionItem = Functions.Module.Remote.GetActionitemById(task.Id);
                _obj.ResolutionGroup.ActionItemExecutionTasks.Add(draftActionItem);
                _obj.Save();
            }
        }
Esempio n. 2
0
        public virtual void AbortApprovingAction(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

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

            var assignees = new List <IRecipient>();

            if (_obj.Signatory != null)
            {
                assignees.Add(_obj.Signatory);
            }
            assignees.AddRange(_obj.AddApprovers.Where(a => a.Approver != null).Select(a => a.Approver));
            if (Functions.Module.ShowDialogGrantAccessRights(_obj, _obj.OtherGroup.All.ToList(), assignees) == false)
            {
                return;
            }

            if (Functions.ApprovalTask.GetReasonBeforeAbort(ApprovalTasks.As(_obj.Task), _obj.ActiveText))
            {
                _obj.Task.Abort();
                e.CloseFormAfterAction = true;
            }
        }
Esempio n. 3
0
        public virtual void SendInvitation(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            var info = Functions.Counterparty.ValidateExchangeAction(_obj, e);

            if (!info.CanDoAction)
            {
                return;
            }

            var dialog  = Dialogs.CreateInputDialog(Counterparties.Resources.InvitationTitle);
            var box     = dialog.AddSelect(_obj.Info.Properties.ExchangeBoxes.Properties.Box.LocalizedName, true, info.DefaultBox).From(info.Boxes);
            var comment = dialog.AddMultilineString(Counterparties.Resources.InvitationMessageHeader, false,
                                                    Counterparties.Resources.InvitationMessageDefault);

            dialog.HelpCode = Constants.Counterparty.HelpCodes.SendInvitation;
            dialog.Buttons.AddOkCancel();
            dialog.Buttons.Default = DialogButtons.Ok;
            dialog.SetOnButtonClick(x =>
            {
                if (x.Button == DialogButtons.Ok && x.IsValid && e.Validate())
                {
                    var result = ExchangeCore.PublicFunctions.BusinessUnitBox.Remote.SendInvitation(box.Value, _obj, comment.Value);
                    if (!string.IsNullOrWhiteSpace(result))
                    {
                        x.AddError(result);
                    }
                    else
                    {
                        var counterpartyExchangeBox = _obj.ExchangeBoxes.FirstOrDefault(b => Equals(b.Box, box.Value));
                        Dialogs.NotifyMessage(counterpartyExchangeBox.Info.Properties.Status.GetLocalizedValue(counterpartyExchangeBox.Status));
                    }
                }
            });
            dialog.Show();
        }
Esempio n. 4
0
        public override void Start(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!Functions.ActionItemExecutionTask.ValidateActionItemExecutionTaskSave(_obj, e))
            {
                return;
            }

            if (!Functions.ActionItemExecutionTask.ValidateActionItemExecutionTaskStart(_obj, e, true))
            {
                return;
            }

            if (!Docflow.PublicFunctions.Module.ShowDialogGrantAccessRightsWithConfirmationDialog(_obj,
                                                                                                  _obj.OtherGroup.All.ToList(),
                                                                                                  e.Action,
                                                                                                  Constants.ActionItemExecutionTask.ActionItemExecutionTaskConfirmDialogID))
            {
                return;
            }
            e.Params.AddOrUpdate(PublicConstants.ActionItemExecutionTask.CheckDeadline, true);

            base.Start(e);
        }
 public virtual void VerificationStateValueInput(Sungero.Presentation.EnumerationValueInputEventArgs e)
 {
     if (e.NewValue == Docflow.OfficialDocument.VerificationState.Completed)
     {
         var args = new Sungero.Domain.Client.ExecuteActionArgs(Sungero.Domain.Shared.FormType.Card, _obj);
         if (!args.Validate())
         {
             // Bug 96585. Прервать смену значения в контроле невозможно.
             e.NewValue = e.OldValue;
         }
     }
 }
Esempio n. 6
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. 7
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();
        }
Esempio n. 8
0
        /// <summary>
        /// Провалидировать доступность действия отправки приглашения \ проверки доступности в сервисе.
        /// </summary>
        /// <param name="args">Аргументы действия, из которого идёт валидация.</param>
        /// <returns>True, если действие можно выполнять.</returns>
        public virtual bool ValidateTinTrrcBeforeExchange(Sungero.Domain.Client.ExecuteActionArgs args)
        {
            var based = args.Validate();

            if (string.IsNullOrWhiteSpace(_obj.TIN))
            {
                if (args.Action.Name == _obj.Info.Actions.SendInvitation.Name)
                {
                    args.AddError(Counterparties.Resources.NeedFillTinForSendInvitation);
                    based = false;
                }
                if (args.Action.Name == _obj.Info.Actions.CanExchange.Name)
                {
                    args.AddError(Counterparties.Resources.NeedFillTinForCanExchange);
                    based = false;
                }
            }
            return(based);
        }
Esempio n. 9
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. 10
0
        public override void Start(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!Sungero.RecordManagement.Functions.AcquaintanceTask.ValidateAcquaintanceTaskStart(_obj, e))
            {
                return;
            }

            // Замена стандартного диалога подтверждения выполнения действия.
            if (!Docflow.PublicFunctions.Module.ShowConfirmationDialog(e.Action.ConfirmationMessage, null, null,
                                                                       Constants.AcquaintanceTask.StartConfirmDialogID))
            {
                return;
            }

            base.Start(e);
        }
        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. 12
0
        public override void Start(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!Sungero.Docflow.Functions.FreeApprovalTask.ValidateFreeApprovalTaskStart(_obj, e))
            {
                return;
            }

            if (!Functions.Module.ShowDialogGrantAccessRightsWithConfirmationDialog(_obj,
                                                                                    _obj.OtherGroup.All.ToList(),
                                                                                    e.Action,
                                                                                    Constants.FreeApprovalTask.StartConfirmDialogID))
            {
                return;
            }

            base.Start(e);
        }
Esempio n. 13
0
        public override void Start(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (!RecordManagement.Functions.DocumentReviewTask.ValidateDocumentReviewTaskStart(_obj, e))
            {
                return;
            }

            if (!Docflow.PublicFunctions.Module.ShowDialogGrantAccessRightsWithConfirmationDialog(_obj,
                                                                                                  _obj.OtherGroup.All.ToList(),
                                                                                                  e.Action,
                                                                                                  Constants.DocumentReviewTask.StartConfirmDialogID))
            {
                return;
            }

            base.Start(e);
        }
Esempio n. 14
0
        public virtual void DoClose(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            var message     = e.Action.ConfirmationMessage;
            var description = ((Domain.Shared.IInternalActionInfo)e.Action).ActionMetadata.GetConfirmationDescription();

            if (_obj.Status == Status.Draft)
            {
                description = ApprovalRuleBases.Resources.Action_DoCloseConfirmationDescription;
            }

            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)
            {
                if (e.Validate())
                {
                    _obj.Status = Status.Closed;
                    _obj.Save();
                }
            }
        }
Esempio n. 15
0
        public virtual void CheckConnection(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (!e.Validate())
            {
                return;
            }

            if (string.IsNullOrEmpty(_obj.Password))
            {
                Dialogs.NotifyMessage(BusinessUnitBoxes.Resources.EnterPasswordToCheckConnection);
                return;
            }

            var result = Functions.BusinessUnitBox.Remote.CheckConnection(_obj);

            if (string.IsNullOrWhiteSpace(result))
            {
                Dialogs.NotifyMessage(BusinessUnitBoxes.Resources.ConnectionEstablished);

                Functions.BusinessUnitBox.Remote.UpdateExchangeServiceCertificates(_obj);
            }
            else
            {
                Dialogs.NotifyMessage(result);
            }

            if (!Functions.BusinessUnitBox.Remote.CheckAllResponsibleCertificates(_obj, _obj.Responsible))
            {
                e.AddWarning(BusinessUnitBoxes.Resources.CertificateNotFound);
            }

            if (!Functions.BusinessUnitBox.Remote.CheckBusinessUnitTinTRRC(_obj))
            {
                e.AddWarning(BusinessUnitBoxes.Resources.OrganizationFailed);
            }
        }
Esempio n. 16
0
        public virtual void CloseProject(Sungero.Domain.Client.ExecuteActionArgs e)
        {
            if (_obj.ActualStartDate == null || _obj.ActualFinishDate == null)
            {
                _obj.State.Properties.ActualStartDate.IsRequired  = true;
                _obj.State.Properties.ActualFinishDate.IsRequired = true;
                e.Validate();
                return;
            }

            var dialogMessage     = Projects.Resources.CloseProjectDialogMessage;
            var dialogDescription = Projects.Resources.CloseProjectDialogDescription;
            var dialog            = Dialogs.CreateTaskDialog(dialogMessage, dialogDescription, MessageType.Question);

            dialog.Buttons.AddYesNo();
            dialog.Buttons.Default = DialogButtons.Yes;
            var result = dialog.Show();

            if (result == DialogButtons.Yes)
            {
                _obj.Stage = Stage.Completed;
                _obj.Save();
            }
        }
Esempio n. 17
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. 18
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);
        }