public ReceiptVoucher SaveFailedReceiptVoucher(ReceiptVoucherViewModel receiptVoucher, long transactionId) { //Insert into failed reciept vouchers only try { using (var paymentMgr = new PaymentManager()) { return(paymentMgr.SaveFailedReceiptVoucher(receiptVoucher, transactionId)); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } finally { //string ToEmails = ConfigurationManager.AppSettings["PaymentFailureEmails"].ToString(); SettingStoreBase _storeBase; _storeBase = new SettingStoreBase(new LaborServicesDbContext()); string ToEmails = _storeBase.GetSettingValueByName("PaymentFailureEmails"); string CCEmail = ""; string subject = "خطأ في إنشاء سند قبض للعميل من علي البورتال"; string body = " خطأ في إنشاء سند قبض للعميل رقم "; body += receiptVoucher.Customerid; body += " من علي البورتال لعقد رقم "; body += receiptVoucher.contractid; MailSender.SendEmail02(ToEmails, CCEmail, subject, body, false, ""); } }
private void LogException(Exception ex) { string tenant = TenantConvention.GetTenant(); var meta = AppUsers.GetCurrent(); DefaultExceptionLogger.Log(tenant, meta.UserId, meta.Name, meta.OfficeName, ex.ToString()); }
public PaymentTransaction AddSuccessTransaction(string customerId, string invoiceNum, string invoiceId, decimal amount, HyperPayResponse hyperPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = customerId, ContractId = invoiceId, PaymentStatus = hyperPay.RequiredCode, PaymentStatusName = hyperPay.RequiredValue, Amount = Convert.ToDecimal(amount), Who = 2, EntityName = "Successfull Payment Transaction for Domestic Invoice No [ " + invoiceNum + " ] with Total price of : [ " + amount + " SR ] and customer : [ " + customerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.DomesticInvoice, TransactionTypeName = TransactionType.DomesticInvoice.ToString() }; using (var paymentMgr = new PaymentManager()) { transaction = paymentMgr.CreatePaymentTransaction(transaction); return(transaction); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public PaymentTransaction AddFailedPaymentTransactionWithNoCheckoutId(ServiceContractPerHour contractToPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = contractToPay.CustomerId, ContractId = contractToPay.ContractId, PaymentStatus = "000000", PaymentStatusName = "Checkout payment failed", Amount = Convert.ToDecimal(contractToPay.FinalPrice), Who = 2, EntityName = "Failed Payment Transaction for Contract Number [ " + contractToPay.ContractNum + " ] with Total price of : [ " + contractToPay.FinalPrice + " SR ] and customer : [ " + contractToPay.CustomerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.ServiceContractPerHour, TransactionTypeName = TransactionType.ServiceContractPerHour.ToString() }; transaction = CreatePaymentTransaction(transaction); return(transaction); } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public virtual Task <APIResponseModel <ReceiptVoucherViewModel> > CreateReceiptVoucher(DomesticInvoice invoice) { CultureInfo info = new CultureInfo("en-us"); ReceiptVoucherViewModel data = new ReceiptVoucherViewModel() { contractid = invoice.ContractId, Customerid = invoice.CustomerId, Contractnumber = invoice.Contract, InvoiceNumber = invoice.Number, amount = invoice.InvoiceAmount.ToString(), datatime = DateTime.Now.ToString("dd/MM/yyyy", info.DateTimeFormat), paymentcode = "2", vatrate = "0.0", who = AppConstants.Who_WebSource, InvoiceId = invoice.Id }; try { var caller = new ApiCaller(Lang); var apiUrl = String.Format("api/Payment/Individual/AddRecieptVoucher"); return(caller.PostResourceAsync <ReceiptVoucherViewModel>(apiUrl, data)); } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(new Task <APIResponseModel <ReceiptVoucherViewModel> >(() => new APIResponseModel <ReceiptVoucherViewModel>() { StatusCode = System.Net.HttpStatusCode.InternalServerError, Result = data })); } }
public async Task <ActionResult> SystemicBankTransfer(HttpPostedFileBase BankFile, string id) { try { using (var client = new HttpClient()) { string apiServiceUrl = SharedClass.ApiServerUrl + (Lang == Language.English ? "en" : "ar") + "/api/HourlyContract/BankTransferStatementFile/" + id; using (var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture))) { content.Add(new StreamContent(BankFile.InputStream), "BankFile", BankFile.FileName); using ( var message = await client.PostAsync(apiServiceUrl, content)) { var input = await message.Content.ReadAsStringAsync(); if (message.IsSuccessStatusCode) { var successMsg = new ResultMessageVM() { Title = DbRes.T("BankTransferIsUploaded", "DalalResources"), Message = DbRes.T("UploadedBankTransferMsg", "DalalResources"), IsWithAutoRedirect = true, UrlToRedirect = Url.Action("Details", "HourlyWorkers", new { id, lang = (Lang == Language.Arabic ? "ar" : "en") }), RedirectTimeout = 10 }; return(View("Success", successMsg)); } } } } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); } var failMsg = new ResultMessageVM() { Title = DbRes.T("ProblemInUploadingBankTransfer", "DalalResources"), Message = DbRes.T("ProblemInUploadingBankTransferMsg", "DalalResources"), IsWithAutoRedirect = false, //UrlToRedirect = Url.Action("Index", "Home", new { lang = Lang == Language.Arabic ? "ar" : "en" }), //RedirectTimeout = 10 }; return(View("Failure", failMsg)); }
public PaymentTransaction UpdatePaymentTransaction(PaymentTransaction model) { try { var paymentModel = new PaymentTransaction(); paymentModel = _PaymentTransactionStoreBase.Update(model); return(paymentModel); } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public ReceiptVoucherViewModel SaveFailedReceiptVoucher(ContractViewModel contractToPay, PaymentTransaction newTransaction) { //Insert into failed reciept vouchers only try { //string ToEmails = ConfigurationSettings.AppSettings["PaymentFailureEmails"].ToString(); string ToEmails = _storeBase.GetSettingValueByName("PaymentFailureEmails"); string CCEmail = ""; string subject = "خطأ في إنشاء سند قبض للعميل من علي البورتال"; string body = " خطأ في إنشاء سند قبض للعميل رقم "; body += contractToPay.CustomerId; body += " من علي البورتال لعقد رقم "; body += contractToPay.ContractId; var receipt = new ReceiptVoucher(); receipt.ContractId = contractToPay.ContractId; receipt.CustomerId = contractToPay.CustomerId; receipt.ContractNumber = contractToPay.ContractNum; receipt.Amount = Convert.ToDecimal(contractToPay.PriceBeforeDiscount); CultureInfo info1 = new CultureInfo("en-us"); receipt.Date = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.PaymentCode = "2";//ToDo receipt.PaymentType = 2; receipt.VatRate = Convert.ToDecimal(contractToPay.VatRate); receipt.Who = 2; receipt.IsSaved = false; receipt.CreatedDate = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.ModifiedDate = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.TransactionId = newTransaction.Id; _ReceiptVoucherStoreBase.Create(receipt); MailSender.SendEmail02(ToEmails, CCEmail, subject, body, false, ""); return(new ReceiptVoucherViewModel()); } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public PaymentTransaction AddFailTransaction(string customerId, string invoiceNum, string invoiceId, decimal amount, HyperPayResponse hyperPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = customerId, ContractId = invoiceId, Amount = amount, Who = 2, EntityName = "Failed Payment Transaction for Contract Number [ " + invoiceNum + " ] with Total price of : [ " + amount + " SR ] and customer : [ " + customerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.DomesticInvoice, TransactionTypeName = TransactionType.DomesticInvoice.ToString() }; if (String.IsNullOrEmpty(hyperPay.CheckoutId)) { transaction.PaymentStatus = "000000"; transaction.PaymentStatusName = "Checkout payment failed"; } else { transaction.PaymentStatus = hyperPay.RequiredCode; transaction.PaymentStatusName = hyperPay.RequiredValue; } using (var paymentMgr = new PaymentManager()) { transaction = paymentMgr.CreatePaymentTransaction(transaction); return(transaction); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public async Task <ReceiptVoucherViewModel> CreateReceiptVoucher(ContractViewModel contractToPay, PaymentTransaction newTransaction) { try { var data = new ReceiptVoucherViewModel(); data.contractid = contractToPay.ContractId; data.Customerid = contractToPay.CustomerId; data.Contractnumber = contractToPay.ContractNum; data.amount = contractToPay.PriceBeforeDiscount; CultureInfo info = new CultureInfo("en-us"); data.datatime = DateTime.Now.ToString("dd/MM/yyyy", info.DateTimeFormat); data.paymentcode = "2";//ToDo data.paymenttype = 2; data.vatrate = contractToPay.VatRate; data.who = 2; var newVoucher = await PostResourceAsync <ReceiptVoucherViewModel>("api/Payment/AddRecieptVoucher", data); if (newVoucher.StatusCode == HttpStatusCode.OK) { //SaveFailedReceiptVoucher(contractToPay, newTransaction); return(newVoucher.Result); } else { return(SaveFailedReceiptVoucher(contractToPay, newTransaction)); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(SaveFailedReceiptVoucher(contractToPay, newTransaction)); } }
public void OnException(ExceptionContext filterContext) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", filterContext.Exception); }