Beispiel #1
0
        internal void worker_DoworkConvertFile(object sender, DoWorkEventArgs e)
        {
            var i           = (ErrTriger)P2.Resources["ErrTriger"];
            var convertfull = new Convettxt();

            P2.Status.Dispatcher.Invoke(() => P2.Status.Content = @"Проверяем параметры!!!");
            if (!Err.FileAddError(P2.ListFile) || !Err.FileError(P2.ListFile.Dispatcher.Invoke(() => P2.ListFile.SelectedItems.Count), i) || !Err.FileScalarError(P2.Scalare))
            {
                Worker.CancelAsync();
            }
            else
            {
                using (var excelPackage = new ExcelPackage(new FileInfo(PathOtchet.Configuration.PathOtchet + GenereteName.GenerateName.Generatenamedowhile())))
                {
                    var proc = (100.0f / P2.ListFile.Dispatcher.Invoke(() => P2.ListFile.SelectedItems.Count));
                    P2.Status.Dispatcher.Invoke(() => P2.Status.Content = @"Конвертируем!!!");
                    if (P2.Scalare.Dispatcher.Invoke(() => P2.Scalare.Text != ""))
                    {
                        foreach (ZnachView item in P2.ListFile.Dispatcher.Invoke(() => P2.ListFile.SelectedItems))
                        {
                            Worker.ReportProgress((int)(proc * 100.0f));
                            convertfull.ConvtxtScalar(item, excelPackage, P2.Scalare.Dispatcher.Invoke(() => P2.Scalare.Text));
                        }
                    }
                    else
                    {
                        foreach (ZnachView item in P2.ListFile.Dispatcher.Invoke(() => P2.ListFile.SelectedItems))
                        {
                            Worker.ReportProgress((int)(proc * 100.0f));
                            convertfull.ConvtxtFull(item, excelPackage);
                        }
                    }
                    excelPackage.Save();
                    excelPackage.Dispose();
                    LoadPathExcel();
                }
            }
        }