Exemplo n.º 1
0
            /// <summary>
            /// builds an entry for a running job - in this case there is no row available since agent logs outcomes only after job finishes
            /// </summary>
            /// <param name="sourceName"></param>
            /// <param name="dr">points to last entry - which should corespond to first step - so we can compute job name and duration</param>
            private void InitializeJobHistoryForRunningJob(string sourceName, DataRow dr)
            {
                try
                {
                    m_originalSourceName = sourceName;

                    m_pointInTime  = Convert.ToDateTime(dr[AgentUtilities.UrnRunDate], System.Globalization.CultureInfo.InvariantCulture);
                    m_fieldJobName = Convert.ToString(dr[AgentUtilities.UrnJobName], System.Globalization.CultureInfo.InvariantCulture);

                    m_severity = SeverityClass.InProgress;

                    m_fieldStepID           = null;
                    m_fieldStepName         = null;
                    m_fieldMessage          = "DropObjectsSR.InProgressStatus"; // $FUTURE - assign its own string when string resources got un-freezed
                    m_fieldSqlSeverity      = null;
                    m_fieldSqlMessageID     = null;
                    m_fieldOperatorEmailed  = null;
                    m_fieldOperatorNetsent  = null;
                    m_fieldOperatorPaged    = null;
                    m_fieldRetriesAttempted = null;
                    m_serverName            = null;

                    m_fieldDuration = Convert.ToString(Convert.ToDateTime(dr[AgentUtilities.UrnServerTime]) - Convert.ToDateTime(dr[AgentUtilities.UrnRunDate], System.Globalization.CultureInfo.InvariantCulture), System.Globalization.CultureInfo.InvariantCulture);
                }
                catch (InvalidCastException)
                {
                    // keep null data if we hit some invalid info
                }
            }
Exemplo n.º 2
0
        internal static Contracts.CompletionResult ConvertToCompletionResult(SeverityClass severity)
        {
            switch (severity)
            {
            case (SeverityClass.Cancelled):
                return(Contracts.CompletionResult.Cancelled);

            case (SeverityClass.Error):
                return(Contracts.CompletionResult.Failed);

            case (SeverityClass.FailureAudit):
                return(Contracts.CompletionResult.Failed);

            case (SeverityClass.InProgress):
                return(Contracts.CompletionResult.InProgress);

            case (SeverityClass.Retry):
                return(Contracts.CompletionResult.Retry);

            case (SeverityClass.Success):
                return(Contracts.CompletionResult.Succeeded);

            case (SeverityClass.SuccessAudit):
                return(Contracts.CompletionResult.Succeeded);

            case (SeverityClass.Unknown):
                return(Contracts.CompletionResult.Unknown);

            default:
                return(Contracts.CompletionResult.Unknown);
            }
        }
Exemplo n.º 3
0
            /// <summary>
            /// builds an entry based on a row returned by enurerator - that can be either a job step or a job outcome
            /// </summary>
            /// <param name="dr"></param>
            private void InitializeJobHistoryFromDataRow(string sourceName, DataRow dr)
            {
                try
                {
                    m_originalSourceName = sourceName;

                    m_pointInTime  = Convert.ToDateTime(dr[AgentUtilities.UrnRunDate], System.Globalization.CultureInfo.InvariantCulture);
                    m_serverName   = Convert.ToString(dr[AgentUtilities.UrnServer], System.Globalization.CultureInfo.InvariantCulture);
                    m_fieldJobName = Convert.ToString(dr[AgentUtilities.UrnJobName], System.Globalization.CultureInfo.InvariantCulture);
                    switch ((Microsoft.SqlServer.Management.Smo.Agent.CompletionResult)Convert.ToInt32(dr[AgentUtilities.UrnRunStatus], System.Globalization.CultureInfo.InvariantCulture))
                    {
                    case CompletionResult.Cancelled:
                        m_severity = SeverityClass.Cancelled;
                        break;

                    case CompletionResult.Failed:
                        m_severity = SeverityClass.Error;
                        break;

                    case CompletionResult.InProgress:
                        m_severity = SeverityClass.InProgress;
                        break;

                    case CompletionResult.Retry:
                        m_severity = SeverityClass.Retry;
                        break;

                    case CompletionResult.Succeeded:
                        m_severity = SeverityClass.Success;
                        break;

                    case CompletionResult.Unknown:
                        m_severity = SeverityClass.Unknown;
                        break;

                    default:
                        m_severity = SeverityClass.Unknown;
                        break;
                    }

                    //
                    // check our subentries, see if any of them have a worse status than we do.
                    // if so, then we should set ourselves to SeverityClass.Warning
                    //
                    if (this.m_subEntries != null)
                    {
                        for (int i = 0; i < this.m_subEntries.Count; i++)
                        {
                            if (this.m_subEntries[i].Severity > this.m_severity &&
                                (this.m_subEntries[i].Severity == SeverityClass.Retry ||
                                 this.m_subEntries[i].Severity == SeverityClass.Warning ||
                                 this.m_subEntries[i].Severity == SeverityClass.FailureAudit ||
                                 this.m_subEntries[i].Severity == SeverityClass.Error))
                            {
                                this.m_severity = SeverityClass.Warning;
                                break;
                            }
                        }
                    }

                    // if stepId is zero then dont show stepID and step name in log viewer
                    // Valid step Ids starts from index 1
                    int currentStepId = (int)dr[AgentUtilities.UrnStepID];
                    if (currentStepId == 0)
                    {
                        m_fieldStepID   = String.Empty;
                        m_fieldStepName = String.Empty;
                    }
                    else
                    {
                        m_fieldStepID   = Convert.ToString(currentStepId, System.Globalization.CultureInfo.CurrentCulture);
                        m_fieldStepName = Convert.ToString(dr[AgentUtilities.UrnStepName], System.Globalization.CultureInfo.CurrentCulture);
                    }

                    m_fieldMessage          = Convert.ToString(dr[AgentUtilities.UrnMessage], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldSqlSeverity      = Convert.ToString(dr[AgentUtilities.UrnSqlSeverity], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldSqlMessageID     = Convert.ToString(dr[AgentUtilities.UrnSqlMessageID], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldOperatorEmailed  = Convert.ToString(dr[AgentUtilities.UrnOperatorEmailed], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldOperatorNetsent  = Convert.ToString(dr[AgentUtilities.UrnOperatorNetsent], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldOperatorPaged    = Convert.ToString(dr[AgentUtilities.UrnOperatorPaged], System.Globalization.CultureInfo.CurrentCulture);
                    m_fieldRetriesAttempted = Convert.ToString(dr[AgentUtilities.UrnRetriesAttempted], System.Globalization.CultureInfo.CurrentCulture);

                    Int64 hhmmss = Convert.ToInt64(dr[AgentUtilities.UrnRunDuration], System.Globalization.CultureInfo.InvariantCulture); // HHMMSS
                    int   hh     = Convert.ToInt32(hhmmss / 10000, System.Globalization.CultureInfo.InvariantCulture);
                    int   mm     = Convert.ToInt32((hhmmss / 100) % 100, System.Globalization.CultureInfo.InvariantCulture);
                    int   ss     = Convert.ToInt32(hhmmss % 100, System.Globalization.CultureInfo.InvariantCulture);
                    m_fieldDuration = Convert.ToString(new TimeSpan(hh, mm, ss), System.Globalization.CultureInfo.CurrentCulture);
                }
                catch (InvalidCastException)
                {
                    // keep null data if we hit some invalid info
                }
            }