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);
                }
            }
        }
コード例 #2
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);
                    }
                }
            }
        }
コード例 #3
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;
            }
        }