public DeliveryPointsManagementView()
        {
            this.Build();

            treeDeliveryPoints.ColumnsConfig = FluentColumnsConfig <DeliveryPoint> .Create()
                                               .AddColumn("Адрес").AddTextRenderer(node => node.CompiledAddress).WrapMode(Pango.WrapMode.WordChar).WrapWidth(1000)
                                               .AddColumn("Номер").AddTextRenderer(x => x.Id.ToString())
                                               .AddColumn("")
                                               .RowCells().AddSetter <CellRendererText>((c, n) => c.Foreground = n.IsActive ? "black" : "red")
                                               .Finish();

            _canDeleteByPresetPermission =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete_counterparty_and_deliverypoint");
            _permissionResult = ServicesConfig.CommonServices.CurrentPermissionService.ValidateEntityPermission(typeof(DeliveryPoint));

            buttonAdd.Sensitive = _permissionResult.CanCreate;

            if (_permissionResult.CanRead)
            {
                treeDeliveryPoints.RowActivated += (o, args) => buttonEdit.Click();
            }
            treeDeliveryPoints.Selection.Changed += OnSelectionChanged;

            IParametersProvider        parametersProvider        = new ParametersProvider();
            IFiasApiParametersProvider fiasApiParametersProvider = new FiasApiParametersProvider(parametersProvider);
            IFiasApiClient             fiasApiClient             = new FiasApiClient(fiasApiParametersProvider.FiasApiBaseUrl, fiasApiParametersProvider.FiasApiToken);

            _deliveryPointViewModelFactory = new DeliveryPointViewModelFactory(fiasApiClient);
        }
        public SmsSendPanelView(
            ICommonServices commonServices,
            ISmsPaymentRepository smsPaymentRepository,
            IFastPaymentRepository fastPaymentRepository,
            IFastPaymentParametersProvider fastPaymentParametersProvider)
        {
            if (commonServices == null)
            {
                throw new ArgumentNullException(nameof(commonServices));
            }
            _smsPaymentRepository          = smsPaymentRepository ?? throw new ArgumentNullException(nameof(smsPaymentRepository));
            _fastPaymentRepository         = fastPaymentRepository ?? throw new ArgumentNullException(nameof(fastPaymentRepository));
            _fastPaymentParametersProvider =
                fastPaymentParametersProvider ?? throw new ArgumentNullException(nameof(fastPaymentParametersProvider));
            var currentPermissionService = commonServices.CurrentPermissionService;

            _interactiveService = commonServices.InteractiveService;
            _phoneFormatter     = new PhoneFormatter(PhoneFormat.BracketWithWhitespaceLastTen);

            Build();
            _orderPermissionResult = currentPermissionService.ValidateEntityPermission(typeof(Order));
            _canSendSmsForAdditionalOrderStatuses =
                currentPermissionService.ValidatePresetPermission("can_send_sms_for_additional_order_statuses");
            _canSendSmsForPayFromYookassa  = currentPermissionService.ValidatePresetPermission("can_send_sms_for_pay_from_yookassa");
            _canSendSmsForPayFromSbpByCard = currentPermissionService.ValidatePresetPermission("can_send_sms_for_pay_from_sbp_by_card");
            Configure();
        }
Esempio n. 3
0
 public PermissionControlledEditButton(
     IJournalDialog dialog,
     IRepresentationModel representationModel,
     IPermissionResult permission,
     bool customEdit = false) : base(dialog, representationModel)
 {
     this.permission = permission;
     _customEdit     = customEdit;
 }
 public CounterpartyPanelView(ICommonServices commonServices)
 {
     if (commonServices == null)
     {
         throw new ArgumentNullException(nameof(commonServices));
     }
     Build();
     _counterpartyPermissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(Counterparty));
     Configure();
 }
Esempio n. 5
0
 public CallTaskPanelView(IPersonProvider personProvider, IEmployeeRepository employeeRepository, ICommonServices commonServices)
 {
     if (commonServices == null)
     {
         throw new ArgumentNullException(nameof(commonServices));
     }
     _personProvider     = personProvider ?? throw new ArgumentNullException(nameof(personProvider));
     _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
     Build();
     _callTaskPermissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(CallTask));
 }
