Beispiel #1
0
 private void DoWorkXlsx(object sender, DoWorkEventArgs e)
 {
     if (!xlsxParseWorker.CancellationPending)
     {
         List <Assembly> keys = map.Keys.Select(item => item).ToList();
         foreach (Assembly dll in keys)
         {
             ListViewItem[] xlsxes = map[dll];
             if (dllToData.TryAdd(dll, new List <DataTable>()))
             {
                 ParallelLoopResult result = Parallel.ForEach(xlsxes, (currentXlsx) =>
                 {
                     dllToData[dll].Add(XlsxParser.getInstance().READExcel(currentXlsx.Text));
                     string logmsg = String.Format("Парсинг файла {0} завершён", currentXlsx.Text);
                     log.Info(logmsg);
                     this.xlsxParseWorker.ReportProgress(0, logmsg);
                 });
             }
             else
             {
                 log.Error("Ошибка добавления сборки в конкуретный словарь");
             }
         }
     }
 }
Beispiel #2
0
        public void onShown(object sender, EventArgs e)
        {
            //Парсинг xlsx'ов

            this.currentCreatedTest.Text = Convert.ToString(0);
            XlsxParser parser = XlsxParser.getInstance();

            //parser.countTotalRows(this.map);
            parser.skip();

            log.Info("Парсим вспомогательные xlsx файлы(contacts, beneficiars,logins)");
            contacts    = parser.parseHelperFile(".\\config\\", "config_contact*.xlsx");
            beneficiars = parser.parseHelperFile(".\\config\\", "config_beneficiar*.xlsx");
            logins      = parser.parseHelperFile(".\\config\\", "config_login*.xlsx");


            xlsxParseWorker                            = new AbortableWorker();
            xlsxParseWorker.DoWork                    += DoWorkXlsx;
            xlsxParseWorker.ProgressChanged           += ProgressChangedXlsx;
            xlsxParseWorker.RunWorkerCompleted        += WorkerCompletedXlsx;
            xlsxParseWorker.WorkerReportsProgress      = true;
            xlsxParseWorker.WorkerSupportsCancellation = true;

            this.dataFinished += new DataFinishedEvent(this.OnDataFinished);
            xlsxParseWorker.RunWorkerAsync();
        }
Beispiel #3
0
 public static XlsxParser getInstance()
 {
     if (instance == null)
     {
         instance = new XlsxParser();
     }
     return(instance);
 }