Esempio n. 1
0
        } // End UpdateJobExecutionStatus()

        #endregion



        #region OtherMethods
        /// <summary>
        /// This method is used to Get the Details of a Job SubScription Details.
        /// </summary>
        /// <param name="JobID">Unique Identifier for a job</param>
        /// <returns>JobBusinessEntity</returns>
        public static JobBusinessEntity GetJobSubScriptionDetails(string jobID)
        {
            bool result; int returnFlag;
            JobBusinessEntity jobBEO;
            // Create a new instance of the DB manager.
            EVDbManager DBManager = new EVDbManager();

            DbCommand dbCommand = DBManager.GetStoredProcCommand(Constants.GetJobSubscriptionDetails);

            DBManager.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, Convert.ToInt32(jobID));
            DBManager.AddOutParameter(dbCommand, Constants.JobReturnFlagOutParameter, DbType.Int32, 4);

            DataSet dsJobs = DBManager.ExecuteDataSet(dbCommand);

            jobBEO = new JobBusinessEntity();
            result = Int32.TryParse(DBManager.GetParameterValue(dbCommand, Constants.JobReturnFlagOutParameter).ToString(), NumberStyles.Integer, null, out returnFlag);
            if (result)
            {
                if (dsJobs != null && dsJobs.Tables.Count > 0 && dsJobs.Tables[0].Rows.Count > 0)
                {
                    DataRow job = dsJobs.Tables[0].Rows[0];
                    jobBEO.Type       = !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeId]) ? Convert.ToInt32(job[Constants.PropertyNameSubscriptionTypeId]) : 0;
                    jobBEO.TypeName   = !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeName]) ? job[Constants.PropertyNameSubscriptionTypeName].ToString() : string.Empty;
                    jobBEO.FolderID   = Convert.ToInt64(job[Constants.PropertyNameFolderId]);
                    jobBEO.FolderName = job[Constants.PropertyNameFolderName].ToString();
                    jobBEO.Visibility = Convert.ToBoolean(job[Constants.PropertyNameVisibility]);
                    jobBEO.Priority   = Convert.ToInt32(job[Constants.PropertyNamePriority]);
                    jobBEO.Name       = !Convert.IsDBNull(job[Constants.PropertyNameJobName]) ? job[Constants.PropertyNameJobName].ToString() : string.Empty;
                }
            }
            return(jobBEO);
        }
