Esempio n. 1
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();
 }
Esempio n. 2
0
        public void parseCell(Range cell, int row, int column, ref int totalRows2, ref int totalColumns2, ref excelSection template3, ref sort sort3, ref countParts countParts2)
        {
            /////////////////////// find and parse tag //////////////////////////
            string tag = parseTag(cell[1, 1]);

            switch (tag)
            {
            case "TextHere":
            {
                populateTitleBlockCell(cell[1, 1], ref template3); cell[1, 1].Value = "";
                break;
            }

            case "HeaderHere":
            {
                populateHeaderList(cell[1, 1], ref template3); cell[1, 1].Value = "";
                break;
            }

            case "BodyHere":
            {
                populateBodySectionCell(cell[1, 1], ref template3);  cell[1, 1].Value = "";
                break;
            }

            case "Sort":
            {
                parseSort(cell[1, 1], ref sort3); cell[1, 1].Value = "";
                break;
            }

            case "Footer":
            {
                getFooterInfo(cell[1, 1], ref template3.footerColor, ref template3.footerList); cell[1, 1].Interior.Color = 16777215; cell[1, 1].Value = "";
                break;
            }

            case "Group":
            {
                getQuantityGrouping(column, ref countParts2.groupedColumns); cell[1, 1].Value = "";
                break;
            }

            case "Quantity":
            {
                getQuantityColumn(column, ref countParts2.quantityColumn); cell[1, 1].Value = "";
                break;
            }

            case "EndRow":
            {
                totalRows2 = row; cell[1, 1].Value = "";         // change loop iterator limit variable for rows if EndRow tag is found
                break;
            }

            case "EndColumn":
            {
                totalColumns2 = column; cell[1, 1] = "";         // change loop iterator limit variable for columns if EndColumn tag is found
                break;
            }
            }
        }
Esempio n. 3
0
        public void start(mainFrame mainFrame1, sort sort1, List <List <string> > unsorted, List <string> headers, List <int> headerIndex, countParts countParts1)
        {
            sortTheSortList();
            sorted = new List <List <string> >();
            sorted.Add(unsorted[0]);
            bool insertHere = false;

            for (int a = 1; a < unsorted.Count; a++)
            {
                for (int b = 0; b < sorted.Count; b++)
                {
                    insertHere = getSort(sort1, unsorted[a], sorted[b]);
                    if (insertHere)
                    {
                        insertRow(unsorted[a], b, ref sorted); break;
                    }
                    //else sorted.Add(unsorted[a]);
                }
                if (!insertHere)
                {
                    sorted.Add(unsorted[a]);
                }
            }
            mainFrame1.writeToConsole("finished sorting components.");
            countParts1.updateQuantity(countParts1.quantityColumn, countParts1.groupedColumns, headerIndex[0], ref sorted);
            mainFrame1.writeToConsole("finished updating quantities.");
        }
Esempio n. 4
0
        private void readTemplateFile(ref Worksheet xlWorkSheet1, int totalRows1, int totalColumns1, ref excelSection template2, ref sort sort2, ref countParts countParts2, mainFrame mainFrame2)
        {
            excelFileParser excelFileParser1 = new excelFileParser();
            excelFileParser bodyRows         = new excelFileParser();


            for (int row = 1; row < totalRows1; row++)
            {
                if (mainFrame.end)
                {
                    throw new Exception("User is closing the program");
                }
                for (int column = 1; column < totalColumns1; column++)
                {
                    excelFileParser1.parseCell(xlWorkSheet.Cells[row, column], row, column, ref totalRows1, ref totalColumns1, ref template2, ref sort2, ref countParts2);
                }
                mainFrame2.writeToConsole("Row " + row + " finished.");
            }
            mainFrame2.writeToConsole("Finished reading template file.");
        }
Esempio n. 5
0
 public void run(ref excelSection template1, ref sort sort1, ref countParts countparts1)
 {
     openTemplateFile(ref xlApp, ref xlWorkBooks, ref xlWorkBook, ref xlWorkSheet);
     readTemplateFile(ref xlWorkSheet, totalRows, totalColumns, ref template1, ref sort1, ref countparts1, mainFrame1);
 }