public override void ExecuteJob(IJobExecutionMessage message, IMQTransaction transaction) { //DirectoryInfo directory = new DirectoryInfo(dir); //string[] files = (string[])directory.GetFiles("topup_*").Where(f => DateTime.Compare(DateTime.Now.AddHours(-1.0), f.CreationTime) < 0) // .Select(z => z.Name).ToArray(); string topups = GetTopupFileNames(); if (!topups.Equals("")) { FtpMessage ftpMessage = new FtpMessage(); ftpMessage.FileName = "ProcessedPaymentFiles_" + DateTime.Now.ToString("yyyyMMddhh24mmss") + ".txt"; ftpMessage.Body = Encoding.ASCII.GetBytes(topups); ftpClient.SendMessage(ftpMessage); } }
protected override void chargeDebt(IDebtCollectionMessage message, int delaySeconds, IMQTransaction transaction) { _logger.LogInfo("ChargeDebr started"); DebtCollectionInfo currentDebt = message.Debts[message.DebtInProcess]; message.Parameters.Add("transactionID", _debtManager.GetDebtTransactionID(currentDebt.Debt.DebtID)); _logger.LogInfo("TransactionID added to parameter"); base.chargeDebt(message, delaySeconds, transaction); _logger.LogInfo("Base charge Debt run"); }
int IBillingAdapter.Process(IBillingMessage message, IMQTransaction tx) { HttpRequest request = new HttpRequest(); HttpResponse httpResponse = null; _logger.LogInfo(" billing message started" + message.BillingCommand); if (message.BillingCommand == (int)BillingCommand.QueryCollectionData) { string messageText = "<billingRequest command = \"balance\" msisdn = \"" + message.BillingSubscriberID + "\" />"; request.Body = messageText; httpResponse = (HttpResponse)_httpBillingSimulator.SendMessage(request); Dictionary <string, string> keyValues = getResponseParameters(httpResponse.Body); keyValues.TryGetValue("balance", out string balance); _logger.LogInfo("Subscriber balance: " + balance); message.BillingOutputParameters["SubscriberBalance"] = Convert.ToDecimal(balance ?? "0.0"); } else if (message.BillingCommand == (int)BillingCommand.QueryScoringData) { string messageBody = "<billingRequest command=\"scoring\" msisdn=\"" + message.BillingSubscriberID + "\" />"; request.Body = messageBody; httpResponse = (HttpResponse)_httpBillingSimulator.SendMessage(request); Dictionary <string, string> keyValues = getResponseParameters(httpResponse.Body); foreach (var a in keyValues.Keys) { _logger.LogInfo(a + " => " + keyValues[a]); } keyValues.TryGetValue("activationDate", out string activationDate); keyValues.TryGetValue("lifecycleStatus", out string lifecycleStatus); keyValues.TryGetValue("tariffType", out string tariffType); _logger.LogInfo("activationDate: " + activationDate); _logger.LogInfo("lifecycleStatus: " + lifecycleStatus); message.BillingOutputParameters["ActivationDate"] = activationDate ?? string.Empty; message.BillingOutputParameters["LifecycleStatus"] = lifecycleStatus ?? string.Empty; message.BillingOutputParameters["SubscriberType"] = tariffType ?? string.Empty; } else if (message.BillingCommand == (int)BillingCommand.BalanceAdjustment) { _logger.LogInfo("message.BillingSubscriberID *** " + message.BillingSubscriberID); message.BillingInputParameters.TryGetValue("AdjustAmount", out object adjustAmount); _logger.LogInfo("message.BillingOutputParameters[\"ChargedAmount\"] *** " + adjustAmount); _logger.LogInfo(" message.ID *** " + message.ID); string messageBody = "<billingRequest command=\"balanceadjustment\" msisdn=\"" + message.BillingSubscriberID + "\" amount=\"" + (adjustAmount ?? 0) + "\" transactionId=\"" + message.ID + "\" />"; message.Parameters.TryGetValue("transactionID", out object value); string transactionID = (string)value; request.Body = messageBody; _logger.LogInfo("transaction id 23 " + value); httpResponse = (HttpResponse)_httpBillingSimulator.SendMessage(request); _logger.LogInfo("transaction id 24 " + value); Dictionary <string, string> keyValues = getResponseParameters(httpResponse.Body); keyValues.TryGetValue("transactionId", out transactionID); keyValues.TryGetValue("adjustedAmount", out string adjustedAmount); _logger.LogInfo("transaction id 25 " + transactionID); if (value == null) { _logger.LogInfo("transaction id 26 "); message.Parameters.Add("transactionID", transactionID); } else { _logger.LogInfo("transaction id 27" + value); message.Parameters["transactionID"] = transactionID; } message.BillingOutputParameters["ChargedAmount"] = Math.Abs(Convert.ToDecimal(adjustedAmount ?? "0")); _logger.LogInfo("transaction id in parameters " + message.Parameters["transactionID"]); } if (httpResponse != null & httpResponse.StatusCode == 200) { message.BillingSuccess = true; message.ReceiptRequired = false; return(message.BillingCommand); } return(httpResponse.StatusCode); }