Esempio n. 2
0
        public JobBusinessEntity GetJobSubScriptionDetails(int jobId)
        {
            var jobSubScriptionDetails = new JobBusinessEntity();

            try
            {
                lock (_db)
                {
                    int returnFlag;
                    var dbCommand = _db.GetStoredProcCommand(Constants.GetJobSubscriptionDetails);

                    _db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
                    _db.AddOutParameter(dbCommand, Constants.JobReturnFlagOutParameter, DbType.Int32, 4);

                    var dsJobs = _db.ExecuteDataSet(dbCommand);
                    var result =
                        Int32.TryParse(
                            _db.GetParameterValue(dbCommand, Constants.JobReturnFlagOutParameter).ToString(),
                            NumberStyles.Integer, null, out returnFlag);
                    if (result)
                    {
                        if (null != dsJobs &&
                            dsJobs.Tables.Count > 0 &&
                            dsJobs.Tables[0].Rows.Count > 0)
                        {
                            var job = dsJobs.Tables[0].Rows[0];
                            jobSubScriptionDetails.Type =
                                !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeId])
                                    ? Convert.ToInt32(job[Constants.PropertyNameSubscriptionTypeId])
                                    : 0;
                            jobSubScriptionDetails.TypeName =
                                !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeName])
                                    ? job[Constants.PropertyNameSubscriptionTypeName].ToString()
                                    : string.Empty;
                            jobSubScriptionDetails.FolderID   = Convert.ToInt64(job[Constants.PropertyNameFolderId]);
                            jobSubScriptionDetails.FolderName = job[Constants.PropertyNameFolderName].ToString();
                            jobSubScriptionDetails.Visibility =
                                Convert.ToBoolean(job[Constants.PropertyNameVisibility]);
                            jobSubScriptionDetails.Priority = Convert.ToInt32(job[Constants.PropertyNamePriority]);
                            jobSubScriptionDetails.Name     = !Convert.IsDBNull(job[Constants.PropertyNameJobName])
                                                              ? job[Constants.PropertyNameJobName].ToString()
                                                              : string.Empty;
                        }
                    }
                    return(jobSubScriptionDetails);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error("Failed to get the job subscription details for Job Id: {0}.", jobId);
                ex.Trace();
                return(jobSubScriptionDetails);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Before job shuts down, shall update job next run
 /// </summary>
 /// <param name="jobParameters">Job Business Object</param>
 protected override void Shutdown(BaseJobBEO jobParameters)
 {
     try
     {
         EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_ShutDown, EventLogEntryType.Information);
         #region Notification section
         //get job details
         JobBusinessEntity jobDetails = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString(CultureInfo.InvariantCulture));
         if (jobDetails != null && jobDetails.NotificationId > 0)
         {
             string defaultMessage = string.Empty;
             defaultMessage            = _isJobFailed ? string.Format(Constants.NotificationErrorMessageFormat, !string.IsNullOrEmpty(_requestDescription) ? _requestDescription : Constants.TaskName) : string.Format(Constants.NotificationSuccessMessageFormat, _requestDescription, _documentCount, ApplicationConfigurationManager.GetValue(Constants.CaseMapUrl), _conversionId.ToString());
             CustomNotificationMessage = defaultMessage;
         }
         #endregion
         JobLogInfo.AddParameters(Constants.CreatedBy, jobParameters.JobScheduleCreatedBy);
         JobLogInfo.AddParameters(Constants.DocumentIncludedInXml, Convert.ToString(_documentCount));
         JobLogInfo.AddParameters(Constants.TaskStartTime, Convert.ToString(startedTime));
         JobLogInfo.AddParameters(Constants.TaskEndTime, Convert.ToString(DateTime.UtcNow));
     }
     catch (EVJobException ex)
     {
         EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
         throw;
     }
     catch (Exception ex)
     {
         _isJobFailed = true;
         // Handle exception in Generate Tasks
         EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
         EVJobException jobException = new EVJobException(ErrorCodes.DoAtomicError, ex);
         JobLogInfo.AddParameters(Constants.JobRunId, jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture));
         jobException.LogMessge = JobLogInfo;
         throw (jobException);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Get Job Task Log Details.
        /// </summary>
        /// <param name="jobId">Job Identifier</param>
        /// <param name="jobRunId">Job Run Identifier</param>
        /// <param name="taskId">Task Identifier</param>
        /// <returns>LogInfo Xml</returns>
        public static string GetLogDetails(int jobId, int jobRunId, int taskId)
        {
            EVDbManager DBManager = new EVDbManager();
            DbCommand   dbCommand = DBManager.GetStoredProcCommand(Constants.GetLogDetailsProcedure);

            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterJobId, DbType.Int32, jobId);
            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterJobRunId, DbType.Int32, jobRunId);
            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterTaskId, DbType.Int32, taskId);
            DBManager.AddOutParameter(dbCommand, Constants.ParamOutTotalNoOfRecord, DbType.Int32, 4);
            JobBusinessEntity jobBeo = new JobBusinessEntity();
            DataSet           dsJobs = DBManager.ExecuteDataSet(dbCommand);
            int totalNoOfRecords     = Convert.ToInt32(DBManager.GetParameterValue(dbCommand, Constants.ParamOutTotalNoOfRecord), CultureInfo.CurrentCulture);

            if (totalNoOfRecords == -1)
            {
                return(string.Empty);
            }
            if (dsJobs != null && dsJobs.Tables.Count > 0 && dsJobs.Tables[0].Rows.Count > 0)
            {
                return(Convert.IsDBNull(dsJobs.Tables[0].Rows[0][Constants.LogInformation]) ? string.Empty : Convert.ToString(dsJobs.Tables[0].Rows[0][Constants.LogInformation]));
            }

            return(string.Empty);
        }
