Exemple #1
0
        private async Task DoSetPin(ISmartCardAdmin smartCard)
        {
            await smartCard.SetUserPin(CurrentStateService.Instance.Pin, CurrentStateService.Instance.Data);

            AppendText("PIN set");

            // read the data back
            var sc   = SmartCardFactory.GetSmartCardForValidation(CurrentStateService.Instance.Pin);
            var data = await sc.GetData();

            AppendText("Verified: " + data + " was written to the card.");
        }
        private async Task DoSetPin(ISmartCardAdmin smartCard)
        {
            await smartCard.SetUserPin(GateKey, TicketState.Instance.TicketData);

            AppendText("data set");

            // read the data back
            var sc   = SmartCardFactory.GetSmartCardForValidation(GateKey);
            var data = await sc.GetData();

            AppendText("Verified: " + data + " was written to the card.");
        }
Exemple #3
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);

            mode = CurrentStateService.Instance.Mode;

            await SmartCardFactory.Initialize(); // this will also clear any prev event handlers

            SmartCardFactory.CardAdded   += OnCardAdded;
            SmartCardFactory.CardRemoved += OnCardRemoved;

            Debug.WriteLine("Subscribed from smartcard factory");
        }
Exemple #4
0
        private async void HandleCard()
        {
            var success = true;

            try
            {
                switch (mode)
                {
                case CardMode.SetPin:
                    AppendText("New PIN", false);
                    await OnNewPin(SmartCardFactory.GetSmartCardForProvisioning(MasterKey));

                    break;

                case CardMode.ReadData:
                    AppendText("Validate PIN", false);
                    await OnValidatePin(SmartCardFactory.GetSmartCardForValidation(CurrentStateService.Instance.Pin));

                    break;

                case CardMode.Reset:
                    await ResetToDefault(SmartCardFactory.GetSmartCardForProvisioning(MasterKey));

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                success = false;
                Debug.WriteLine(e);

                AppendText(e.ToString());
            }

            if (success)
            {
                AppendText("Complete");
            }

            QuitButton.IsEnabled = true;
        }
        private async void HandleCard()
        {
            var success = true;

            try
            {
                switch (mode)
                {
                case Mode.Cashier:
                    AppendText("Set Data", false);
                    await OnNewPin(SmartCardFactory.GetSmartCardForProvisioning(MasterKey));

                    break;

                case Mode.SkiLift:
                    AppendText("Validate PIN", false);
                    await OnValidateData(SmartCardFactory.GetSmartCardForValidation(GateKey));

                    break;

                case Mode.Reset:
                    await ResetToDefault(SmartCardFactory.GetSmartCardForProvisioning(MasterKey));

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                success = false;
                Debug.WriteLine(e);

                AppendText(e.ToString());
            }

            if (success)
            {
                AppendText("Complete");
            }
        }
Exemple #6
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            await SmartCardFactory.Initialize();

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            RootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (RootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                RootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                RootFrame.CacheSize = 1;

                // Set the default language
                RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = RootFrame;
            }

            if (RootFrame.Content == null)
            {
                // Removes the turnstile navigation for startup.
                if (RootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in RootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                RootFrame.ContentTransitions = null;
                RootFrame.Navigated         += this.RootFrame_FirstNavigated;

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!RootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }