Exemplo n.º 1
0
 public DelimitedFileDetectionResultWithColumns(DelimitedFileDetectionResult result, IEnumerable <IColumn> columns = null, string columnFile = "") :
     this(result.FileName, result.SkipRows, result.CodePageId, result.ByteOrderMark, result.QualifyAlways, result.IdentifierInContainer, result.CommentLine, result.EscapeCharacter, result.FieldDelimiter, result.FieldQualifier, result.HasFieldHeader, result.IsJson, result.NoDelimitedFile, result.NewLine, columns, columnFile)
 {
 }
Exemplo n.º 2
0
        private static DelimitedFileDetectionResultWithColumns ReadManifestFromStream(Stream manifestStream, string manifestName, string fileName, string identifierInContainer)
        {
            Logger.Information("Configuration read from manifest file {filename}", manifestName);
            var mani            = JsonConvert.DeserializeObject <ManifestData>(new StreamReader(manifestStream, Encoding.UTF8, true, 4096, false).ReadToEnd());
            var fileSettingMani = new DelimitedFileDetectionResult(fileName, 0, Encoding.UTF8.CodePage, false, true, identifierInContainer, "#", "\\", ",", "\"", false, false, false, RecordDelimiterType.LF);

            var columnCollection = new List <Column>();

            foreach (var fld in mani.Fields)
            {
                IValueFormat vf;
                switch (fld.Type.ToLower().TrimEnd('?', ')', ',', '(', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))
                {
                case "int":
                case "long":
                case "byte":
                case "short":
                    vf = new ImmutableValueFormat(DataType.Integer);
                    break;

                case "decimal":
                case "single":
                case "double":
                    vf = new ImmutableValueFormat(DataType.Numeric, decimalSeparator: ".");
                    break;

                case "uuid":
                case "guid":
                    vf = new ImmutableValueFormat(DataType.Guid);
                    break;

                case "bit":
                    vf = new ImmutableValueFormat(DataType.Boolean);
                    break;

                case "date":
                case "localdate":
                    vf = new ImmutableValueFormat(DataType.DateTime, "yyyy/MM/dd", "-");
                    break;

                case "datetime":
                case "localdatetime":
                    vf = new ImmutableValueFormat(DataType.DateTime, "yyyy/MM/ddTHH:mm:ss.FFFFFFF", "-");
                    break;

                case "time":
                case "localtime":
                    vf = new ImmutableValueFormat(DataType.DateTime, "HH:mm:ss.FFFFFFF");
                    break;

                default:
                    vf = new ImmutableValueFormat();
                    break;
                }

                columnCollection.Add(new Column(fld.PubName, vf)
                {
                    ColumnOrdinal = fld.Ordinal, DestinationName = fld.PubName
                });
            }
            return(new DelimitedFileDetectionResultWithColumns(fileSettingMani, columnCollection, string.Empty));
        }