Esempio n. 5
0
        /// <summary>
        /// Generate part of notification message common to all events during bulk tagging
        /// </summary>
        /// <param name="bulkTagRecord"></param>
        /// <param name="notificationMessage"></param>
        private static void GenerateGeneralNotificationDetailsForReviewerBulkTagJob
            (ActiveJob job, BulkTagJobBusinessEntity bulkTagJobBeo, StringBuilder notificationMessage, JobBusinessEntity jobBeo)
        {
            notificationMessage.Append(Row);
            notificationMessage.Append(Column);
            notificationMessage.Append(HtmlBold);
            notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageStartTime));
            notificationMessage.Append(HtmlCloseBold);

            notificationMessage.Append(HttpUtility.HtmlEncode(jobBeo.JobScheduleStartDate.ConvertToUserTime()));

            notificationMessage.Append(CloseColumn);
            notificationMessage.Append(CloseRow);
            notificationMessage.Append(Row);
            notificationMessage.Append(Column);
            notificationMessage.Append(HtmlBold);
            notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageEndTime));
            notificationMessage.Append(HtmlCloseBold);

            notificationMessage.Append(HttpUtility.HtmlEncode(jobBeo.JobCompletedDate.ConvertToUserTime()));

            notificationMessage.Append(CloseColumn);
            notificationMessage.Append(CloseRow);
            notificationMessage.Append(Row);
            notificationMessage.Append(Column);
            notificationMessage.Append(HtmlBold);
            notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageLocation));
            notificationMessage.Append(HtmlCloseBold);


            notificationMessage.Append(HttpUtility.HtmlEncode(GetTaggingLocation(bulkTagJobBeo)));


            notificationMessage.Append(CloseColumn);
            notificationMessage.Append(CloseRow);

            notificationMessage.Append(Row);
            notificationMessage.Append(Column);
            notificationMessage.Append(HtmlBold);
            notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageTagName));
            notificationMessage.Append(HtmlCloseBold);

            notificationMessage.Append(HttpUtility.HtmlEncode(bulkTagJobBeo.TagDetails.Name));

            notificationMessage.Append(CloseColumn);
            notificationMessage.Append(CloseRow);
        }
Esempio n. 6
0
        private static string ConstructNotificationBodyForReviewerBulkTag
            (ActiveJob activeJob, BulkTagJobBusinessEntity bulkTagJobBeo, TagLogBEO tagLogBeo, JobBusinessEntity jobBeo)
        {
            //Add notification message to be sent
            var notificationMessage = new StringBuilder();

            notificationMessage.Append(Table);

            if (bulkTagJobBeo.IsOperationTagging)
            {
                notificationMessage.Append(Row);
                notificationMessage.Append(Header);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageHeadingForTagging));
                notificationMessage.Append(CloseHeader);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTagging));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);

                GenerateGeneralNotificationDetailsForReviewerBulkTagJob(activeJob, bulkTagJobBeo, notificationMessage, jobBeo);

                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.DocumentTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsAlreadyTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.AlreadyTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsFailed));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.FailedTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
            }
            else
            {
                notificationMessage.Append(Row);
                notificationMessage.Append(Header);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageHeadingForUntagging));
                notificationMessage.Append(CloseHeader);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntagging));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);

                GenerateGeneralNotificationDetailsForReviewerBulkTagJob(activeJob, bulkTagJobBeo, notificationMessage, jobBeo);

                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntaggingDocumentsUnTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.DocumentTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntaggingDocumentsNotUntagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(
                        (tagLogBeo.FailedTag + tagLogBeo.AlreadyTag).ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
            }

            notificationMessage.Append(CloseTable);
            return(notificationMessage.ToString());
        }
