private void Ta_ProcessCompleted(object sender, EventArgs e) { try { PersoProcessingOutcome tpo = (e as PersoProcessingOutcomeEventArgs).TerminalProcessingOutcome; if (tpo == null)//error occurred, error displayed via Ta_ExceptionOccured { return; } if (tpo is PersoProcessingOutcome) { SetStatusLabel("Complete"); if (tpo.CardData != null) { SetCardData(tpo.CardData); } } else { SetStatusLabel(string.Format("{0}\n{1}", tpo.UserInterfaceRequest.MessageIdentifier, tpo.UserInterfaceRequest.Status)); } } catch (Exception ex) { SetStatusLabel(ex.Message); } }
protected void OnProcessCompleted(PersoProcessingOutcome po) { try { if (po == null) //exception occurred { return; } switch (po.NextProcessState) { case EMVPersoPreProcessingStateEnum.EndProcess: cardQProcessor.StopServiceQProcess(); ProcessCompleted?.Invoke(this, new PersoProcessingOutcomeEventArgs() { TerminalProcessingOutcome = po }); break; default: throw new PersoException("Unimplemeted TerminalPreProcessingStateEnum in OnProcessCompleted"); } } catch (Exception ex) { Logger.Log("Error in OnProcessCompleted:" + ex.Message); return; } }
public void DoEntryPointBAll(String path, string secDomainAID, string masterKey, string packageAid, string execModuleAid, string instanceAid) { Task.Run(() => { try { ProtocolActivation_B().ContinueWith((parentTask) => { try { if (cancellationTokenForPreProcessing.Token.IsCancellationRequested) { cancellationTokenForPreProcessing.Dispose(); return; } PersoProcessing pxml = new PersoProcessing(cardQProcessor); pxml.RemoveApp(secDomainAID, masterKey, packageAid); using (MemoryStream capFile = new MemoryStream()) { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { byte[] data = new byte[fs.Length]; fs.Read(data, 0, (int)fs.Length); capFile.Write(data, 0, (int)fs.Length); } pxml.LoadCapFile(capFile, secDomainAID, masterKey); } pxml.InstallAndMakeSelectable(secDomainAID, masterKey, packageAid, execModuleAid, instanceAid); PersoProcessingOutcome processingOutcome = new PersoProcessingOutcome() { NextProcessState = EMVPersoPreProcessingStateEnum.EndProcess, UIRequestOnOutcomePresent = true, UserInterfaceRequest = new UserInterfaceRequest() { MessageIdentifier = MessageIdentifiersEnum.ClearDisplay, Status = StatusEnum.ReadyToRead }, UIRequestOnRestartPresent = false, }; OnProcessCompleted(processingOutcome); } catch (Exception ex) { OnExceptionOccured(ex); } }, TaskContinuationOptions.OnlyOnRanToCompletion); } catch (Exception ex) { OnExceptionOccured(ex); } }); }
private void DoEntryPointBGetCardData() { Task.Run(() => { try { ProtocolActivation_B().ContinueWith((parentTask) => { try { if (cancellationTokenForPreProcessing.Token.IsCancellationRequested) { cancellationTokenForPreProcessing.Dispose(); return; } PersoProcessing pxml = new PersoProcessing(cardQProcessor); String cardData = pxml.GetCardData(); PersoProcessingOutcome processingOutcome = new PersoProcessingOutcome() { NextProcessState = EMVPersoPreProcessingStateEnum.EndProcess, UIRequestOnOutcomePresent = true, UserInterfaceRequest = new UserInterfaceRequest() { MessageIdentifier = MessageIdentifiersEnum.ClearDisplay, Status = StatusEnum.ReadyToRead }, UIRequestOnRestartPresent = false, CardData = cardData, }; OnProcessCompleted(processingOutcome); } catch (Exception ex) { OnExceptionOccured(ex); } }, TaskContinuationOptions.OnlyOnRanToCompletion); } catch (Exception ex) { OnExceptionOccured(ex); } }); }
public void DoEntryPointBInstallApp(string secDomainAID, string masterKey, string packageAid, string execModuleAid, string instanceAid) { Task.Run(() => { try { ProtocolActivation_B().ContinueWith((parentTask) => { try { if (cancellationTokenForPreProcessing.Token.IsCancellationRequested) { cancellationTokenForPreProcessing.Dispose(); return; } PersoProcessing pxml = new PersoProcessing(cardQProcessor); pxml.InstallAndMakeSelectable(secDomainAID, masterKey, packageAid, execModuleAid, instanceAid); PersoProcessingOutcome processingOutcome = new PersoProcessingOutcome() { NextProcessState = EMVPersoPreProcessingStateEnum.EndProcess, UIRequestOnOutcomePresent = true, UserInterfaceRequest = new UserInterfaceRequest() { MessageIdentifier = MessageIdentifiersEnum.ClearDisplay, Status = StatusEnum.ReadyToRead }, UIRequestOnRestartPresent = false, }; OnProcessCompleted(processingOutcome); } catch (Exception ex) { OnExceptionOccured(ex); } }, TaskContinuationOptions.OnlyOnRanToCompletion); } catch (Exception ex) { OnExceptionOccured(ex); } }); }
public void CancelTransactionRequest() { cardQProcessor.StopServiceQProcess(); //StopServiceQProcess(); if (cancellationTokenForPreProcessing != null) { cancellationTokenForPreProcessing.Cancel(); } PersoProcessingOutcome processingOutcomeOUT = new PersoProcessingOutcome() { NextProcessState = EMVPersoPreProcessingStateEnum.EndProcess, UIRequestOnOutcomePresent = true }; UserInterfaceRequest uird = new UserInterfaceRequest() { MessageIdentifier = MessageIdentifiersEnum.ClearDisplay, Status = StatusEnum.ReadyToRead }; processingOutcomeOUT.UserInterfaceRequest = uird; OnProcessCompleted(processingOutcomeOUT); }