/// <summary> /// Logs the tagging message. /// </summary> /// <param name="documents">The documents.</param> /// <param name="isSuccess">if set to <c>true</c> [is success].</param> /// <param name="message">The message.</param> private void LogTaggingMessage(IEnumerable <DocumentDetail> documents, bool isSuccess, string message) { try { var logs = documents.Select(document => new JobWorkerLog <LawImportTaggingLogInfo> { JobRunId = (!string.IsNullOrEmpty(PipelineId)) ? Convert.ToInt64(PipelineId) : 0, CorrelationId = (!string.IsNullOrEmpty(document.CorrelationId)) ? Convert.ToInt64(document.CorrelationId) : 0, WorkerInstanceId = WorkerId, WorkerRoleType = TaggingWorkerRoleType, Success = isSuccess, LogInfo = new LawImportTaggingLogInfo() { DCN = document.document.DocumentControlNumber, CrossReferenceField = document.document.CrossReferenceFieldValue, DocumentId = document.document.DocumentId, Message = message, Information = !isSuccess ? string.Format("{0} for DCN:{1}", message, document.document.DocumentControlNumber) : message } }).ToList(); LogPipe.ShouldNotBe(null); var logMessage = new PipeMessageEnvelope { Body = logs }; LogPipe.Send(logMessage); } catch (Exception ex) { ReportToDirector(ex.ToUserString()); ex.Trace().Swallow(); } }
/// <summary> /// Processes the work item. pushes give document files for conversion /// </summary> /// <param name="message">The message.</param> protected override void ProcessMessage(PipeMessageEnvelope message) { if (message == null || message.Body == null) { return; } var docCollection = message.Body as ConversionDocCollection; if (docCollection == null || docCollection.Documents == null || !docCollection.Documents.Any()) { return; //nothing to process } //initial converterAdapter. Near native conversion priority assume to be the same for all documents. //need to pass job id to adapter if (ConverterAdapter == null) { ConverterAdapter = new NearNativeConversionAdapter(true, WorkAssignment.JobId.ToString(CultureInfo.InvariantCulture), BootObject.NearNativeConversionPriority, Constants.BulkReProcessConversionContext); } ImportReconvert(docCollection); SendMessage(message); #endregion Loop through documents and push for conversion }
protected override void ProcessMessage(PipeMessageEnvelope message) { try { var recordInfo = (ProjectDocumentRecordInfo)message.Body; recordInfo.ShouldNotBe(null); _docStart = recordInfo.StartNumber; _docEnd = recordInfo.EndNumber; var projectDocumentDataList = GetDocuments(); if (projectDocumentDataList == null) { return; } SetDocumentIndexStatusAndContentSize(projectDocumentDataList); Send(projectDocumentDataList); IncreaseProcessedDocumentsCount(projectDocumentDataList.Count()); //Progress Status } catch (Exception ex) { ex.Trace().Swallow(); ReportToDirector(ex); } }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { try { if (null != envelope && null != envelope.Body) { var documentCollection = envelope.Body as DocumentCollection; if (null != documentCollection) { var documentDetails = documentCollection.documents; if (documentDetails == null || !documentDetails.Any()) { Tracer.Warning("Tag Comment Worker: No documents in the document collection."); return; } ProcessTagsAndComments(documentDetails); Send(envelope); IncreaseProcessedDocumentsCount(documentDetails.Count); } } } catch (Exception ex) { ex.Trace().Swallow(); ReportToDirector(ex); } }
/// <summary> /// Sends the specified document batch to next worker in the pipeline. /// </summary> /// <param name="docBatch">The document batch.</param> /// <param name="docCollection">The original document collection.</param> private void SendImportReconversionBatch(List <ReconversionDocumentBEO> docBatch, ConversionDocCollection docCollection) { //create new message for the batcha and send var newDocCollection = new ConversionDocCollection(); newDocCollection.BaseJobConfig = docCollection.BaseJobConfig; newDocCollection.BaseJobTypeId = docCollection.BaseJobTypeId; newDocCollection.DataSet = docCollection.DataSet; newDocCollection.Documents = docBatch; //use the docBatch for this message newDocCollection.HeartbeatFilePath = docCollection.HeartbeatFilePath; newDocCollection.JobConfig = docCollection.JobConfig; var message = new PipeMessageEnvelope { Body = newDocCollection }; //update processSet table's status BulkUpdateImportReprocessingState(newDocCollection); //send to specified output pipe Pipe outPipe = GetOutputDataPipe(Constants.OutputPipeNameToConversionReprocessImport); if (outPipe != null) { outPipe.Send(message); } }
/// <summary> /// Send Worker response to Pipe. /// </summary> /// <param name="recordList"></param> private void Send(List <LoadFileRecord> recordList) { // In case of append, assign the dcn for the documents here if (m_Parameters.IsAppend) { // Assign DCN AssignDocumentControlNumber(recordList); } var recordCollection = new LoadFileRecordCollection { Records = recordList, dataset = m_Dataset, UniqueThreadString = _uniqueThreadString }; OutputDataPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope { Body = recordCollection }; OutputDataPipe.Send(message); IncreaseProcessedDocumentsCount(recordList.Count); }
/// <summary> /// This method processes the pipe message and updates the document in Search Sub System /// </summary> /// <param name="envelope"></param> protected override void ProcessMessage(PipeMessageEnvelope envelope) { var documentRecords = envelope.Body as DocumentRecordCollection; Debug.Assert(documentRecords != null, "documentRecords != null"); documentRecords.Documents.Count.ShouldBeGreaterThan(0); documentRecords.ReviewsetDetails.ShouldNotBe(null); documentRecords.ReviewsetDetails.ReviewSetId.ShouldNotBeEmpty(); documentRecords.ReviewsetDetails.BinderId.ShouldNotBeEmpty(); try { UpdateDocuments(documentRecords); if (documentRecords.ReviewsetDetails.Activity == "Split") { Send(documentRecords); } else { Send(documentRecords.ReviewsetDetails); } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); LogMessage(false, string.Format("Error in IndexUpdateWorker - Exception: {0}", ex.ToUserString()), documentRecords.ReviewsetDetails.CreatedBy, documentRecords.ReviewsetDetails.ReviewSetName); } IncreaseProcessedDocumentsCount(documentRecords.Documents.Count); }
/// <summary> /// Generates the message. /// </summary> /// <returns></returns> protected override void ProcessMessage(PipeMessageEnvelope envelope) { var printCollection = (PrintDocumentCollection)envelope.Body; totalDocumentCount = printCollection.TotalDocumentCount; ValidateDocuments(printCollection.Documents); }
public void Send(PipeMessageEnvelope pipeMessage) { //Tracer.Trace("MSMQ Send({0})", messageQueue.Path); var msg = pipeMessage.GetMSMQMessage(); msg.Priority = MessagePriority.Normal; msg.Formatter = OverdriveMessageFormatter; if (trans) { //using (TransactionScope transaction = OverdriveTransactionScope.CreateInherited()) //{ // messageQueue.Send(msg, MessageQueueTransactionType.Automatic); // transaction.Complete(); //} // How about we pardon Send from participating in any ambient transaction? // MessageQueueTransactionType.None causes Send to fail silently, so it has to be set to MessageQueueTransactionType.Single _messageQueue.Send(msg, MessageQueueTransactionType.Single); } else { _messageQueue.Send(msg); } pipeMessage.Id = msg.Id; }
/// <summary> /// overrides base ProcessMessage method /// </summary> /// <param name="envelope"></param> protected override void ProcessMessage(PipeMessageEnvelope envelope) { var reviewsetRecord = (DocumentRecordCollection)envelope.Body; reviewsetRecord.ShouldNotBe(null); reviewsetRecord.ReviewsetDetails.CreatedBy.ShouldNotBeEmpty(); reviewsetRecord.Documents.ShouldNotBe(null); try { if (reviewsetRecord.DocumentTags == null || !reviewsetRecord.DocumentTags.Any()) { Send(reviewsetRecord); } else { UpdateTag(reviewsetRecord); Send(reviewsetRecord); } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); LogMessage(false, string.Format("Error in IndexTaggerWorker - Exception: {0}", ex.ToUserString()), reviewsetRecord.ReviewsetDetails.CreatedBy, reviewsetRecord.ReviewsetDetails.ReviewSetName); } }
private void Send(PipeMessageEnvelope message) { if (OutputDataPipe != null) { OutputDataPipe.Send(message); } }
/// <summary> /// overrides base ProcessMessage method /// </summary> /// <param name="envelope"></param> protected override void ProcessMessage(PipeMessageEnvelope envelope) { var reviewsetRecord = (DocumentRecordCollection)envelope.Body; reviewsetRecord.ShouldNotBe(null); reviewsetRecord.ReviewsetDetails.CreatedBy.ShouldNotBeEmpty(); reviewsetRecord.Documents.ShouldNotBe(null); _createdBy = reviewsetRecord.ReviewsetDetails.CreatedBy; if (EVHttpContext.CurrentContext == null) { // Moq the session MockSession(); } try { //stores converted document list var tempList = ConvertDocumentRecordtoReviewsetDocument(reviewsetRecord.Documents, reviewsetRecord.ReviewsetDetails); TagDocumentsNotReviewed(reviewsetRecord, tempList); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); LogMessage(false, string.Format("Error in VaultTaggerWorker - Exception: {0}", ex.ToUserString()), reviewsetRecord.ReviewsetDetails.CreatedBy, reviewsetRecord.ReviewsetDetails.ReviewSetName); } }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { if (null == envelope) { throw new ArgumentNullException("envelope"); } try { if (!FamiliesLinkingRequested && !IsOverlay) { Tracer.Error("Families linking was not requested, but families linker still got a message!\r\n" + " Label = {0}, Body is {1}", envelope.Label, (envelope.Body == null) ? "null" : envelope.Body.GetType().FullName); return; } if (envelope.Label == "EndOfDataMarker") { FinalizeRelationships(); return; } ProcessFamilyInfoRecordsFromOtherWorkers(envelope); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
protected override void ProcessMessage(PipeMessageEnvelope message) { var documentresultCollection = (NearDuplicationResultInfoCollection)message.Body; _documentsFields = new List <DocumentFieldsBEO>(); _documentsFieldsForSearchEngineUpdate = new Dictionary <string, List <KeyValuePair <string, string> > >(); foreach (var resultDocument in documentresultCollection.ResultDocuments) { ConstructDocumentFieldsForVault(resultDocument); ConstructDocumentFieldsForSearchEngineUpdate(resultDocument.DocumentId, _documentsFields.Where(f => f.DocumentReferenceId == resultDocument.DocumentId).ToList()); } //Add documents fields into Vault var databaseUpdateStaus = UpdateNearDuplicationFieldsInDatabase(); //Add documents fields into search engine var searchEngineUpdateStaus = UpdateNearDuplicationFieldsInSearchEngine(); if (!databaseUpdateStaus || !searchEngineUpdateStaus) { ConstructAndSendLog(documentresultCollection.ResultDocuments, databaseUpdateStaus, true); } IncreaseProcessedDocumentsCount(documentresultCollection.ResultDocuments.Count()); }
internal static Message GetMSMQMessage(this PipeMessageEnvelope pipeMessage) { Message MSMQMessage = new Message(); if (pipeMessage.CorrelationId != null) { MSMQMessage.CorrelationId = pipeMessage.CorrelationId; } if (pipeMessage.Label != null) { MSMQMessage.Label = pipeMessage.Label; } MSMQMessage.Body = pipeMessage.Body; MessageFlags appSpecific = MessageFlags.None; if (pipeMessage.IsPostback) { appSpecific |= MessageFlags.Postback; } MSMQMessage.AppSpecific = (int)appSpecific; // Debugging //long messageSize = Utils.BinSizeOf(pipeMessage.Body); //if (messageSize > 100000) //{ // Tracer.Trace( // "Message label = {0}, Message size = {1}", pipeMessage.Label, Utils.BinSizeOf(pipeMessage.Body)); //} return(MSMQMessage); }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { if (null == envelope) { throw new ArgumentNullException("envelope"); } try { if (!FamiliesLinkingRequested && !IsOverlay) { Tracer.Error("Families linking was not requested, but families linker still got a message!\r\n" + " Label = {0}, Body is {1}", envelope.Label, (envelope.Body == null) ? "null" : envelope.Body.GetType().FullName); return; } if (envelope.Label == "EndOfDataMarker") { FinalizeRelationships(); return; } ProcessFamilyInfoRecordsFromOtherWorkers(envelope); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
/// <summary> /// Processes the work item. /// </summary> /// <param name="message">The message.</param> protected override void ProcessMessage(PipeMessageEnvelope message) { try { DocumentCollection recordParserResponse = (DocumentCollection)message.Body; #region Assertion recordParserResponse.ShouldNotBe(null); recordParserResponse.documents.ShouldNotBe(null); #endregion if (_jobParameter.IsAppend) { throw new Exception(Constants.ErrorMessageInvalidPipeLine); } if (recordParserResponse == null) { return; } if (recordParserResponse.dataset != null) { _dataset = recordParserResponse.dataset; } if (recordParserResponse.documents != null && recordParserResponse.documents.Any()) { ProcessDocuments(recordParserResponse); } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
/// <summary> /// Construct the log and send it to log worker /// </summary> public void LogMessage(bool isError, string msg, string userGuid) { try { if (isError) { Tracer.Error(msg); } else { Tracer.Info(msg); return; } var logInfoList = new List <JobWorkerLog <TagLogInfo> > { ConstructTagLog(true, true, false, string.Empty, msg, WorkerRoletype, userGuid) }; LogPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope { Body = logInfoList }; LogPipe.Send(message); } catch (Exception ex) { ex.Trace().Swallow(); } }
/// <summary> /// overrides base ProcessMessage method /// </summary> /// <param name="envelope"></param> protected override void ProcessMessage(PipeMessageEnvelope envelope) { try { var reviewsetRecord = (DocumentRecordCollection)envelope.Body; reviewsetRecord.ShouldNotBe(null); reviewsetRecord.Documents.ShouldNotBe(null); reviewsetRecord.ReviewsetDetails.ShouldNotBe(null); reviewsetRecord.ReviewsetDetails.CreatedBy.ShouldNotBeEmpty(); reviewsetRecord.ReviewsetDetails.DatasetId.ShouldNotBe(0); reviewsetRecord.ReviewsetDetails.MatterId.ShouldNotBe(0); reviewsetRecord.ReviewsetDetails.SplitReviewSetId.ShouldNotBeEmpty(); reviewsetRecord.ReviewsetDetails.BinderId.ShouldNotBeEmpty(); _createdBy = reviewsetRecord.ReviewsetDetails.CreatedBy; _totalDocumentCount = reviewsetRecord.TotalDocumentCount; var removeTmpList = ConvertDocumentRecordtoReviewsetDocument(reviewsetRecord.Documents, reviewsetRecord.ReviewsetDetails.CreatedBy, reviewsetRecord.ReviewsetDetails.SplitReviewSetId); UnAssignReviewsetInVault(removeTmpList, reviewsetRecord.ReviewsetDetails.DatasetId); UnAssignReviewsetInSearchIndex(removeTmpList, reviewsetRecord.ReviewsetDetails); ////TODO: Search Engine Replacement - Search Sub System - Update ReviewSetId in search engine Send(reviewsetRecord); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { DocumentCollection documentCollection = null; #region Extract document details from incoming message object. documentCollection = envelope.Body as DocumentCollection; #region Assertion documentCollection.ShouldNotBe(null); #endregion try { //get the documents yet to converted List <ConversionDocumentBEO> documentsInConversionQueue = _nearNativeConverter.GetDocumentsQueuedForConversion(WorkAssignment.JobId); if (documentsInConversionQueue != null && documentsInConversionQueue.Any()) { //this is to avoid tight loop which consumes resources, especially network bandwidth int waitTime = GetConversionValidationWaitTime(documentsInConversionQueue); Thread.Sleep(waitTime); InputDataPipe.Purge(); // We don't need more than one "try again later" message in that pipe InputDataPipe.Send(envelope); } //IncreaseProcessedDocumentsCount(0); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
protected override void ProcessMessage(PipeMessageEnvelope message) { try { _exportDocumentCollection = (ExportDocumentCollection)message.Body; #region Assertion //Pre Condition PipelineId.ShouldNotBeEmpty(); BootParameters.ShouldNotBe(null); BootParameters.ShouldBeTypeOf <string>(); _exportDocumentCollection.ShouldNotBe(null); _exportDocumentCollection.Documents.ShouldNotBe(null); _exportDocumentCollection.Documents.LongCount().ShouldBeGreaterThan(0); #endregion if (_exportDocumentCollection == null || _exportDocumentCollection.Documents == null) { Tracer.Error("ExportOption Volume Worker: Document detail is not set in pipe message for job run id: {0}", PipelineId); return; } if (_volume == null) { InitializeForProcessing(BootParameters); } CalculateVolume(_exportDocumentCollection.Documents); } catch (Exception ex) { ex.Trace().Swallow(); ReportToDirector(ex); } }
/// <summary> /// Processes the work item. /// </summary> /// <param name="message">The message.</param> protected override void ProcessMessage(PipeMessageEnvelope message) { try { _parserResponse = (LoadFileRecordCollection)message.Body; #region Dataset Detaills if (_dataset == null) { _dataset = _parserResponse.dataset; if (_dataset != null && !string.IsNullOrEmpty(_dataset.CompressedFileExtractionLocation)) { _datasetPath = _dataset.CompressedFileExtractionLocation; } } if (String.IsNullOrEmpty(_uniqueThreadString)) { _uniqueThreadString = _parserResponse.UniqueThreadString; } #endregion ParseRecordText(); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); LogMessage(false, ex.ToUserString()); } }
protected override void ProcessMessage(PipeMessageEnvelope message) { try { if (message.Body == null) { return; } var lawDocumentsList = (LawSyncDocumentCollection)message.Body; if (_jobParameter == null) { if (lawDocumentsList.IsLawSyncReprocessJob) { _jobParameter = lawDocumentsList.OrginalJobParameter; } else { _jobParameter = (LawSyncBEO)XmlUtility.DeserializeObject(BootParameters, typeof(LawSyncBEO)); } } _redactableSetCollectionId = lawDocumentsList.RedactableSetCollectionId; _datasetExtractionPath = lawDocumentsList.DatasetExtractionPath; _datasetCollectionId = lawDocumentsList.DatasetCollectionId; _lawSyncJobId = lawDocumentsList.LawSynJobId; _logInfoList = new List <JobWorkerLog <LawSyncLogInfo> >(); _documentProcessStateList = new List <DocumentConversionLogBeo>(); var lawImagingDocuments = lawDocumentsList.Documents.Where(d => d.IsImaging).ToList(); if (_jobParameter.IsProduceImage && lawImagingDocuments.Any()) { var documentIds = lawImagingDocuments.Select(d => d.DocumentReferenceId).ToList(); _documentsBinaryList = GetNearNativeFileForDocuments(_jobParameter.MatterId, _redactableSetCollectionId, documentIds); foreach (var document in lawImagingDocuments) { SendDocumentForImaging(document); } } if (_documentProcessStateList.Any()) { UpdateDcoumentProcessState(_documentProcessStateList); } Send(lawDocumentsList); if (_logInfoList != null && _logInfoList.Any()) { SendLogPipe(_logInfoList); } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); LogMessage(Constants.LawSyncFailureinImagingMessage + ex.ToUserString()); } }
/// <summary> /// Process the message /// </summary> /// <param name="envelope">PipeMessageEnvelope</param> protected override void ProcessMessage(PipeMessageEnvelope envelope) { var printCollection = (PrintDocumentCollection)envelope.Body; InitializeForProcessing(BootParameters); _mTotalDocumentCount = printCollection.TotalDocumentCount; ProcessTheDocument(printCollection.Documents); }
/// <summary> /// Processes the work item. /// </summary> /// <param name="message">The message.</param> protected override void ProcessMessage(PipeMessageEnvelope message) { var documentCollection = (LawDocumentCollection)message.Body; documentCollection.ShouldNotBe(null); documentCollection.Documents.ShouldNotBe(null); _dataset = documentCollection.Dataset; try { var documentDetailList = new List <DocumentDetail>(); var logs = new List <JobWorkerLog <LawImportLogInfo> >(); var docManager = new LawDocumentManager(_jobParams, PipelineId, WorkerId, _dataset); foreach (var doc in documentCollection.Documents) { JobWorkerLog <LawImportLogInfo> log; var docs = docManager.GetDocuments(doc.LawDocumentId.ToString(CultureInfo.InvariantCulture), doc.DocumentControlNumber, doc, out log); if (docs != null) { documentDetailList.AddRange(docs); } if (log != null) { logs.Add(log); } } //Log messages for missing native, missing images and missing text if (logs.Any()) { SendLog(logs); } if (_jobParams.ImportOptions == ImportOptionsBEO.AppendNew) { Send(documentDetailList); SendThreads(documentDetailList); SendFamilies(documentDetailList); return; } //Process documents for overlay scenario if (documentDetailList.Any()) { ProcessDocuments(documentDetailList); SendThreads(documentDetailList); SendFamilies(documentDetailList); } } catch (Exception ex) { ReportToDirector(ex.ToUserString()); ex.Trace().Swallow(); LogErrorMessage(documentCollection.Documents, false, ProcessFailedMessage); } }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLog(List <JobWorkerLog <EdLoaderParserLogInfo> > log) { var message = new PipeMessageEnvelope { Body = log }; LogPipe.Send(message); }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLog(List <JobWorkerLog <ExportFileCopyLogInfo> > log) { var message = new PipeMessageEnvelope() { Body = log }; LogPipe.Send(message); }
/// <summary> /// Sends the specified job details. /// </summary> /// <param name="jobDetails">The job details.</param> private void Send(List <ProductionDocumentDetail> jobDetails) { var message = new PipeMessageEnvelope() { Body = jobDetails }; OutputDataPipe.Send(message); }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLogPipe(List <JobWorkerLog <LawSyncLogInfo> > log) { LogPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope { Body = log }; LogPipe.Send(message); }
/// <summary> /// Send Worker response to Pipe. /// </summary> private void Send(LawSyncDocumentCollection documentCollection) { var message = new PipeMessageEnvelope { Body = documentCollection }; OutputDataPipe.Send(message); IncreaseProcessedDocumentsCount(documentCollection.Documents.Count); }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLog(List <JobWorkerLog <OverlaySearchLogInfo> > log) { var message = new PipeMessageEnvelope() { Body = log }; LogPipe.Send(message); }
/// <summary> /// Send Message /// </summary> private void SendMessage() { // We get here if Completed() is called for the first time. // Need to send special message to DeleteProjectCleanup worker. var pipelineSection = FindPipelineSection("DeleteProjectCleanup"); var dataPipeName = pipelineSection.DataPipeName; using (var dataPipe = new Pipe(dataPipeName)) { dataPipe.Open(); var envelope = new PipeMessageEnvelope() { Label = "PleaseCleanup" }; dataPipe.Send(envelope); } _finalizationRequested = true; }
protected override void ProcessMessage(PipeMessageEnvelope envelope) { if (null == envelope) { throw new ArgumentNullException("envelope"); } try { if (!ThreadsLinkingRequested && !IsOverlay) { Tracer.Error("Threads linking was not requested, but threads linker still got a message!\r\n" + " Label = {0}, Body is {1}", envelope.Label, (envelope.Body == null) ? "null" : envelope.Body.GetType().FullName); return; } if (envelope.Label == "EndOfDataMarker") { FinalizeRelationships(); if (FamiliesLinkingRequested || IsOverlay) { // When both linkings are requested it is responsibility of threads linker // to tell to family linker when it can finalize the data SendEndOfDataMarkerToFamiliesLinker(); } return; } var threadsInfo = envelope.Body as ThreadsInfo; if (threadsInfo != null) { //Tracer.Warning("Starting intermediate threads calculations"); var threadsCalculationResults = _threadsProcessor.ProcessThreadsInfo(threadsInfo); resultsAccumulator.Append(threadsCalculationResults); // Plan B: we don't do intermediate production now. //Tracer.Warning("Starting intermediate threads production"); //ProduceThreadsRecords(threadsCalculationResults); //Tracer.Warning("Finished intermediate threads production"); } } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); } }
/// <summary> /// Processes the work item. /// </summary> /// <param name="message">The message.</param> protected override void ProcessMessage(PipeMessageEnvelope message) { var documentCollection = (LawDocumentCollection)message.Body; documentCollection.ShouldNotBe(null); documentCollection.Documents.ShouldNotBe(null); _dataset = documentCollection.Dataset; try { var documentDetailList = new List<DocumentDetail>(); var logs = new List<JobWorkerLog<LawImportLogInfo>>(); var docManager = new LawDocumentManager(_jobParams, PipelineId, WorkerId, _dataset); foreach (var doc in documentCollection.Documents) { JobWorkerLog<LawImportLogInfo> log; var docs = docManager.GetDocuments(doc.LawDocumentId.ToString(CultureInfo.InvariantCulture), doc.DocumentControlNumber, doc, out log); if (docs != null) documentDetailList.AddRange(docs); if (log != null) logs.Add(log); } //Log messages for missing native, missing images and missing text if (logs.Any()) SendLog(logs); if (_jobParams.ImportOptions == ImportOptionsBEO.AppendNew) { Send(documentDetailList); SendThreads(documentDetailList); SendFamilies(documentDetailList); return; } //Process documents for overlay scenario if (documentDetailList.Any()) { ProcessDocuments(documentDetailList); SendThreads(documentDetailList); SendFamilies(documentDetailList); } } catch (Exception ex) { ReportToDirector(ex.ToUserString()); ex.Trace().Swallow(); LogErrorMessage(documentCollection.Documents, false, ProcessFailedMessage); } }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLog(List<JobWorkerLog<LawImportLogInfo>> log) { LogPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope { Body = log }; LogPipe.Send(message); }
private void SendThreads(ThreadsInfo threadsInfo) { if (threadsInfo == null || threadsInfo.ThreadInfoList == null || !threadsInfo.ThreadInfoList.Any()) { return; } Pipe familiesAndThreadsPipe = GetOutputDataPipe("ThreadsLinker"); familiesAndThreadsPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope() { Body = threadsInfo }; familiesAndThreadsPipe.Send(message); }
private void SendFamilies(FamiliesInfo familiesInfo) { if (familiesInfo == null || familiesInfo.FamilyInfoList == null || !familiesInfo.FamilyInfoList.Any()) { return; } Pipe familiesAndThreadsPipe = GetOutputDataPipe("FamiliesLinker"); familiesAndThreadsPipe.ShouldNotBe(null); var message = new PipeMessageEnvelope() { Body = familiesInfo }; familiesAndThreadsPipe.Send(message); }
/// <summary> /// Logs the error message. /// </summary> /// <param name="documents">The documents.</param> /// <param name="isSuccess">if set to <c>true</c> [is success].</param> /// <param name="message">The message.</param> private void LogErrorMessage(IEnumerable<RVWDocumentBEO> documents, bool isSuccess, string message) { try { var logs = documents.Select(document => new JobWorkerLog<LawImportLogInfo> { JobRunId = (!string.IsNullOrEmpty(PipelineId)) ? Convert.ToInt64(PipelineId) : 0, WorkerInstanceId = WorkerId, WorkerRoleType = Constants.LawImportStartupWorkerRoleType, Success = isSuccess, LogInfo = new LawImportLogInfo() { DCN = document.DocumentControlNumber, CrossReferenceField = document.CrossReferenceFieldValue, DocumentId = document.DocumentId, Message = message, Information = !isSuccess ? string.Format("{0} for DCN:{1}", message, document.DocumentControlNumber) : message } }).ToList(); LogPipe.ShouldNotBe(null); var logMessage = new PipeMessageEnvelope { Body = logs }; LogPipe.Send(logMessage); } catch (Exception ex) { ReportToDirector(ex.ToUserString()); ex.Trace().Swallow(); } }
private void ProcessFamilyInfoRecordsFromOtherWorkers(PipeMessageEnvelope envelope) { var familiesInfo = envelope.Body as FamiliesInfo; if (familiesInfo != null) { familiesProcessor.ProcessFamiliesInfo(familiesInfo); } }
public void Send(PipeMessageEnvelope pipeMessage) { //Tracer.Trace("MSMQ Send({0})", messageQueue.Path); var msg = pipeMessage.GetMSMQMessage(); msg.Priority = MessagePriority.Normal; msg.Formatter = OverdriveMessageFormatter; if (trans) { //using (TransactionScope transaction = OverdriveTransactionScope.CreateInherited()) //{ // messageQueue.Send(msg, MessageQueueTransactionType.Automatic); // transaction.Complete(); //} // How about we pardon Send from participating in any ambient transaction? // MessageQueueTransactionType.None causes Send to fail silently, so it has to be set to MessageQueueTransactionType.Single _messageQueue.Send(msg, MessageQueueTransactionType.Single); } else { _messageQueue.Send(msg); } pipeMessage.Id = msg.Id; }
/// <summary> /// Send Log to Log Worker. /// </summary> /// <param name="log"></param> private void SendLog(List<JobWorkerLog<OverlaySearchLogInfo>> log) { var message = new PipeMessageEnvelope { Body = log }; LogPipe.Send(message); }
private void SendEndOfDataMarkerToFamiliesLinker() { var familiesAndThreadsPipe = GetOutputDataPipe("FamiliesLinker"); var message = new PipeMessageEnvelope {Label = "EndOfDataMarker"}; if (familiesAndThreadsPipe != null) { familiesAndThreadsPipe.Send(message); } }
/// <summary> /// Send data to Data pipe /// </summary> /// <param name="docDetails"></param> private void Send(List<DocumentDetail> docDetails) { var documentList = new DocumentCollection { documents = docDetails, dataset = _dataset, IsDeleteTagsForOverlay = false, IsIncludeNativeFile = _isIncludeNativeFile }; var message = new PipeMessageEnvelope { Body = documentList }; OutputDataPipe.Send(message); IncreaseProcessedDocumentsCount(docDetails.Count); }