Esempio n. 7
0
        /// <summary>
        /// This method is responsible to construct the Notification subject and Notification Body for the message to be delivered
        /// </summary>
        /// <param name="job"></param>
        /// <param name="jobStatus"></param>
        /// <param name="notificationMessageBeo"></param>
        /// <param name="message"></param>
        private static void ConstructBulkTagNotification(ActiveJob job, Director.JobStatus jobStatus,
                                                         NotificationMessageBEO notificationMessageBeo, JobBusinessEntity jobDetails, string notificationMessage)
        {
            var stream         = new StringReader(job.Beo.BootParameters);
            var xmlStream      = new XmlSerializer(typeof(BulkTagJobBusinessEntity));
            var bootParameters = xmlStream.Deserialize(stream) as BulkTagJobBusinessEntity;

            stream.Close();

            var message = new StringBuilder();

            message.Append(string.IsNullOrEmpty(jobDetails.TypeName) ? string.Empty : " Type: ");
            message.Append(jobDetails.Visibility
                               ? jobDetails.TypeName
                               : jobDetails.TypeName.Replace("Job", "Task"));
            message.Append("<br/>");
            message.Append(jobDetails.Name);
            if (job.Beo != null)
            {
                message.Append(" Instance: ");
                message.Append(job.Beo.JobRunId);
            }
            message.Append("<br/>");
            message.Append("Folder: ");
            message.Append(jobDetails.FolderName);
            message.Append(" ");
            message.Append("<br/>");
            message.Append("Status: ");
            message.Append(notificationMessage);

            if (null != bootParameters)
            {
                var tagLog = RVWTagBO.GetTagLog(Convert.ToInt32(bootParameters.TagDetails.DatasetId), job.JobId);

                if (jobStatus == Director.JobStatus.Completed)
                {
                    notificationMessageBeo.NotificationSubject = message.ToString().Replace("<br/>", "  ");
                    if (tagLog != null)
                    {
                        notificationMessageBeo.NotificationBody = ConstructNotificationBodyForReviewerBulkTag(job, bootParameters, tagLog, jobDetails);
                    }
                }
                else
                {
                    notificationMessageBeo.NotificationBody = notificationMessageBeo.NotificationSubject = message.ToString().Replace("<br/>", "  ");
                }
            }
            notificationMessageBeo.SendDefaultMessage = (jobStatus ==
                                                         Director.JobStatus.Completed);
        }
