コード例 #1
0
        /// <summary>
        ///  Get fields value to write in .DAT file
        /// </summary>
        private string GetFieldsValue(ExportDocumentDetail docDetail)
        {
            StringBuilder sbLoadFileData = new StringBuilder();

            if (exportFieldsSelection != null && docDetail != null && docDetail.Fields != null)
            {
                foreach (
                    var resultField in
                    exportFieldsSelection.Select(
                        selectedFields =>
                        docDetail.Fields.FirstOrDefault(o => o.FieldName == selectedFields.DataSetFieldName)))
                {
                    string fieldValue = string.Empty;
                    if (resultField != null && !string.IsNullOrEmpty(resultField.FieldValue) &&
                        resultField.FieldTypeId != Constants.ContentFieldType)
                    {
                        fieldValue = resultField.FieldValue;

                        #region Date Format

                        if (resultField.FieldTypeId == 61 &&
                            dateFormatForData != string.Empty)
                        {
                            fieldValue = DocumentBO.ConvertFieldsValueIntoDateFormatForExportJob(resultField,
                                                                                                 dateFormatForData);
                        }

                        #endregion
                    }
                    sbLoadFileData.Append(quoteCharacter);
                    if (!string.IsNullOrEmpty(fieldValue))
                    {
                        sbLoadFileData.Append(fieldValue);
                    }
                    sbLoadFileData.Append(quoteCharacter);
                    sbLoadFileData.Append(columnDelimiter);
                }
            }

            var contentField = exportFieldsSelection.FirstOrDefault(f => f.DataSetFieldName.ToUpper() == "CONTENT");
            if (contentField != null)
            {
                if (documentContentFieldsValueCollection != null && documentContentFieldsValueCollection.Any() &&
                    !string.IsNullOrEmpty(docDetail.DocumentId))
                {
                    if (documentContentFieldsValueCollection.ContainsKey(docDetail.DocumentId))
                    {
                        var fieldValue = documentContentFieldsValueCollection[docDetail.DocumentId];

                        sbLoadFileData.Append(quoteCharacter);
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            sbLoadFileData.Append(fieldValue.Replace(Constants.ConcordanceFieldSplitter,
                                                                     contentNewLine.ToString()));
                        }
                        sbLoadFileData.Append(quoteCharacter);
                        sbLoadFileData.Append(columnDelimiter);
                    }
                }
            }

            return(sbLoadFileData.ToString());
        }