示例#1
0
文件: Job.cs 项目: chrhodes/EyeOnLife
        private static SQLInformation.Data.ApplicationDataSet.JSJobsRow Add(MSMOA.Job job, SQLInformation.Data.ApplicationDataSet.JobServersRow jobServerRow)
        {
            SQLInformation.Data.ApplicationDataSet.JSJobsRow dataRow = null;

            try
            {
                dataRow    = Common.ApplicationDataSet.JSJobs.NewJSJobsRow();
                dataRow.ID = Guid.NewGuid();

                dataRow.Name_JSJob    = job.Name;
                dataRow.JobServer_ID  = jobServerRow.ID;
                dataRow.Instance_ID   = jobServerRow.Instance_ID;
                dataRow.Name_Instance = jobServerRow.Name_Instance;

                dataRow.ExpandJobSteps = true;

                dataRow.SnapShotDate  = DateTime.Now;
                dataRow.SnapShotError = "";

                Common.ApplicationDataSet.JSJobs.AddJSJobsRow(dataRow);
                Common.ApplicationDataSet.JSJobsTA.Update(Common.ApplicationDataSet.JSJobs);
            }
            catch (Exception ex)
            {
                VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5);
                // TODO(crhodes):
                // Wrap anything above that throws an exception that we want to ignore,
                // e.g. property not available because of SQL Edition.

                UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256));
            }

            return(dataRow);
        }
示例#2
0
        public static void LoadFromSMO(MSMOA.Job job, Guid jobID)
        {
#if TRACE
            long startTicks = VNC.AppLog.Trace3("Enter", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 0);
#endif

            foreach (MSMOA.JobStep jobStep in job.JobSteps)
            {
                GetInfoFromSMO(jobStep, jobID);
            }
#if TRACE
            VNC.AppLog.Trace3("Exit", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 1, startTicks);
#endif
        }
示例#3
0
文件: Job.cs 项目: chrhodes/EyeOnLife
 public static void UpdateDataSet(this MSMOA.Job job, Data.ApplicationDataSet.JSJobsRow dataRow)
 {
     try
     {
         //dataRow.X = job.X;
     }
     catch (Exception ex)
     {
         VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 7);
         // TODO(crhodes):
         // Wrap anything above that throws an exception that we want to ignore,
         // e.g. property not available because of SQL Edition.
     }
 }
示例#4
0
文件: Job.cs 项目: chrhodes/EyeOnLife
        private static void Update(MSMOA.Job job, SQLInformation.Data.ApplicationDataSet.JSJobsRow dataRow)
        {
            try
            {
                job.UpdateDataSet(dataRow);

                UpdateDatabaseWithSnapShot(dataRow, "");
            }
            catch (Exception ex)
            {
                VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6);

                UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256));
            }
        }
示例#5
0
 protected override void ProcessRecord()
 {
     if (jobs != null && jobs.Count > 0)
     {
         base.WriteObject(jobs, true);
     }
     else if (this.SqlServer != null)
     {
         var jobCol = this.SqlServer.JobServer.Jobs;
         if (_dynLib != null && _dynLib.ParameterHasValue("JobName"))
         {
             string[] names = _dynLib.GetParameterValues <string>("JobName");
             for (int i = 0; i < jobCol.Count; i++)
             {
                 Microsoft.SqlServer.Management.Smo.Agent.Job job = jobCol[i];
                 if (names.Contains(job.Name, new SmoContext.CaseInsensitiveComparer()))
                 {
                     SmoJob smoj = job;
                     base.WriteObject(smoj);
                 }
             }
         }
         else
         {
             for (int i = 0; i < jobCol.Count; i++)
             {
                 SmoJob smoj = jobCol[i];
                 base.WriteObject(smoj);
             }
         }
     }
     else
     {
         throw new ArgumentException("SqlServer can't be null if you don't connect to an instance.");
     }
 }
示例#6
0
文件: Job.cs 项目: chrhodes/EyeOnLife
        private static SQLInformation.Data.ApplicationDataSet.JSJobsRow GetInfoFromSMO(MSMOA.Job job, SQLInformation.Data.ApplicationDataSet.JobServersRow jobServerRow)
        {
#if TRACE
            long startTicks = VNC.AppLog.Trace4(string.Format("Enter ({0})", job.Name), LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
#endif

            SQLInformation.Data.ApplicationDataSet.JSJobsRow dataRow = null;

            try
            {
                var dbs = from db in Common.ApplicationDataSet.JSJobs
                          where db.JobServer_ID == jobServerRow.ID
                          select db;

                var dbs2 = from db2 in dbs
                           where db2.Name_JSJob == job.Name
                           select db2;

                if (dbs2.Count() > 0)
                {
                    dataRow = dbs2.First();
                    Update(job, dataRow);
                }
                else
                {
                    dataRow = Add(job, jobServerRow);
                }
            }
            catch (Exception ex)
            {
                VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 3);
            }

#if TRACE
            VNC.AppLog.Trace4("Exit", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4, startTicks);
#endif
            return(dataRow);
        }