Пример #1
0
        public ConceptCSV TestGoodRead()
        {
            ConceptCSV TestConcept = new ConceptCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutExample1.csv");

            TestConcept.ReadConcept();
            Assert.IsNotNull(TestConcept);
            return(TestConcept);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public void ReadConceptAndWriteCSV()
        {
            ConceptCSV TestConcept = new ConceptCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutExample1.csv");

            TestConcept.ReadConcept();
            List <string> TestMissing = TestConcept.CheckForMissingShipToAddresses();
            ShipToCSV     TestShip    = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ",");

            TestShip.PopulateSpreadsheet(TestMissing, TestConcept);
            TestShip.WriteCSV();
        }
Пример #4
0
        } // ValidateConceptRows

        /// <summary>
        /// Check to see if the shipping vendor in the spreadsheet is a valid vendor in JDE
        /// </summary>
        /// <param name="csv"></param>
        /// <returns></returns>
        private bool CheckShippingVendor(ConceptCSV csv)
        {
            bool result = csv.CheckShippingVendor();

            if (!result)
            {
                log.Error($"Vendor number {csv.DT.Rows[0].Field<string>("SHIPPING VENDOR")} is not of type V or V3");
                using (new CenterDialog(this))
                {
                    MessageBox.Show($"Error in csv. The shipping vendor number {csv.DT.Rows[0].Field<string>("SHIPPING VENDOR")} is not a vendor in JDE.");
                }
            }
            else
            {
                log.Debug($"The shipping vendor number {csv.DT.Rows[0].Field<string>("SHIPPING VENDOR")} is a valid vendor.");
            }
            return(result);
        } // CheckShippingVendor
Пример #5
0
        } // ValidateFreightRows

        /// <summary>
        /// The process flow to follow when you encounter missing ship to locations in the spreadsheet.
        /// </summary>
        /// <param name="names"></param>
        /// <param name="conceptCSV"></param>
        private void FollowMissingShipToPath(List <string> names, ConceptCSV conceptCSV, LoadingForm frm)
        {
            // 1.) Tell the user about the missing ship to addresses
            using (new CenterDialog(this))
            {
                MessageBox.Show($"There are {names.Count.ToString()} ship to locations that don't exist in JDE.\r\nPress OK to review the list.\r\nThen Save to CSV to create a CSV.\r\nThis CSV needs to be updated and uploaded to JDE.",
                                "Missing Ship To Locations",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            // 2.) Populate the datatable
            frm.AddText("Populating the datatable for review.");
            MissingShipToCSV = new ShipToCSV();
            MissingShipToCSV.PopulateSpreadsheet(names, conceptCSV);
            this.dgv_DataDisplay.DataSource = MissingShipToCSV.DT;
            // 3.) Make the save to CSV available.
            frm.AddText("Datatable population complete.");
            btn_SaveCSV.Enabled = true;
            return;
        } // FollowMissingShipToPath
Пример #6
0
        } // ValidateConceptHeader

        /// <summary>
        /// Validate the row data
        /// </summary>
        /// <param name="csv"></param>
        /// <returns></returns>
        private bool ValidateConceptRows(ref ConceptCSV csv)
        {
            bool result = csv.ValidateRows();

            if (!result)
            {
                // TODO:  Fix this to display the bad data
                log.Error("Failed to validate row data for one or more rows");
                using (new CenterDialog(this))
                {
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show($"Error in csv. Failed to validate data in one or more rows.  See log file and documentation for more information.", "Error in Rollout CSV Data", buttons);
                }
            }
            else
            {
                log.Debug("All row data is valid for all required columns");
            }
            return(result);
        } // ValidateConceptRows
Пример #7
0
        } // AnyZeroAddresses

        /// <summary>
        /// Validate concept header minimal columns are there
        /// </summary>
        /// <param name="csv"></param>
        /// <returns></returns>
        private bool ValidateConceptHeader(ref ConceptCSV csv)
        {
            bool result = csv.ValidateHeader();

            if (!result)
            {
                // TODO: Fix this to display the missing information
                log.Error("Failed to validate required headers");
                using (new CenterDialog(this))
                {
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show($"Error in csv.  There are missing required header rows.  See Log file and documentation for more information.", "Error in Rollout CSV Headers", buttons);
                }
            }
            else
            {
                log.Debug("All required columns exist");
            }
            return(result);
        } // ValidateConceptHeader
Пример #8
0
        public void TestGoodExampleSpreadsheet()
        {
            bool       passed      = true;
            ConceptCSV TestConcept = TestGoodRead();

            if (null != TestConcept)
            {
                passed = TestConcept.ValidateHeader();
                if (passed)
                {
                    passed = TestConcept.ValidateRows();
                    int numRows = TestConcept.RowCount;
                    passed = passed && (56 == numRows);
                    Assert.IsTrue(passed);
                }
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Пример #9
0
        } // ValidateTaxExplanations

        /// <summary>
        /// Verify a valid concept code exists in JDE for this customer.
        /// </summary>
        /// <param name="conceptCSV"></param>
        /// <returns></returns>
        private bool ConceptCodeExists(ConceptCSV conceptCSV)
        {
            bool   result;
            string concept = JDE.GetConceptID(Double.Parse(conceptCSV.DT.Rows[0].Field <string>("CUSTOMER NUMBER"))).Trim();

            if (String.Empty == concept)
            {
                log.Error($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} does not have a concept code populated in F0101.ABAC08");
                using (new CenterDialog(this))
                {
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} does not have a concept code populated in the Address Book.\r\nPlease fix this in the spreadsheet or JDE before continuing.", "Data Error", buttons);
                }
                result = false;
            }
            else
            {
                log.Debug($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} has a concept.");
                result = true;
            }
            return(result);
        } // ConceptCodeExists
