Example #1
0
        protected void ValidateRunningJobs()
        {
            Dictionary <String, Object> sqlParameters = new Dictionary <String, Object>();

            sqlParameters.Add(":machinename", Environment.MachineName);

            // Pull the jobs running on this machine.
            DataTable dt = SqlUtilities.GetData(_ConnectionString, _SqlJobsInProgress, sqlParameters);

            if ((dt != null) && (dt.Rows != null) && (dt.Rows.Count > 0))
            {
                sqlParameters.Add(":inprogress", false);
                sqlParameters.Add(":scanrequested", false);
                sqlParameters.Add(":jobstatus", "Error");
                sqlParameters.Add(":statusdescription", "See activity log for details.");
                sqlParameters.Add(":pkey", -1);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        if (!MiscUtilities.isAlive(dt.Rows[i]["definition_name"].ToString()))
                        {
                            sqlParameters[":pkey"] = MiscUtilities.ObjectToInteger(dt.Rows[i]["pkey"], "No primary key defined.");
                            SqlUtilities.ExcecuteNonQuery(_ConnectionString, _SqlUpdateInProgressStatus, sqlParameters);
                        }
                    }
                    catch (Exception ex)
                    {
                        LocalLog.AddLine("Error while updating in progress job status.  Error message was: " + ex.Message);
                        _AppLog.WriteEntry(ex.StackTrace, System.Diagnostics.EventLogEntryType.Error);
                    }
                }
            }
        }