Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public static void WriteByParallelTaskContext(Exception ex, DataSource dataSource, string customMessage = null)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(customMessage))
                {
                    ex = new Exception(customMessage, ex);
                }

                NotifyViaMail(ex);

                WriteByParallelTaskContext(LogEntryType.Error, dataSource, ExceptionFormatter.Format(ex));
            }
            catch (Exception thrownException)
            {
                WriteExceptionToLog(thrownException);
            }
        }
Ejemplo n.º 3
0
        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)); });
        }