Exemplo n.º 1
0
        public PlotTask MapPlotTask(IDataReader reader)
        {
            var p = new PlotTask();

            p.JobId         = Convert.ToInt32(reader.GetValue(0));
            p.PlotTicket    = Convert.ToInt32(reader.GetValue(1));
            p.JobStatus     = Convert.ToInt32(reader.GetValue(2));
            p.Date          = reader.GetDateTime(3);
            p.TotalPlan     = Convert.ToInt32(reader.GetValue(4));
            p.UserId        = reader.GetSafe <string>(5);
            p.TaskId        = Convert.ToInt32(reader.GetValue(6));
            p.TypePlan      = reader.GetSafe <string>(7);
            p.IdStamp       = reader.GetSafe <string>(8);
            p.IdPlanchette  = reader.GetSafe <string>(9);
            p.OrdPlan       = Convert.ToInt32(reader.GetValue(10));
            p.TypMap        = reader.GetSafe <string>(11);
            p.PathPlan      = reader.GetSafe <string>(12);
            p.ListEnergy    = reader.GetSafe <string>(13);
            p.PathResultPdf = Settings.LocalRootPath
                              + reader.GetSafe <string>(14).Substring(Settings.ProductionRootPath.Length);
            p.Scale            = reader.GetSafe <string>(15);
            p.Essay            = Convert.ToInt32(reader.GetValue(16));
            p.PlotTicketStatus = Convert.ToInt32(reader.GetValue(17));
            p.Side             = reader.GetSafe <string>(18);
            if (!string.IsNullOrEmpty(p.PathPlan))
            {
                p.PathPlan = GetFileUncPath(p.PathPlan);
            }
            return(p);
        }
Exemplo n.º 2
0
        private bool ProcessPlotTickects(PlotTask plotTask)
        {
            Logger.Info("Plot task: {0} {1}", plotTask.TaskId, plotTask.CommandLineParameters());

            using (var process = new Process())
            {
                process.StartInfo.FileName  = Settings.AcConsolePath;
                process.StartInfo.Arguments = plotTask.CommandLineParameters();
                //process.StartInfo.Arguments = @"/i ""C:\Test\plot\Plot01\Scripts\edpl-1326-2.dwg"" /m ""W:\RWA004\Cardex\Est\Edpl\Vvs\Reperage\El\edpl-1326-2.dwg"" /s ""C:\Test\Plot\Plot01\Scripts\PlotDwg.scr"" /f ""C:\Test\Plot\Plot01\Scripts\dump2.pdf"" /isolate";
                process.StartInfo.CreateNoWindow        = true;
                process.StartInfo.ErrorDialog           = false;
                process.StartInfo.UseShellExecute       = false;
                process.StartInfo.RedirectStandardError = true;
                //process.StartInfo.RedirectStandardInput = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
                //process.EnableRaisingEvents = true;
                //process.OutputDataReceived += (sender, e) => {
                //	Console.ForegroundColor = ConsoleColor.Green;
                //	Console.WriteLine(e.Data);
                //	Console.ResetColor();
                //};
                //process.ErrorDataReceived += (sender, e) => {
                //	Console.ForegroundColor = ConsoleColor.Red;
                //	Console.WriteLine(e.Data);
                //	Console.ResetColor();
                //};
                //process.Exited += (sender, e) => {
                //	Console.ForegroundColor = ConsoleColor.Red;
                //	Console.WriteLine(e);
                //	Console.ResetColor();
                //};
                process.Start();
                //process.BeginErrorReadLine();
                //process.BeginOutputReadLine();

                //Thread.Sleep(1000);
                //process.StandardInput.WriteLine("Y");
                //process.StandardInput.WriteLine();
                //process.StandardInput.Flush();

                var standardOutput = process.StandardOutput.ReadToEnd();

                lock (_sysLock)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(standardOutput);
                    Console.ResetColor();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(process.StandardError.ReadToEnd());
                    Console.ResetColor();
                }

                process.WaitForExit(Settings.MaximumConsoleExecutionTime * 1000);

                if (!process.HasExited)
                {
                    process.Kill();
                }

                return(standardOutput.Contains("PLOT SUCCESSFUL"));
            }
        }