Esempio n. 1
0
        public EBOMexcelFile(excelFileHandler excelFileHandler2, List <List <string> > componentList, excelSection template, string fileName, mainFrame mainFrame1, int xmlPartCount, List <string> titleBlockInfo)
        {
            populateTitleBlock(excelFileHandler2.xlWorkSheet, titleBlockInfo, template.TBrowIndex, template.TBcolumnIndex); mainFrame1.writeToConsole("Finished writing title block.");
            populateHeaderRow(excelFileHandler2.xlWorkSheet, template.Htext, template.HrowIndex, template.HcolumnIndex); mainFrame1.writeToConsole("Finished writing header row.");
            int finalCount = populateBody(excelFileHandler2.xlWorkSheet, componentList, template, mainFrame1); mainFrame1.writeToConsole("Finished writing body.");

            mainFrame1.missingParts(compareComponentCounts(xmlPartCount, finalCount));
            createFooter(excelFileHandler2.xlWorkSheet, componentList.Count + template.rowIndex[0][0], template.footerColor, template.footerList); mainFrame1.writeToConsole("Finished writing footer.");
            if (!saveExcelFile(excelFileHandler2.xlWorkSheet, fileName))
            {
                excelFileHandler2.xlWorkBook.Close(SaveChanges: false);
            }
            mainFrame1.writeToConsole("Saved new EBOM file.");
        }
Esempio n. 2
0
 public void start() // main order of the program.
 {
     runParser = new Thread(delegate()
     {
         try
         {
             try
             {
                 excelSection template  = new excelSection(); //initiating necessary objects
                 sort sort1             = new sort();
                 countParts countParts1 = new countParts();
                 excelFileHandler1      = new excelFileHandler(this);
                 excelFileHandler1.run(ref template, ref sort1, ref countParts1);                                                                                                                                   // read template excel file
                 xmlFileHandler xmlFileHandler1 = new xmlFileHandler(this, template, filename);                                                                                                                     // read source xml file
                 sort1.start(this, sort1, xmlFileHandler1.componentAttributes, template.Htext, template.HcolumnIndex, countParts1);                                                                                 // sort xml file info
                 EBOMexcelFile eBOMexcelFile1 = new EBOMexcelFile(excelFileHandler1, sort1.sorted, template, xmlFileHandler1.exportFileName, this, xmlFileHandler1.totalPartCount, xmlFileHandler1.titleBlockInfo); // create new EBOM from xml file using template file info
                 writeToConsole("Complete");
                 mainFrameScreen1.enableStartButton(true);
                 mainFrameScreen1.enableSourceButton(true);
             }
             catch (Exception e)
             {
                 MessageBox.Show(e.ToString());
             }
             finally
             {
                 try
                 {
                     Marshal.FinalReleaseComObject(excelFileHandler1.xlWorkSheet);
                     //template.xlWorkBook.Close(false, misValue, misValue);
                     excelFileHandler1.xlWorkBook.Close(SaveChanges: false);
                     //template.xlWorkBook.Close();
                     Marshal.FinalReleaseComObject(excelFileHandler1.xlWorkBook);
                     excelFileHandler1.xlWorkBooks.Close();
                     Marshal.FinalReleaseComObject(excelFileHandler1.xlWorkBooks);
                     excelFileHandler1.xlApp.Quit();
                     Marshal.FinalReleaseComObject(excelFileHandler1.xlApp); // excel objects don't releast comObjects to excel so you have to force it
                 }
                 catch {}
             }
         }
         finally
         {
             GC.Collect();
             GC.WaitForPendingFinalizers();
         }
     });
     runParser.Name = "CreateEBOM";
     runParser.Start();
 }