コード例 #1
0
        public void DoCompare(string file1, string file2)
        {
            string tempFilePath1 = null;
            string tempFilePath2 = null;

            tempFilePath1 = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\Data\temp1.xml";
            tempFilePath2 = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\Data\temp2.xml";


            DataGridViewCompare.ItemsSource = null;
            DataGridViewCompare.Columns.Clear();
            try
            {
                XmlComparissonData compareData = new XmlComparissonData();

                StreamReader str  = new StreamReader(file1);
                StreamReader str2 = new StreamReader(file2);

                //TODO: If checkbox is checked, we need to remove the 'revised' elements and replace with the originals. perhaps do a search of all elements with a -X?
                //TODO: If checked, we should load a file into memory, revise necessary nodes, ala XMLTest1Replace Functions, and push the resulting string to the streamreader
                //TODO: Perhaps add logic to only look for 1 or 2 character revision.
                if (FileOneRevisionCB.IsChecked ?? false)
                {
                    str.Close();
                    XMLTest1Replace fieldReplacer   = new XMLTest1Replace();
                    Regex           BeforeDash      = new Regex(".*(?=\\-)");
                    Regex           AfterDash       = new Regex("(\\d+)[^-]*$");
                    string          NewMasterBill   = null;
                    string          NewMasterBillWM = null;
                    string          NewCommInv      = null;

                    XMLTest1Replace matchEntry = new XMLTest1Replace();

                    XmlDocument doc = new XmlDocument();
                    doc.Load(file1);

                    XmlNamespaceManager namespaces = new XmlNamespaceManager(doc.NameTable);
                    namespaces.AddNamespace("dft", "http://www.kewill.com/Customs/edi");

                    XmlNodeList WorkMgmtNode = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:DASHBOARD_WORK_MGMT", namespaces);
                    foreach (XmlNode node in WorkMgmtNode)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            NewMasterBillWM = node["MASTER_BILL"].InnerText;
                        }
                    }

                    XmlNodeList GeneralShipmentInformation = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:EDI_SHIPMENT_HEADER", namespaces);
                    foreach (XmlNode node in GeneralShipmentInformation)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            NewMasterBill = node["MASTER_BILL"].InnerText;
                        }
                    }

                    String NewMasterBill2   = BeforeDash.Match(NewMasterBill).ToString();
                    String NewMasterBillWM2 = BeforeDash.Match(NewMasterBillWM).ToString();

                    XmlNodeList elemList = doc.GetElementsByTagName("MASTER_BILL");
                    for (int i = 0; i < elemList.Count; i++)
                    {
                        elemList[i].InnerText = NewMasterBill2;
                    }

                    XmlNodeList WorkMgmtNode2 = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:DASHBOARD_WORK_MGMT", namespaces);
                    foreach (XmlNode node in WorkMgmtNode2)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            node["MASTER_BILL"].InnerText = NewMasterBillWM2;
                        }
                    }

                    XmlNodeList commInv = doc.SelectNodes("/dft:SHIPMENT//dft:COMM_INV_NO", namespaces);
                    foreach (XmlNode node in commInv)
                    {
                        if (node.InnerText != null)
                        {
                            NewCommInv = node.InnerText;
                        }
                        NewCommInv = BeforeDash.Match(NewCommInv).ToString();
                        if (node.InnerText != null)
                        {
                            node.InnerText = NewCommInv;
                        }
                    }

                    //TODO: Add Master_bill_addl

                    doc.Save(tempFilePath1);
                    //TODO: make this store in temp location and delete
                    str = new StreamReader(tempFilePath1);
                }

                if (FileTwoRevisionCB.IsChecked ?? false)
                {
                    str2.Close();
                    XMLTest1Replace fieldReplacer   = new XMLTest1Replace();
                    Regex           BeforeDash      = new Regex(".*(?=\\-)");
                    Regex           AfterDash       = new Regex("(\\d+)[^-]*$");
                    string          NewMasterBill   = null;
                    string          NewMasterBillWM = null;
                    string          NewCommInv      = null;

                    XMLTest1Replace matchEntry = new XMLTest1Replace();

                    XmlDocument doc = new XmlDocument();
                    doc.Load(file2);

                    XmlNamespaceManager namespaces = new XmlNamespaceManager(doc.NameTable);
                    namespaces.AddNamespace("dft", "http://www.kewill.com/Customs/edi");

                    XmlNodeList WorkMgmtNode = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:DASHBOARD_WORK_MGMT", namespaces);
                    foreach (XmlNode node in WorkMgmtNode)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            NewMasterBillWM = node["MASTER_BILL"].InnerText;
                        }
                    }

                    XmlNodeList GeneralShipmentInformation = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:EDI_SHIPMENT_HEADER", namespaces);
                    foreach (XmlNode node in GeneralShipmentInformation)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            NewMasterBill = node["MASTER_BILL"].InnerText;
                        }
                    }

                    String NewMasterBill2   = BeforeDash.Match(NewMasterBill).ToString();
                    String NewMasterBillWM2 = BeforeDash.Match(NewMasterBillWM).ToString();

                    XmlNodeList elemList = doc.GetElementsByTagName("MASTER_BILL");
                    for (int i = 0; i < elemList.Count; i++)
                    {
                        elemList[i].InnerText = NewMasterBill2;
                    }

                    XmlNodeList WorkMgmtNode2 = doc.SelectNodes("/dft:SHIPMENT/dft:SHIPMENT_MAIN/dft:DASHBOARD_WORK_MGMT", namespaces);
                    foreach (XmlNode node in WorkMgmtNode2)
                    {
                        if (node["MASTER_BILL"] != null)
                        {
                            node["MASTER_BILL"].InnerText = NewMasterBillWM2;
                        }
                    }

                    XmlNodeList commInv = doc.SelectNodes("/dft:SHIPMENT//dft:COMM_INV_NO", namespaces);
                    foreach (XmlNode node in commInv)
                    {
                        if (node.InnerText != null)
                        {
                            NewCommInv = node.InnerText;
                        }
                        NewCommInv = BeforeDash.Match(NewCommInv).ToString();
                        if (node.InnerText != null)
                        {
                            node.InnerText = NewCommInv;
                        }
                    }

                    //TODO: Add Master_bill_addl

                    doc.Save(tempFilePath2);
                    //TODO: make this store in temp location and delete
                    str2 = new StreamReader(tempFilePath2);
                }

                XmlSerializer xSerializer = new XmlSerializer(typeof(Shipment));

                Shipment shipmentOne = (Shipment)xSerializer.Deserialize(str);
                Shipment shipmentTwo = (Shipment)xSerializer.Deserialize(str2);

                ComparisonConfig config = new ComparisonConfig();
                config.MembersToIgnore.Add("Length");
                config.MembersToIgnore.Add("LongLength");

                //TODO: add this as a user defineable exclusion
                config.MembersToIgnore.Add("MatchEntry");
                config.MembersToIgnore.Add("SubSubBill");
                config.MembersToIgnore.Add("MatchShipment");

                //TODO: REMOVE THIS!!!!
                config.MembersToIgnore.Add("MasterBill");

                config.MaxDifferences        = 9999;
                config.IgnoreCollectionOrder = true;

                var spec = new Dictionary <Type, IEnumerable <string> >();
                //TODO : Add a spec for each main element that have the potential of multiple instances within the file
                spec.Add(typeof(ShipmentHeaderFlex), new string[] { "MasterBill", "HouseBill", "SubBill", "SubSubBill" });
                spec.Add(typeof(ShipmentId), new string[] { "MasterBill", "HouseBill", "SubBill", "SubSubBill", "SeqNo" });
                spec.Add(typeof(ShipmentDate), new string[] { "MasterBill", "HouseBill", "SubBill", "SubSubBill", "TracingDateNo" });
                spec.Add(typeof(InvoiceHeader), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice" });
                spec.Add(typeof(InvoiceHeaderFlex), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice" });
                spec.Add(typeof(InvoiceAddresses), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "PartiesQualifier" });
                spec.Add(typeof(InvoiceLine), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo" });
                spec.Add(typeof(InvoiceParty), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "PartiesQualifier" });
                spec.Add(typeof(InvoiceLineFlex), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo" });
                spec.Add(typeof(InvoiceLineTariffClass), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffNo", "TariffLineNo" });

                spec.Add(typeof(PgEs), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr" });

                spec.Add(typeof(PgEpaEs), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr" });
                spec.Add(typeof(PgEpaEsParties), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "PartySeqNbr" });
                spec.Add(typeof(PgEpaEsProdComp), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "ComponentSeqNbr" });
                spec.Add(typeof(PgEpaEsAddlItemId), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "ItemSeqNbr" });
                spec.Add(typeof(PgEpaEsRemarks), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "RemarksSeqNbr" });

                spec.Add(typeof(PgFdaEs), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr" });
                spec.Add(typeof(PgFdaEsParties), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "PartySeqNbr" });
                spec.Add(typeof(PgFdaEsCountries), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "CountrySeqNbr" });
                spec.Add(typeof(PgFdaEsContainers), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "ContainerNo" });
                spec.Add(typeof(PgFdaEsCompliance), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "ComplianceSeqNbr" });
                spec.Add(typeof(PgFdaEsIngredients), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "IngredientSeqNbr" });
                spec.Add(typeof(PgFdaEsRemarks), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "RemarksSeqNbr" });
                spec.Add(typeof(PgFdaEsAddlLots), new string[] { "ManufacturerId", "CommInvNo", "DateInvoice", "CommInvLineNo", "TariffLineNo", "PgCd", "PgSeqNbr", "LotSeqNbr" });

                config.CollectionMatchingSpec = spec;

                CompareLogic compareLogic = new CompareLogic(config);

                ComparisonResult result = compareLogic.Compare(shipmentOne, shipmentTwo);

                Regex r = new Regex("(?<=\\.)[^.]*$");

                //ISSUES: Doesnt show if an additional item exists, such as a 2nd invoice header. Shows count and legnth differences.
                //ISSUES: Figure out a better way to display the differneces in added/removed elements like EDI_INVOICE_HEADER
                //          - Perhaps add functionality to equalize like nodes, such as revisions with an appended -X in certain elements. (MasterBill, CommInvNo, MasterBillAddl)
                //          - Maybe a checkbox to mark for comparing revisions?

                if (result.AreEqual)
                {
                    System.Windows.MessageBox.Show("These Files are identical.");
                }

                foreach (var diff in result.Differences)
                {
                    if (diff.Object1Value.ToString() == "(null)")
                    {
                        SingleDifferenceData diffData = new SingleDifferenceData();
                        diffData.AlterationType = "ADDED";
                        diffData.NodeName       = r.Match(diff.PropertyName).ToString();
                        diffData.ParentNodeName = r.Match(diff.ParentPropertyName).ToString();
                        if (diff.Object1Value == "USeTeamDesktopTool.Data_Classes.InvoiceHeader")
                        {
                            diffData.InitialValue = "VIEW XML";
                        }
                        else
                        {
                            diffData.InitialValue = diff.Object1Value;
                        }

                        if (diff.Object2Value == "USeTeamDesktopTool.Data_Classes.InvoiceHeader")
                        {
                            diffData.FinalValue = "VIEW XML";
                        }
                        else
                        {
                            diffData.FinalValue = diff.Object2Value;
                        }
                        diffData.OriginalDocPath = diff.ParentPropertyName;
                        compareData.AllFileDifferencesList.Add(diffData);
                    }
                    else if (diff.Object2Value.ToString() == "(null)")
                    {
                        SingleDifferenceData diffData = new SingleDifferenceData();
                        diffData.AlterationType = "REMOVED";
                        diffData.NodeName       = r.Match(diff.PropertyName).ToString();
                        diffData.ParentNodeName = r.Match(diff.ParentPropertyName).ToString();
                        if (diff.Object1Value == "USeTeamDesktopTool.Data_Classes.InvoiceHeader")
                        {
                            diffData.InitialValue = "VIEW XML";
                        }
                        else
                        {
                            diffData.InitialValue = diff.Object1Value;
                        }

                        if (diff.Object2Value == "USeTeamDesktopTool.Data_Classes.InvoiceHeader")
                        {
                            diffData.FinalValue = "VIEW XML";
                        }
                        else
                        {
                            diffData.FinalValue = diff.Object2Value;
                        }

                        diffData.OriginalDocPath = diff.ParentPropertyName;
                        compareData.AllFileDifferencesList.Add(diffData);
                    }
                    else if (diff.Object1Value != diff.Object2Value)
                    {
                        SingleDifferenceData diffData = new SingleDifferenceData();
                        diffData.AlterationType  = "CHANGED";
                        diffData.NodeName        = r.Match(diff.PropertyName).ToString();
                        diffData.ParentNodeName  = r.Match(diff.ParentPropertyName).ToString();
                        diffData.InitialValue    = diff.Object1Value;
                        diffData.FinalValue      = diff.Object2Value;
                        diffData.OriginalDocPath = diff.ParentPropertyName;
                        compareData.AllFileDifferencesList.Add(diffData);
                    }
                }

                DataTable table = new DataTable();
                table = ToDataTable <SingleDifferenceData>(compareData.AllFileDifferencesList);
                DataGridViewCompare.ItemsSource = compareData.AllFileDifferencesList;

                //STEP 2 : Use Parsed Path to gather nodes and paths from the initial document.
                //STEP 3 : If needed, used Parsed Path to gather data from the second comparison document.
                //STEP 4 : Build method to consolidate and display the changes only. Using the .out file, we should be able to go back through the two
                //         documents and get the node name and possibly display it as follows
                //
                //           DIFF_TYPE | PATH                                        | NODE_NAME  | INITIAL_VALUE | FINAL_VALUE
                //           --------------------------------------------------------------------------------------------------
                //           CHANGE    | SHIPMENT/SHIPMENT_MAIN/DASHBOARD_WORK_MGMT/ | PROCESS_CD | U             | P
                //
                str.Close();
                str2.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: '{0}'", e);
                System.Windows.MessageBox.Show("An error occured. Contact the correct handsome edi guy.");
            }

            if (File.Exists(tempFilePath1))
            {
                File.Delete(tempFilePath1);
            }
            if (File.Exists(tempFilePath2))
            {
                File.Delete(tempFilePath2);
            }
        }
