Beispiel #1
0
        protected override void BeginWork()
        {
            base.BeginWork();
            var hostId = ServerConnectivity.GetHostIPAddress();

            _redactitPushUrl = CmgServiceConfigBO.GetServiceConfigurationsforConfig
                                   (hostId, External.DataAccess.Constants.SystemConfigurationService, Constants.QueueServerUrl);
            _redactitTimeout = ApplicationConfigurationManager.GetValue(Constants.RedactItTimeout, Constants.NearNativeViewerSection);
            var baseServiceUri = new Uri(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.WcfHostUrl));
            var lawServiceUri  = new Uri(baseServiceUri, Constants.LawSyncConversionCallBackMethod);

            _redactitCallbackUrl = lawServiceUri.OriginalString;
            _vaultManager        = EVUnityContainer.Resolve <IDocumentVaultManager>(Constants.DocumentVaultManager);
        }
        /// <summary>
        /// Gets the document global conversion timeout.
        /// </summary>
        /// <returns>document conversion time out</returns>
        internal static TimeSpan GetDocumentGlobalConversionTimeout()
        {
            var documentGlobalConversionTimeoutInMinutes = 1440;//24 hours

            try
            {
                var hostId = ServerConnectivity.GetHostIPAddress();
                var conversionTimeOutConfigValue = CmgServiceConfigBO.GetServiceConfigurationsforConfig(hostId,
                                                                                                        "System Configuration Service",
                                                                                                        DocumentGlobalConversionTimeoutConfigName);
                documentGlobalConversionTimeoutInMinutes = Convert.ToInt32(conversionTimeOutConfigValue);
            }
            catch (Exception ex)
            {
                ex.AddUsrMsg("Unable to read the document global conversion timeout from  server configuration ");
                ex.Trace().Swallow();
            }

            return(new TimeSpan(0, documentGlobalConversionTimeoutInMinutes, 0));
        }
        /// <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);
        }