Esempio n. 6
0
        public DeliveryPointPanelView(ICommonServices commonServices)
        {
            if (commonServices == null)
            {
                throw new ArgumentNullException(nameof(commonServices));
            }
            Build();
            _deliveryPointPermissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(DeliveryPoint));
            _orderPermissionResult         = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(Order));
            IParametersProvider        parametersProvider        = new ParametersProvider();
            IFiasApiParametersProvider fiasApiParametersProvider = new FiasApiParametersProvider(parametersProvider);
            IFiasApiClient             fiasApiClient             = new FiasApiClient(fiasApiParametersProvider.FiasApiBaseUrl, fiasApiParametersProvider.FiasApiToken);

            _deliveryPointViewModelFactory = new DeliveryPointViewModelFactory(fiasApiClient);
            Configure();
        }
        private void UpdateUserEntityPermission()
        {
            permissionResult = new PermissionResult(EntityPermission.AllAllowed);

            UserBase user;

            using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                user = UserRepository.GetCurrentUser(uow);
            }
            if (user == null)
            {
                logger.Warn("Не определен текущий пользователь, при проверке прав в журнале");
                return;
            }

            permissionResult = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(RepresentationModel.EntityType, user.Id);
        }
 public ComplaintDiscussionViewModel(
     ComplaintDiscussion complaintDiscussion,
     IFileDialogService fileDialogService,
     IEmployeeService employeeService,
     ICommonServices commonServices,
     IUnitOfWork uow,
     IUserRepository userRepository
     ) : base(complaintDiscussion, commonServices)
 {
     _fileDialogService = fileDialogService ?? throw new ArgumentNullException(nameof(fileDialogService));
     _employeeService   = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
     _userRepository    = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
     newCommentFiles    = new GenericObservableList <ComplaintFile>();
     _canCompleteComplaintDiscussionPermission = CommonServices.CurrentPermissionService.ValidatePresetPermission("can_complete_complaint_discussion");
     UoW = uow;
     _complaintPermissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(Complaint));
     CreateCommands();
     ConfigureEntityPropertyChanges();
 }
Esempio n. 9
0
        private void ConfigureDlg()
        {
            _employeeDocumentsPermissionsSet = _commonServices.PermissionService
                                               .ValidateUserPermission(typeof(EmployeeDocument), _commonServices.UserService.CurrentUserId);

            if (Entity.Id != 0 && !_employeeDocumentsPermissionsSet.CanRead)
            {
                _commonServices.InteractiveService
                .ShowMessage(QS.Dialog.ImportanceLevel.Error, "Недостаточно прав для просмотра документов", "Недостаточно прав");
                FailInitialize = true;
                TabParent?.ForceCloseTab(this, QS.Navigation.CloseSource.Self);
            }

            var canUpdate = _employeeDocumentsPermissionsSet.CanUpdate ||
                            (Entity.Id == 0 && _employeeDocumentsPermissionsSet.CanCreate);

            foreach (var widget in table1.Children)
            {
                if (widget != GtkScrolledWindow)
                {
                    widget.Sensitive = canUpdate;
                }
            }
            buttonSave.Sensitive        = canUpdate;
            ytextviewIssueOrg.Sensitive = canUpdate;

            comboCategory.ItemsEnum = typeof(EmployeeDocumentType);
            comboCategory.Binding.AddBinding(Entity, e => e.Document, w => w.SelectedItemOrNull).InitializeFromSource();

            yentryPasSeria.MaxLength = 30;
            yentryPasSeria.Binding.AddBinding(Entity, e => e.PassportSeria, w => w.Text).InitializeFromSource();
            yentryPassportNumber.MaxLength = 30;
            yentryPassportNumber.Binding.AddBinding(Entity, e => e.PassportNumber, w => w.Text).InitializeFromSource();
            yentryDocName.Binding.AddBinding(Entity, e => e.Name, w => w.Text).InitializeFromSource();

            ytextviewIssueOrg.Binding.AddBinding(Entity, e => e.PassportIssuedOrg, w => w.Buffer.Text).InitializeFromSource();
            ydatePassportIssuedDate.Binding.AddBinding(Entity, e => e.PassportIssuedDate, w => w.DateOrNull).InitializeFromSource();
            ycheckMainDoc.Binding.AddBinding(Entity, e => e.MainDocument, w => w.Active).InitializeFromSource();
            OnDocumentTypeSelected(this, null);
        }
Esempio n. 10
0
        protected void InitializePermissionValidator()
        {
            permissionResult = new PermissionResult(EntityPermission.AllAllowed);

            Type entityType = typeof(TEntity);
            int? currUserId;

            using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                currUserId = UserRepository.GetCurrentUser(uow)?.Id;
            }
            if (!currUserId.HasValue)
            {
                return;
            }
            permissionResult = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(entityType, currUserId.Value);

            if (!permissionResult.CanRead)
            {
                var message = PermissionsSettings.GetEntityReadValidateResult(entityType);
                MessageDialogHelper.RunErrorDialog(message);
                FailInitialize = true;
            }
        }