Пример #10
0
        } // FollowMissingShipToPath

        /// <summary>
        /// The control flow for loading a rollout spreadsheet.
        /// </summary>
        private void LoadRolloutFlow()
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config"));
            this.dgv_DataDisplay.DataSource = null;
            MissingShipToCSV = null; // make sure to clear this out each time we load a spreadsheet
            // 1.) Get the file 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 \t as a delimiter");
                    conceptCSV = new ConceptCSV(FileToLoad, "\t");
                    using (LoadingForm frm = new LoadingForm())
                    {
                        frm.AddText("Loading Concept Spreadsheet.");
                        frm.Visible = true;
                        conceptCSV.ReadConcept();
                        // 3.) Validate the required columns exist in the spreadsheet
                        log.Debug($"Attempting to validate all required columns exist in the file.");
                        frm.AddText("Validating Concept Required Columns Exist.");
                        if (!ValidateConceptHeader(ref conceptCSV))
                        {
                            return;
                        }
                        // 4a.) Validate the data in the rows match the column requirements
                        log.Debug("Validating all row data in all required columns.");
                        frm.AddText("Validating data in concept spreadsheet.");
                        if (!ValidateConceptRows(ref conceptCSV))
                        {
                            return;
                        }
                        // 4b.) Validate the Shipping Vendor
                        log.Debug("Validating the shipping vendor is V or V3.");
                        frm.AddText("Validating the shipping vendor is a vendor in JDE.");
                        if (!CheckShippingVendor(conceptCSV))
                        {
                            return;
                        }
                        // 4c.) Validate the concept ID exists for the Customer C3 Record
                        log.Debug("Validating the Customer Number has a concept in ABAC08.");
                        frm.AddText("Validating the Customer Number has a concept code.");
                        if (!ConceptCodeExists(conceptCSV))
                        {
                            return;
                        }
                        // 5.) Verify the ship to addresses exist
                        log.Debug("Verify all Ship To addresses exist");
                        frm.AddText("Checking for missing ship to addresses in JDE.");
                        List <string> MissingShipTo = conceptCSV.CheckForMissingShipToAddresses();
                        if (0 < MissingShipTo.Count)
                        {
                            // 6a.) We found new ship to addresses, so start down that path
                            log.Debug("There are Ship To addresses that are missing.  Should we add them?");
                            frm.AddText("Found missing ship to addresses.");
                            FollowMissingShipToPath(MissingShipTo, conceptCSV, frm);
                            frm.Visible = false;
                        }
                        else
                        {
                            // 6b.) All ship to addresses exist.  So, verify the item numbers are valid
                            log.Debug("Verify all items exist in JDE.");
                            frm.AddText("No missing ship to addresses.");
                            frm.AddText("Checking for missing item numbers.");
                            List <string> MissingItems = conceptCSV.CheckForMissingItemNumbers();
                            if (0 < MissingItems.Count)
                            {
                                log.Debug("There are item numbers that don't exist in JDE.");
                                using (new CenterDialog(this))
                                {
                                    MessageBox.Show($"The following part numbers don't exist in JDE.  Please change them or add them to the 3SUW branch plant: {String.Join(",", MissingItems)}",
                                                    "Data Error!!",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                                }
                                frm.Close();
                                return;
                            }
                            else
                            {
                                log.Debug("All items exist in JDE");
                                frm.AddText("All items exist in JDE.");
                                using (new CenterDialog(this))
                                {
                                    DialogResult result = MessageBox.Show($"All {conceptCSV.DT.Rows.Count} rows of data are valid in JDE.\r\nLoad the EDI Data into JDE?\r\nSelect No to preview the detail data before load.",
                                                                          "Load EDI Data?",
                                                                          MessageBoxButtons.YesNoCancel,
                                                                          MessageBoxIcon.Information);
                                    if (DialogResult.Cancel == result)
                                    {
                                        return;
                                    }

                                    // 7.) Save the data into a concept & save that to JDE
                                    log.Debug($"Tranform the conceptCSV into a concept");
                                    frm.AddText("Transforming the spreadsheet into a concept object.");
                                    Concept concept = XfrmConcept.CSVtoConcept(conceptCSV);
                                    if (DialogResult.Yes == result)
                                    {
                                        log.Debug($"Populating header file F47011 with data");
                                        frm.AddText("Populating the EDI header file with concept data.");
                                        JDE.PopulateF47011(concept);
                                        log.Debug($"Populating detail file F47012 with data");
                                        frm.AddText("Populating the EDI detail file with concept data & freight lines.");
                                        JDE.PopulateF47012(concept);
                                        frm.AddText("Success!");
                                        // 8.) Prompt the user to go to JDE
                                        log.Debug($"Successfully processed the EDI information into F47011 and F47012");
                                        MessageBox.Show("The concept was successfully loaded into JDE.\r\nPlease go to JDE, review the data, and run the Rollout Order Import report.",
                                                        "Success!",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Information);
                                        frm.Close();
                                    }
                                    else if (DialogResult.No == result)
                                    {
                                        frm.AddText("Success!");
                                        frm.Close();
                                        this.dgv_DataDisplay.DataSource = concept.OrderDetails;
                                    }
                                }
                            }
                        }
                    }
                }
                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);
                    }
                }
            }
        } // LoadRolloutFlow