protected override void ProcessMessage(PipeMessageEnvelope envelope) { List <ProductionDocumentDetail> productionDocuments = null; List <ProductionDocumentDetail> errorDocuments = null; try { productionDocuments = envelope.Body as List <ProductionDocumentDetail>; Debug.Assert(productionDocuments != null, "productionDocuments != null"); if (productionDocuments == null || !productionDocuments.Any()) { Tracer.Warning("Empty batch received! Skipped."); return; } productionDocuments.ShouldNotBeEmpty(); using (new EVTransactionScope(TransactionScopeOption.Suppress)) { if (productionDocuments != null && productionDocuments.Any()) { var productionDocument = productionDocuments.First(); productionDocument.MatterId.ShouldNotBeEmpty(); _mMatterId = productionDocument.MatterId; productionDocument.dataSetBeo.ShouldNotBe(null); productionDocument.dataSetBeo.CollectionId.ShouldNotBeEmpty(); _mCollectionId = productionDocument.dataSetBeo.CollectionId; var docs = productionDocuments.Select(doc => new DocumentDataBEO { DocumentId = doc.DocumentId, CollectionId = _mCollectionId }).ToList(); var docFields = MatterBO.GetCollectionDocumentFields(Int64.Parse(_mMatterId), docs); docFields.ShouldNotBe(null); _documentDetails = ConstructDocumentFieldsForSearchSubSystem(docFields); ProcessDocumentFields(productionDocuments); } } } catch (Exception ex) { errorDocuments = productionDocuments; ReportToDirector(ex); ex.Trace().Swallow(); } ProductionLogHelper.SendProductionLogs(LogPipe, errorDocuments, PipelineId, WorkerId, Constants.ProductionVaultIndexingUpdateWokerRoleId); }
/// <summary> /// Processes the message for production. /// </summary> /// <param name="productionDocuments">The production documents.</param> private void ProcessMessageForProduction(List <ProductionDocumentDetail> productionDocuments) { var documentConversionLogBeos = new List <DocumentConversionLogBeo>(); if (productionDocuments == null || !productionDocuments.Any()) { return; } var productionDocument = productionDocuments.FirstOrDefault(); if (productionDocument != null && !String.IsNullOrEmpty(productionDocument.MatterId)) { _matterId = Convert.ToInt64(productionDocument.MatterId); } var errorDocuments = new List <ProductionDocumentDetail>(); foreach (var productionDocumentDetail in productionDocuments) { byte conversionStatus = EVRedactItErrorCodes.Submitted; short reasonId = EVRedactItErrorCodes.Na; try { ProductionProfile profileBusinessEntity = productionDocumentDetail.Profile; TiffImageColor tiffImageColor; string hostId = ServerConnectivity.GetHostIPAddress(); string redactitPushUrl = CmgServiceConfigBO.GetServiceConfigurationsforConfig (hostId, External.DataAccess.Constants.SystemConfigurationService, "QueueServerUrl"); string redactitTimeout = GetConfigurationValue("RedactItTimeout", NearNativeViewer); string fileTypeKeyword = "pdf"; string thumbNailFormat = string.Empty; string tiffBpp = string.Empty; string tiffMonochrome = string.Empty; string oneFilePerPage = string.Empty; //Append the push url var uri = new StringBuilder(productionDocumentDetail.QueryString); //Apply the 6.outputtype if (profileBusinessEntity != null) { switch (profileBusinessEntity.ImageType) { case ImageType.Jpg: fileTypeKeyword = Constants.PdfKeyword; thumbNailFormat = Constants.JpgKeyword; break; case ImageType.Png: fileTypeKeyword = Constants.PdfKeyword; thumbNailFormat = Constants.PngKeyword; break; case ImageType.Tiff: fileTypeKeyword = Constants.TiffKeyword; tiffImageColor = profileBusinessEntity.TiffImageColor; if (tiffImageColor == TiffImageColor.One) //monochrome { tiffMonochrome = Constants.TrueString; } else { tiffBpp = ((int)tiffImageColor).ToString(); } if (profileBusinessEntity.IsOneImagePerPage) { oneFilePerPage = Constants.TrueString; } break; default: fileTypeKeyword = Constants.PdfKeyword; if (profileBusinessEntity.IsOneImagePerPage) { oneFilePerPage = Constants.TrueString; } break; } } uri.Append(Constants.QueryStringOutputFormatPrefix); uri.Append(fileTypeKeyword); uri.Append("&StepTimeout="); uri.Append(redactitTimeout); //Apply the 7.Redact It Job priority uri.Append(PriorityQueryStringName); //uri.Append(_nearNativeConversionPriority.ToString()); uri.Append(_conversionPriority); //Apply the 8.thumbnails elements if reqd if (!String.IsNullOrEmpty(thumbNailFormat)) { uri.Append(Constants.QueryStringThumbFormatPrefix); uri.Append(thumbNailFormat); uri.Append(Constants.QueryStringThumbPagesPrefix); uri.Append(Constants.ThumbPagesAll); // a-All f-firstpageonly 1-Pagenumber uri.Append(Constants.QueryStringThumbNamePrefix); uri.Append((productionDocumentDetail.XdlThumbFileName == string.Empty ? Constants.ThumbDefaultPageName : productionDocumentDetail.XdlThumbFileName)); //this is mandatory if jpeg or png needed. uri.Append(Constants.QueryStringThumbQualityPrefix); uri.Append(Constants.ThumbQuality); //1-100 uri.Append(Constants.QueryStringThumbSizesPrefix); uri.Append(Constants.ThumbDefaultSizes); //1000,1000 } //Apply 9. tiff colour if applicable if (!String.IsNullOrEmpty(tiffBpp)) { uri.Append(Constants.QueryStringTiffBppPrefix); uri.Append(tiffBpp); uri.Append(Constants.QueryStringTifDPI); } //Apply 10. tiff monochrome if applicable if (!String.IsNullOrEmpty(tiffMonochrome)) { uri.Append(Constants.QueryStringTiffMonochromePrefix); uri.Append(tiffMonochrome); uri.Append(Constants.QueryStringTifDPI); } //Apply 11. Check if one file per page is needed if (!String.IsNullOrEmpty(oneFilePerPage)) { uri.Append(Constants.QueryStringOneFilePerPagePrefix); uri.Append(oneFilePerPage); } uri.Append(Constants.PublishBlankPagesQueryString); uri.Append(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PublishBlankPages)); uri.Append(Constants.QueryStringScrubbedText); uri.Append(productionDocumentDetail.GetText.ToString()); //TODO: Log the data var request = WebRequest.Create(redactitPushUrl); byte[] byteArray = Encoding.UTF8.GetBytes(uri.ToString()); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; using (var dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); using (var response = request.GetResponse()) { string status = ((HttpWebResponse)response).StatusDescription.ToUpper().Trim(); if (!status.Equals(Constants.OkKeyword)) { Tracer.Warning( " DCN = {0}, DocumentId = {1}, CollectionId = {2} and HeartBeatFile {3}\r\n", productionDocumentDetail.DCNNumber, productionDocumentDetail.DocumentId, productionDocumentDetail.DatasetCollectionId, productionDocumentDetail.HeartBeatFile); } } } productionDocumentDetail.ConversionEnqueueTime = DateTime.UtcNow; } catch (Exception ex) { ex.AddUsrMsg("Production Imaging Worker: Unable to produce the document DCN: {0}", productionDocumentDetail.DCNNumber); ex.Trace().Swallow(); conversionStatus = EVRedactItErrorCodes.Failed; reasonId = EVRedactItErrorCodes.FailedToSendFile; productionDocument.ErrorMessage = string.Format("Document with DCN:{0} is {1}-{2}", productionDocumentDetail.DCNNumber, Constants.ProductionPreFailure, ex.Message); errorDocuments.Add(productionDocument); } documentConversionLogBeos.Add(ConvertToDocumentConversionLogBeo(productionDocumentDetail, conversionStatus, reasonId)); } ProductionLogHelper.SendProductionLogs(LogPipe, errorDocuments, PipelineId, WorkerId, Constants.ProductionImagingWokerRoleId); BulkUpdateProcessSetStatus(documentConversionLogBeos); }