Beispiel #1
0
        public virtual void Run(IJobRunEnv env)
        {
            JobReportEnvBase repenv = null;

            if (m_job.Root != this)
            {
                repenv = CreateReportEnv();
            }
            if (repenv != null)
            {
                try
                {
                    env.SetReportEnv(GroupId, repenv);
                    repenv.OnStart();
                }
                catch (Exception err)
                {
                    ProgressInfo.Warning("Error initializing reports:" + err.Message);
                }
            }
            try
            {
                using (var ub = new UsageBuilder(UsageEventName))
                {
                    GetUsageParams(ub);

                    try
                    {
                        if (m_job.m_process != null)
                        {
                            JobCommand oldcmd = m_job.m_process.CurrentCommand;
                            try
                            {
                                m_job.m_process.CurrentCommand = this;
                                DoRun(env);
                            }
                            finally
                            {
                                m_job.m_process.CurrentCommand = oldcmd;
                                // close connections
                                ConnPack = null;
                            }
                        }
                        else
                        {
                            try
                            {
                                DoRun(env);
                            }
                            finally
                            {
                                // close connections
                                ConnPack = null;
                            }
                        }
                        ub["result"] = "ok";
                    }
                    catch (Exception err)
                    {
                        ub["result"] = "error";
                        ub["error"]  = err.Message;
                        throw;
                    }
                }
            }
            finally
            {
                if (repenv != null)
                {
                    try
                    {
                        repenv.OnFinish();
                    }
                    catch (Exception err)
                    {
                        ProgressInfo.Warning("Error finishing reports:" + err.Message);
                    }
                    try
                    {
                        repenv.Dispose();
                    }
                    catch (Exception err)
                    {
                        ProgressInfo.Warning("Error disposing reports:" + err.Message);
                    }
                }
            }
        }
Beispiel #2
0
 public void SetReportEnv(string command, JobReportEnvBase repenv)
 {
     m_reportEnvs[command] = repenv;
 }