Exemplo n.º 1
0
        public void GenerateXml()
        {
            DatabaseTableModel table = new DatabaseTableModel();

            File.Delete(AppDomain.CurrentDomain.BaseDirectory + @"\MyFile.xml");
            table.SourceConnectionString      = AppDomain.CurrentDomain.BaseDirectory + @"\myfile.csv";
            table.SourceDatabaseType          = AtlasDataConvert.Enumerations.DatabaseType.CSV;
            table.SourceName                  = "MyFile";
            table.DestinationConnectionString = AppDomain.CurrentDomain.BaseDirectory + @"\myfleConverted.csv";
            table.DestinationDatabaseType     = AtlasDataConvert.Enumerations.DatabaseType.CSV;
            table.DestinationName             = "MyFileConverted";

            table.Fields = new List <DatabaseField>();
            table.Fields.Add(new DatabaseField()
            {
                SourceName = "Field1", DestinationName = "FieldConverted1"
            });
            table.Fields.Add(new DatabaseField()
            {
                SourceName = "Field2", DestinationName = "FieldConverted2"
            });
            table.Fields.Add(new DatabaseField()
            {
                SourceName = "Field3", DestinationName = "FieldConverted3"
            });

            ProcessDataFilesService.GenerateModelXml(table, AppDomain.CurrentDomain.BaseDirectory + @"\MyFile.xml");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            DatabaseTableModel table = new DatabaseTableModel();

            string[]      splitLine;
            string        required;
            DatabaseField field     = new DatabaseField();
            string        directory = @"C:\Development\ProjectAtlas\DataConversion\CapsysTemplates";// AppDomain.CurrentDomain.BaseDirectory;

            //string directory = AppDomain.CurrentDomain.BaseDirectory;
            foreach (string fileName in Directory.GetFiles(directory + @"\Input"))
            {
                Console.WriteLine("Processing::{0}", fileName);
                table = new DatabaseTableModel();
                table.DestinationDatabaseType     = DatabaseType.CSV;
                table.SourceDatabaseType          = DatabaseType.FoxPro;
                table.SourceCommandType           = CommandType.Table;
                table.DestinationConnectionString = "";
                table.DestinationName             = Path.GetFileNameWithoutExtension(fileName);
                table.SourceName             = Path.GetFileNameWithoutExtension(fileName);
                table.SourceConnectionString = table.SourceName;

                table.Fields = new List <DatabaseField>();
                foreach (string line in File.ReadAllLines(fileName))
                {
                    field                 = new DatabaseField();
                    splitLine             = line.Split(',');
                    field.DataLength      = splitLine[5];
                    field.DestinationName = splitLine[2];
                    field.FieldDataType   = GetDataTypeFromString(splitLine[0]);
                    field.SourceName      = splitLine[3];
                    required              = splitLine[12].ToUpper();
                    field.IsRequired      = required == "TRUE" ? true : false;
                    if (!splitLine[0].Contains("Formula") && !splitLine[0].Contains("Address"))
                    {
                        table.Fields.Add(field);
                    }
                }
                File.Delete(fileName.Replace("Input", "Output").Replace(".csv", ".xml"));
                ProcessDataFilesService.GenerateModelXml(table, fileName.Replace("Input", "Output").Replace(".csv", ".xml"));
            }
            Console.ReadKey();
        }