Exemplo n.º 1
0
        public override void OnNavigatedTo(Dictionary <string, object> parameters, NavigationMode mode)
        {
            if (_qrScanner != null && !_qrScanner.IsStarted)
            {
                _qrScanner.StartAsync();
            }

            Employee = (Employee)parameters["Employee"];

            if (mode == NavigationMode.Back)
            {
                if (SessionState.ContainsKey("DevicesToTake"))
                {
                    _devicesToTake = (ObservableCollection <Device>)SessionState["DevicesToTake"];
                }
                if (SessionState.ContainsKey("DevicesToReturn"))
                {
                    _devicesToReturn = (ObservableCollection <Device>)SessionState["DevicesToReturn"];
                }

                UpdateDeviceGroups();
            }

            LoadData();

            LogOutService.Restart();
        }
Exemplo n.º 2
0
        public override void OnNavigatedTo(Dictionary <string, object> parameters, NavigationMode mode)
        {
            Device = (Device)parameters["Device"];

            LoadData();

            LogOutService.Restart();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Сканированией пропуска и получение данных
        /// </summary>
        public override void OnNavigatedTo(Dictionary <string, object> parameters, NavigationMode mode)
        {
            CoreWindow.GetForCurrentThread().KeyDown += ScannerViewModel_KeyDown;

            Settings.IsAuthorized          = false;
            Settings.CurrentSessionBadgeId = null;
            LogOutService.Stop();

            AppVersion = AppInfoHelper.GetAppVersionString();

            base.OnNavigatedTo(parameters, mode);
        }
Exemplo n.º 4
0
        public static bool LogOut(out LogOutResponseModel response)
        {
            bool result;

            try
            {
                LogOutService logOutService = new LogOutService();
                response = null;
                string jsonString = logOutService.DefContent();
                response = JsonHelper.JsonDeserialize <List <LogOutResponseModel> >(jsonString)[0];
                result   = true;
            }
            catch
            {
                response = null;
                result   = false;
            }
            return(result);
        }
Exemplo n.º 5
0
        private void UserTimeoutViewModel_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            Debug.WriteLine(args.VirtualKey.ToString());

            if (_badgeId.Length <= AppConst.MAX_BADGEID_LENGTH)
            {
                var n = Math.Abs((int)VirtualKey.Number0 - (int)args.VirtualKey);
                if (_badgeId.Length < 3 && n != 0)
                {
                    return;
                }

                if (_badgeId.Length >= 3 && !_badgeId.StartsWith("000"))
                {
                    return;
                }

                _badgeId += n;
            }

            if (_badgeId.Length == AppConst.MAX_BADGEID_LENGTH && !_scanned)
            {
                _scanned = true;
                CoreWindow.GetForCurrentThread().KeyDown -= UserTimeoutViewModel_KeyDown;


                if (Settings.CurrentSessionBadgeId == _badgeId)
                {
                    _remainingTimer.Stop();
                    _remainingTimer.Tick -= RemainingTimerTick;

                    Popup.Current.Close();
                    LogOutService.Restart();
                }

                _scanned = false;
                _badgeId = string.Empty;

                CoreWindow.GetForCurrentThread().KeyDown += UserTimeoutViewModel_KeyDown;
            }
        }
Exemplo n.º 6
0
 public override void OnNavigatedTo(Dictionary <string, object> parameters, NavigationMode mode)
 {
     LogOutService.Restart();
 }
Exemplo n.º 7
0
        private async void RecognizeAsync(string qrCodeContent)
        {
            LogOutService.Restart();

            if (ScanningState == ScanningState.Scanning)
            {
                return;
            }

            try
            {
                UpdateScanningState(ScanningState.Scanning);

                TaskStarted("scanning");

                int id;

                if (!int.TryParse(qrCodeContent, out id))
                {
                    UpdateScanningState(ScanningState.Error, "Не удалось распознать устройство");
                    await Task.Delay(3000);

                    UpdateScanningState(ScanningState.Waiting);
                    _qrScanner.StartScanning();
                    return;
                }

                if (!_devicesToTake.Any(x => x.Id == id) && !_devicesToReturn.Any(x => x.Id == id))
                {
                    var device = await _deviceService.GetDeviceByIdAsync(id);

                    if (string.IsNullOrEmpty(device.BadgeId))
                    {
                        _devicesToTake.Add(device);
                    }
                    else
                    {
                        _devicesToReturn.Add(device);
                    }

                    UpdateDeviceGroups();

                    UpdateScanningState(ScanningState.DeviceInBucket);

                    await Task.Delay(1000);
                }
                else
                {
                    UpdateScanningState(ScanningState.Error, "Устройство уже в списке");
                    await Task.Delay(3000);
                }

                UpdateScanningState(ScanningState.Waiting);
                _qrScanner.StartScanning();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);

                UpdateScanningState(ScanningState.Error, "Не удалось отсканировать устройство");
                await Task.Delay(3000);

                UpdateScanningState(ScanningState.Scanning);
                _qrScanner.StartScanning();
            }
            finally
            {
                TaskFinished("scanning");
            }
        }