private static void NotifyViaMail(Exception ex) { // if a MailException itself, exit to avoid an infinite loop if (ex is MailException || !EnableMailNotifications) { return; } if (mailNotifier == null) { WriteToLog(LogEntryType.Warning, "Email notifications are enabled but not configured. The email could not be sent."); return; } string msg = ""; Integration integration = null; JobInstance jobInstance = null; JobStepInstance jobStepInstance = null; try { // returns null if not found jobInstance = JobQueueManager.GetJobInstanceByParallelTaskId(Thread.CurrentThread.ManagedThreadId); if (jobInstance != null) { integration = jobInstance.Integration; jobStepInstance = jobInstance.RunningJobStepInstance; } var jobInfo = MailFormatter.GetFormattedJobInfoAsHtml(integration, jobInstance, jobStepInstance); msg = MailFormatter.GetTextAsFormattedDiv(jobInfo) + ExceptionFormatter.FormatExceptionForWeb(ex); } catch (Exception innerEx) { StringBuilder failureInfo = new StringBuilder(); failureInfo.AppendFormat("<b>Job info could not be obtained because of error:</b><br /> {0} {1}", innerEx.Message, innerEx.StackTrace); failureInfo.Append(HtmlBuilder.GetLineBreak(2)); msg = MailFormatter.GetTextAsFormattedDiv(failureInfo.ToString()) + ExceptionFormatter.FormatExceptionForWeb(ex); } // Exceptions are caught within MailNotifier class and logged via the SyncEngineLogger if (integration == null) { mailNotifier.SendMessage("SyncObjX Integration Services - An Error Has Occurred", msg); } else { mailNotifier.SendMessage(string.Format("SyncObjX Integration Services - Error Occurred in \"{0}\"", integration.Name), msg); } }
public static void WriteToLog(JobInstance jobInstance, JobStepInstance jobStepInstance, JobBatch jobBatch) { foreach (var logger in registeredLoggers) { try { logger.Logger.WriteToLog(jobInstance, jobStepInstance, jobBatch); } catch (Exception ex) { WriteExceptionToLog(jobInstance.Integration, jobBatch.AssociatedDataSource.DataSource, jobInstance, jobStepInstance, ex); } } }
public static void WriteToLog(LogEntryType logEntryType, JobInstance jobInstance, string format, params object[] args) { Integration integration = null; JobStepInstance jobStepInstance = null; if (jobInstance != null) { integration = jobInstance.Integration; jobStepInstance = jobInstance.RunningJobStepInstance; } try { WriteToLog(logEntryType, integration, null, jobInstance, jobStepInstance, () => { return(string.Format(format, args)); }); } catch (Exception ex) { WriteExceptionToLog(jobInstance, ex); } }
public static void WriteByParallelTaskContext(LogEntryType logEntryType, DataSource dataSource, Func <string> messageDelegate) { Integration integration = null; JobInstance jobInstance = null; JobStepInstance jobStepInstance = null; try { // returns null if not found jobInstance = JobQueueManager.GetJobInstanceByParallelTaskId(Thread.CurrentThread.ManagedThreadId); if (jobInstance != null) { integration = jobInstance.Integration; jobStepInstance = jobInstance.RunningJobStepInstance; } WriteToLog(logEntryType, integration, dataSource, jobInstance, jobStepInstance, messageDelegate); } catch (Exception ex) { WriteExceptionToLog(integration, dataSource, jobInstance, jobStepInstance, ex); } }
public void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, string message) { using (var dbContext = new ls.LoggingDataContext(ConnectionString)) { Guid?integrationId = null; Guid?dataSourceId = null; Guid?jobInstanceId = null; Guid?jobStepInstanceId = null; if (integration != null) { integrationId = integration.Id; } if (dataSource != null) { dataSourceId = dataSource.Id; } if (jobInstance != null) { jobInstanceId = jobInstance.Id; } if (jobStepInstance != null) { jobStepInstanceId = jobStepInstance.Id; } dbContext.AddLogEntry(integrationId, dataSourceId, jobInstanceId, jobStepInstanceId, (byte)logEntryType, message); } }
public void WriteToLog(JobInstance jobInstance, JobStepInstance jobStepInstance, JobBatch jobBatch) { using (var dbContext = new ls.LoggingDataContext(ConnectionString)) { foreach (var entityBatch in jobBatch.EntityBatches) { int countOfInsertsWithoutError = 0; int countOfUpdatesWithoutError = 0; int countOfDeletionsWithoutError = 0; if (!entityBatch.HasBeenProcessed) { WriteToLog(LogEntryType.Error, jobInstance.Integration, jobBatch.AssociatedDataSource.DataSource, jobInstance, jobStepInstance, "The entity batch has not been processed by a data source. No history can be logged."); continue; } var entityBatchHistoryId = (int)dbContext.AddEntityBatchHistory(jobInstance.Integration.Id, jobInstance.Id, jobStepInstance.Id, jobBatch.AssociatedDataSource.DataSource.Id, Enum.GetName(typeof(SyncSide), jobBatch.SyncSide), entityBatch.EntityDefinition.TechnicalEntityName, entityBatch.EntityDefinition.UserFriendlyEntityName, StringHelper.GetDelimitedString(entityBatch.EntityDefinition.PrimaryKeyColumnNames)) .FirstOrDefault().InsertedID; string batchHistoryTemplate = @"DECLARE @EntityBatchRecordId int INSERT INTO EntityBatchRecordHistory VALUES ({0}, GETDATE(), '{1}', '{2}', '{3}', {4}) SELECT @EntityBatchRecordId = SCOPE_IDENTITY()"; string batchHistoryDetailTemplate = "\n\rINSERT INTO EntityBatchRecordHistoryDetail VALUES (@EntityBatchRecordId, GETDATE(), '{0}', NULL, {1}, {2})"; // log inserts foreach (var insertedRecord in entityBatch.RecordsToAdd) { //var entityBatchHistoryRecordId = (int)dbContext.AddEntityBatchRecordHistory(entityBatchHistoryId, 'I', StringHelper.GetDelimitedStringFromList(insertedRecord.PrimaryKeyValues), // insertedRecord.HasError, insertedRecord.ErrorMessage).FirstOrDefault().InsertedID; if (entityBatch.LoggingBehavior.MaxNumberOfInsertsWithoutErrorToLog.HasValue && !insertedRecord.HasError) { countOfInsertsWithoutError++; if (countOfInsertsWithoutError > entityBatch.LoggingBehavior.MaxNumberOfInsertsWithoutErrorToLog.Value) { continue; } } StringBuilder sqlForInsert = new StringBuilder(); sqlForInsert.AppendFormat(batchHistoryTemplate, entityBatchHistoryId, "I", StringHelper.GetDelimitedString(insertedRecord.PrimaryKeyValues), insertedRecord.HasError, insertedRecord.ErrorMessage == null ? "NULL" : "'" + insertedRecord.ErrorMessage.Replace("'", "''") + "'"); foreach (var fieldValuePair in insertedRecord.FieldValuePairs) { //dbContext.AddEntityBatchRecordHistoryDetail(entityBatchHistoryRecordId, fieldValuePair.Key, null, null, fieldValuePair.Value); sqlForInsert.AppendFormat(batchHistoryDetailTemplate, fieldValuePair.Key, "NULL", fieldValuePair.Value == null ? "NULL" : "'" + fieldValuePair.Value.Replace("'", "''") + "'"); } dbContext.ExecuteCommand(sqlForInsert.ToString()); } // log updates foreach (var updatedRecord in entityBatch.RecordsToUpdate) { //var entityBatchHistoryRecordId = (int)dbContext.AddEntityBatchRecordHistory(entityBatchHistoryId, 'U', StringHelper.GetDelimitedStringFromList(updatedRecord.PrimaryKeyValues), // updatedRecord.HasError, updatedRecord.ErrorMessage).FirstOrDefault().InsertedID; if (entityBatch.LoggingBehavior.MaxNumberOfUpdatesWithoutErrorToLog.HasValue && !updatedRecord.HasError) { countOfUpdatesWithoutError++; if (countOfUpdatesWithoutError > entityBatch.LoggingBehavior.MaxNumberOfUpdatesWithoutErrorToLog.Value) { continue; } } StringBuilder sqlForUpdate = new StringBuilder(); sqlForUpdate.AppendFormat(batchHistoryTemplate, entityBatchHistoryId, "U", StringHelper.GetDelimitedString(updatedRecord.PrimaryKeyValues), updatedRecord.HasError, updatedRecord.ErrorMessage == null ? "NULL" : "'" + updatedRecord.ErrorMessage.Replace("'", "''") + "'"); foreach (var fieldValuePair in updatedRecord.FieldValuePairs) { //dbContext.AddEntityBatchRecordHistoryDetail(entityBatchHistoryRecordId, fieldValuePair.Key, null, fieldValuePair.Value.OldValue, fieldValuePair.Value.NewValue); sqlForUpdate.AppendFormat(batchHistoryDetailTemplate, fieldValuePair.Key, fieldValuePair.Value.OldValue == null ? "NULL" : "'" + fieldValuePair.Value.OldValue.Replace("'", "''") + "'", fieldValuePair.Value.NewValue == null ? "NULL" : "'" + fieldValuePair.Value.NewValue.Replace("'", "''") + "'"); } dbContext.ExecuteCommand(sqlForUpdate.ToString()); } // log deletions foreach (var deletedRecord in entityBatch.RecordsToDelete) { if (entityBatch.LoggingBehavior.MaxNumberOfDeletionsWithoutErrorToLog.HasValue && !deletedRecord.HasError) { countOfDeletionsWithoutError++; if (countOfDeletionsWithoutError > entityBatch.LoggingBehavior.MaxNumberOfDeletionsWithoutErrorToLog.Value) { continue; } } var entityBatchHistoryRecordId = (int)dbContext.AddEntityBatchRecordHistory(entityBatchHistoryId, 'D', StringHelper.GetDelimitedString(deletedRecord.PrimaryKeyValues), deletedRecord.HasError, deletedRecord.ErrorMessage).FirstOrDefault().InsertedID; } } } }
private static string GetLogLine(DateTime logDate, LogEntryType logEntryType, JobInstance jobInstance, JobStepInstance jobStepInstance, JobBatch jobBatch, string message) { StringBuilder fullLine = new StringBuilder(); fullLine.Append(logDate); fullLine.Append("\t"); fullLine.Append(logEntryType); fullLine.Append("\t"); fullLine.Append(string.Format("{0} ({1})", jobInstance.Integration.Name, jobInstance.Integration.Id)); fullLine.Append("\t"); fullLine.Append(string.Format("{0} ({1})", jobBatch.AssociatedDataSource.DataSource.Name, jobBatch.AssociatedDataSource.DataSource.Id)); fullLine.Append("\t"); fullLine.Append(string.Format("{0} ({1})", jobInstance.Job.Name, jobInstance.Job.Id)); fullLine.Append("\t"); fullLine.Append(string.Format("{0} ({1})", jobInstance.QueueRequest.InvocationSourceType, jobInstance.QueueRequest.Id)); fullLine.Append("\t"); fullLine.Append(jobInstance.Id); fullLine.Append("\t"); fullLine.Append(JobFilterHelper.GetTextForDatabase(jobInstance.Filters)); fullLine.Append("\t"); fullLine.Append(string.Format("{0} ({1})", jobStepInstance.JobStep.Name, jobStepInstance.JobStep.Id)); fullLine.Append("\t"); fullLine.Append(jobStepInstance.Id); fullLine.Append("\t"); fullLine.Append(message); return(fullLine.ToString()); }
public void WriteToLog(JobInstance jobInstance, JobStepInstance jobStepInstance, JobBatch jobBatch) { string path = null; for (int i = 0; i <= NUMBER_OF_FILEACCESS_RETRIES; i++) { try { path = GetIntegrationLogPathAndFileName(jobInstance.Integration); break; } catch (IOException) { if (i == NUMBER_OF_FILEACCESS_RETRIES) { throw; } else { Thread.Sleep(DELAY_ON_FILEACCES_RETRY); } } } lock (_lock) { for (int i = 0; i <= NUMBER_OF_FILEACCESS_RETRIES; i++) { try { using (TextWriter log = File.AppendText(path)) { StringBuilder logLine = new StringBuilder(); var now = DateTime.Now; var errorLogLineMinusMessage = GetLogLine(now, LogEntryType.Error, jobInstance, jobStepInstance, jobBatch, null); var warningLogLineMinusMessage = GetLogLine(now, LogEntryType.Warning, jobInstance, jobStepInstance, jobBatch, null); var infoLogLineMinusMessage = GetLogLine(now, LogEntryType.Info, jobInstance, jobStepInstance, jobBatch, null); foreach (var entityBatch in jobBatch.EntityBatches) { int countOfInsertsWithoutError = 0; int countOfUpdatesWithoutError = 0; int countOfDeletionsWithoutError = 0; if (entityBatch.RecordsToAdd.Count == 0 && entityBatch.RecordsToUpdate.Count == 0 && entityBatch.RecordsToDelete.Count == 0) { continue; } if (!entityBatch.HasBeenProcessed) { logLine.Append(warningLogLineMinusMessage); logLine.AppendLine("The entity batch has not been processed by a data source. No history can be logged."); continue; } logLine.Append(infoLogLineMinusMessage); if (entityBatch.EntityDefinition.TechnicalEntityName == entityBatch.EntityDefinition.UserFriendlyEntityName) { logLine.AppendLine(string.Format("Entity batch applied on sync side '{0}' for entity '{1}':", jobBatch.SyncSide, entityBatch.EntityDefinition.TechnicalEntityName)); } else { logLine.AppendLine(string.Format("Entity batch applied on sync side '{0}' for entity '{1}' ({2}):", jobBatch.SyncSide, entityBatch.EntityDefinition.TechnicalEntityName, entityBatch.EntityDefinition.UserFriendlyEntityName)); } foreach (var insertedRecord in entityBatch.RecordsToAdd) { if (entityBatch.LoggingBehavior.MaxNumberOfInsertsWithoutErrorToLog.HasValue && !insertedRecord.HasError) { countOfInsertsWithoutError++; if (countOfInsertsWithoutError > entityBatch.LoggingBehavior.MaxNumberOfInsertsWithoutErrorToLog.Value) { continue; } } if (insertedRecord.HasError) { logLine.Append(errorLogLineMinusMessage); logLine.AppendLine(string.Format("INSERT failed with error: {0}. Command text is: {1}. Failed values are:", insertedRecord.ErrorMessage, insertedRecord.CommandText)); } else if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsAndInfo) { if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsInfoAndDebug) { logLine.AppendLine(string.Format("Command text successfully executed: {0}", insertedRecord.CommandText)); } logLine.Append(infoLogLineMinusMessage); logLine.AppendLine(string.Format("INSERT applied for keys \"{0}\" with values:", LogHelper.GetKeysAndValuesAsText(entityBatch.EntityDefinition.PrimaryKeyColumnNames, insertedRecord.PrimaryKeyValues.ToList()))); } StringBuilder insertedMessage = new StringBuilder(); foreach (var fieldValuePair in insertedRecord.FieldValuePairs) { insertedMessage.AppendLine(string.Format("{0}{1}: {2}", PRE_MESSAGES_TABS, fieldValuePair.Key, fieldValuePair.Value == null ? "NULL" : "'" + fieldValuePair.Value + "'")); } logLine.AppendLine(insertedMessage.ToString()); WriteAndClearLogLineIfExceedsSize(jobInstance.Integration.Id, log, logLine); } foreach (var updatedRecord in entityBatch.RecordsToUpdate) { if (entityBatch.LoggingBehavior.MaxNumberOfUpdatesWithoutErrorToLog.HasValue && !updatedRecord.HasError) { countOfUpdatesWithoutError++; if (countOfUpdatesWithoutError > entityBatch.LoggingBehavior.MaxNumberOfUpdatesWithoutErrorToLog.Value) { continue; } } if (updatedRecord.HasError) { logLine.Append(errorLogLineMinusMessage); logLine.AppendLine(string.Format("UPDATE with keys '{0}' failed with error: {1}. Command text is: {2}. Failed values are:", LogHelper.GetKeysAndValuesAsText(entityBatch.EntityDefinition.PrimaryKeyColumnNames, updatedRecord.PrimaryKeyValues.ToList()), updatedRecord.ErrorMessage, updatedRecord.CommandText)); } else if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsAndInfo) { if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsInfoAndDebug) { logLine.AppendLine(string.Format("Command text successfully executed: {0}", updatedRecord.CommandText)); } logLine.Append(infoLogLineMinusMessage); logLine.AppendLine(string.Format("UPDATE applied for keys \"{0}\" with values:", LogHelper.GetKeysAndValuesAsText(entityBatch.EntityDefinition.PrimaryKeyColumnNames, updatedRecord.PrimaryKeyValues.ToList()))); } StringBuilder updatedMessage = new StringBuilder(); foreach (var fieldValuePair in updatedRecord.FieldValuePairs) { updatedMessage.AppendLine(string.Format("{0}{1}: {2} -> {3}", PRE_MESSAGES_TABS, fieldValuePair.Key, fieldValuePair.Value.OldValue == null ? "NULL" : "'" + fieldValuePair.Value.OldValue + "'", fieldValuePair.Value.NewValue == null ? "NULL" : "'" + fieldValuePair.Value.NewValue + "'")); } logLine.Append(updatedMessage.ToString()); WriteAndClearLogLineIfExceedsSize(jobInstance.Integration.Id, log, logLine); } foreach (var deletedRecord in entityBatch.RecordsToDelete) { if (entityBatch.LoggingBehavior.MaxNumberOfDeletionsWithoutErrorToLog.HasValue && !deletedRecord.HasError) { countOfDeletionsWithoutError++; if (countOfDeletionsWithoutError > entityBatch.LoggingBehavior.MaxNumberOfDeletionsWithoutErrorToLog.Value) { continue; } } if (deletedRecord.HasError) { logLine.Append(errorLogLineMinusMessage); logLine.AppendLine(string.Format("DELETE with keys \"{0}\" failed with error: {1}.", LogHelper.GetKeysAndValuesAsText(entityBatch.EntityDefinition.PrimaryKeyColumnNames, deletedRecord.PrimaryKeyValues.ToList()), deletedRecord.ErrorMessage)); } else if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsAndInfo) { if (jobInstance.Integration.LoggingLevel >= LoggingLevel.ErrorsWarningsInfoAndDebug) { logLine.AppendLine(string.Format("Command text successfully executed: {0}", deletedRecord.CommandText)); } logLine.Append(infoLogLineMinusMessage); logLine.AppendLine(string.Format("DELETE applied for keys '{0}'.", LogHelper.GetKeysAndValuesAsText(entityBatch.EntityDefinition.PrimaryKeyColumnNames, deletedRecord.PrimaryKeyValues.ToList()))); } WriteAndClearLogLineIfExceedsSize(jobInstance.Integration.Id, log, logLine); } } log.Write(logLine); log.Flush(); log.Close(); } break; } catch (IOException) { if (i == NUMBER_OF_FILEACCESS_RETRIES) { throw; } else { Thread.Sleep(DELAY_ON_FILEACCES_RETRY); } } } } }
public void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, string message) { string path = null; for (int i = 0; i <= NUMBER_OF_FILEACCESS_RETRIES; i++) { try { if (integration == null) { path = GetServiceLogPathAndFileName(); } else { path = GetIntegrationLogPathAndFileName(integration); } break; } catch (IOException) { if (i == NUMBER_OF_FILEACCESS_RETRIES) { throw; } else { Thread.Sleep(DELAY_ON_FILEACCES_RETRY); } } } lock (_lock) { for (int i = 0; i <= NUMBER_OF_FILEACCESS_RETRIES; i++) { try { using (TextWriter log = File.AppendText(path)) { StringBuilder logLine = new StringBuilder(); logLine.Append(DateTime.Now); logLine.Append("\t"); logLine.Append(logEntryType); logLine.Append("\t"); if (integration == null) { logLine.Append("N/A"); } else { logLine.Append(string.Format("{0} ({1})", integration.Name, integration.Id)); } logLine.Append("\t"); if (dataSource == null) { logLine.Append("N/A"); } else { logLine.Append(string.Format("{0} ({1})", dataSource.Name, dataSource.Id)); } logLine.Append("\t"); if (jobInstance == null) { logLine.Append("N/A\tN/A\tN/A\tN/A\t"); } else { logLine.Append(string.Format("{0} ({1})", jobInstance.Job.Name, jobInstance.Job.Id)); logLine.Append("\t"); logLine.Append(string.Format("{0} ({1})", jobInstance.QueueRequest.InvocationSourceType, jobInstance.QueueRequest.Id)); logLine.Append("\t"); logLine.Append(jobInstance.Id); logLine.Append("\t"); logLine.Append(JobFilterHelper.GetTextForDatabase(jobInstance.Filters)); logLine.Append("\t"); } if (jobStepInstance == null) { logLine.Append("N/A\tN/A\t"); } else { logLine.Append(string.Format("{0} ({1})", jobStepInstance.JobStep.Name, jobStepInstance.JobStep.Id)); logLine.Append("\t"); logLine.Append(jobStepInstance.Id); logLine.Append("\t"); } logLine.Append(message); log.WriteLine(logLine); log.Flush(); log.Close(); if (integration == null) { serviceLogFileInfo.CurrentFileSizeInBytes += logLine.Length; } else { logFileInfoByIntegrationId[integration.Id].CurrentFileSizeInBytes += logLine.Length; } } break; } catch (IOException) { if (i == NUMBER_OF_FILEACCESS_RETRIES) { throw; } else { Thread.Sleep(DELAY_ON_FILEACCES_RETRY); } } } } }
public static void WriteExceptionToLog(Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, Exception ex, string customMessage = null) { if (!String.IsNullOrWhiteSpace(customMessage)) { ex = new Exception(customMessage, ex); } NotifyViaMail(ex); WriteToLog(LogEntryType.Error, integration, dataSource, jobInstance, jobStepInstance, () => { return(ExceptionFormatter.Format(ex)); }); }
public static void WriteExceptionToLog(Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, Exception ex, string customMessageFormat, params object[] args) { WriteExceptionToLog(integration, dataSource, jobInstance, jobStepInstance, ex, string.Format(customMessageFormat, args)); }
public static void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, Func <string> messageDelegate) { if (integration == null && jobInstance != null) { integration = jobInstance.Integration; } if (jobStepInstance == null && jobInstance != null) { jobStepInstance = jobInstance.RunningJobStepInstance; } string message = null; foreach (var logger in registeredLoggers) { if ((int)logEntryType <= (int)logger.MaxLoggingLevel) { if (message == null) { message = messageDelegate(); } logger.Logger.WriteToLog(logEntryType, integration, dataSource, jobInstance, jobStepInstance, message); } } }
public static void WriteToLog(LogEntryType logEntryType, Integration integration, DataSource dataSource, JobInstance jobInstance, JobStepInstance jobStepInstance, string message) { WriteToLog(logEntryType, integration, dataSource, jobInstance, jobStepInstance, () => { return(message); }); }
public static void WriteToLog(LogEntryType logEntryType, JobInstance jobInstance, JobStepInstance jobStepInstance, DataSource dataSource, string format, params object[] args) { try { WriteToLog(logEntryType, jobInstance.Integration, dataSource, jobInstance, jobStepInstance, () => { return(string.Format(format, args)); }); } catch (Exception ex) { WriteExceptionToLog(jobInstance, ex); } }
public static void WriteToLog(LogEntryType logEntryType, JobInstance jobInstance, JobStepInstance jobStepInstance, DataSource dataSource, string message) { try { WriteToLog(logEntryType, jobInstance.Integration, dataSource, jobInstance, jobStepInstance, message); } catch (Exception ex) { WriteExceptionToLog(jobInstance, ex, "An exception occurred for message: {0}", message ?? ""); } }
public static string GetFormattedJobInfoAsHtml(Integration integration, JobInstance jobInstance, JobStepInstance jobStepInstance) { StringBuilder jobInfo = new StringBuilder(); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Integration: ")); if (integration == null) { jobInfo.Append("N/A"); } else { jobInfo.Append(string.Format("{0} ({1})", integration.Name, integration.Id)); } jobInfo.Append(HtmlBuilder.GetLineBreak()); if (jobInstance == null) { jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job:") + " N/A"); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Queue Request:") + " N/A"); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Instance:") + " N/A"); jobInfo.Append(HtmlBuilder.GetLineBreak()); } else { jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job: ")); jobInfo.Append(string.Format("{0} ({1})", jobInstance.Job.Name, jobInstance.Job.Id)); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Queue Request: ")); jobInfo.Append(string.Format("{0} ({1})", jobInstance.QueueRequest.InvocationSourceType, jobInstance.QueueRequest.Id)); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Instance: ")); jobInfo.Append(jobInstance.Id); jobInfo.Append(HtmlBuilder.GetLineBreak()); } if (jobStepInstance == null) { jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Step:") + " N/A"); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Step Instance:") + " N/A"); jobInfo.Append(HtmlBuilder.GetLineBreak()); } else { jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Step: ")); jobInfo.Append(string.Format("{0} ({1})", jobStepInstance.JobStep.Name, jobStepInstance.JobStep.Id)); jobInfo.Append(HtmlBuilder.GetLineBreak()); jobInfo.Append(HtmlBuilder.WrapInBoldTags("Job Step Instance: ")); jobInfo.Append(jobStepInstance.Id); jobInfo.Append(HtmlBuilder.GetLineBreak()); } jobInfo.Append(HtmlBuilder.GetLineBreak()); return(jobInfo.ToString()); }