Esempio n. 11
0
        protected override void CreateNodeActions()
        {
            _paymentPermissionResult = CurrentPermissionService.ValidateEntityPermission(typeof(Payment));

            NodeActionsList.Clear();
            CreateAddNewPaymentAction();

            var addAction = new JournalAction("Добавить",
                                              (selected) => _paymentPermissionResult.CanCreate,
                                              (selected) => VisibleCreateAction,
                                              (selected) => CreateEntityDialog(),
                                              "Insert"
                                              );

            NodeActionsList.Add(addAction);

            var editAction = new JournalAction("Изменить",
                                               (selected) => _paymentPermissionResult.CanUpdate && selected.Any(),
                                               (selected) => VisibleEditAction,
                                               (selected) => selected.OfType <PaymentJournalNode>().ToList().ForEach(EditEntityDialog)
                                               );

            NodeActionsList.Add(editAction);

            if (SelectionMode == JournalSelectionMode.None)
            {
                RowActivatedAction = editAction;
            }

            NodeActionsList.Add(new JournalAction(
                                    "Завершить распределение",
                                    x => true,
                                    x => true,
                                    selectedItems => CompleteAllocation()
                                    )
                                );
        }
Esempio n. 12
0
        private void ConfigureWorkSchedules()
        {
            driverWorkScheduleSetPermission =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidateEntityPermission(
                    typeof(DriverWorkScheduleSet));

            ytreeDriverScheduleSets.ColumnsConfig = FluentColumnsConfig <DriverWorkScheduleSet> .Create()
                                                    .AddColumn("Код")
                                                    .HeaderAlignment(0.5f)
                                                    .MinWidth(75)
                                                    .AddTextRenderer(x => x.Id == 0 ? "Новый" : x.Id.ToString())
                                                    .XAlign(0.5f)
                                                    .AddColumn("Активен")
                                                    .HeaderAlignment(0.5f)
                                                    .AddToggleRenderer(x => x.IsActive)
                                                    .XAlign(0.5f)
                                                    .Editing(false)
                                                    .AddColumn("Дата\nактивации")
                                                    .HeaderAlignment(0.5f)
                                                    .AddTextRenderer(x => x.DateActivated.ToString("g"))
                                                    .AddColumn("Дата\nдеактивации")
                                                    .HeaderAlignment(0.5f)
                                                    .AddTextRenderer(x => x.DateDeactivated != null ? x.DateDeactivated.Value.ToString("g") : "")
                                                    .AddColumn("Автор")
                                                    .HeaderAlignment(0.5f)
                                                    .AddTextRenderer(x => x.Author != null ? x.Author.ShortName : "-")
                                                    .XAlign(0.5f)
                                                    .AddColumn("Изменил")
                                                    .HeaderAlignment(0.5f)
                                                    .AddTextRenderer(x => x.LastEditor != null ? x.LastEditor.ShortName : "-")
                                                    .XAlign(0.5f)
                                                    .AddColumn("Создан\nавтоматически")
                                                    .HeaderAlignment(0.5f)
                                                    .AddToggleRenderer(x => x.IsCreatedAutomatically)
                                                    .XAlign(0.5f)
                                                    .Editing(false)
                                                    .AddColumn("")
                                                    .Finish();

            ytreeDriverScheduleSets.RowActivated += (o, args) => {
                if (ytreeDriverScheduleSets.GetSelectedObject() != null &&
                    (driverWorkScheduleSetPermission.CanUpdate || driverWorkScheduleSetPermission.CanRead))
                {
                    OpenDriverWorkScheduleSetEditWindow();
                }
            };
            ytreeDriverScheduleSets.ItemsDataSource = Entity.ObservableDriverWorkScheduleSets;

            ybuttonCopyScheduleSet.Sensitive = false;
            ybuttonCopyScheduleSet.Clicked  += OnButtonCopyScheduleSetClicked;

            ybuttonEditScheduleSet.Sensitive = false;
            ybuttonEditScheduleSet.Clicked  += (sender, args) => OpenDriverWorkScheduleSetEditWindow();

            ytreeDriverScheduleSets.Selection.Changed += (o, args) => {
                ybuttonCopyScheduleSet.Sensitive = ytreeDriverScheduleSets.GetSelectedObject() != null &&
                                                   driverWorkScheduleSetPermission.CanCreate;
                ybuttonEditScheduleSet.Sensitive = ytreeDriverScheduleSets.GetSelectedObject() != null &&
                                                   (driverWorkScheduleSetPermission.CanUpdate || driverWorkScheduleSetPermission.CanRead);
            };

            ybuttonCreateScheduleSet.Clicked  += (sender, args) => OpenDriverWorkScheduleSetCreateWindow();
            ybuttonCreateScheduleSet.Sensitive = driverWorkScheduleSetPermission.CanCreate;
        }
Esempio n. 13
0
        private static IPermissionResult ParseError(GuestControllerWebCallResponse response)
        {
            IPermissionResult permissionResult = GuestControllerErrorParser.GetPermissionResult(response.error);

            return(permissionResult ?? MakeGenericFailure());
        }
