private async Task <object> ExecuteGenericRequest(IGenericRequest request) { if (request.Value is int num) { await Task.Delay(1); return(request.CreateResponse(num + 1)); } if (request.Value is DateTime dt) { await Task.Delay(2); return(request.CreateResponse(dt.AddYears(1))); } if (request.Value is string s) { await Task.Delay(3); return(request.CreateResponse($"Hello {s}!")); } return(request.CreateResponse(null)); }
public Request MappingRequest(IGenericRequest gRequest) { var request = new Request() { CashierID = gRequest.PayLoad.CashierID, CurrencyCode = gRequest.PayLoad.CurrencyCode, SessionId = gRequest.PayLoad.SessionId, TransactionType = MapOpreation(gRequest.OperationType) }; var mapper = new Mapper <Request>() //.ConstructUsing(() => new Request()) .ConstructUsing(() => request) .Map(x => x.AccountNumber, "accountnumber", p => (string)p) .Map(x => x.AgreementDate, "agreementdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.AgreementNumber, "agreementnumber", p => (string)p) .Map(x => x.AuthCode, "authno", p => (string)p) .Map(x => x.BatchNumber, "batchno", p => (string)p) .Map(x => x.BOCLoyaltyItems, "bocloyaltyitems", p => (string)p) .Map(x => x.CheckOutDate, "checkoutdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.ContractOrRoomNo, "contractorroomno", p => (string)p) .Map(x => x.CVV2, "cvv2", p => (string)p) .Map(x => x.ExpirationDate, "expirationdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.ExtMerchantId, "extmerchantid", p => (string)p) .Map(x => x.ExtReferenceNumber, "extreferencenumber", p => (string)p) .Map(x => x.ExtTerminalId, "extterminalid", p => (string)p) .Map(x => x.GenericLoyaltyBins, "genericloyaltybins", p => (string)p) .Map(x => x.GenericLoyaltyFlag, "genericloyaltyflag", p => (string)p) .Map(x => x.GiftTransactionType, "gifttransactiontype", p => (string)p) .Map(x => x.Language, "language", p => (string)p) .Map(x => x.LoyaltyIdentificationMethod, "loyaltyidentification", p => (string)p) .Map(x => x.LoyaltyTransactionType, "loyaltyrequesttype", p => (string)p) .Map(x => x.MessageCode, "messagecode", p => (string)p) .Map(x => x.MessageType, "messagetype", p => (string)p) .Map(x => x.OrigGiftReferenceNumber, "origgiftreferenceno", p => (string)p) .Map(x => x.OrigLoyaltyReferenceNumber, "origloyaltyreferencenumber", p => (string)p) .Map(x => x.OrigReferNumber, "origrefernumber", p => (string)p) .Map(x => x.OrigTransactionAmount, "amount", p => string.IsNullOrEmpty(((string)p)) ? null : (decimal?)decimal.Parse((string)p)) //.Map(x => x.OrigTransactionAmount, "amount", p =>(string)p) .Map(x => x.Password, "password", p => (string)p) .Map(x => x.PrepareReceiptTicket, "preparereceiptindicator", p => ((string)p)) .Map(x => x.ReceiptContent, "receiptcontent", p => (string)p) .Map(x => x.ReturnPANEncrypted, "returnpanencrypted", p => (string)p) .Map(x => x.StartDate, "startdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.SupplyCVMResult, "supplycvmresult", p => (string)p) .Map(x => x.TransactionType, "authtype", p => (string)p) .Map(x => x.ValidFrom, "validfrom", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.CashBackAmount, "cachbackamount", p => string.IsNullOrEmpty(((string)p)) ? null : (decimal?)decimal.Parse((string)p)) .Map(x => x.EACAccountNumber, "eacaccountnumber", p => (string)p) .Map(x => x.EACPhoneNumber, "eacphonenumber", p => (string)p) .Map(x => x.EACPaymentFlag, "eacpaymentflag", p => (string)p) ; var result = mapper.MapFrom(gRequest.PayLoad.AdditionalInfo); return(result); }
public IActionResult Post1(IGenericRequest request, GenericResponse response, IEFTPlugin plugin) { MethodInfo theMethod = plugin.GetType().GetMethod(request.OperationType); theMethod.Invoke(plugin, new object[] { request, response }); // response = plugin.Request(request, response); return(Ok(JsonConvert.SerializeObject(response))); }
public GenericResponse PaymentOld(IGenericRequest request, GenericResponse response) { var status = "Error"; var stringResponse = ""; var content = "";//BuildPaymentRequestString(request).ToString(); if (DoRequest(content)) { stringResponse = Socket.Receive(); if (stringResponse != null) { //response = BuildPaymentResponse(response, stringResponse); status = "success"; } } response.Result.Status = status; return(response); }
public GenericResponse PrintReceipt(IGenericRequest gRequest, GenericResponse response) { var request = MappingRequest(gRequest); var status = "Error"; var stringResponse = ""; var content = request.GetContent(Formatting); // BuildPaymentRequestString(gRequest).ToString(); if (DoRequest(content)) { stringResponse = Socket.Receive(); if (stringResponse != null) { //response = BuildPaymentResponse(response, stringResponse); status = "success"; } } response.Result.Status = status; return(response); }
public GenericResponse Init(IGenericRequest request, GenericResponse response) { IPAddress IP; var success = "Error"; bool result = false; try { result = Socket.Connect(configuration.Value.EFT_IPAddress, 11000); } catch (Exception e) { Console.WriteLine("error:", e); } if (result) { success = "success"; } response.Result.Status = success; return(response); }
public GenericResponse Payment(IGenericRequest gRequest, GenericResponse response) { var request = MappingRequest(gRequest); var status = "Error"; var stringResponse = ""; var res = new JCCResponse(); var content = request.GetContent(Formatting); if (DoRequest(content)) { stringResponse = Socket.Receive(); if (stringResponse != null) { var r = Helper.ResponseSplitedBySeparator(stringResponse, Convert.ToChar(Convert.ToUInt32(Formatting.Fields.FirstOrDefault().Value, 16))); res = ParseEFTTransactionResponse(r); response = BuildPaymentResponse(response, stringResponse); status = "success"; } } response.Result.Status = status; return(response); }
public string BuildPaymentRequestString2(IGenericRequest request) { var separator = (char)0x1E; StringBuilder content = null; //content.Append(request.SessionId).Append(separator); //content.Append(request.AuthType).Append(separator); //content.Append(request.Amount).Append(separator); //content.Append(request.AdditionalAmount).Append(separator); //content.Append(request.CurrencyCode).Append(separator); //content.Append(request.ContractOrRoomNo).Append(separator); //content.Append(request.CheckOutDate).Append(separator); //content.Append(request.ContractNoForCarRental).Append(separator); //content.Append(request.AgreementDate).Append(separator); //content.Append(request.PrepareReceiptIndicator ? "1" : "0").Append(separator); //content.Append(request.CashierID).Append(separator); //content.Append(request.DCCAlertSupport ? "1" : "0").Append(separator); //content.Append(request.BOCLoyaltyItems).Append(separator); //content.Append(request.ExtTerminalId).Append(separator); //content.Append(request.TokenNumber).Append(separator); return(content.ToString()); }
public GenericResponse Ping(IGenericRequest request, GenericResponse response) { var success = "Error"; var ip = request.PayLoad.AdditionalInfo["ipAddress"]; try { if (ip != null) { if (PingHelper.Ping(ip.ToString()).Status == IPStatus.Success) { success = "success"; } } } catch (PingException e) { } response.Result.Status = success; return(response); }
public GenericResponse Payment(IGenericRequest gRequest, GenericResponse response) { var request = MappingRequest(gRequest); var status = "Error"; var stringResponse = ""; var content = ""; try { content = request.GetContent(Formatting); // BuildPaymentRequestString(gRequest).ToString(); if (DoRequest(content)) { try { stringResponse = Socket.Receive(); if (stringResponse != null) { var r = Helper.ResponseSplitedBySeparator(stringResponse, Convert.ToChar(Convert.ToUInt32(Formatting.Fields.FirstOrDefault().Value, 16))); response = BuildPaymentResponse(response, ParseEFTTransactionResponse(r)); status = "success"; } } catch (Exception e) { response.Result.ErrorCode = e.Message; } } } catch (ArgumentOutOfRangeException e) { response.Result.ErrorCode = e.Message; } response.Result.Status = status; return(response); }
public Request MappingRequest(IGenericRequest gRequest) { var request = new Request() { CashierID = gRequest.PayLoad.CashierID, CurrencyCode = gRequest.PayLoad.CurrencyCode, SessionId = gRequest.PayLoad.SessionId, AuthNo = MapOpreation(gRequest.OperationType), TerminalId = gRequest.Info.TerminalID }; var mapper = new Mapper <Request>() .ConstructUsing(() => request) .Map(x => x.AgreementDate, "agreementdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.BOCLoyaltyItems, "bocloyaltyitems", p => (string)p) .Map(x => x.CheckOutDate, "checkoutdate", p => string.IsNullOrEmpty(((string)p)) ? null : (DateTime?)DateTime.ParseExact((string)p, "MM-dd-yyyy", null)) .Map(x => x.GiftTransactionType, "gifttransactiontype", p => (string)p) .Map(x => x.Amount, "amount", p => string.IsNullOrEmpty(((string)p)) ? null : (decimal?)decimal.Parse((string)p)) .Map(x => x.AdditionalAmount, "additionalamount", p => string.IsNullOrEmpty(((string)p)) ? null : (decimal?)decimal.Parse((string)p)) .Map(x => x.AuthNo, "authno", p => (string)p) .Map(x => x.ContractNoForCarRental, "contractnoforcarrental", p => (string)p) .Map(x => x.DCCAlertSupport, "dccalertsupport", p => (string)p) .Map(x => x.LoyaltyIdentification, "loyaltyidentification", p => (string)p) .Map(x => x.LoyaltyRequestType, "loyaltyrequesttype", p => (string)p) .Map(x => x.OriginalGiftReceiptNo, "origgiftreferenceno", p => (string)p) .Map(x => x.OriginalLoyaltyReceiptNumber, "origloyaltyreferencenumber", p => (string)p) .Map(x => x.OriginalReceiptNumber, "origrefernumber", p => (string)p) .Map(x => x.PrepareReceiptIndicator, "preparereceiptindicator", p => (string)p) .Map(x => x.PrintingContext, "receiptcontent", p => (string)p) .Map(x => x.RoomNo, "contractorroomno", p => (string)p) .Map(x => x.TokenNo, "tokenno", p => (string)p) ; var r = mapper.MapFrom(gRequest.PayLoad.AdditionalInfo); return(r); }
// Constructor public GenericRequest(IGenericRequest concreteImplementation) { _genericRequest = concreteImplementation; }
public GenericResponse Ping(IGenericRequest request, GenericResponse response) { throw new NotImplementedException(); }
public Class1(IGenericRequest genericRequest) { _genericRequest = genericRequest; }
// Constructor public GenericRequest(IGenericRequest <TEntity> concreteImplementation) { genericRequest = concreteImplementation; }