private void RusGuardService_СardStatusRead(object sender, CardStateEventArgs e)
 {
     guiDispatcher.RunInGuiTread(delegate {
         CardUid = e.CardUid;
         UpdateState();
     });
 }
        public IssueByIdentifierViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigation,
            IGuiDispatcher guiDispatcher,
            IUserService userService,
            ILifetimeScope autofacScope,
            StockRepository stockRepository,
            EmployeeRepository employeeRepository,
            FeaturesService featuresService,
            IValidator validator,
            BaseParameters baseParameters,
            IInteractiveQuestion interactive,
            IChangeableConfiguration configuration,
            SizeService sizeService,
            ICardReaderService cardReaderService = null) : base(navigation)
        {
            this.unitOfWorkFactory  = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.guiDispatcher      = guiDispatcher ?? throw new ArgumentNullException(nameof(guiDispatcher));
            this.userService        = userService ?? throw new ArgumentNullException(nameof(userService));
            this.autofacScope       = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            this.validator          = validator ?? throw new ArgumentNullException(nameof(validator));
            this.BaseParameters     = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            this.interactive        = interactive ?? throw new ArgumentNullException(nameof(interactive));
            this.configuration      = configuration ?? throw new ArgumentNullException(nameof(configuration));
            SizeService             = sizeService ?? throw new ArgumentNullException(nameof(sizeService));
            this.cardReaderService  = cardReaderService;
            IsModal = false;
            EnableMinimizeMaximize = true;
            Title = "Выдача по картам СКУД";

            UowOfDialog = unitOfWorkFactory.CreateWithoutRoot();
            var entryBuilder = new CommonEEVMBuilderFactory <IssueByIdentifierViewModel>(this, this, UowOfDialog, navigation, autofacScope);

            if (cardReaderService != null)
            {
                cardReaderService.RefreshDevices();
                cardReaderService.СardStatusRead           += RusGuardService_СardStatusRead;
                cardReaderService.CardFamilies.ListChanged += CardFamilies_ListChanged;
            }
            UpdateState();


            WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish();
            Warehouse = stockRepository.GetDefaultWarehouse(UowOfDialog, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);

            //Настройка таймера сброса
            timerCleanSuccessfullyText           = new Timer(40000);
            timerCleanSuccessfullyText.AutoReset = false;
            timerCleanSuccessfullyText.Elapsed  += delegate(object sender, ElapsedEventArgs e) {
                guiDispatcher.RunInGuiTread(() => SuccessfullyText = null);
            };

            ReadConfig();
        }
        public void RunCreation(string server, string dbname)
        {
            var page = navigation.OpenViewModel <AdminLoginViewModel, string>(null, "root");

            page.PageClosed += delegate(object sender, PageClosedEventArgs e) {
                if (e.CloseSource == CloseSource.Save)
                {
                    //Вызываем через guiDispatcher для того чтобы диалог с паролем закрылся, до начала операции создания БД.
                    guiDispatcher.RunInGuiTread(() => StartCreation(server, dbname, page.ViewModel.Login, page.ViewModel.Password));
                }
            };
        }