protected string ProcessPinRequest(PinIssuanceRequest request) { string response = string.Empty; new PANE.ERRORLOG.Error().LogInfo("Start ProcessPinRequest"); new PANE.ERRORLOG.Error().LogInfo("Before Retrieve from PostCard"); if (string.IsNullOrEmpty(request.Track2)) { throw new Exception("Track 2 data is empty"); } Card theCard = CardUtilities.GetCardFromPostCard(request.CardPAN, "pc_cards_1_A"); new PANE.ERRORLOG.Error().LogInfo("After Retrieve from PostCard"); switch (request.Function.ToLower()) { case "pinselection": response = DoPinSelection(request, theCard); break; case "pinchange": response = DoPinChange(request, theCard); break; } new PANE.ERRORLOG.Error().LogInfo("End ProcessPinRequest"); return(response); }
protected override async Task OnTeamsMembersAddedAsync(IList <TeamsChannelAccount> teamsMembersAdded, TeamInfo teamInfo, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { await base.OnTeamsMembersAddedAsync(teamsMembersAdded, teamInfo, turnContext, cancellationToken); DotNetInteractiveProcessRunner.Instance.SessionLanguage = null; var card = CardUtilities.CreateAdaptiveCardAttachment(CardJsonFiles.SelectLanguage); var attach = MessageFactory.Attachment(card); await turnContext.SendActivityAsync(attach); }
public static Activity GetAboutCards(Activity activity) { var cards = CardUtilities.CreateCards(); var image = new List <string>(); image.Add(@"https://botmood.azurewebsites.net/images/iconNeutro.png"); var card = CardUtilities.CreateHeroCard("BotMood", "Como você está se sentindo?", "", image); cards.Add(card.ToAttachment()); var msg1 = activity.CreateReply(); msg1.Attachments = cards; return(msg1); }
public string ActivateCard(string card, string phoneNumber) { bool usePrimeHSM = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UsePrimeHSM"]); string theMessage = ""; string response = string.Empty; string encryptionIndicator = string.Empty; try { new PANE.ERRORLOG.Error().LogInfo("PinController Web service entered..."); if (string.IsNullOrWhiteSpace(card)) { return("1:Card value cannot be null"); } if (string.IsNullOrWhiteSpace(phoneNumber)) { return("1:Phone cannot be null"); } if (Convert.ToBoolean("false")) { theMessage = "C:cardpan=5334771222311096,expiryDate=2204,pin=1234,terminalId=12345678,PinOffset=1234|5399232123033091"; // -Sterling //theMessage = "C:cardpan=5399233021500835,expiryDate=1907,pin=1234,terminalId=12345678,PinOffset=1234|5399232123033091"; // -FBN } else { string expiry = ""; string pan = getCardDetails(card, phoneNumber, out expiry); if (string.IsNullOrWhiteSpace(pan) || string.IsNullOrWhiteSpace(expiry)) { return("1:No such card tied to customer"); } theMessage = String.Format("C:cardpan={0},expiryDate={1},pin=1234,terminalId=12345678,PinOffset=1234|5399232123033091", pan, expiry); new PANE.ERRORLOG.Error().LogInfo(theMessage); //call prime method to get Pin Issuance Request } // formulate the actual request data USSDPinIssuanceRequest theRequest = PosMessageParser.ParseRequestMessage <USSDPinIssuanceRequest>(theMessage.Split('|')[0]); string oldPan = theMessage.Split('|')[1]; IRequest pinRequest = theRequest as USSDPinIssuanceRequest; pinRequest.TerminalId = string.Format("USSD{0}", theRequest.CardPAN.Substring(theRequest.CardPAN.Length - 4)); pinRequest.Function = "pinselection"; Card theCard = null; string pinoffset = string.Empty; if (usePrimeHSM) { theCard = CardUtilities.RetrieveCard(pinRequest.CardPAN, pinRequest.ExpiryDate, "pc_cards_1_A"); pinoffset = CardUtilities.GetCardPinOffset(oldPan, "pc_cards_1_A"); } else { theCard = CardUtilities.RetrieveCard(pinRequest.CardPAN, pinRequest.ExpiryDate, "pc_cards_1_A"); pinoffset = CardUtilities.GetCardPinOffset(oldPan, "pc_cards_1_A"); } if (theCard == null) { return("1:Invalid card data"); } if (pinoffset == null) { return("1:Pinoffset of existing card is null"); } if (theCard.expiry_date != pinRequest.ExpiryDate) { return("1:Invalid expiry date"); } response = new PosMessageProcessor().DoCardActivation( new PinIssuanceRequest() { CardPAN = pinRequest.CardPAN, ExpiryDate = pinRequest.ExpiryDate, Pin = pinRequest.Pin, ConfirmPin = pinRequest.Pin, TerminalId = pinRequest.TerminalId, // Track2 = "5399233021500835D1907221011408619F", // IccData = "<IccRequest><AmountAuthorized>000000000000</AmountAuthorized><AmountOther>000000000000</AmountOther><ApplicationInterchangeProfile>3800</ApplicationInterchangeProfile><ApplicationTransactionCounter>006C</ApplicationTransactionCounter><Cryptogram>E7ADCDEFBDE1A846</Cryptogram><CryptogramInformationData>80</CryptogramInformationData><CvmResults>420300</CvmResults><IssuerApplicationData>0110A0800322000062E300000000000000FF</IssuerApplicationData><TerminalCapabilities>E040E0</TerminalCapabilities><TerminalCountryCode>566</TerminalCountryCode><TerminalType>12</TerminalType><TerminalVerificationResult>0080048000</TerminalVerificationResult><TransactionCurrencyCode>566</TransactionCurrencyCode><TransactionDate>170707</TransactionDate><TransactionType>92</TransactionType><UnpredictableNumber>B4072947</UnpredictableNumber></IccRequest>" }, theCard, pinoffset, oldPan); // pinRequest as PinIssuanceRequest, } catch (Exception ex) { response = string.Format("1:{0}", ex.Message); new PANE.ERRORLOG.Error().LogToFile(ex); } return(response); }
public string Execute(string theMessage) { bool usePrimeHSM = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UsePrimeHSM"]); string response = string.Empty; string encryptionIndicator = string.Empty; try { new PANE.ERRORLOG.Error().LogInfo("PinController Web service entered..."); if (theMessage == null) { throw new ApplicationException("Invalid request data. The request data is null"); } if (!(theMessage.ToUpper().StartsWith("C:") || theMessage.ToUpper().StartsWith("E:"))) { throw new ApplicationException("Invalid request data. The request data is expected to start with C: or E:"); } encryptionIndicator = theMessage.Substring(0, 2); theMessage = theMessage.Substring(2); if (encryptionIndicator == "E:") { theMessage = KeyManager.Rijndael(PrimeUtility.Configuration.ConfigurationManager.UssdConfig.UssdEncryptionKey, theMessage, CryptoMode.DECRYPTION); new PANE.ERRORLOG.Error().LogInfo("Request Data: " + theMessage); if (theMessage == null) { throw new ApplicationException("Invalid request data. Unable to decrypt the data, the expected encryption is Rijndael"); } } // formulate the actual request data USSDPinIssuanceRequest theRequest = PosMessageParser.ParseRequestMessage <USSDPinIssuanceRequest>(theMessage); IRequest pinRequest = theRequest as USSDPinIssuanceRequest; pinRequest.TerminalId = string.Format("USSD{0}", theRequest.CardPAN.Substring(theRequest.CardPAN.Length - 4)); pinRequest.Function = "pinselection"; // make the call Card theCard = CardUtilities.RetrieveCard(pinRequest.CardPAN, pinRequest.ExpiryDate); if (theCard == null) { throw new ApplicationException("Invalid card data"); } if (theCard.expiry_date != pinRequest.ExpiryDate) { throw new ApplicationException("Invalid expiry date"); } response = new PosMessageProcessor().DoPinSelection( new PinIssuanceRequest() { CardPAN = pinRequest.CardPAN, ExpiryDate = pinRequest.ExpiryDate, Pin = pinRequest.Pin, ConfirmPin = pinRequest.Pin, TerminalId = pinRequest.TerminalId }, theCard); // pinRequest as PinIssuanceRequest, } catch (Exception ex) { response = string.Format(PinConstants.DECLINED_RESPONSE_FORMAT, ex.Message); new PANE.ERRORLOG.Error().LogToFile(ex); } // encrypt the response before responding if (encryptionIndicator == "E:") { try { response = KeyManager.Rijndael(PrimeUtility.Configuration.ConfigurationManager.UssdConfig.UssdEncryptionKey, response, CryptoMode.ENCRYPTION); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); } } response = encryptionIndicator + response; return(response); }
public string IssuePin(string card, string phoneNumber) { bool usePrimeHSM = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UsePrimeHSM"]); string theMessage = ""; string response = string.Empty; string encryptionIndicator = string.Empty; IRequest pinRequest = new USSDPinIssuanceRequest(); try { new PANE.ERRORLOG.Error().LogInfo("PinController Web service entered..."); new PANE.ERRORLOG.Error().LogInfo(string.Format("{0} - {1}", card, phoneNumber)); if (string.IsNullOrWhiteSpace(card)) { return("1:Card value cannot be null"); } if (string.IsNullOrWhiteSpace(phoneNumber)) { return("1:Phone cannot be null"); } if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UseDefaultUSSDCardData"])) { // theMessage = "C:cardpan=5334771222311096,expiryDate=2204"; //- Sterling // theMessage = "C:cardpan=5399232123065994,expiryDate=1802"; //-FBN //theMessage = "C:cardpan=6280515555555555,expiryDate=2008"; //Keystone theMessage = "C:cardpan=5334775926989586,expiryDate=2009"; } else { string expiry = ""; string pan = getCardDetails(card, phoneNumber, out expiry); if (string.IsNullOrWhiteSpace(pan) || string.IsNullOrWhiteSpace(expiry)) { return("1:An error occurred."); } theMessage = String.Format("C:cardpan={0},expiryDate={1},pin=1234,terminalId=12345678,PinOffset=1234|5399232123033091", pan, expiry); new PANE.ERRORLOG.Error().LogInfo(theMessage); //call prime method to get Pin Issuance Request } // formulate the actual request data USSDPinIssuanceRequest theRequest = PosMessageParser.ParseRequestMessage <USSDPinIssuanceRequest>(theMessage); pinRequest = theRequest as USSDPinIssuanceRequest; pinRequest.Pin = new Random().Next(1111, 9999).ToString(); pinRequest.TerminalId = string.Format("USSD{0}", theRequest.CardPAN.Substring(theRequest.CardPAN.Length - 4)); pinRequest.Function = "pinselection"; Card theCard = null; if (usePrimeHSM) { string staticKeyName = System.Configuration.ConfigurationManager.AppSettings["StaticKeyName"]; string panEncryptionKey = LiteDAO.GetLocalKey(staticKeyName); string encryptedPan = ThalesSim.Core.Cryptography.TripleDES.TripleDESDecrypt(new ThalesSim.Core.Cryptography.HexKey(panEncryptionKey.Substring(0, 32)), pinRequest.CardPAN); theCard = GetCardDetailsFromService(encryptedPan, pinRequest.ExpiryDate); } else { theCard = CardUtilities.RetrieveCard(pinRequest.CardPAN, pinRequest.ExpiryDate, "pc_cards_1_A"); } if (theCard == null) { return("1:Invalid card data"); } if (theCard.expiry_date != pinRequest.ExpiryDate) { return("1:Invalid expiry date"); } response = new PosMessageProcessor().DoPinOffsetUpdate( new PinIssuanceRequest() { CardPAN = pinRequest.CardPAN, ExpiryDate = pinRequest.ExpiryDate, Pin = pinRequest.Pin, ConfirmPin = pinRequest.Pin, TerminalId = pinRequest.TerminalId }, theCard); // pinRequest as PinIssuanceRequest, } catch (Exception ex) { response = string.Format("1:{0}", ex.Message); new PANE.ERRORLOG.Error().LogToFile(ex); } return(response); }
#pragma warning disable CS1998 protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { var value = turnContext.Activity; var attachments = turnContext.Activity.Attachments; if (turnContext.Activity.Value == null) // someone typed in something, it isn't a card { var content = turnContext.Activity.Text; var code = CheckForCode(content); var conversationReference = turnContext.Activity.GetConversationReference(); var mention = new Mention { Mentioned = turnContext.Activity.From, Text = $"<at>{turnContext.Activity.From.Name}</at>", }; if (!string.IsNullOrEmpty(code)) { if (DotNetInteractiveProcessRunner.Instance.CanExecuteCode) { var submissionToken = Guid.NewGuid().ToString("N"); var messageText = string.Empty; var user = UserGame.GetOrCreateUser(mention, turnContext.Activity.From); if (UserGame.CurrentChatUser?.Id != user.Id) { UserGame.CurrentChatUser = user; messageText = $"Hey {mention.Text} It looks like you're typing some code. Let me run it for you! 😊"; } else { messageText = UserGame.GetMessageForUser(mention); } await turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, async (context, token) => { var message = MessageFactory.Text(messageText); if (messageText.Contains(mention.Text)) { message.Entities.Add(mention); } await context.SendActivityAsync(message, token); }, cancellationToken); // build the envelope var submitCode = new SubmitCode(code); submitCode.SetToken(submissionToken); var envelope = KernelCommandEnvelope.Create(submitCode); var channel = ContentSubjectHelper.GetOrCreateChannel(submissionToken); EnvelopeHelper.StoreEnvelope(submissionToken, envelope); var cardSent = false; channel .Timeout(DateTimeOffset.UtcNow.Add(TimeSpan.FromMinutes(1))) .Buffer(TimeSpan.FromSeconds(1)) .Subscribe( onNext: async formattedValues => { turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, (context, token) => { if (formattedValues.Count > 0) { var hasHtml = formattedValues.Any(f => f.MimeType == HtmlFormatter.MimeType); if (hasHtml) { if (!cardSent) { cardSent = true; var card = new HeroCard { Title = "Your output is too awesome 😎", Subtitle = "Use the viewer to see it.", Buttons = new List <CardAction> { new TaskModuleAction("Open Viewer", new { data = submissionToken }) }, }.ToAttachment(); var message = MessageFactory.Attachment(card); context.SendActivityAsync(message, token).Wait(); } } else { var content = string.Join("\n", formattedValues.Select(f => f.Value)); var message = MessageFactory.Text($"```\n{content.HtmlEncode()}"); context.SendActivityAsync(message, token).Wait(); } } return(Task.CompletedTask); }, cancellationToken).Wait(); }, onCompleted: async() => { await turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, async(context, token) => { await Task.Delay(1000); var message = MessageFactory.Text($"{mention.Text} all done here 👍"); message.Entities.Add(mention); await context.SendActivityAsync(message, token); }, cancellationToken); }, onError: async error => { await turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, async(context, token) => { await Task.Delay(1000); var message = MessageFactory.Text($@"{mention.Text} there were some issues 👎 :\n {error.Message}"); message.Entities.Add(mention); await context.SendActivityAsync(message, token); }, cancellationToken); }); user.IncrementCodeSubmissionCount(); await DotNetInteractiveProcessRunner.Instance.ExecuteEnvelope(submissionToken); } else { await turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, async (context, token) => { var message = MessageFactory.Text($"Sorry {mention.Text} cannot execute your code now. 😓"); message.Entities.Add(mention); await context.SendActivityAsync(message, token); }, cancellationToken); } } else if (string.IsNullOrWhiteSpace(DotNetInteractiveProcessRunner.Instance.SessionLanguage)) { var card = CardUtilities.CreateAdaptiveCardAttachment(CardJsonFiles.SelectLanguage); var attach = MessageFactory.Attachment(card); await turnContext.SendActivityAsync(attach, cancellationToken); } else if (content.Contains("👊")) { var mentioned = turnContext.Activity.GetMentions()?.FirstOrDefault(m => m.Mentioned.Id.EndsWith(_botId)); if (mentioned != null) { await turnContext.Adapter.ContinueConversationAsync(_botId, conversationReference, async (context, token) => { var message = MessageFactory.Text($"{mention.Text} back at you my friend! 👊"); message.Entities.Add(mention); await context.SendActivityAsync(message, token); }, cancellationToken); } } } else { var userAction = turnContext.Activity.Value; if (((JObject)userAction).Value <string>("userAction").Equals("SelectLanguage")) { if (string.IsNullOrWhiteSpace(DotNetInteractiveProcessRunner.Instance.SessionLanguage)) { var language = ((JObject)userAction).Value <string>("language"); DotNetInteractiveProcessRunner.Instance.SessionLanguage = language; var languageLabel = ((JObject)userAction).Value <string>("languageLabel"); var message = MessageFactory.Text($"All set. Let's write some {DotNetInteractiveProcessRunner.Instance.SessionLanguage} code together! 🤘🏻"); await turnContext.SendActivityAsync(message, cancellationToken); } } } }
public string DoPinOffsetUpdate(PinIssuanceRequest request, Card theCard) { string guid = Guid.NewGuid().ToString(); int step = 0; new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection HIT! [{0}]; Step: {1}", guid, ++step)); string response = string.Empty; ThalesHsm hsm = new ThalesHsm(); IGeneratePinOffsetResponse pinOffsset = null; // ChangePINResponse cpResponse = null; string clearPin = null; if (request.Pin != request.ConfirmPin) { response = "1:Invalid request data. New Pin and Confirm New Pin are not the same"; return(response); } new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection [{0}]; Step: {1}", guid, ++step)); // obatin the account number string accountNo = ""; try { accountNo = theCard.pan.Substring(theCard.pan.Length - 13, 12); } catch (Exception) { response = "1:Invalid CardNumber, ensure the card number is minimum of 16 digits"; return(response); } new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection [{0}]; Step: {1}", guid, ++step)); // Step 1: Generate a new encrypted Random Pin string _encryptedPIN; try { clearPin = request.Pin; _encryptedPIN = hsm.PinGenerator().EncryptClearPin(clearPin, accountNo).EncryptedPin; new PANE.ERRORLOG.Error().LogInfo("Clear Pin: " + clearPin); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(new Exception("Unable to Encrypt clear Pin", ex)); //Exception ex2 = new ApplicationException("System error"); //throw ex2; response = "1:System PIN Error"; return(response); } new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection [{0}]; Step: {1}", guid, ++step)); // Step 2: Generate the Pin offset for the random pin try { if (theCard.pan.StartsWith("4")) { pinOffsset = hsm.PinGenerator().GenerateVISAPinOffset(_encryptedPIN, accountNo, theCard.pan); } else { pinOffsset = hsm.PinGenerator().GeneratePinOffset(_encryptedPIN, accountNo, theCard.pan); } new PANE.ERRORLOG.Error().LogInfo("PinVerificationKey :" + ConfigurationManager.HsmConfig.PinVerificationKey); new PANE.ERRORLOG.Error().LogInfo("PinValidationData :" + ConfigurationManager.HsmConfig.PinValidationData); new PANE.ERRORLOG.Error().LogInfo("DecimalisationTable for pin :" + ConfigurationManager.HsmConfig.DecimalisationTable); new PANE.ERRORLOG.Error().LogInfo("PinOffsset :" + pinOffsset); new PANE.ERRORLOG.Error().LogInfo("EncryptedPIN :" + _encryptedPIN); new PANE.ERRORLOG.Error().LogInfo("AccountNo :" + accountNo); new PANE.ERRORLOG.Error().LogInfo("Card.Pan :" + theCard.pan); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(new Exception("Unable to Generate the Pin offset for the random pin", ex)); response = "1:System PIN OffSet Error"; return(response); } new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection [{0}]; Step: {1}", guid, ++step)); // Step 3: Update PostCard with the generated pin offset try { bool usePrimeHSM = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UsePrimeHSM"]); bool useActiveActive = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UseActiveActive"]); if (usePrimeHSM) { string staticKeyName = System.Configuration.ConfigurationManager.AppSettings["StaticKeyName"]; string panEncryptionKey = LiteDAO.GetLocalKey(staticKeyName); string encryptedPan = ThalesSim.Core.Cryptography.TripleDES.TripleDESDecrypt(new ThalesSim.Core.Cryptography.HexKey(panEncryptionKey.Substring(0, 32)), theCard.pan); UpdatePinOffsetService(encryptedPan, theCard.expiry_date, pinOffsset.Offset.Substring(0, 4)); } else if (useActiveActive) { CardUtilities.UpdateCardPinOffset_ActiveActive(theCard, pinOffsset.Offset.Substring(0, 4)); } else { CardUtilities.UpdateCardPinOffset(theCard, pinOffsset.Offset.Substring(0, 4)); } } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(new Exception("Unable to Update PostCard with the generated pin offset", ex)); //Exception ex2 = new ApplicationException("System error"); //throw ex2; response = "1:System PIN OffSet Update Error"; return(response); } new PANE.ERRORLOG.Error().LogInfo(string.Format("In PosMessageProcessor.DoPinSelection [{0}]; Step: {1}", guid, ++step)); return(string.Format("0:{0}", clearPin)); }
public string DoPinSelection(PinIssuanceRequest request, Card theCard) { new PANE.ERRORLOG.Error().LogInfo("Started Do PinSelection"); if (request.Pin != request.ConfirmPin) { throw new ApplicationException("New Pin and Confirm New Pin are not the same"); } string response = string.Empty; ThalesHsm hsm = new ThalesHsm(); IGeneratePinOffsetResponse pinOffsset = null; ChangePINResponse cpResponse = null; string clearRandomPin = null; // obatin the account number string accountNo = ""; try { accountNo = theCard.pan.Substring(theCard.pan.Length - 13, 12); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); throw new ApplicationException("Unable to derive account number from card PAN. Ensure that card PAN is minimum of 16 digits"); } // Step 1: Generate a new encrypted Random Pin string _encryptedPIN; try { clearRandomPin = new Random().Next(1111, 9999).ToString(); _encryptedPIN = hsm.PinGenerator().EncryptClearPin(clearRandomPin, accountNo).EncryptedPin; new PANE.ERRORLOG.Error().LogInfo("Generated Default Pin"); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); Exception ex2 = new ApplicationException("Unable to Generate a new default Pin"); throw ex2; } // Step 2: Generate the Pin offset for the random pin try { if (theCard.pan.StartsWith("4")) { pinOffsset = hsm.PinGenerator().GenerateVISAPinOffset(_encryptedPIN, accountNo, theCard.pan); } else { pinOffsset = hsm.PinGenerator().GeneratePinOffset(_encryptedPIN, accountNo, theCard.pan); new PANE.ERRORLOG.Error().LogInfo("Generated Pin Offset"); } } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); Exception ex2 = new ApplicationException("Unable to Generate the Pin offset for the random pin"); throw ex2; } // Step 3: Update PostCard with the generated pin offset try { CardUtilities.UpdateCardPinOffset(theCard, pinOffsset.Offset.Substring(0, 4)); new PANE.ERRORLOG.Error().LogInfo("Updated Pin Offset"); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); Exception ex2 = new ApplicationException("Unable to Update PostCard with the generated pin offset"); throw ex; } // Step 4: Do PinChange with random pin as oldpin and translated pin as newpin try { new PANE.ERRORLOG.Error().LogInfo("Connecting To FEP"); Engine theFepEngine = new PinIssuance.Net.Bridge.PostBridge.Client.Engine( PinConfigurationManager.FepConfig.BridgeHostIp, PinConfigurationManager.FepConfig.InternalServerPort, new CardAcceptor(request.TerminalId, request.TerminalId) { }, "trx" ); bool isConnectedToFEP = theFepEngine.Connect(); new PANE.ERRORLOG.Error().LogInfo(string.Format("Connected to FEP - {0}", isConnectedToFEP)); cpResponse = theFepEngine.DoChangePIN ( new CardDetails() { ExpiryDate = DateTime.ParseExact(theCard.expiry_date, "yyMM", DateTimeFormatInfo.InvariantInfo), PAN = theCard.pan, PIN = GetPinBlockToPopulateIn52ISO(accountNo, clearRandomPin), //pinbytearr, NewPINBlock = GetPinBlockToPopulateIn53ISO(accountNo, request.ConfirmPin), //newEncryptedPinBlock IccData = request.IccData, Track2 = request.Track2 }, new Bridge.PostBridge.Client.DTO.Account(accountNo, ""), theCard.seq_nr ); } catch (Exception ex) { new PANE.ERRORLOG.Error().LogToFile(ex); Exception ex2 = new ApplicationException("Unable to Do PinChange with random pin as oldpin and translated pin as newpin"); throw ex2; } // Step 5: Obtain the isser script from PinChange response and return to the Pos if (cpResponse == null || string.IsNullOrEmpty(cpResponse.IssuerScript)) { throw new ApplicationException("Invalid pin change response"); } if (cpResponse.ResponseCode == "00") { //response = string.Format("C:1|APPROVED|{0}|{1}", cpResponse.IssuerAuthenticationData, cpResponse.IssuerScript); response = string.Format("true|{0}", cpResponse.IccData); new PANE.ERRORLOG.Error().LogInfo("Pin Change Response: " + response); } else { // response = string.Format("C:2|DECLINED|{0}", cpResponse.ResponseCode); response = string.Format("false|{0}", cpResponse.ResponseDescription); } new PANE.ERRORLOG.Error().LogInfo("Ended PinSelection"); return(response); }
public void CanGetShuffledDeck() { List <Card> deck = CardUtilities.GetShuffledDeck(); Assert.Equal(52, deck.Distinct().Count()); }
public async Task ProcessText(IDialogContext context, string query) { switch (query) { case "olá": case "ola": case "ajuda": case "oi": case "socorro": case "cancelar": case "começar": case "comecar": case "recomeçar": case "recomecar": await Wellcome(context); context.Wait(ReadText); return; } var medidores = new Medidores(); var textAnalysis = new TextAnalysisService(); double sentiment = await textAnalysis.Sentiment(language : "pt", text : query); var medidor = medidores.CalculaMedidor(sentiment); var image = @"https://botmood.azurewebsites.net/images/" + medidor.Image; await context.PostAsync("O grau de emoção é um valor entre 0 e 1, sendo que 0 significa totalmente negativo e 1 totalmente positivo."); await context.PostAsync("Naturalmente meu grau de precisão é menor quanto menor for a frase. A brincadeira fica mais legal " + "se você escrever uma opinião, tal qual faria em um site de opiniões como o TripAdvisor."); var img = new List <string>() { image }; var card1 = CardUtilities.CreateHeroCard("", "Grau de emoção", sentiment.ToString("0.00"), img, null); var reply1 = context.MakeMessage(); reply1.Attachments = CardUtilities.CreateCards(); reply1.Attachments.Add(card1.ToAttachment()); await context.PostAsync(reply1); var keyPhrases = await textAnalysis.KeyPhrases(language : "pt", text : query); if ((keyPhrases != null) && (keyPhrases.Count > 0)) { var key = ""; foreach (var s in keyPhrases) { if (!string.IsNullOrEmpty(s)) { if (key.Length > 0) { key = key + ", "; } key = key + s; } } var card2 = CardUtilities.CreateHeroCard("", "Palavras chave", key, null, null); var reply2 = context.MakeMessage(); reply2.Attachments = CardUtilities.CreateCards(); reply2.Attachments.Add(card2.ToAttachment()); await context.PostAsync(reply2); } //var detectLanguage = await textAnalysis.DetectLanguage(result.Query); context.Wait(ReadText); }
public void CanCreateDeck() { List <Card> deck = CardUtilities.CreateDeck(); Assert.Equal(52, deck.Count); }