Esempio n. 14
0
 public PermissionControlledDeleteButton(IJournalDialog dialog, IRepresentationModel representationModel, IPermissionResult permission) : base(dialog, representationModel)
 {
     this.permission = permission;
 }
 public FixedPricesPanelViewModel(IFixedPricesDialogOpener fixedPricesDialogOpener, ICommonServices commonServices)
 {
     this.fixedPricesDialogOpener   = fixedPricesDialogOpener ?? throw new ArgumentNullException(nameof(fixedPricesDialogOpener));
     _deliveryPointPermissionResult = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(DeliveryPoint));
     _counterpartyPermissionResult  = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(Domain.Client.Counterparty));
 }
        public EmployeeViewModel(
            IAuthorizationService authorizationService,
            IEmployeeWageParametersFactory employeeWageParametersFactory,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IEmployeePostsJournalFactory employeePostsJournalFactory,
            ICashDistributionCommonOrganisationProvider commonOrganisationProvider,
            ISubdivisionParametersProvider subdivisionParametersProvider,
            IWageCalculationRepository wageCalculationRepository,
            IEmployeeRepository employeeRepository,
            IUnitOfWorkGeneric <Employee> uowGeneric,
            ICommonServices commonServices,
            IValidationContextFactory validationContextFactory,
            IPhonesViewModelFactory phonesViewModelFactory,
            IWarehouseRepository warehouseRepository,
            IRouteListRepository routeListRepository,
            DriverApiUserRegisterEndpoint driverApiUserRegisterEndpoint,
            UserSettings userSettings,
            IUserRepository userRepository,
            BaseParametersProvider baseParametersProvider,
            IAttachmentsViewModelFactory attachmentsViewModelFactory,
            bool traineeToEmployee = false,
            INavigationManager navigationManager = null
            ) : base(commonServices?.InteractiveService, navigationManager)
        {
            _authorizationService         = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
            EmployeeWageParametersFactory =
                employeeWageParametersFactory ?? throw new ArgumentNullException(nameof(employeeWageParametersFactory));
            EmployeeJournalFactory         = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            EmployeePostsJournalFactory    = employeePostsJournalFactory ?? throw new ArgumentNullException(nameof(employeePostsJournalFactory));
            SubdivisionJournalFactory      = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            _subdivisionParametersProvider = subdivisionParametersProvider ?? throw new ArgumentNullException(nameof(subdivisionParametersProvider));
            _wageCalculationRepository     = wageCalculationRepository ?? throw new ArgumentNullException(nameof(wageCalculationRepository));
            _employeeRepository            = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            _warehouseRepository           = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository));
            _routeListRepository           = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository));
            _driverApiUserRegisterEndpoint = driverApiUserRegisterEndpoint ?? throw new ArgumentNullException(nameof(driverApiUserRegisterEndpoint));
            _userSettings           = userSettings ?? throw new ArgumentNullException(nameof(userSettings));
            UoWGeneric              = uowGeneric ?? throw new ArgumentNullException(nameof(uowGeneric));
            _commonServices         = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            _userRepository         = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            _baseParametersProvider = baseParametersProvider ?? throw new ArgumentNullException(nameof(baseParametersProvider));

            if (commonOrganisationProvider == null)
            {
                throw new ArgumentNullException(nameof(commonOrganisationProvider));
            }

            if (validationContextFactory == null)
            {
                throw new ArgumentNullException(nameof(validationContextFactory));
            }

            if (phonesViewModelFactory == null)
            {
                throw new ArgumentNullException(nameof(phonesViewModelFactory));
            }

            ConfigureValidationContext(validationContextFactory);

            PhonesViewModel = phonesViewModelFactory.CreateNewPhonesViewModel(UoW);

            if (Entity.Id == 0)
            {
                Entity.OrganisationForSalary = commonOrganisationProvider.GetCommonOrganisation(UoW);
                FillHiddenCategories(traineeToEmployee);

                TabName = "Новый сотрудник";
            }
            else
            {
                TabName = Entity.GetPersonNameWithInitials();
            }

            AttachmentsViewModel = (attachmentsViewModelFactory ?? throw new ArgumentNullException(nameof(attachmentsViewModelFactory)))
                                   .CreateNewAttachmentsViewModel(Entity.ObservableAttachments);

            if (Entity.Phones == null)
            {
                Entity.Phones = new List <Phone>();
            }

            Entity.PropertyChanged += OnEntityPropertyChanged;

            organizations = UoW.GetAll <Organization>().ToList();

            CanRegisterMobileUser = string.IsNullOrWhiteSpace(Entity.AndroidLogin) && string.IsNullOrWhiteSpace(Entity.AndroidPassword);

            _employeePermissionSet = _commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(Employee));

            if (!_employeePermissionSet.CanRead)
            {
                AbortOpening(PermissionsSettings.GetEntityReadValidateResult(typeof(Employee)));
            }

            SetPermissions();
        }