コード例 #2
0
        //TODO: Need to redo these below sections. We should now do the following :
        //              -   Need to access a file on a network drive. If file is locked, enter a loop that checks to see if unlocked every few seconds.
        //              -   When opened, lock file so other users cannot access
        //              -   load and update the file.
        //              -   save and close, unlocking the file
        private void GenerateNewXmlDataBTN_Click(object sender, RoutedEventArgs e)
        {
            NewMatchEntryTB.Text    = "";
            NewSubSubBillTB.Text    = "";
            NewMasterBillDBTB.Text  = "";
            NewMasterBillEETB.Text  = "";
            NewHouseBillTB.Text     = "";
            NewMatchShipmentTB.Text = "";

            AppData appData = new AppData();

            //TODO : Change to server address
            appDataFileLocation = @"\\pdc-evs-file\US_Common\US_Brokerage\EDI\USeTeamDesktopTool\Data\AppData.json";

            if (WaitForFile(appDataFileLocation) == true)
            {
                using (FileStream fs = new FileStream(appDataFileLocation, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        appData = (AppData)serializer.Deserialize(sr, typeof(AppData));

                        string fmt          = "00000";
                        string recentMatch  = appData.MatchEntry;
                        string resultString = Regex.Match(recentMatch, @"\d+").Value;
                        int    currentNo    = Int32.Parse(resultString);
                        currentNo += 1;

                        string finalNo         = currentNo.ToString(fmt);
                        string generateMatchNo = String.Format("AB" + finalNo);

                        //FORMAT "ABXXXXX"
                        NewMatchEntryTB.Text = generateMatchNo;
                        NewSubSubBillTB.Text = generateMatchNo;

                        //FORMAT "ABTESTXXXXX"
                        string generateMB = String.Format("ABTEST" + finalNo);
                        NewMasterBillDBTB.Text = generateMB;
                        NewMasterBillEETB.Text = "RDWY";

                        //FORMAT "ABXXX-XX"
                        string generateHBMS = String.Format("AB000-" + currentNo);
                        NewHouseBillTB.Text     = generateHBMS;
                        NewMatchShipmentTB.Text = generateHBMS;

                        //FORMAT "ABTEST-XX"
                        recentMatch = appData.CommInvNo;
                        string resultStringInv = Regex.Match(recentMatch, @"\d+").Value;
                        int    currentNoInv    = Int32.Parse(resultStringInv);
                        //currentNoInv += 1;

                        if (invCount > 1)
                        {
                            string generateCI = String.Format("ABTESTING-" + currentNoInv);
                            NewCommInvNoTB.Text = generateCI;
                            int    finalInvNo  = currentNoInv + invCount - 1;
                            string generateCI2 = String.Format("ABTESTING-" + finalInvNo);
                            NewCommInvNoTB2.Text = generateCI2;
                        }
                        else
                        {
                            string generateCI = String.Format("ABTESTING-" + currentNoInv);
                            NewCommInvNoTB.Text = generateCI;
                        }
                        NewClientNoTB.Text  = clientNo;
                        NewProcessCDTB.Text = processCD;


                        //private void DropFileToTest1BTN_Click(object sender, RoutedEventArgs e)
                        //{
                        //TODO: Add replace logic
                        string          fileLoc    = FilePathTB.Text;
                        XMLTest1Replace matchEntry = new XMLTest1Replace();

                        XmlDocument doc = new XmlDocument();
                        doc.Load(fileLoc);

                        string matchEntryNew    = NewMatchEntryTB.Text;
                        string masterBillWMNew  = NewMasterBillDBTB.Text;
                        string masterBillEENew  = NewMasterBillEETB.Text;
                        string houseBillNew     = NewHouseBillTB.Text;
                        string matchShipmentNew = NewMatchShipmentTB.Text;
                        string subSubBillnew    = NewSubSubBillTB.Text;
                        string entryNoNew       = NewEntryNoTB.Text;
                        string commInvNoNew     = NewCommInvNoTB.Text;
                        string commInvNoNew2    = NewCommInvNoTB2.Text;
                        string clientNo2        = NewClientNoTB.Text;
                        string processCD2       = NewProcessCDTB.Text;

                        //matchEntry.xmlNodeParse(doc, "CUST_NO", clientNo2);
                        matchEntry.xmlNodeParse(doc, "PROCESS_CD", processCD2);
                        matchEntry.xmlNodeParse(doc, "MATCH_ENTRY", matchEntryNew);
                        matchEntry.xmlNodeParse(doc, "MASTER_BILL", masterBillEENew);
                        matchEntry.xmlNodeParse(doc, "MASTER_BILL_ADDL", masterBillWMNew);
                        matchEntry.xmlNodeParseMBWM(doc, masterBillWMNew);
                        matchEntry.xmlNodeParse(doc, "HOUSE_BILL", houseBillNew);
                        matchEntry.xmlNodeParse(doc, "MATCH_SHIPMENT", matchShipmentNew);
                        matchEntry.xmlNodeParse(doc, "SUB_SUB_BILL", subSubBillnew);
                        matchEntry.xmlNodeParseEntryNo(doc);

                        foreach (string invText in eachInvoice)
                        {
                            matchEntry.xmlNodeParseCommInv(doc, invText, commInvNoNew);

                            string recentMatch2  = commInvNoNew;
                            string resultString2 = Regex.Match(recentMatch2, @"\d+").Value;
                            int    currentNo2    = Int32.Parse(resultString2);
                            currentNo2 = currentNo2 + 1;

                            commInvNoNew = String.Format("ABTESTING-" + currentNo2);
                        }

                        SaveFileDialog saveFileDialog1 = new SaveFileDialog
                        {
                            Title            = "Save XML Files",
                            CheckFileExists  = false,
                            CheckPathExists  = true,
                            DefaultExt       = ".xml",
                            Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*",
                            FilterIndex      = 1,
                            RestoreDirectory = true,
                            FileName         = NewMatchEntryTB.Text,
                            InitialDirectory = @"\\mdcdvbz500\HF\INBOUND"
                        };

                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            //TODO: ADD CHECKS TO ENSURE JSON FORMAT
                            string FILE = saveFileDialog1.FileName;
                            doc.Save(FILE);

                            //string json = File.ReadAllText(appDataFileLocation);
                            //dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
                            //jsonObj["LastUpdated"] = System.DateTime.Now;
                            //jsonObj["MatchEntry"] = matchEntryNew;
                            //jsonObj["MasterBillEE"] = masterBillEENew;
                            //jsonObj["MatchShipment"] = matchShipmentNew;

                            appData.LastUpdated   = System.DateTime.Now;
                            appData.MatchEntry    = matchEntryNew;
                            appData.MasterBillEE  = masterBillEENew;
                            appData.MatchShipment = matchShipmentNew;

                            if (invCount > 1)
                            {
                                //jsonObj["CommInvNo"] = commInvNoNew2;
                                appData.CommInvNo = commInvNoNew2;
                            }
                            else
                            {
                                //jsonObj["CommInvNo"] = commInvNoNew;
                                appData.CommInvNo = commInvNoNew;
                            }

                            //string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
                            //File.WriteAllText(appDataFileLocation, output);
                            string eventDescription = "New File was created and dropped to test 1 with MatchEntry of " + matchEntryNew + ".";
                            eventLogger.RecordEvent(appLogFileLocation, eventDescription, DateTime.Now, "Test1FileCreation");

                            sr.Close();
                        }
                    }

                    fs.Close();
                }

                File.SetAttributes(appDataFileLocation, FileAttributes.Normal);

                if (WaitForFile(appDataFileLocation) == true)
                {
                    using (StreamWriter sw = File.CreateText(appDataFileLocation))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(sw, appData);
                        sw.Close();
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("The log file used to obtain the correct key elements is in use by another user. Please try again shortly. If this issues continues, please contact Anthony.");
                }

                File.SetAttributes(appDataFileLocation, FileAttributes.Normal);
            }
            else
            {
                //TODO: Add logic to see which folder was not accesible.
                System.Windows.MessageBox.Show("The log file used to obtain the correct key elements is in use by another user. Please try again shortly. If this issues continues, please contact Anthony.");
            }
            //}
        }