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();
            }
        }
示例#2
0
        /// <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>
        /// Processes the work item. pushes give document files for conversion
        /// </summary>
        /// <param name="message">The message.</param>
        protected override void ProcessMessage(PipeMessageEnvelope message)
        {
            try
            {
                DocumentCollection           documentCollection = null;
                IEnumerable <DocumentDetail> documentDetails    = null;

                message.ShouldNotBe(null);

                if (!message.IsPostback)
                {
                    Send(message);
                }

                #region Extract document details from incoming message object.

                documentCollection = message.Body as DocumentCollection;

                #region Assertion

                documentCollection.ShouldNotBe(null);

                #endregion

                Debug.Assert(documentCollection != null, "documentCollection != null");
                _matterId       = documentCollection.dataset.Matter.FolderID;
                documentDetails = documentCollection.documents;

                if (documentDetails == null || !documentDetails.Any())
                {
                    throw new EVException().AddErrorCode(ErrorCodes.NoDocumentsInConversionWorker);                                                        //?? resource file.
                }
                var updateDocument = documentDetails.Where(p => (!p.IsNewDocument));
                if (updateDocument.Any())
                {
                    using (new EVTransactionScope(System.Transactions.TransactionScopeOption.Suppress))
                    {
                        // Incase of Overlay, for specific documents delete existing Document Binary
                        //1)Native Document- Delete files from nativeset collection(i.e dataset)
                        var nativeDoc = documentDetails.Where(p => (!p.IsNewDocument && p.docType == DocumentsetType.NativeSet));
                        if (nativeDoc.Any() && documentCollection.IsIncludeNativeFile)     //If native file included then only need to delete existing native file documents.
                        {
                            DeleteNearNativeForOverlay(nativeDoc);
                        }
                        //2) Image Document -Delete files from imageset collection
                        var imageDoc = documentDetails.Where(p => (!p.IsNewDocument && p.docType == DocumentsetType.ImageSet));
                        if (imageDoc.Any())
                        {
                            DeleteNearNativeForOverlay(imageDoc);
                        }
                    }
                }

                #endregion Extract document details from incoming message object.

                #region Loop through documents and push for conversion

                if (documentDetails.Any())
                {
                    //send native set and image set documents seperatley
                    //this helps in tracking the correct processed documents
                    //For Eg:If native set is not selected then then native document treated as not processed
                    ProcessDocuments(documentDetails.Where(doc => doc.docType == DocumentsetType.NativeSet),
                                     documentCollection, true);
                    ProcessDocuments(documentDetails.Where(doc => doc.docType == DocumentsetType.ImageSet),
                                     documentCollection, false);
                }
            }
            catch (Exception ex)
            {
                ReportToDirector(ex);
                ex.Trace().Swallow();
                //LogMessage(false, ex.ToUserString());
            }
            #endregion Loop through documents and push for conversion
        }