public HttpResponseMessage InventoryReturnTransaction(string userName, string password, string integrationModule, string documentRef = "") { var transactionResponse = new TransactionResponse(); try { _log.InfoFormat("Login attempt for {0} - {1}", userName, integrationModule); CostCentreLoginResponse response = _costCentreApplicationService.CostCentreLogin(userName, password, "HQAdmin"); AuditCCHit(response.CostCentreId, "Login", "Login attempt for " + integrationModule, response.ErrorInfo); if (response.CostCentreId == Guid.Empty) { transactionResponse.ErrorInfo = "Invalid user credentials"; transactionResponse.Result = "Error"; } else { transactionResponse = _integrationService.ExportReturnsTransactions(integrationModule, documentRef); } } catch (Exception ex) { transactionResponse.Result = "Error"; transactionResponse.ErrorInfo = "Error: An error occurred executing the task.Result details=>" + ex.Message + "Inner Exception:" + (ex.InnerException != null ? ex.InnerException.Message : ""); _log.Error(string.Format("Error: An error occurred when exporting transactions for {0}\n", integrationModule), ex); } return Request.CreateResponse(HttpStatusCode.OK, transactionResponse); }
private TransactionResponse GenerateSapResponse(string docref="",OrderType orderType=OrderType.OutletToDistributor) { var response=new TransactionResponse(); var transactions = _sapTransactionsDownloadService.GetOrdersPendingExport(docref, orderType); if (transactions != null && transactions.Any()) { response.DocRefs = transactions.Select(n => n.OrderRef).Distinct<string>().ToList();//I use it for acknowledging transaction only response.TransactionData = transactions.ToCsv(); } return response; }
public HttpResponseMessage TransactionGet(string userName, string password, string integrationModule,string documentRef="",OrderType ordertype=OrderType.OutletToDistributor, bool includeInvoiceAndReceipts=false,DocumentStatus documentStatus=DocumentStatus.Closed) { var transactionResponse = new TransactionResponse(); try { _log.InfoFormat("Login attempt for {0} - {1}", userName, integrationModule); CostCentreLoginResponse response = _costCentreApplicationService.CostCentreLogin(userName, password, "HQAdmin"); AuditCCHit(response.CostCentreId, "Login", "Login attempt for " + integrationModule, response.ErrorInfo); if (response.CostCentreId == Guid.Empty) { transactionResponse.ErrorInfo = "Invalid user credentials"; transactionResponse.Result = "Error"; } else { transactionResponse = _integrationService.ExportTransactions(integrationModule, documentRef,ordertype, includeInvoiceAndReceipts,documentStatus); } } catch (Exception ex) { transactionResponse.Result = "Error"; transactionResponse.ErrorInfo = "Error: An error occurred executing the task.Result details=>" + ex.Message+"Inner Exception:"+(ex.InnerException !=null?ex.InnerException.Message:""); _log.Error(string.Format("Error: An error occurred when exporting transactions for {0}\n",integrationModule), ex); } return Request.CreateResponse(HttpStatusCode.OK, transactionResponse); }
private TransactionResponse MapTransactionResponse(List<ShellOrderExportDto> orders) { var response = new TransactionResponse(); if(orders==null ||!orders.Any()) { response.ErrorInfo = "Success"; response.Result = "Order not found"; response.ResultInfo = "No transaction to export"; return response; } response.TransactionData = orders.ToCsv(); return response; }
private TransactionResponse GenerateQuickBooksResponse(string documentRef,bool includeInvoiceAndReceipts,DocumentStatus documentStatus=DocumentStatus.Closed) { var response = new TransactionResponse(); var orders = _quickBooksTransactionsDownloadService.GetOrdersPendingExport(documentRef, includeInvoiceAndReceipts, documentStatus); if (orders == null || !orders.Any()) { response.ErrorInfo = "Success"; response.Result = "Order not found"; response.ResultInfo = "No transaction to export"; return response; } response.DocRefs = orders.Where(p => p.DocumentType == DocumentType.Order).Select(n => n.GenericReference).Distinct<string>().ToList (); response.TransactionData = JsonConvert.SerializeObject(orders); response.ErrorInfo = "Success"; response.Result = "success"; return response; }
private TransactionResponse GenerateQuickBooksResponseForReturnsTransactions(string documentRef) { var response = new TransactionResponse(); var orders = _quickBooksTransactionsDownloadService.GetReturnsPendingExport(documentRef); if (orders == null || !orders.Any()) { response.ErrorInfo = "Success"; response.Result = "Order not found"; response.ResultInfo = "No transaction to export"; return response; } response.DocRefs = orders.Where(p => p.DocumentType == DocumentType.ReturnsNote).Select(n=>n.SalesmanCode).ToList<string>(); response.TransactionData = JsonConvert.SerializeObject(orders); response.ErrorInfo = "Success"; response.Result = "success"; return response; }
public TransactionResponse ExportReturnsTransactions(string integrationModule, string documentRef = "") { var response = new TransactionResponse(); if (string.IsNullOrEmpty(integrationModule)) { response.ErrorInfo = "Integration Module is not provided"; response.Result = "Cannot generate export orders"; response.ResultInfo = "Invalid request"; return response; } response = GenerateQuickBooksResponseForReturnsTransactions(documentRef); return response; }
public TransactionResponse ExportTransactions(string integrationModule, string documentRef = "", OrderType orderType = OrderType.OutletToDistributor, bool includeInvoiceAndReceipts = false,DocumentStatus documentStatus=DocumentStatus.Closed) { var response = new TransactionResponse(); if(string.IsNullOrEmpty(integrationModule)) { response.ErrorInfo = "Integration Module is not provided"; response.Result = "Cannot generate export orders"; response.ResultInfo = "Invalid request"; return response; } var requestingIntegrator = (IntegrationModule)Enum.Parse(typeof(IntegrationModule), integrationModule); switch (requestingIntegrator) { case IntegrationModule.Sage: response = GenerateSageResponse(documentRef); break; case IntegrationModule.SAP: response = GenerateSapResponse(documentRef,orderType); break; case IntegrationModule.QuickBooks: response = GenerateQuickBooksResponse(documentRef, includeInvoiceAndReceipts,documentStatus); break; default: response.ErrorInfo = "Integration Module provided is not recognised"; response.Result = "Cannot generate export orders"; response.ResultInfo = "Invalid request"; break; } return response; }