public static void PushHistoricalTransactions(DateTime startDate, DateTime endDate) { if (startDate.Date > endDate.Date) { Logger.LogInfo("End date should be greater than or equal to start date!"); return; } if (ConfigurationHelper.RetailerId <= 0) { Logger.LogInfo("Please set the retailer Id before processing transactions!"); return; } if (string.IsNullOrEmpty(ConfigurationHelper.RetailerName)) { Logger.LogInfo("Please set the retailer name before processing transactions!"); return; } DeleteAllTransactionXMLs(); int count = 0; for (DateTime date = startDate.Date; date.Date <= endDate.Date; date = date.AddDays(1)) { string transPath = Path.Combine(ConfigurationHelper.TransactionsPath, string.Format("trans_{0}.xml", date.ToString("yyyyMMdd"))); bool transXMLCreated = ExtractUtilityHelper.QDXTransactionToXML(date, transPath); if (!transXMLCreated) { continue; } count++; var transactions = GetBOFile(BOFileType.Transactions, date, transPath); if (transactions != null) { Logger.LogInfo(string.Format("PUSHING: Transaction for {0}", date.ToString(Constants.DateFormat))); Proxy.PushBOFile(transactions); ExtractUtilityHelper.SafelyDeleteFile(transPath); } } if (count == 0) { Logger.LogInfo("No transactions were processed."); return; } Logger.LogInfo(string.Format("Pushed {0} transactions!", count)); Logger.LogInfo("Triggering BO files processor!"); Proxy.ProcessBOFilesForRetailer(ConfigurationHelper.RetailerId); Proxy.Close(); _proxy = null; }
public async Task TimeCard_count_equals_four() { IEndPointConfiguration ep = EndPoints.First(x => x.ProviderName == CurrentDatabaseProviderName && x.API_Name == API_Name.BackOffice); await DropAndRecreateDatabase(ep); List <TimeCard> timeCards = await BOServiceClient.CallAsync(async x => await x.TimeCardsService.GetTimeCards(), ep.Name); Assert.AreEqual(4, timeCards.Count); }
public async Task Employee_count_equals_two() { IEndPointConfiguration ep = EndPoints.First(x => x.ProviderName == CurrentDatabaseProviderName && x.API_Name == API_Name.BackOffice); await DropAndRecreateDatabase(ep); List <Employee> employees = await BOServiceClient.CallAsync(async x => await x.EmployeesService.GetEmployees(), ep.Name); Assert.AreEqual(2, employees.Count); }
public static void RunJob() { try { Logger.LogInfo("******************* Application START *******************"); Logger.LogInfo("Extracting items from Back Office"); ExtractUtilityHelper.RunExtractUtility(ConfigurationHelper.ItemsParam); Logger.LogInfo("Extracting departments from Back Office"); ExtractUtilityHelper.RunExtractUtility(ConfigurationHelper.DepartmentsParam); Logger.LogInfo("Extracting transactions from Back Office"); string transactionPath = ExtractUtilityHelper.ExtractTransactionXML(); var departments = GetBOFile(BOFileType.Departments); if (departments != null && departments.FileContent != null) { Logger.LogInfo("Pushing departments file to the web service!"); var result = Proxy.PushBOFile(departments); } var items = GetBOFile(BOFileType.Items); if (items != null && items.FileContent != null) { Logger.LogInfo("Pushing items file to the web service!"); Proxy.PushBOFile(items); } var transactions = GetBOFile(BOFileType.Transactions, ConfigurationHelper.TransactionDate, transactionPath); if (transactions != null) { Logger.LogInfo("Pushing transaction files to the web service!"); Proxy.PushBOFile(transactions); } Logger.LogInfo("Triggering BO files processor!"); Proxy.ProcessBOFilesForRetailer(ConfigurationHelper.RetailerId); Proxy.Close(); _proxy = null; Logger.LogInfo("+++++++++++++++++++ Done! +++++++++++++++++++"); Logger.Flush(); } catch (Exception ex) { Logger.Flush(); Logger.LogException(ex); } }
public Deal GetDeal(int id) { try { return(BOServiceClient.GetDeal(id)); } catch (FaultException ex) { TwinkleMessageBox.ShowError(ex.Message); BOServiceClient.Abort(); return(null); } }
public static bool PushBOFile(this BOServiceClient client, LocalFile lf) { var retVal = client.PushBOFile(lf.BOFile); CloudBlobClient blobStorage = new CloudBlobClient(retVal.AccountName, new StorageCredentialsSharedAccessSignature(retVal.Signature)); blobStorage.Timeout = TimeSpan.FromHours(1); var container = blobStorage.GetContainerReference(retVal.Container); var blob = container.GetBlobReference(retVal.Name); blob.UploadByteArray(lf.FileContent, defaultRequestOptions); return(client.Uploaded(lf.BOFile.RetailerId, retVal.Name)); }