protected override void BeginWork() { base.BeginWork(); _jobParameter = (NearDuplicationJobBEO)XmlUtility.DeserializeObject(BootParameters, typeof(NearDuplicationJobBEO)); #region Assertion _jobParameter.DatasetId.ShouldBeGreaterThan(0); _jobParameter.MatterId.ShouldBeGreaterThan(0); _jobParameter.CollectionId.ShouldNotBeEmpty(); // _jobParameter.JobName.ShouldNotBeEmpty(); #endregion _ingestionId = string.Format("{0}_Dataset-{1}_RunId-{2}", _jobParameter.JobName, _jobParameter.DatasetId, PipelineId); _familyThreshHold = ((_jobParameter.FamilyThreshold > 0) ? (byte)_jobParameter.FamilyThreshold : Constants.NearDuplicationFamilyThresholdDefaultValue); _clusterThreshHold = ((_jobParameter.ClusterThreshold > 0) ? (byte)_jobParameter.ClusterThreshold : Constants.NearDuplicationClusterThresholdDefaultValue); //Get Vault Database Connection string var documentVaultManager = new DocumentVaultManager(); _connectionString = documentVaultManager.GetConnectionStringForMatter(_jobParameter.MatterId); //Get Polaris license server IP address _licenseServer = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.NearDuplicationPolarisLicenseKeyName); }
/// <summary> /// Clean Zip files in shared space /// </summary> private void CleanZipFilesInSharedSpace() { string sharedLocation = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.BaseSharedPath); sharedLocation = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.TargetDirectoryPath); DirectoryInfo dir = new DirectoryInfo(sharedLocation); if (dir.Exists) { FileInfo[] files = dir.GetFiles(); if (files.Length > 0) { int interval = int.Parse(ConfigurationManager.AppSettings[Constants.CleanFolderInHours]); List <FileInfo> filesToDelete = files.Where(o => o.Extension.Contains(Constants.ZipExtension) && o.CreationTime <= DateTime.Now.AddHours(-interval)).ToList(); if (filesToDelete.Count > 0) { foreach (FileInfo t in filesToDelete) { try { t.Delete(); } catch (Exception ex) { EvLog.WriteEntry(Constants.ErrorInDeletingDirectory + t.FullName, Constants.ErrorInDeletingDirectory + t.FullName + Constants.DueTo + ex.Message, EventLogEntryType.Error); } } } } } }
/// <summary> /// Get the configuration parameters used for Email Documents /// </summary> /// <returns>string</returns> private static string GetEmailDocumentConfigurations() { string sharedLocation = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.BaseSharedPath); string sourceDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.SourceDirectoryPath); string targetDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.TargetDirectoryPath); string toReturn = Constants.TargetDirectory.ConcatStrings(new List <string> { Constants.PipeSeperator, targetDirectoryPath, Constants.Comma, Constants.SourceDirectory, Constants.PipeSeperator, sourceDirectoryPath, Constants.Comma, Constants.WaitTimeToCheckCompressedFiles, Constants.PipeSeperator, ConfigurationManager.AppSettings[Constants.WaitTimeToCheckCompressedFiles], Constants.Comma, Constants.DeleteSourceFiles, Constants.PipeSeperator, ConfigurationManager.AppSettings[Constants.DeleteSourceFiles] }); return(toReturn); }
protected override void BeginWork() { base.BeginWork(); _jobParameter = (NearDuplicationJobBEO)XmlUtility.DeserializeObject(BootParameters, typeof(NearDuplicationJobBEO)); #region "Assertion" _jobParameter.DatasetId.ShouldBeGreaterThan(0); _jobParameter.MatterId.ShouldBeGreaterThan(0); _jobParameter.CollectionId.ShouldNotBeEmpty(); // _jobParameter.JobName.ShouldNotBeEmpty(); #endregion _ingestionId = string.Format("{0}_Dataset-{1}_RunId-{2}", _jobParameter.JobName, _jobParameter.DatasetId, PipelineId); var familyThreshHold = ((_jobParameter.FamilyThreshold > 0) ? (byte)_jobParameter.FamilyThreshold : Constants.NearDuplicationFamilyThresholdDefaultValue); var clusterThreshHold = ((_jobParameter.ClusterThreshold > 0) ? (byte)_jobParameter.ClusterThreshold : Constants.NearDuplicationClusterThresholdDefaultValue); //Get Vault Database Connection string var documentVaultManager = new DocumentVaultManager(); _connectionString = documentVaultManager.GetConnectionStringForMatter(_jobParameter.MatterId); //Get Dataset details _dataset = DataSetBO.GetDataSetDetailForDataSetId(_jobParameter.DatasetId); _dataset.ShouldNotBe(null); //Get Polaris license server IP address var licenseServer = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.NearDuplicationPolarisLicenseKeyName); try { //Initialize Near Dupe Adapter _nearDuplicationAdapter = new EVPolarisNearDuplicationAdapter(); _nearDuplicationAdapter.InitializeAdapter(_connectionString, _ingestionId, licenseServer, clusterThreshHold, familyThreshHold); } catch (Exception ex) { Tracer.Error( "Near Duplication Start Up Worker: Failed to initialize Near duplication engine for job run id:{0}, exception:{1}", PipelineId, ex); throw; } // _nearDuplicationAdapter.DeleteAllData(); }
/// <summary> /// Create Folders for Temporary storage of files for delivery options /// </summary> private void CreateFoldersForTemperoryStorage() { string sharedLocation = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.BaseSharedPath); if (Directory.Exists(sharedLocation)) { string deliveryOptionsPath = Path.Combine(sharedLocation, Constants.DeliveryOptions); if (!Directory.Exists(deliveryOptionsPath)) { try { Directory.CreateDirectory(deliveryOptionsPath); } catch (Exception ex) { ex.AddResMsg(ErrorCodes.WriteAccessForSharePathIsDenied); throw; } } string sourceDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.SourceDirectoryPath); if (!Directory.Exists(sourceDirectoryPath)) { try { Directory.CreateDirectory(sourceDirectoryPath); } catch (Exception ex) { ex.AddResMsg(ErrorCodes.WriteAccessForSharePathIsDenied); throw; } } string targetDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.TargetDirectoryPath); if (!Directory.Exists(targetDirectoryPath)) { try { Directory.CreateDirectory(targetDirectoryPath); } catch (Exception ex) { ex.AddResMsg(ErrorCodes.WriteAccessForSharePathIsDenied); throw; } } } else { throw new EVException().AddResMsg(ErrorCodes.SourceDirectoryNotExists); } }
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> /// Deletes the DataSet From EvMaster /// </summary> /// <param name="task">DeleteDataSetTaskBEO</param> /// <param name="jobParameters">DeleteDataSetJobBEO</param> private void DeleteDataSetFromEvMaster(DeleteDataSetTaskBEO task, DeleteDataSetJobBEO jobParameters) { if (jobParameters != null) { string datasetUuid = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}", Constants.Matter, Constants.Hyphen, jobParameters.MatterId, Constants.Hyphen, Constants.Dataset, Constants.Hyphen, jobParameters.DataSetId, Constants.Hyphen, Constants.Collection, Constants.Hyphen, jobParameters.CollectionId); DataSetBO.DeleteDataSetFromEVMaster(datasetUuid); var externalizationEnabled = Convert.ToBoolean(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.ExternalizationConfiguration)); if (externalizationEnabled) { DocumentBO.DeleteExternalization(jobParameters.MatterId, task.ExtractionPath, task.DocumentSets); } } }
/// <summary> /// Get the configuration parameters used for print document /// </summary> /// <returns>string</returns> private static string GetPrintDocumentConfigurations() { string sharedLocation = CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.BaseSharedPath); string sourceDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.SourceDirectoryPath); string targetDirectoryPath = Path.Combine(Path.Combine(sharedLocation, Constants.DeliveryOptions), Constants.TargetDirectoryPath); string toReturn = string.Empty; try { toReturn = Constants.TargetDirectory.ConcatStrings(new List <string> { Constants.PipeSeperator, targetDirectoryPath, Constants.Comma, Constants.SourceDirectory, Constants.PipeSeperator, sourceDirectoryPath, Constants.Comma, Constants.RedactitUri, Constants.PipeSeperator, CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.QueueServerUrl), Constants.Comma, Constants.CallBackUri, Constants.PipeSeperator, CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PrintCallBackUri), Constants.Comma, Constants.WaitAttemptsCount, Constants.PipeSeperator, ConfigurationManager.AppSettings[Constants.WaitAttemptsCount], Constants.Comma, Constants.DeleteSourceFiles, Constants.PipeSeperator, ConfigurationManager.AppSettings[Constants.DeleteSourceFiles], Constants.Comma, Constants.RedactItPostSupported, Constants.PipeSeperator, ConfigurationManager.AppSettings[Constants.RedactItPostSupported] }); } catch (Exception exp) { EvLog.WriteEntry(Constants.GetPrintDocumentConfigurations, exp.Message + Constants.Colon + exp.StackTrace, EventLogEntryType.Error); } return(toReturn); }
/// <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> /// This is the method that sends the web request to redact it. /// </summary> /// <param name="requestId">request id</param> /// <param name="queryString">Query String</param> /// <returns>Status of operation</returns> public bool CreatePostWebRequestForCreatingPdf(string requestId, string queryString) { requestId.ShouldNotBeEmpty(); queryString.ShouldNotBeEmpty(); string status; var success = true; var request = WebRequest.Create(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.QueueServerUrl)); var byteArray = Encoding.UTF8.GetBytes(queryString); request.Method = Constants.Post; request.ContentType = Constants.UrlEncodedContentType; request.ContentLength = byteArray.Length; using (var dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); } using (var response = request.GetResponse()) { status = ((HttpWebResponse)response).StatusDescription.ToUpper().Trim(); } if (status.Equals(Constants.Ok)) { EvLog.WriteEntry(requestId + Constants.Colon + Constants.CallPushMethodCalled, status, EventLogEntryType.Information); } else { success = false; EvLog.WriteEntry( requestId + Constants.Colon + Constants.CallPushMethodCalled + Constants.RedactitServerResponseWithStatus, status, EventLogEntryType.Error); } return(success); }
private void SendDocumentForImaging(LawSyncDocumentDetail document) { int conversionStatus = (int)LawSyncProcessState.InProgress; try { var queryString = new StringBuilder(); var sourceExtractionPath = Path.Combine(_datasetExtractionPath, Guid.NewGuid().ToString(), Constants.SourceKeyword); Directory.CreateDirectory(sourceExtractionPath); document.DocumentExtractionPath = sourceExtractionPath; //Need to be deleted. //1)Set source file(xdl,zdl) & Markup xml var source = CreateSourceFiles(sourceExtractionPath, document.DocumentReferenceId); if (string.IsNullOrEmpty(source)) { document.IsImagesXdlAvailable = false; _documentProcessStateList.Add(GetDocumentProcessStateInformation(document, (int)LawSyncProcessState.Failed)); ConstructLog(document.LawDocumentId, document.CorrelationId, document.DocumentControlNumber, Constants.LawSyncMissingImageMessage); return; } document.IsImagesXdlAvailable = true; queryString.Append(source); //2)Set Image Folder queryString.Append(Constants.QueryStringTargetPrefix); queryString.Append(HttpUtility.UrlEncode(document.ImagesFolderPath));//Target folder for redact it to generate pdf //3)Set Produced Image File name var fileName = document.DocumentControlNumber + Constants.Tifextension; queryString.Append(Constants.QueryStringDestinationFileName); queryString.Append(fileName); //4)Set Hearbeat file path- Use to get the status of the document. The extension is .txt var heartBeatFile = Path.Combine(document.ImagesFolderPath, string.Format("{0}{1}{2}", document.DocumentControlNumber, Constants.HeartbeatFileName, Constants.TextFileExtension)); queryString.Append(Constants.QueryStringHeartBeatFileName); queryString.Append(HttpUtility.UrlEncode(heartBeatFile)); document.RedactItHeartBeatFilePath = heartBeatFile; //5)Set Image Format(.Tiff) queryString.Append(Constants.QueryStringOutputFormatPrefix); queryString.Append(Constants.TifKeyword); //6)Set Image Color settings if (_jobParameter.TiffImageColor == TiffImageColors.One) //tiff monochrome { queryString.Append(Constants.QueryStringTiffMonochromePrefix); queryString.Append(Constants.TrueString); queryString.Append(Constants.QueryStringTifDPI); } else //tiff colour { var tiffBpp = ((int)_jobParameter.TiffImageColor).ToString(CultureInfo.InvariantCulture); queryString.Append(Constants.QueryStringTiffBppPrefix); queryString.Append(tiffBpp); queryString.Append(Constants.QueryStringTifDPI); } //7)Set Redact-It Timeout queryString.Append(Constants.StepTimeout); queryString.Append(_redactitTimeout); //8)Set One images per page queryString.Append(Constants.QueryStringOneFilePerPagePrefix); queryString.Append(Constants.TrueString); //9)Set Redact It Job priority queryString.Append(Constants.QueryStringPriority); queryString.Append(((int)_jobParameter.ConversionPriority)); //10 Redact-It callback Url queryString.Append(Constants.QueryStringNotificationUrlPrefix); queryString.Append(_redactitCallbackUrl); queryString.Append(Constants.PublishBlankPagesQueryString); queryString.Append(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PublishBlankPages)); PushDocumentToQueueServer(queryString, document.LawDocumentId, heartBeatFile); } catch (Exception ex) { ConstructLog(document.LawDocumentId, document.CorrelationId, document.DocumentControlNumber, Constants.LawSyncImageSendFailureMessage); ex.AddDbgMsg("Law Document Id:{0}", document.LawDocumentId); ex.Trace().Swallow(); ReportToDirector(ex); conversionStatus = (int)LawSyncProcessState.Failed; } _documentProcessStateList.Add(GetDocumentProcessStateInformation(document, conversionStatus)); }
/// <summary> /// Initializes Job BEO /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="bootParameters">Boot parameters</param> /// <param name="createdBy">Job created by</param> /// <returns>Job Business Entity</returns> protected override CompareSavedSearchResultsJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy) { try { LogMessage(Constants.InitializationStartMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); //using job framework Logging LogMessage(Constants.InitializationStartMessage, false, LogCategory.Job, null); try { // Set level of logging _fileType = (ApplicationConfigurationManager.GetValue(Constants.RequiredFileType)); _encodingType = (ApplicationConfigurationManager.GetValue(Constants.RequiredEncoding)); _xslFilePathForComparisonReport = (CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.XslFilePathForComparisonReport)); LogMessage(Constants.InitializationDoneForConfigurableItemMessage, false, LogCategory.Job, null); LogMessage(Constants.InitializationDoneForConfigurableItemMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); } catch { _isJobFailed = true; LogMessage(Constants.InitializationDoneForConfigurableItemErrorMessage, true, LogCategory.Job, null); LogMessage(Constants.InitializationDoneForConfigurableItemErrorMessage, GetType(), Constants.InitializeMethodFullName, EventLogEntryType.Information, jobId, jobRunId); } //Constructing Search Results property Beo from passed boot paramter _searchResultsProperty = (SearchResultsPropertiesDataContract) XmlUtility.DeserializeObject(bootParameters, typeof(SearchResultsPropertiesDataContract)); //Initialize the JobBEO object _jobBeo.JobName = string.Format("Compare Job - {0} at {1}", _searchResultsProperty.SearchResultsName, DateTime.UtcNow.ConvertToUserTime()); _jobBeo.JobDescription = _searchResultsProperty.SearchResultsDescription; _jobBeo.FileType = _fileType; _jobBeo.JobTypeName = Constants.JobTypeName; _jobBeo.JobId = jobId; _jobBeo.JobRunId = jobRunId; // Obtain User BEO of job owner -> will be used for audit log purpose _userEntityOfJobOwner = UserBO.GetUserUsingGuid(createdBy); _jobBeo.JobScheduleCreatedBy = (_userEntityOfJobOwner.DomainName.Equals("N/A")) ? _userEntityOfJobOwner.UserId : _userEntityOfJobOwner.DomainName + "\\" + _userEntityOfJobOwner.UserId; } catch (EVException ex) { _isJobFailed = true; WriteToEventViewer(ex, GetType(), MethodBase.GetCurrentMethod().Name, jobId, jobRunId); HandleJobException(null, ErrorCodes.ProblemInJobInitialization); } catch (Exception ex) { _isJobFailed = true; // Handle exception in initialize LogMessage(ex, GetType(), MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, jobId, jobRunId); HandleJobException(ex, ErrorCodes.ProblemInJobInitialization); } return(_jobBeo); }
/// <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); }
/// <summary> /// Construct Query string for Redact-it /// </summary> /// <param name="jobId">Job Id</param> /// <param name="document">Document:Contains the document details (DocumentID) and field information's(filed type)</param> /// <param name="title">Title</param> /// <param name="separatorSheet">separator sheet path</param> /// <param name="sb">String builder</param> /// <param name="documentInfo">RVWDocumentBEO</param> /// <param name="fieldValue"></param> public void ConstructQueryString(string jobId, DocumentResult document, string title, string separatorSheet, StringBuilder sb, RVWDocumentBEO documentInfo, string fieldValue) { var targetDirectoryPath = Path.Combine(_mSharedLocation, _mBootParameters.Name); //Url Encode for target file path targetDirectoryPath = HttpUtility.UrlEncode(targetDirectoryPath); separatorSheet = HttpUtility.UrlEncode(separatorSheet); var sourceCount = 0; if (documentInfo.DocumentBinary.FileList.Count > 0) { //Adds the separator sheet for each document sb.Append(Constants.Source.ConcatStrings(new List <string> { sourceCount.ToString(CultureInfo.InvariantCulture), Constants.EqualTo, separatorSheet, Constants.Ampersand })); foreach (var t in documentInfo.DocumentBinary.FileList) { sourceCount++; //Adds the native/image/production files for each document sb.Append(Constants.Source.ConcatStrings(new List <string> { sourceCount.ToString(CultureInfo.InvariantCulture), Constants.EqualTo, HttpUtility.UrlEncode(t.Path), Constants.Ampersand })); } } else { sb.Append(Constants.Source0.ConcatStrings(new List <string> { separatorSheet, Constants.Source1, HttpUtility.UrlEncode(documentInfo.NativeFilePath) })); } sb.Append(Constants.Target.ConcatStrings(new List <string> { targetDirectoryPath, Constants.CSFName, fieldValue, Constants.PdfAndNotificationUrl, CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.CallBackUri), Constants.BulkPrintRequestId, jobId })); sb.Append(Constants.MatterId.ConcatStrings(new List <string> { document.MatterID.ToString(), Constants.CollectionId, document.CollectionID, Constants.DocumentId, document.DocumentID })); sb.Append(Constants.Title + title); sb.Append(Constants.NotificationVerb); sb.Append(Constants.PublishBlankPagesQueryString); sb.Append(CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PublishBlankPages)); }
/// <summary> /// Sends the state of the documents for conversion and mark process. /// </summary> /// <param name="queuedDocuments">The queued documents.</param> /// <param name="docToPush">The doc to push.</param> /// <param name="isNativeDocuments">if set to <c>true</c> [is native documents].</param> private void SendDocumentsForConversionAndMarkProcessState(IEnumerable <RVWDocumentBEO> queuedDocuments, Dictionary <string, IEnumerable <string> > docToPush, bool isNativeDocuments) { var documentConversionLogBeos = new List <DocumentConversionLogBeo>(); foreach (var document in queuedDocuments) { byte processStatus = EVRedactItErrorCodes.Submitted; int reasonId = EVRedactItErrorCodes.Na; IEnumerable <string> fileListForConversion = null; string fileListKey = document.DocumentId + ":" + document.CollectionId; docToPush.TryGetValue(fileListKey, out fileListForConversion); if (fileListForConversion == null || !fileListForConversion.Any()) { //if native is not selected then there wont be entry for processed document if (isNativeDocuments && !isNativeSetIncluded) { continue; } } try { m_Converter.PushDocumentForConversion( document.MatterId.ToString(CultureInfo.InvariantCulture), document.CollectionId, document.DocumentId, docToPush[fileListKey], CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PublishBlankPages)); } catch (WebException webException) { if (webException.Response != null) { webException.AddDbgMsg("ResponseURI = {0}", webException.Response.ResponseUri); } webException.Trace().Swallow(); processStatus = EVRedactItErrorCodes.Failed; reasonId = EVRedactItErrorCodes.FailedToSendFile; } catch (Exception ex) { processStatus = EVRedactItErrorCodes.Failed; //if document is not supprot type then 1012 un support file type is the reason and //other problem in submitting the document (1059) is the reason reasonId = Utils.GetConversionErrorReason(ex.GetErrorCode()); // Prevent certain exceptions from polluting the log if (ex.GetErrorCode().Equals("140") || // "No files associated with the document provided for conversion." ex.GetErrorCode().Equals("138")) // "... extension not mapped to a queue" { ex.Swallow(); } else { ex.Trace().Swallow(); } LogMessage(false, ex.ToUserString()); } //Update post push validation state if (processStatus != EVRedactItErrorCodes.Submitted) { documentConversionLogBeos.Add(ConvertToConversionLogBeo(document, processStatus, (short)reasonId)); } } BulkAddOrUpdateProcessedDocuments(_matterId, documentConversionLogBeos, true); }
/// <summary> /// Reconvert document from import jobs /// </summary> /// <param name="docCollection">The documents</param> public void ImportReconvert(ConversionDocCollection docCollection) { // loop through documents to push each document for conversion var documentConversionLogBeo = new List <DocumentConversionLogBeo>(); var validationList = new List <ReconversionDocumentBEO>(); foreach (var document in docCollection.Documents) { short reasonId; byte status; int fileSize = 0; try { //if FileList does not exists, do not send for conversion if (document.FileList == null) { //can not find file LogMessage(false, "File paths null or Files does not exist"); } else { //calculate file size; multiple images file will add them together fileSize = 0; foreach (var file in document.FileList) { if (String.IsNullOrEmpty(file)) { continue; } var fileInfo = new FileInfo(file); if (fileInfo.Exists) { fileSize += (int)Math.Ceiling(fileInfo.Length / Constants.KBConversionConstant); } } } var filesWithReasonCodes = Utils.GetReasonCodes(document.FileList); var heartbeatFilePath = docCollection.GetDefaultHeartbeatFileFullPath(document); var matterId = docCollection.DataSet.Matter.FolderID; ConverterAdapter.PushDocumentForConversionWithHearbeat( matterId.ToString(CultureInfo.InvariantCulture), document.CollectionId, document.DocumentId, filesWithReasonCodes.Item1, heartbeatFilePath, CmgServiceConfigBO.GetServiceConfigurationsforConfig(Constants.PublishBlankPages)); reasonId = filesWithReasonCodes.Item2; status = filesWithReasonCodes.Item3; document.ConversionCheckCounter = 0; document.SubmittedTime = DateTime.UtcNow; document.ConversionEnqueueTime = DateTime.UtcNow; //only add submitted documents for validation, otherwise we might wait for heartbeat files that never exists. validationList.Add(document); IncreaseProcessedDocumentsCount(1); } catch (Exception ex) { ReportToDirector(ex); ex.Trace().Swallow(); if (ex is WebException) { reasonId = EVRedactItErrorCodes.FailedToSendFile; } else { reasonId = Utils.GetConversionErrorReason(ex.GetErrorCode()); } status = EVRedactItErrorCodes.Failed; LogMessage(false, ex.ToUserString()); } var logBeo = ConvertToReoconversionDocumentBeo(document, status, reasonId); logBeo.Size = fileSize; documentConversionLogBeo.Add(logBeo); } docCollection.Documents = validationList; BulkUpdateProcessedDocuments(docCollection.DataSet.Matter.FolderID, documentConversionLogBeo); }