/// <summary> /// Sets the document error. /// </summary> /// <param name="documentErrorCollection">The document error collection.</param> /// <param name="documentDetail">The document detail.</param> /// <param name="logInfo">The log information.</param> private static void SetDocumentError(DocumentErrorCollection documentErrorCollection, DocumentDetail documentDetail, SearchIndexLogInfo logInfo) { if (documentErrorCollection == null||documentErrorCollection.FailedDocumentCount==0) return; var documentError = documentErrorCollection.DocumentErrors.FirstOrDefault( d => documentDetail.document.DocumentId.Equals(d.Id, StringComparison.CurrentCultureIgnoreCase)); if (documentError != null) logInfo.Message = documentError.ErrorMessage; }
/// <summary> /// Sends the log. /// </summary> /// <param name="documentCollection">The document collection.</param> /// <param name="isSentForIndexing">if set to <c>true</c> [is sent for indexing].</param> /// <param name="documentErrorCollection"></param> private void SendLog(DocumentCollection documentCollection, bool isSentForIndexing,DocumentErrorCollection documentErrorCollection=null) { if (documentCollection == null || documentCollection.documents == null) return; var message = isSentForIndexing ? "Sent for indexing." : "Failed to send for indexing."; var nativeDocumentList = documentCollection.documents.FindAll( n => n.docType == DocumentsetType.NativeSet); if (!nativeDocumentList.Any()) return; var searchIndexLogInfos = new List<JobWorkerLog<SearchIndexLogInfo>>(); try { foreach (var documentDetail in nativeDocumentList) { if (documentDetail.document == null) continue; var logInfo = new SearchIndexLogInfo { Information = string.Format("DCN:{0}", documentDetail.document.DocumentControlNumber), DocumentId = documentDetail.document.DocumentId, DCNNumber = documentDetail.document.DocumentControlNumber, CrossReferenceField = documentDetail.document.CrossReferenceFieldValue, Message = message }; SetDocumentError(documentErrorCollection, documentDetail, logInfo); if (String.IsNullOrEmpty(documentDetail.CorrelationId)) { documentDetail.CorrelationId = "0"; } var searchIndexLogInfo = new JobWorkerLog<SearchIndexLogInfo> { JobRunId = Convert.ToInt32(PipelineId), CorrelationId = long.Parse(documentDetail.CorrelationId), WorkerInstanceId = WorkerId, WorkerRoleType = "8A65E2DC-753C-E311-82FA-005056850057", Success = isSentForIndexing, LogInfo = logInfo }; searchIndexLogInfos.Add(searchIndexLogInfo); } LogPipe.Open(); var pipleMessageEnvelope = new PipeMessageEnvelope { Body = searchIndexLogInfos }; LogPipe.Send(pipleMessageEnvelope); } catch (Exception exception) { exception.AddDbgMsg("Failed to log document details"); exception.Trace().Swallow(); ReportToDirector(exception); } }