private void UpdateDocumentsMetadatasInLaw(LawSyncDocumentCollection lawDocumentsList)
        {
            try
            {
                var lawEvAdapter = LawBO.GetLawAdapter(_jobParameter.LawCaseId);
                var lawDocumentUpdateList = new List<LawDocumentBEO>();
                var metadatNameList = new List<string>();
                if (_jobParameter.MappingFields != null && _jobParameter.MappingFields.Any())
                {
                    metadatNameList.AddRange(_jobParameter.MappingFields.Select(fields => fields.Name).ToList());
                }
                if (_jobParameter.MappingTags != null && _jobParameter.MappingTags.Any())
                {
                    metadatNameList.AddRange(_jobParameter.MappingTags.Select(tags => tags.Name).ToList());
                }
                metadatNameList.Add(_jobParameter.LawSyncTagName);

                foreach (var document in lawDocumentsList.Documents.Where(d=>!d.IsErrorOnGetMetadata))
                {
                    var lawDocumentUpdate = new LawDocumentBEO
                                            {
                                                LawDocId = document.LawDocumentId,
                                                LawMetadatas = document.MetadataList
                                            };
                    lawDocumentUpdateList.Add(lawDocumentUpdate);

                }

                if (lawDocumentUpdateList.Any())
                {
                    lawEvAdapter.UpdateLawMetadata(lawDocumentUpdateList, metadatNameList);

                    foreach (var document in lawDocumentsList.Documents.Where(d => !d.IsErrorOnGetMetadata))
                    {
                        _documentProcessStateList.Add(GetDocumentProcessStateInformation(document, (int)LawSyncProcessState.Completed));
                    }
                }

            }
            catch (Exception ex)
            {
                //Construct Log
                foreach (var document in lawDocumentsList.Documents) 
                {
                    ConstructLog(document.LawDocumentId, document.CorrelationId, document.DocumentControlNumber,
                        Constants.LawSyncFailureinSyncMetadataMessage);
                    _documentProcessStateList.Add(GetDocumentProcessStateInformation(document, (int)LawSyncProcessState.Failed));
                    document.IsErrorOnSyncMetadata = true;
                }
                ex.Trace().Swallow();
                ReportToDirector(ex);
            }
        }
 /// <summary>
 /// Send Worker response to Pipe.
 /// </summary>
 private void Send(List<LawSyncDocumentDetail> lawDocumentsList)
 {
     var documentCollection = new LawSyncDocumentCollection
                              {
                                  Documents = lawDocumentsList,
                                  DatasetId = _jobParameter.DatasetId,
                                  DatasetCollectionId = _dataset.CollectionId,
                                  MatterId = _jobParameter.MatterId,
                                  RedactableSetCollectionId = _dataset.RedactableDocumentSetId,
                                  DatasetExtractionPath = _dataset.CompressedFileExtractionLocation,
                                  LawSynJobId=WorkAssignment.JobId
                              };
     var message = new PipeMessageEnvelope {Body = documentCollection};
     OutputDataPipe.Send(message);
     IncreaseProcessedDocumentsCount(lawDocumentsList.Count);
 }
 /// <summary>
 /// Send Worker response to Pipe.
 /// </summary>
 private void Send(LawSyncDocumentCollection documentCollection)
 {
     var message = new PipeMessageEnvelope { Body = documentCollection };
     OutputDataPipe.Send(message);
     IncreaseProcessedDocumentsCount(documentCollection.Documents.Count);
 }
        private void ProcessDocumentImages(LawSyncDocumentCollection lawDocumentsList)
        {
            var documentReady = new List<LawSyncDocumentDetail>();
            var documentNotReady = new List<LawSyncDocumentDetail>();

            foreach (var lawImagingDocument in lawDocumentsList.Documents)
            {
                CheckConversionStateAndSyncImages(lawImagingDocument, documentNotReady, documentReady);
            }

            if (documentNotReady.Any())
            {
                lawDocumentsList.Documents.Clear();
                lawDocumentsList.Documents = documentNotReady;
                InputDataPipe.Send(new PipeMessageEnvelope { Body = lawDocumentsList, IsPostback = true });
            }
            IncreaseProcessedDocumentsCount(documentReady.Count);
        }