/// <summary> /// Send the SalesOrderList to the data onboarding web service. This method accepts a SalesOrderList rather than a DataTable /// </summary> /// <param name="salesOrders">Sales Order Data List</param> /// <param name="primaryKey">Primary key field in the data</param> /// <param name="dateController">DateController field in the data</param> /// <param name="measureFields">List of measure fields in the data</param> /// <param name="longTextFields">List of long text fields in the data</param> /// <param name="commaAnalyzerFields">List of comma analyzer (CSV) fields in the data</param> /// <returns></returns> public bcl.DTO.DTO_Result SendData(DTO.SalesOrder.DTO_SalesOrderList salesOrders, string primaryKey, string dateController, List <string> measureFields = null, List <string> longTextFields = null, List <string> commaAnalyzerFields = null) { bcl.DTO.DTO_Result Results = new Framework.Bcl.DTO.DTO_Result(false); //Add the data to the Sales order datatable helper. SalesOrderDataTableHelper.AddSalesOrders(salesOrders); //check if the datatable is not empty if (SalesOrderDataTableHelper.SalesOrderTable != null) { if (SalesOrderDataTableHelper.SalesOrderTable.Rows.Count > 0) { //send the datatable for onboarding via the eMite data onboarding web service. Results = SendData(SalesOrderDataTableHelper.SalesOrderTable, primaryKey, dateController, measureFields, longTextFields, commaAnalyzerFields); SalesOrderDataTableHelper.Dispose(); } else { Results = new bcl.DTO.DTO_Result(false, "No records to index"); } } else { Results = new bcl.DTO.DTO_Result(false, "No records to index"); } return(Results); }
/// <summary> /// Entry point of the Adventure works adapter. /// </summary> public void Start() { bool ExitLoop = true; //authenticated token is globaly available via the BM_Authentication business module Log.Info("Authenticated Token: " + BM.Helpers.BM_Authentication.AuthenticatedToken); //only proceed if the authentication token is valid i.e. the code successfully authenticated with the source api. In this sample this will always be true. if (BM.Helpers.BM_Authentication.IsAuthenticated) { //get sales order filter criteria var SalesOrderFilter = GetQueryRange(); //loop until EndDate < DateTime.UTCNow do { bcl.DTO.DTO_Result OnboardResults = null; Log.Info("StartDate: " + SalesOrderFilter.StartDate.ToString("yyyy-MM-ddHH:mm:ss") + " | EndDate: " + SalesOrderFilter.EndDate.ToString("yyyy-MM-ddHH:mm:ss")); //load sales orders using the sale order filter var Data = BmSalesOrder.Get(SalesOrderFilter); //check if call was successful if (Data.Successful) { //check if there were results returned for the poll. if (Data.Results != null) { //cast the data into the SalesOrderList Object DTO.SalesOrder.DTO_SalesOrderList SalesOrders = (DTO.SalesOrder.DTO_SalesOrderList)Data.Results; //Send data for onboarding. OnboardResults = BmSalesOrder.Onboard(SalesOrders); //check if data onboarding was successful. if (OnboardResults.Errors != null) { //output error logs if any. if (OnboardResults.Errors.Count > 0) { Log.Warn(OnboardResults.Errors[0]); } } } } //check if the current poll EndDate is less than UtcNow. So that we can prepare a new filter criteria for the next data poll if (SalesOrderFilter.EndDate < DateTime.UtcNow) { //set filter criteia for next poll. SalesOrderFilter.StartDate = SalesOrderFilter.EndDate; //add the configured QueryInterval set by the user for each poll. SalesOrderFilter.EndDate = SalesOrderFilter.StartDate.AddMinutes(Config.QueryInterval); ExitLoop = false; } else { ExitLoop = true; } } while (ExitLoop == false); } }