Пример #1
0
        /// <summary>
        /// Converts one file
        /// </summary>
        static void ConvertSingleFile()
        {
            if (!File.Exists(_sourceFile))
            {
                Console.Error.WriteLine("Error: Cannot find source file: " + _sourceFile);
                return;
            }
            if (!Directory.Exists(_outputDirectory))
            {
                Console.Error.WriteLine("Error: Cannot find output directory: " + _outputDirectory);
                return;
            }

            if (!_quiet)
            {
                Console.WriteLine("Starting conversion of file: " + _sourceFile);
            }
            //Open th TPS File
            TPSReader.TPSReader tpsR = new TPSReader.TPSReader(_sourceFile);
            tpsR.Open();
            tpsR.Process();             //process the file

            TableSchemaCollection tsc           = tpsR.GetTableSchemas();
            TableSchemaCollection limittoTables = new TableSchemaCollection();

            //If we are going to limit the table output... then make sure they are in the collection
            if (_tables.Count > 0)
            {
                foreach (TableSchema ts in tsc.Values)
                {
                    if (_tables.Contains(ts.TableName))
                    {
                        limittoTables.Add(ts.TableID, ts);
                    }
                }
            }

            if (_tables.Count > 0)
            {
                tpsR.ExportDataToCSV(limittoTables, _outputDirectory);
            }
            else
            {
                tpsR.ExportDataToCSV(tsc, _outputDirectory);
            }

            if (!_quiet)
            {
                Console.WriteLine("Done converting file: " + _sourceFile);
            }
        }
Пример #2
0
        void FileInfoBWDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string filename = e.Argument as string;

            if (!System.IO.File.Exists(filename))
            {
                throw new Exception("TPS File does not exist");
            }

            _tpsReader = new TPSReader.TPSReader(filename);
            _tpsReader.Open();

            //Process the TPS File
            _tpsReader.Process();

            //Get The Table List
            TableSchemaCollection tableSchemas = _tpsReader.GetTableSchemas();

            e.Result = tableSchemas;

            return;
        }
Пример #3
0
        static void ConvertDirectory()
        {
            if (!Directory.Exists(_sourceDirectory))
            {
                Console.Error.WriteLine("Error: Cannot find source directory: " + _sourceDirectory);
                return;
            }

            if (!Directory.Exists(_outputDirectory))
            {
                Console.Error.WriteLine("Error: Cannot find output directory: " + _outputDirectory);
                return;
            }

            string[] TPSFiles = Directory.GetFiles(_sourceDirectory, "*.TPS");

            foreach (string TPSFile in TPSFiles)
            {
                if (!_quiet)
                {
                    Console.WriteLine("Starting conversion of file: " + TPSFile);
                }
                try{
                    TPSReader.TPSReader tpsR = new TPSReader.TPSReader(TPSFile);
                    tpsR.Open();
                    tpsR.Process();
                    tpsR.ExportDataToCSV(tpsR.GetTableSchemas(), _outputDirectory);
                    tpsR.Close();
                }catch (Exception ex) {
                    Console.Error.WriteLine("Error converting file: " + TPSFile);
                    Console.Error.WriteLine("Error: " + ex.ToString());
                }
                if (!_quiet)
                {
                    Console.WriteLine("Done converting file: " + TPSFile);
                }
            }
        }