コード例 #1
0
        private void StartWorker(Accoreconsole console)
        {
            Init();

            if (!_worker.IsBusy)
            {
                _watch.Start();
                this._worker.RunWorkerAsync(console);
            }
        }
 private void accToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(this._fileName))
     {
         Accoreconsole console = new Accoreconsole();
         StartWorker(console);
     }
     else
     {
         MessageBox.Show("Invalid file name !!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void mergePDFsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string outPdfFileName = "MergedPdf.pdf";
            string error          = "";

            ChangeFilter(Filter.PdfFile);
            MultiselectFiles(true);

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog.FileNames.Length >= 2)
                {
                    List <string> pdfFileNames = new List <string>();
                    pdfFileNames.AddRange(openFileDialog.FileNames);
                    Accoreconsole console = new Accoreconsole();
                    WriteLog("Task : Merge PDFs", LogMessageType.Information);
                    WriteLog("PDF File/Files : ", LogMessageType.Information);

                    for (int i = 0; i < pdfFileNames.Count; ++i)
                    {
                        WriteLog(i + 1 + " : " + pdfFileNames[i], LogMessageType.Information);
                    }

                    try
                    {
                        if (console.mergerPdfFiles(pdfFileNames, outPdfFileName, out error))
                        {
                            WriteLog("Success : saved...", LogMessageType.Information);
                        }
                        else
                        {
                            WriteLog("Failed to merge pdf files : " + error, LogMessageType.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog("Failed to save pdf file : " + error, LogMessageType.Error);
                        WriteLog(ex.Message, LogMessageType.Error);
                    }
                }
            }
            else
            {
                WriteLog("Select 2 or more pdf files...", LogMessageType.Error);
            }
        }
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker  = sender as BackgroundWorker;
            Accoreconsole    console = e.Argument as Accoreconsole;

            int    i   = 0;
            string msg = "";

            if (!(worker == null))
            {
                if (!(console == null))
                {
                    console.Process(_fileName);
                    msg = console.GetLog();
                    worker.ReportProgress(++i, msg);
                }
            }
        }
        private void extractAllVectorContentsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string error = "";

            ChangeFilter(Filter.PdfFile);
            MultiselectFiles(false);
            openFileDialog.Title = "Select PDF File";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                WriteLog("Task : Extract all vector contents form TrueView exported PDF", LogMessageType.Information);
                WriteLog("Open PDF File : " + openFileDialog.FileName, LogMessageType.Information);

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    WriteLog("Output Text File : " + saveFileDialog.FileName, LogMessageType.Information);

                    Accoreconsole console = new Accoreconsole();

                    try
                    {
                        if (console.ExtractAllText(openFileDialog.FileName, saveFileDialog.FileName, out error))
                        {
                            WriteLog("Success : saved...", LogMessageType.Information);
                        }
                        else
                        {
                            WriteLog("Failed to extract text : " + error, LogMessageType.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteLog("Failed to save text file : " + error, LogMessageType.Error);
                        WriteLog(ex.Message, LogMessageType.Error);
                    }
                }
            }
        }
コード例 #6
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker  = sender as BackgroundWorker;
            Accoreconsole    console = e.Argument as Accoreconsole;

            int    i   = 0;
            string msg = "";

            if (!(worker == null))
            {
                if (!(console == null))
                {
                    for (int index = 0; index < _colA.Count; ++index)
                    {
                        if (console.ConvertDwgToPdf(_colC[index]) == 0)
                        {
                            ++i;
                        }
                        msg = console.GetLog();
                        worker.ReportProgress(i, msg);
                    }
                }
            }
        }
コード例 #7
0
        public void Convert()
        {
            //Accoreconsole console = new Accoreconsole();
            var newLine = string.Format("{0},{1}", "Pdf File Name", "Time(ms)");
            var csv     = new StringBuilder();

            csv.AppendLine(newLine);
            try
            {
                Console.WriteLine("Reading csv file " + this._fileName);
                Status st = ReadCsvFile();
                if (st == Status.FileReadSuccess)
                {
                    Console.WriteLine("Success..." + this._fileName);
                }
                else if (st == Status.FileNotFound)
                {
                    Console.WriteLine("File not found..." + this._fileName);
                }
                else
                {
                    Console.WriteLine("File reading failed..." + this._fileName);
                    return;
                }
                //StartWorker(console);  //for BG Worker, not needed
                if (this._watch == null)
                {
                    this._watch = new Stopwatch();
                }

                for (int i = 0; i < this._colC.Count; ++i)
                {
                    Accoreconsole console = new Accoreconsole();
                    Console.WriteLine("Converting file : " + _colC[i] + "...");

                    if (i == 0)
                    {
                        _watch.Start();
                    }
                    else
                    {
                        _watch.Restart();
                    }

                    if (console.ConvertDwgToPdf(_colC[i]) == 0)
                    {
                        _successCount++;
                        Console.WriteLine("Success : " + _colC[i]);
                    }
                    else
                    {
                        _failedCount++;
                    }
                    _watch.Stop();
                    newLine = string.Format("{0},{1}", Path.GetDirectoryName(_colC[i]) + "\\" + Path.GetFileNameWithoutExtension(_colC[i]) + "_Conv.pdf", _watch.ElapsedMilliseconds.ToString());
                    csv.AppendLine(newLine);
                    string[] str = console.GetLog().Split('\n');
                    foreach (string s in str)
                    {
                        Console.WriteLine(s);
                    }
                    this._avgTime += _watch.ElapsedMilliseconds;
                    Console.WriteLine("Total Time : " + _watch.ElapsedMilliseconds.ToString() + " ms");
                    Console.WriteLine("Total Files = " + _fileCount + " Success = " + _successCount + " In Process : " + (_fileCount - (_successCount + _failedCount)) + " Failed = " + _failedCount);
                    Console.WriteLine("---------------------------------------------------------------");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                if (_watch != null)
                {
                    _watch.Stop();
                    Console.WriteLine("Total Time : " + _watch.ElapsedMilliseconds.ToString() + " ms");
                    _watch = null;
                }

                csv.AppendLine();
                csv.AppendLine(String.Format("{0},{1}", "Total File Count", this._fileCount));
                csv.AppendLine(String.Format("{0},{1}", "Success", this._successCount));
                csv.AppendLine(String.Format("{0},{1}", "Failed", this._failedCount));
                csv.AppendLine(String.Format("{0},{1}", "Success Rate", (this._successCount / (this._fileCount * 1.0)) * 100 + " %"));
                csv.AppendLine(String.Format("{0},{1}", "Average Time", (this._avgTime * 1.0) / (this._successCount + this._failedCount)));
                File.WriteAllText("csv_log.csv", csv.ToString());
                csv = null;
            }
        }