private void ReadMapInfo(out List <string> csv, Encoding encode, string path, string lon, string lat)
        {
            csv = new List <string>();
            csv.Add(string.Empty);
            char separator = CsvToTablesDataLoaderParams.GetSeparator(path);


            if (lon != "longitude" || lat != "latitude")
            {
                using (StreamReader reader = new StreamReader(path, encode))
                {
                    string[] tmp = reader.ReadLine().Split(separator);

                    tmp.SetValue("longitude", tmp.ToList().IndexOf(lon));
                    tmp.SetValue("latitude", tmp.ToList().IndexOf(lat));
                    for (int i = 0; i < tmp.Length; i++)
                    {
                        csv[0] += tmp[i];
                        if (i < tmp.Length - 1)
                        {
                            csv[0] += separator;
                        }
                    }
                    do
                    {
                        csv.Add(reader.ReadLine());
                    } while (!reader.EndOfStream);
                }
            }
        }
        private static CsvToTablesDataLoaderParams CreateEmptyData(string fileName)
        {
            char separator = GetSeparator(fileName);
            var  name      = Path.GetFileNameWithoutExtension(fileName);

            // Create all instances
            var dataLoaderParams = new CsvToTablesDataLoaderParams();

            // Generate TableMetadataEntity properties
            dataLoaderParams.TableMetadataEntity = new TableMetadataEntity
            {
                EntitySet      = name,
                Name           = name,
                Source         = name,
                Category       = name,
                ReleasedDate   = DateTime.Now,
                ExpiredDate    = DateTime.Now.AddDays(1),
                LastUpdateDate = DateTime.Now
            };

            dataLoaderParams.ProducerParams = new EntityProducerParams
            {
                PlacemarkParams   = new PlacemarkParams(),
                PropertyToTypeMap = new PropertyToTypeMapper(),
            };

            // Generate ProcessorParams properties
            dataLoaderParams.ProcessorParams = new TableProcessorParams
            {
                PartitionKeyPropertyName = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                RowKeyPropertyName       = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                TableMetadataPartitionKeyPropertyName        = "Name",
                TableMetadataRowKeyPropertyName              = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                TableColumnsMetadataPartitionKeyPropertyName = DataLoaderConstants.PropNameEntitySet,
                TableColumnsMetadataRowKeyPropertyName       = "Column",
                EntityMetadataPartitionKeyPropertyName       = DataLoaderConstants.PropNameEntitySet,
                EntityMetadataRowKeyPropertyName             = DataLoaderConstants.PropNameEntityKind
            };

            dataLoaderParams.TableColumnsMetadata = new TableColumnsMetadata
            {
                PropertyToTypeColumnsMetadata = new PropertyToTypeColumnsMetadataMapper()
            };

            using (var reader = new CsvReader(new StreamReader(fileName, GetEncoding(fileName)), true, GetSeparator(fileName)))
            {
                string defaultDescription      = DefaultDescription();
                string defaultDescriptionToAdd = string.Empty;
                foreach (string header in reader.GetFieldHeaders())
                {
                    if (header.Trim().ToLower() == "name")
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.NameProperties           = new[] { "name" };
                        dataLoaderParams.ProducerParams.PlacemarkParams.NamePropertyFormatString = "{0}";
                    }

                    if (header.Trim().ToLower() == "id")
                    {
                        dataLoaderParams.ProcessorParams.RowKeyPropertyName = "id";
                    }

                    if (header.Trim().ToLower().StartsWith("lat"))
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.LatitudeProperty = header.Trim();
                    }

                    if (header.Trim().ToLower().StartsWith("lon"))
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.LongitudeProperty = header.Trim();
                    }

                    dataLoaderParams.ProducerParams.PropertyToTypeMap.Add(header.Trim(), "string");
                    defaultDescriptionToAdd = string.Format(defaultDescription, header, name);
                    dataLoaderParams.TableColumnsMetadata.PropertyToTypeColumnsMetadata.Add(header.Trim(), string.Empty, defaultDescriptionToAdd, "ogdi=\"ogdiUrl\"");
                }
            }
            return(dataLoaderParams);
        }
        private static CsvToTablesDataLoaderParams CreateEmptyData(string fileName)
        {
            char separator = GetSeparator(fileName);
            var name = Path.GetFileNameWithoutExtension(fileName);

            // Create all instances
            var dataLoaderParams = new CsvToTablesDataLoaderParams();

            // Generate TableMetadataEntity properties
            dataLoaderParams.TableMetadataEntity = new TableMetadataEntity
            {
                EntitySet = name,
                Name = name,
                Source = name,
                Category = name,
                ReleasedDate = DateTime.Now,
                ExpiredDate = DateTime.Now.AddDays(1),
                LastUpdateDate = DateTime.Now
            };

            dataLoaderParams.ProducerParams = new EntityProducerParams
            {
                PlacemarkParams = new PlacemarkParams(),
                PropertyToTypeMap = new PropertyToTypeMapper(),
            };

            // Generate ProcessorParams properties
            dataLoaderParams.ProcessorParams = new TableProcessorParams
            {
                PartitionKeyPropertyName = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                RowKeyPropertyName = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                TableMetadataPartitionKeyPropertyName = "Name",
                TableMetadataRowKeyPropertyName = DataLoaderConstants.ValueUniqueAutoGenInitCaps,
                TableColumnsMetadataPartitionKeyPropertyName = DataLoaderConstants.PropNameEntitySet,
                TableColumnsMetadataRowKeyPropertyName = "Column",
                EntityMetadataPartitionKeyPropertyName = DataLoaderConstants.PropNameEntitySet,
                EntityMetadataRowKeyPropertyName = DataLoaderConstants.PropNameEntityKind
            };

            dataLoaderParams.TableColumnsMetadata = new TableColumnsMetadata
            {
                PropertyToTypeColumnsMetadata = new PropertyToTypeColumnsMetadataMapper()
            };

            using (var reader = new CsvReader(new StreamReader(fileName,GetEncoding(fileName)), true, GetSeparator(fileName)))
            {
                string defaultDescription = DefaultDescription();
                string defaultDescriptionToAdd = string.Empty;
                foreach (string header in reader.GetFieldHeaders())
                {
                    if (header.Trim().ToLower() == "name")
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.NameProperties = new[] { "name" };
                        dataLoaderParams.ProducerParams.PlacemarkParams.NamePropertyFormatString = "{0}";
                    }

                    if (header.Trim().ToLower() == "id")
                    {
                        dataLoaderParams.ProcessorParams.RowKeyPropertyName = "id";
                    }

                    if (header.Trim().ToLower().StartsWith("lat"))
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.LatitudeProperty = header.Trim();
                    }

                    if (header.Trim().ToLower().StartsWith("lon"))
                    {
                        dataLoaderParams.ProducerParams.PlacemarkParams.LongitudeProperty = header.Trim();
                    }

                    dataLoaderParams.ProducerParams.PropertyToTypeMap.Add(header.Trim(), "string");
                    defaultDescriptionToAdd = string.Format(defaultDescription, header, name);
                    dataLoaderParams.TableColumnsMetadata.PropertyToTypeColumnsMetadata.Add(header.Trim(), string.Empty, defaultDescriptionToAdd, "ogdi=\"ogdiUrl\"");
                }
            }
            return dataLoaderParams;
        }