protected override bool Completed() { base.Completed(); try { var lawSyncSummary = LawBO.GetLawSyncProcessSetJobSummary(MatterId, JobId); var jobSummaryKeyValuePairs = new EVKeyValuePairs(); jobSummaryKeyValuePairs.Set("ImageFolder", SyncImage ? GetImageLocation() : "N/A"); jobSummaryKeyValuePairs.Set("ImageSyncFailureCount", SyncImage ? lawSyncSummary.ImageSyncFailureCount.ToString(CultureInfo.InvariantCulture) : "N/A"); jobSummaryKeyValuePairs.Set("MetadatSyncFailureCount", lawSyncSummary.MetadataSyncFailureCount.ToString(CultureInfo.InvariantCulture)); jobSummaryKeyValuePairs.Set("TotalDocument", (lawSyncSummary.LawSyncSuceessCount + lawSyncSummary.LawSyncFailureCount).ToString( CultureInfo.InvariantCulture)); JobMgmtBO.UpdateJobResult(JobId, lawSyncSummary.LawSyncSuceessCount, lawSyncSummary.LawSyncFailureCount, jobSummaryKeyValuePairs); } catch (Exception ex) { ex.Trace().Swallow(); } return(true); }
/// <summary> /// Construct Notification message for Export AnalysisSet Documents /// </summary> /// <param name="activeJob"></param> /// <returns></returns> private static string ConstructNotificationMessageForExportAnalysisSetDocuments(ActiveJob activeJob) { try { var stringBuilder = new StringBuilder(); var documentQuery = (DocumentQuery)XmlUtility.DeserializeObject(activeJob.Beo.BootParameters, typeof(DocumentQuery)); var dataset = DataSetBO.GetDataSetDetailForDataSetId(documentQuery.DatasetId); var jobInfo = JobMgmtBO.GetJobDetails(activeJob.JobId.ToString(CultureInfo.InvariantCulture)); var filePath = string.Format("{0}\\{1}{2}", dataset.CompressedFileExtractionLocation, jobInfo.Name, ".csv"); if (!string.IsNullOrEmpty(filePath)) { stringBuilder.Append(ConversionResultsExportFilePathOpenDiv); stringBuilder.Append(filePath); stringBuilder.Append(ConversionResultsExportFilePathCloseDiv); } stringBuilder.Append(AnalysissetDocumentsResultsImageTag); stringBuilder.Append(ConversionResultsDownloadLinkOpenAnchor); stringBuilder.Append(ConversionResultsExportDownloadHandler + activeJob.JobId.ToString(CultureInfo.InvariantCulture)); stringBuilder.Append(AnalysissetDocumentsResultsDownloadLinkText); stringBuilder.Append(ConversionResultsDownLoadLinkCloseAnchor); return(stringBuilder.ToString()); } catch (Exception ex) { ex.Trace().Swallow(); } return(string.Empty); }
/// <summary> /// Shutdown method will be called at end of the job /// </summary> /// <param name="jobParameters">Job Business Object</param> protected override void Shutdown(CompareSavedSearchResultsJobBEO jobParameters) { try { long reportId = 0; _encoder = _encodingType.Equals(Constants.UniCode, StringComparison.CurrentCultureIgnoreCase) ? (Encoding) new UnicodeEncoding() : new UTF8Encoding(); if (_fileType.Equals(Constants.FileTypeCsv, StringComparison.CurrentCultureIgnoreCase)) { //Writing generated report to Db reportId = SearchResultsBO.SaveExportResults(_searchResultsProperty.SearchResultId, _encoder.GetBytes(_reportString.ToString()), true, _fileType, _userEntityOfJobOwner.UserGUID); _reportString = null; } #region Notification section //Getting Job detail detail var jobBeo = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString(CultureInfo.InvariantCulture)); if (jobBeo.NotificationId > 0) { string defaultMessage; defaultMessage = _isJobFailed ? string.Format(Constants.FailureNotificationMessage, _searchResultsProperty.SearchResultsName) : string.Format(Constants.CompareReportMessage, _searchResultsProperty.SearchResultsName, ApplicationConfigurationManager.GetValue(Constants.ReportHandlerUrl) , Constants.CompareReport, _searchResultsProperty.SearchResultId, _fileType, reportId, _searchResultsProperty.DocumentQuery.QueryObject.DatasetId); CustomNotificationMessage = defaultMessage; } #endregion Notification section } catch (EVException ex) { WriteToEventViewer(ex, GetType(), MethodBase.GetCurrentMethod().Name, jobParameters.JobId, jobParameters.JobRunId); HandleJobException(null, ErrorCodes.ProblemInShutDown); } catch (Exception ex) { // Handle exception LogMessage(ex, GetType(), MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, jobParameters.JobId, jobParameters.JobRunId); HandleJobException(ex, ErrorCodes.ProblemInShutDown); } }
/// <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, Constants.Event_Job_ShutDown, EventLogEntryType.Information); #region Notification section //get job details var jobDetails = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString()); if (jobDetails != null && jobDetails.NotificationId > 0) { var defaultMessage = string.Empty; defaultMessage = isJobFailed ? string.Format(Constants.NotificationErrorMessageFormat, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName) : documentCount > 0 ? string.Format(Constants.NotificationSuccessMessageFormat, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName, documentCount, ApplicationConfigurationManager.GetValue(Constants.CaseMapUrl), conversionId, fileType) : string.Format(Constants.NotificationSuccessMessageFormatZeroDocs, !string.IsNullOrEmpty(requestDescription) ? requestDescription : Constants.TaskName); CustomNotificationMessage = defaultMessage; } JobLogInfo.AddParameters(Constants.CreatedBy, jobParameters.JobScheduleCreatedBy); JobLogInfo.AddParameters(Constants.DocumentIncludedInXml, Convert.ToString(documentCount)); #endregion } catch (EVJobException ex) { EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); LogException(JobLogInfo, ex, LogCategory.Job, ErrorCodes.ProblemInShutDown, string.Empty); } catch (Exception ex) { isJobFailed = true; // Handle exception in Generate Tasks EvLog.WriteEntry(Constants.JobTypeName + MethodBase.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error); LogException(JobLogInfo, ex, LogCategory.Job, ErrorCodes.ProblemInShutDown, string.Empty); } }
/// <summary> /// Begins the work. /// </summary> protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (AnalyticsProjectInfo)XmlUtility.DeserializeObject(BootParameters, typeof(AnalyticsProjectInfo)); _analyticProject = new AnalyticsProject(); _documentBachSize = Convert.ToInt32( ApplicationConfigurationManager.GetValue("IncludeDocumentsIntoProjectInSubSystemJobBatchSize", "AnalyticsProject")); _dataset = DataSetBO.GetDataSetDetailForDataSetId(Convert.ToInt64(_jobParameter.DatasetId, CultureInfo.CurrentCulture)); _jobParameter.DocumentSource.CollectionId = _dataset.CollectionId; _totalDocumentCount = _analyticProject.GetProjectDocumentsCountByTaskId( Convert.ToInt64(_jobParameter.MatterId, CultureInfo.CurrentCulture), _jobParameter.ProjectCollectionId, _jobParameter.PrimarySystemJobId); //Update job log initial state var jobSummaryKeyValuePairs = new EVKeyValuePairs(); JobMgmtBO.UpdateJobResult(WorkAssignment.JobId, 0, _totalDocumentCount, jobSummaryKeyValuePairs); if (_jobParameter.IsRerunJob || _jobParameter.IsAddAdditionalDocuments) //Rerun job or Add additional documents- need get to get existing IndexId ,if already created { _indexId = AnalyticsProject.GetIndexIdForProject(_jobParameter.MatterId, WorkAssignment.JobId, _dataset.CollectionId, _jobParameter.ProjectCollectionId, false); } if (string.IsNullOrEmpty(_indexId)) { _indexId = "idx-" + Guid.NewGuid().ToString().ToLowerInvariant(); _analyticProject.InsertIndexId(_jobParameter.MatterId, WorkAssignment.JobId, _dataset.CollectionId, _jobParameter.ProjectCollectionId, _indexId); } AnalyticsProject.CreateAnalyticalIndex(_jobParameter.MatterId, WorkAssignment.JobId, _indexId); //Create Index in Spark SVM.. IncreaseProcessedDocumentsCount(_totalDocumentCount); }
/// <summary> /// Begins the work. /// </summary> protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (AnalyticsProjectInfo)XmlUtility.DeserializeObject(BootParameters, typeof(AnalyticsProjectInfo)); _analyticProject = new AnalyticsProject(); _dataset = DataSetBO.GetDataSetDetailForDataSetId(Convert.ToInt64(_jobParameter.DatasetId, CultureInfo.CurrentCulture)); _totalDocumentCount = _analyticProject.GetSelectedDocumentsCount(_dataset.CollectionId, _jobParameter, WorkAssignment.JobId); //Update job log initial state var jobSummaryKeyValuePairs = new EVKeyValuePairs(); JobMgmtBO.UpdateJobResult(WorkAssignment.JobId, 0, _totalDocumentCount, jobSummaryKeyValuePairs); _documentBachSize = Convert.ToInt32(ApplicationConfigurationManager.GetValue("IncludeDocumentsIntoProjectJobBatchSize", "AnalyticsProject")); _jobParameter.DocumentSource.CollectionId = _dataset.CollectionId; IncreaseProcessedDocumentsCount(_totalDocumentCount); }
/// <summary> /// Before job shuts down, shall update job next run /// </summary> /// <param name="jobParameters">Job Business Object</param> protected override void Shutdown(SaveSearchResultsJobBEO jobParameters) { jobParameters.ShouldNotBe(null); LogMessage(Constants.ShutdownLogMessage, false, LogCategory.Job, null); var additionalDetails = new List <KeyValuePair <string, string> >(); var aditionalDetail = new KeyValuePair <string, string>(Constants.SearchDescription, _searchResultsProperty.SearchResultsDescription); additionalDetails.Add(aditionalDetail); aditionalDetail = new KeyValuePair <string, string>(Constants.SearchQuery, jobParameters.DocumentQuery.QueryObject.DisplayQuery); additionalDetails.Add(aditionalDetail); aditionalDetail = new KeyValuePair <string, string>(Constants.NoOfDocuments, _dcnList.Count.ToString(CultureInfo.InvariantCulture)); additionalDetails.Add(aditionalDetail); aditionalDetail = new KeyValuePair <string, string>(Constants.DocumentControlNumberList, string.Join(",", _dcnList.ToArray())); additionalDetails.Add(aditionalDetail); #region Notification section //Getting Job detail detail var jobBeo = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString(CultureInfo.InvariantCulture)); if (jobBeo.NotificationId > 0) { string defaultMessage; var nameEndIndex = jobBeo.Name.LastIndexOf(Constants.JobDateSeparator, StringComparison.Ordinal); var savedSearchResultName = nameEndIndex >= 0 ? jobBeo.Name.Substring(0, nameEndIndex) : jobBeo.Name; defaultMessage = string.Format(Constants.SuccessNotificationMessage, HttpUtility.HtmlEncode(savedSearchResultName), ApplicationConfigurationManager.GetValue(Constants.SaveSearchResultUrl)); CustomNotificationMessage = defaultMessage; } #endregion }
/// <summary> /// Perform shutdown activities for a job if any. /// </summary> /// <param name="jobParameters">Job input parameters / settings obtained during Initialize()</param> protected override void Shutdown(DeduplicationJobBEO jobParameters) { EvLog.WriteEntry(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EVENT_JOB_SHUTDOWN_KEY, EventLogEntryType.Information); #region LogDetails if (LogDetails != null) { LogDetails.NoOfDocAffected = (TaskCount - FailedTask); var strLogXml = CreateXMLPropertyString(LogDetails); var info = new LogInfo { CustomMessage = strLogXml }; LogJobMessage(info, true); } // Update Job master with the success and failure count JobMgmtBO.UpdateJobResult(_jobid, _successCount, _failureCount, null); #endregion }
/// <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); } }
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(); } }