public void TestSteps() { bool SkipF0101 = true; bool SkipF03012 = true; // 1.) Read the concept ConceptCSV TestConceptCSV = new ConceptCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutExample1.csv", ","); TestConceptCSV.ReadConcept(); // 2.) Test for missing entries List <string> TestMissing = TestConceptCSV.CheckForMissingShipToAddresses(); // 3.) If entries are missing, do the following: if (0 < TestMissing.Count && !SkipF0101) { // 4.) Populate the missing CSV using the list of missing items ShipToCSV MissingShipToCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ","); MissingShipToCSV.PopulateSpreadsheet(TestMissing, TestConceptCSV); // 5.) Populate the transformed data structure ShipTo MissingShipTo = XfrmShipTo.CSVToShipTo(MissingShipToCSV, false); // Don't look up JDE Addresses // 6.) Upload the transformed data structure to the F0101 Z-File JDE.PopulateF0101Z2(MissingShipTo); // 7.) Now write the CSV to disk MissingShipToCSV.WriteCSV(); // 8.) Now, someone must run R01010Z to load the data into JDE. // Popup window } else if (!SkipF03012) { // TODO: 9.) Check for F03012 records // 10.) If F03012 records are missing: ShipToCSV MissingShipToCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ","); MissingShipToCSV.ReadShipTo(); if (MissingShipToCSV.ValidateHeader() && // Required row is all there MissingShipToCSV.ValidateRows(false)) // We can't have an empty tax area code { // 11.) Convert the CSV into a data structure we can upload ShipTo PopulatedShipTo = XfrmShipTo.CSVToShipTo(MissingShipToCSV, true); // Lookup JDE Address // 12.) Upload the data structure into JDE JDE.PopulateF03012Z1(PopulatedShipTo); // 13.) Now someone must run R03010Z to load the data into JDE. } else { //TODO: Say we don't have a valid spreadsheet int x = 0; x++; } } else { Concept TestConcept = XfrmConcept.CSVtoConcept(TestConceptCSV); JDE.PopulateF47011(TestConcept); JDE.PopulateF47012(TestConcept); } }
public void ReadShipToCSVandPopulateF0101Z2() { ShipToCSV PopulatedCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ","); PopulatedCSV.ReadShipTo(); PopulatedCSV.ValidateHeader(); PopulatedCSV.ValidateRows(true); ShipTo PopulatedShipTo = XfrmShipTo.CSVToShipTo(PopulatedCSV, false); // Dont lookup JDE address JDE.PopulateF0101Z2(PopulatedShipTo); }
} // SaveCSVFlow /// <summary> /// The control flow for uploading and saving a Ship To CSV address book file. /// This data flow doesn't need the tax information. /// </summary> private void AddressBookFlow() { log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config")); log.Debug($"Beginning address book F0101 Z-File Load flow."); using (LoadingForm frm = new LoadingForm()) { frm.Visible = true; MissingShipToCSV = null; // make sure to clear this out each time we load a spreadsheet // 1.) Get the file to load frm.AddText("Get file name to load."); string FileToLoad = FileIO.GetFileName(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileFilter); if (String.Empty != FileToLoad) { try { // 2.) Load the file log.Debug($"Attempting to load file {FileToLoad} using <tab> as a delimiter"); frm.AddText($"Attempting to load file {FileToLoad} using <tab> as a delimiter."); MissingShipToCSV = new ShipToCSV(FileToLoad, "\t"); MissingShipToCSV.ReadShipTo(); frm.AddText($"Successfully read file {FileToLoad}."); // 3.) Validate the required columns exist in the spreadsheet log.Debug($"Attempting to validate all required columns exist in the file."); frm.AddText("Validating required columns exist in the file."); if (!ValidateShipToHeader(ref MissingShipToCSV)) { return; } // 4.) Validate the data in the rows match the column requirements frm.AddText("Validate data is in the correct format for each row and column."); log.Debug("Validating all row data in all required columns"); if (!ValidateShipToRows(ref MissingShipToCSV, true)) { return; } // Allow blank TankAreaCode // 5.) Either populate the data table for viewing or load the data into JDE using (new CenterDialog(this)) { DialogResult result = MessageBox.Show($"All {MissingShipToCSV.DT.Rows.Count} rows of data are valid.\r\nLoad the Data into JDE?\r\nSelect No to preview the detail data before load.", "Load Data?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (DialogResult.Cancel == result) { return; } // 5a.) Save the data into a ShipTo & save that to JDE log.Debug($"Tranform the ShipToCSV into a ShipTo object"); frm.AddText($"Converting CSV file to a JDE loadable object."); ShipTo ship = XfrmShipTo.CSVToShipTo(MissingShipToCSV, false); // Don't look up the JDE address, because you don't have any yet if (DialogResult.Yes == result) { log.Debug($"Populating F0101Z2 with data"); frm.AddText("Loading JDE F0101Z2 with data."); JDE.PopulateF0101Z2(ship); // 5b.) Prompt the user to go to JDE log.Debug($"Successfully processed the Ship To information into F0101Z2 with batch number {ship.batch}."); frm.AddText($"Successfully processed bactch number: {ship.batch}."); using (new CenterDialog(this)) { MessageBox.Show($"Your BATCH NUMBER is: {ship.batch}\r\n\r\nThe ship to information was successfully loaded into JDE.\r\nPlease go to JDE, and run the address book load UBE.\r\nThen come back and load the customer master information.\r\n\r\n", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (DialogResult.No == result) { frm.AddText("Successfully created JDE loadable object."); this.dgv_DataDisplay.DataSource = ship.NewShipTos; } } } catch (Exception er) { log.Error($"{er.Message} + {er.InnerException} + {er.StackTrace}"); using (new CenterDialog(this)) { MessageBox.Show($"{er.Message} + {er.InnerException} + {er.StackTrace}", "Error in Rollout", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } return; } // AddressBookFlow