Esempio n. 8
0
        internal void SendNotifications(ActiveJob job, Director.JobStatus jobStatus, string notificationMessage)
        {
            if (DebugMode)
            {
                return;
            }
            try
            {
                if (null != job)
                {
                    JobBusinessEntity jobDetails = null;
                    var jobBusinessEntity        = JobMgmtBO.GetJobDetails(job.JobId.ToString());
                    var userName = jobBusinessEntity.CreatedBy;
                    jobDetails = job.BusinessEntity;
                    var userBusinessEntity = UserBO.GetUser(userName);

                    #region Construct the notification message object

                    NotificationMessageBEO notificationMessageBeo = null;
                    try
                    {
                        notificationMessageBeo = new NotificationMessageBEO
                        {
                            NotificationId    = job.Beo.JobNotificationId,
                            CreatedByUserGuid = userBusinessEntity.UserGUID,
                            CreatedByUserName =
                                (userBusinessEntity.DomainName.Equals(@"N/A"))
                                                                 ? userBusinessEntity.UserId
                                                                 : userBusinessEntity.DomainName + @"\" +
                                userBusinessEntity.UserId,
                            SubscriptionTypeName = jobDetails.TypeName,
                            FolderId             = jobDetails.FolderID
                        };
                    }
                    catch
                    {
                        Tracer.Error("Unable to construct notification message for Job Id: {0}", job.JobId);
                    }

                    #endregion

                    #region Call Notification API

                    if (null != jobDetails && null != notificationMessageBeo &&
                        ((0 != notificationMessageBeo.NotificationId ||
                          !string.IsNullOrEmpty(notificationMessageBeo.SubscriptionTypeName)) &&
                         !string.IsNullOrEmpty(notificationMessageBeo.CreatedByUserGuid)))
                    {
                        #region Construct notification message

                        var message = new StringBuilder();
                        message.Append(string.IsNullOrEmpty(jobDetails.TypeName) ? string.Empty : " Type: ");
                        message.Append(jobDetails.Visibility
                                           ? jobDetails.TypeName
                                           : jobDetails.TypeName.Replace("Job", "Task"));
                        message.Append("<br/>");
                        message.Append(jobDetails.Name);
                        if (job.Beo != null)
                        {
                            message.Append(" Instance: ");
                            message.Append(job.Beo.JobRunId);
                        }
                        message.Append("<br/>");
                        message.Append("Folder: ");
                        message.Append(jobDetails.FolderName);
                        message.Append(" ");
                        message.Append("<br/>");
                        message.Append("Status: ");
                        message.Append(notificationMessage);

                        #region Job type specific custom message

                        try
                        {
                            switch (job.JobTypeId)
                            {
                            case 14:     // Load File Job custom message as per FSD.
                            {
                                var stream         = new StringReader(job.Beo.BootParameters);
                                var xmlStream      = new XmlSerializer(typeof(ImportBEO));
                                var bootParameters = xmlStream.Deserialize(stream) as ImportBEO;
                                stream.Close();

                                if (null != bootParameters &&
                                    string.IsNullOrEmpty(bootParameters.NotificationMessage))
                                {
                                    if (bootParameters.IsAppend)
                                    {
                                        if (jobStatus == Director.JobStatus.Completed)
                                        {
                                            message.Append(NotificationMessageCustomLoadFileAppendSuccessMessage);
                                            message.Append(jobDetails.FolderName);
                                            message.Append(NotificationMessageCustomLoadFileAppendMessagePart2);
                                            message.Append(job.JobId.ToString());
                                        }
                                        else
                                        {
                                            message.Append(NotificationMessageCustomLoadFileAppendFailureMessage);
                                            message.Append(jobDetails.FolderName);
                                            message.Append(NotificationMessageCustomLoadFileAppendMessagePart2);
                                            message.Append(job.JobId.ToString());
                                        }
                                    }
                                    else
                                    {
                                        if (jobStatus == Director.JobStatus.Completed)
                                        {
                                            message.Append(
                                                NotificationMessageCustomLoadFileOverlaySuccessMessagePart1);
                                            message.Append(jobDetails.FolderName);
                                            message.Append(
                                                NotificationMessageCustomLoadFileOverlaySuccessMessagePart2);
                                            message.Append(job.JobId.ToString());
                                        }
                                        else
                                        {
                                            message.Append(
                                                NotificationMessageCustomLoadFileOverlayFailureMessagePart1);
                                            message.Append(jobDetails.FolderName);
                                            message.Append(
                                                NotificationMessageCustomLoadFileOverlayFailureMessagePart2);
                                            message.Append(job.JobId.ToString());
                                            message.Append(
                                                NotificationMessageCustomLoadFileOverlayFailureMessagePart3);
                                        }
                                    }
                                }
                            }
                                notificationMessageBeo.SendDefaultMessage = (jobStatus ==
                                                                             Director.JobStatus.Completed);
                                break;

                            case 16:     // Reviewer bulk tag job custom message as per FSD.
                                ConstructBulkTagNotification(job, jobStatus, notificationMessageBeo, jobBusinessEntity, notificationMessage);
                                break;

                            case 38:
                                message.Append(jobStatus == Director.JobStatus.Completed
                                                       ? ConstructNotificationMessageForConversionResultsExport(job)
                                                       : NotificationMessageCustomConversionResultsExportError);
                                break;

                            case 54:
                                if (jobStatus == Director.JobStatus.Completed)
                                {
                                    message.Append(ConstructNotificationMessageForExportAnalysisSetDocuments(job));
                                }
                                break;

                            case BillingReportJobTypeId:

                                message.Append(ConstructBillingReportNotificationMessage(job, jobStatus));
                                break;
                            }
                        }
                        catch
                        {
                            Tracer.Error("Unable to set custom notification message for Job Id:{0}", job.JobId);
                        }

                        #endregion

                        if (job.JobTypeId != 16)
                        {
                            notificationMessageBeo.NotificationSubject = message.ToString().Replace("<br/>", "  ");
                            notificationMessageBeo.NotificationBody    = message.ToString();
                        }


                        #endregion

                        #region Send notification message by invoking notifications API

                        try
                        {
                            if (!string.IsNullOrEmpty(notificationMessageBeo.NotificationBody))
                            {
                                NotificationBO.SendNotificationMessage(notificationMessageBeo);
                            }
                        }
                        catch
                        {
                            Tracer.Error("Unable to send notification message for Job Id: {0}", job.JobId);
                        }

                        #endregion
                        if (job.JobTypeId == 14 || job.JobTypeId == 16) // Load File Import
                        {
                            return;                                     //For Load File Import- Custom message will be sent by default notification message.
                        }
                        if (jobStatus == Director.JobStatus.Completed && job.Beo.JobNotificationId > 0)
                        {
                            var customNotify = new NotificationMessageBEO
                            {
                                NotificationId     = job.Beo.JobNotificationId,
                                SendDefaultMessage = true,
                                CreatedByUserGuid  = userBusinessEntity.UserGUID
                            };

                            NotificationBO.SendNotificationMessage(customNotify);
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                ex.AddUsrMsg("Unable to send notification message.").Trace().Swallow();
            }
        }
      /// <summary>
      /// Generate part of notification message common to all events during bulk tagging
      /// </summary>
      /// <param name="bulkTagRecord"></param>
      /// <param name="notificationMessage"></param>
      private static void GenerateGeneralNotificationDetailsForReviewerBulkTagJob
          (ActiveJob job, BulkTagJobBusinessEntity bulkTagJobBeo, StringBuilder notificationMessage, JobBusinessEntity jobBeo)
      {
          notificationMessage.Append(Row);
          notificationMessage.Append(Column);
          notificationMessage.Append(HtmlBold);
          notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageStartTime));
          notificationMessage.Append(HtmlCloseBold);

          notificationMessage.Append(HttpUtility.HtmlEncode(jobBeo.JobScheduleStartDate.ConvertToUserTime()));

          notificationMessage.Append(CloseColumn);
          notificationMessage.Append(CloseRow);
          notificationMessage.Append(Row);
          notificationMessage.Append(Column);
          notificationMessage.Append(HtmlBold);
          notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageEndTime));
          notificationMessage.Append(HtmlCloseBold);

          notificationMessage.Append(HttpUtility.HtmlEncode(jobBeo.JobCompletedDate.ConvertToUserTime()));

          notificationMessage.Append(CloseColumn);
          notificationMessage.Append(CloseRow);
          notificationMessage.Append(Row);
          notificationMessage.Append(Column);
          notificationMessage.Append(HtmlBold);
          notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageLocation));
          notificationMessage.Append(HtmlCloseBold);


          notificationMessage.Append(HttpUtility.HtmlEncode(GetTaggingLocation(bulkTagJobBeo)));


          notificationMessage.Append(CloseColumn);
          notificationMessage.Append(CloseRow);

          notificationMessage.Append(Row);
          notificationMessage.Append(Column);
          notificationMessage.Append(HtmlBold);
          notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageTagName));
          notificationMessage.Append(HtmlCloseBold);

          notificationMessage.Append(HttpUtility.HtmlEncode(bulkTagJobBeo.TagDetails.Name));

          notificationMessage.Append(CloseColumn);
          notificationMessage.Append(CloseRow);
      }
      private static string ConstructNotificationBodyForReviewerBulkTag
          (ActiveJob activeJob, BulkTagJobBusinessEntity bulkTagJobBeo, TagLogBEO tagLogBeo, JobBusinessEntity jobBeo)
        {
            //Add notification message to be sent
            var notificationMessage = new StringBuilder();
            notificationMessage.Append(Table);

            if (bulkTagJobBeo.IsOperationTagging)
            {
                notificationMessage.Append(Row);
                notificationMessage.Append(Header);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageHeadingForTagging));
                notificationMessage.Append(CloseHeader);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTagging));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);

                GenerateGeneralNotificationDetailsForReviewerBulkTagJob(activeJob, bulkTagJobBeo, notificationMessage, jobBeo);

                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.DocumentTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsAlreadyTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.AlreadyTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForTaggingDocumentsFailed));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.FailedTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
            }
            else
            {
                notificationMessage.Append(Row);
                notificationMessage.Append(Header);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageHeadingForUntagging));
                notificationMessage.Append(CloseHeader);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntagging));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);

                GenerateGeneralNotificationDetailsForReviewerBulkTagJob(activeJob, bulkTagJobBeo, notificationMessage, jobBeo);

                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntaggingDocumentsUnTagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(tagLogBeo.DocumentTag.ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
                notificationMessage.Append(Row);
                notificationMessage.Append(Column);
                notificationMessage.Append(HtmlBold);
                notificationMessage.Append(HttpUtility.HtmlEncode(NotificationMessageForUntaggingDocumentsNotUntagged));
                notificationMessage.Append(HtmlCloseBold);
                notificationMessage.Append(
                    HttpUtility.HtmlEncode(
                        (tagLogBeo.FailedTag + tagLogBeo.AlreadyTag).ToString(CultureInfo.InvariantCulture)));
                notificationMessage.Append(CloseColumn);
                notificationMessage.Append(CloseRow);
            }

            notificationMessage.Append(CloseTable);
            return notificationMessage.ToString();
        }
        /// <summary>
        /// This method is responsible to construct the Notification subject and Notification Body for the message to be delivered
        /// </summary>
        /// <param name="job"></param>
        /// <param name="jobStatus"></param>
        /// <param name="notificationMessageBeo"></param>
        /// <param name="message"></param>
        private static void ConstructBulkTagNotification(ActiveJob job, Director.JobStatus jobStatus,
            NotificationMessageBEO notificationMessageBeo, JobBusinessEntity jobDetails, string notificationMessage)
        {
            var stream = new StringReader(job.Beo.BootParameters);
            var xmlStream = new XmlSerializer(typeof(BulkTagJobBusinessEntity));
            var bootParameters = xmlStream.Deserialize(stream) as BulkTagJobBusinessEntity;
            stream.Close();

            var message = new StringBuilder();
            message.Append(string.IsNullOrEmpty(jobDetails.TypeName) ? string.Empty : " Type: ");
            message.Append(jobDetails.Visibility
                               ? jobDetails.TypeName
                               : jobDetails.TypeName.Replace("Job", "Task"));
            message.Append("<br/>");
            message.Append(jobDetails.Name);
            if (job.Beo != null)
            {
                message.Append(" Instance: ");
                message.Append(job.Beo.JobRunId);
            }
            message.Append("<br/>");
            message.Append("Folder: ");
            message.Append(jobDetails.FolderName);
            message.Append(" ");
            message.Append("<br/>");
            message.Append("Status: ");
            message.Append(notificationMessage);

            if (null != bootParameters)
            {
                var tagLog = RVWTagBO.GetTagLog(Convert.ToInt32(bootParameters.TagDetails.DatasetId), job.JobId);               

                if (jobStatus == Director.JobStatus.Completed)
                {
                    notificationMessageBeo.NotificationSubject = message.ToString().Replace("<br/>", "  ");
                    if (tagLog != null)
                    {
                        notificationMessageBeo.NotificationBody = ConstructNotificationBodyForReviewerBulkTag(job, bootParameters, tagLog, jobDetails);
                    }
                }
                else
                {
                    notificationMessageBeo.NotificationBody = notificationMessageBeo.NotificationSubject = message.ToString().Replace("<br/>", "  ");
                }
            }
            notificationMessageBeo.SendDefaultMessage = (jobStatus ==
                                                         Director.JobStatus.Completed);
        }