コード例 #1
0
        /// <summary>
        ///  Get ContentFields
        /// </summary>
        private string GetContentFieldsValue(ExportDocumentDetail docDetail)
        {
            string fieldValue = string.Empty;

            try
            {
                if (exportFieldsSelection != null)
                {
                    var contentField = exportFieldsSelection.FirstOrDefault(f => f.DataSetFieldName.ToUpper() == "CONTENT");
                    if (contentField != null)
                    {
                        fieldValue = DocumentBO.GetDocumentContentFieldsForExportJob(Convert.ToInt64(_exportLoadJobDetailBeo.MatterId), _dataset.CollectionId, docDetail.DocumentId);
                        fieldValue = DocumentBO.Base64DecodeForExportJob(fieldValue);  //Decode the content field
                        fieldValue = fieldValue.Replace(Constants.ConcordanceRecordSplitter, contentNewLine.ToString()).Replace(Constants.ConcordanceFieldSplitter, contentNewLine.ToString()).Replace(Constants.ConcordanceRowSplitter, contentNewLine.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
            }

            return(fieldValue);
        }
コード例 #2
0
        private bool CopyTextFiles(ExportDocumentDetail documentDetail, out string errorMessage)
        {
            var result           = true;
            var textErrorBuilder = new StringBuilder();

            try
            {
                if (documentDetail.TextFiles != null && documentDetail.TextFiles.Count > 0)
                {
                    foreach (var file in documentDetail.TextFiles)
                    {
                        var targetPath = string.Empty;
                        GetFileName(documentDetail, ref result, textErrorBuilder, file, ref targetPath);
                        if (!result)
                        {
                            continue;
                        }
                        bool retry;
                        do
                        {
                            try
                            {
                                if (file.IsTextFieldExportEnabled)
                                {
                                    var contentFieldValue = string.Empty;
                                    var textFieldId       = DocumentBO.GetFieldIdByNameForExportJob(_dataset, _exportDocumentCollection.ExportOption.TextFieldToExport, false);
                                    var field             = _dataset.DatasetFieldList.FirstOrDefault(f => f.Name.ToLower().Equals(_exportDocumentCollection.ExportOption.TextFieldToExport.ToLower()));

                                    if (field != null && field.FieldType != null)
                                    {
                                        if (field.FieldType.DataTypeId == ContentFieldTypeID)
                                        {
                                            contentFieldValue =
                                                DocumentBO.GetDocumentContentFieldsForExportJob(Convert.ToInt64(_exportLoadJobDetailBeo.MatterId), _dataset.CollectionId, documentDetail.DocumentId);
                                            contentFieldValue = DocumentBO.Base64DecodeForExportJob(contentFieldValue);   //Decode the content field
                                        }
                                        else
                                        {
                                            contentFieldValue =
                                                DocumentBO.GetFieldValueForExportJob(Convert.ToInt64(_exportLoadJobDetailBeo.MatterId), _dataset.CollectionId, documentDetail.DocumentId, textFieldId);
                                        }
                                    }

                                    File.WriteAllText(targetPath, contentFieldValue, _encodingType);
                                }
                                else
                                {
                                    File.Copy(file.SourceFilePath, targetPath);
                                }
                                retry = false;
                            }
                            catch (IOException ioEx)
                            {
                                result = false;
                                var hResult = System.Runtime.InteropServices.Marshal.GetHRForException(ioEx);
                                if (hResult == ExceptionHr)  //Capture "File already exists" exception only and generate the new filename and retry to copy it again
                                {
                                    var fileName = GetFileNameForDuplicates(Path.GetFileName(targetPath), file.DestinationFolder);
                                    targetPath = Path.Combine(file.DestinationFolder, fileName);
                                    retry      = true;
                                }
                                else
                                {
                                    textErrorBuilder.Append(Constants.ExportNativeTextCopyErrorMessage);
                                    textErrorBuilder.Append(file.SourceFilePath);
                                    textErrorBuilder.Append(Constants.ExportBreakMessage);
                                    retry = false;
                                }
                            }
                            catch (Exception)
                            {
                                result = false;
                                textErrorBuilder.Append(Constants.ExportNativeTextCopyErrorMessage);
                                textErrorBuilder.Append(file.SourceFilePath);
                                textErrorBuilder.Append(Constants.ExportBreakMessage);
                                retry = false;
                            }
                        } while (retry);
                        file.DestinationFolder = targetPath;
                    }
                }
                else if (_isIncludeText)
                {
                    textErrorBuilder.Append(TextFileError);
                    result = false;
                }
            }
            catch (Exception ex)
            {
                ex.AddUsrMsg("Export File Copy Worker: Unable to copy text files for job run id: {0}", PipelineId).Trace().Swallow();
                result = false;
            }
            errorMessage = textErrorBuilder.ToString();
            return(result);
        }