コード例 #1
0
        public void DoPINSelect(object obj)
        {
            // COMP1 DA52 75B0 3808 D031 E5D5 8394 86BF 5489
            // COMP2 8664 2349 0B62 8F4C 64E0 0725 577C 9EEA
            // COMP3 4338 E5B5 AB40 92CE 5D91 0E4C 4662 2A13

            //TEST TPK: X6A3FDB0309D54300E4D15526A1547454
            //          UD019BA0D484B9968CB186F183B843620
            //          TMK (clear): U5D3757F8326B5E7C803485B0D0C2CB62
            //          New key (clear): 31BAAEA801CD0EADB9DAFED0CDF240E6
            //          New key(TMK): X6A3FDB0309D54300E4D15526A1547454
            //           New key(LMK): UD019BA0D484B9968CB186F183B843620


            if (obj is IPINPad)
            {
                var pinPad = (IPINPad)obj;
                var ui     = TaskScheduler.FromCurrentSynchronizationContext();

                //TestPinOperations testPinOperations = new TestPinOperations(this);
                NativeAppAPI.NativeAppClient _client = new NativeAppAPI.NativeAppClient(StartupProperties.URL);

                PINSelectLogic pinSelect = new PINSelectLogic(_client, pinPad);
                pinSelect.UiUpdate += new UiUpdateEventHandler(OnUiUpdate);

                CancellationTokenSource cts = new CancellationTokenSource();

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        pinSelect.DoPINSelect();
                    }
                    catch (System.ServiceModel.EndpointNotFoundException enfex)
                    {
                        Error = enfex.Message;
                    }
                    catch (Exception ex)
                    {
                        Error = String.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.ToString());
                    }
                    finally
                    {
                        pinPad.Dispose();
                    }
                },
                                      cancellationToken: CancellationToken.None,
                                      creationOptions: TaskCreationOptions.None,
                                      scheduler: TaskScheduler.Default)
                .ContinueWith(manifest =>
                {
                    CommandManager.InvalidateRequerySuggested();
                }, TaskScheduler.FromCurrentSynchronizationContext());
                //.ContinueWith(task =>
                //{

                //}, TaskContinuationOptions.NotOnFaulted);
            }
        }
コード例 #2
0
        public void DoPinSelectTest(object obj)
        {
            if (obj is IPINPad)
            {
                var pinPad = (IPINPad)obj;
                var ui     = TaskScheduler.FromCurrentSynchronizationContext();

                TestPinOperations testPinOperations = new TestPinOperations(this);

                PINSelectLogic pinSelect = new PINSelectLogic(testPinOperations, pinPad);
                pinSelect.UiUpdate += new UiUpdateEventHandler(OnUiUpdate);

                CancellationTokenSource cts = new CancellationTokenSource();

                Task.Factory.StartNew(() =>
                {
                    Error = String.Empty;
                    Info  = "Starting PIN Select Test";
                    try
                    {
                        pinSelect.DoPINSelect();
                    }
                    catch (System.ServiceModel.EndpointNotFoundException enfex)
                    {
                        Error = enfex.Message;
                    }
                    catch (Exception ex)
                    {
                        Error = ex.Message;
                    }
                    finally
                    {
                        Info = "Finished PIN Select Test";
                        pinPad.Dispose();
                    }
                },
                                      cancellationToken: CancellationToken.None,
                                      creationOptions: TaskCreationOptions.None,
                                      scheduler: TaskScheduler.Default)
                .ContinueWith(manifest =>
                {
                    CommandManager.InvalidateRequerySuggested();
                }, TaskScheduler.FromCurrentSynchronizationContext());
                //.ContinueWith(task =>
                //{

                //}, TaskContinuationOptions.NotOnFaulted);
            }
        }