예제 #1
0
        public void TestYmlWriter()
        {
            XmlDocument doc = CreateTestDoc();

            // now test the yml file
            string filename = PathToTestData + "test.yml";

            TYml2Xml.Xml2Yml(doc, filename + ".new");
            Assert.AreEqual(true, TTextFile.SameContent(filename,
                                                        filename + ".new"), "the files should be the same: " + filename);
            System.IO.File.Delete(filename + ".new");
        }
예제 #2
0
        public void TestReadAndWriteYaml()
        {
            // parse a winforms yaml file, write it again, check if the same

            string      filename     = PathToTestData + "testReadWrite.yml";
            TYml2Xml    converterYml = new TYml2Xml(filename);
            XmlDocument docFromYML   = converterYml.ParseYML2XML();

            TYml2Xml.Xml2Yml(docFromYML, filename + ".new");
            Assert.AreEqual(true, TTextFile.SameContent(filename,
                                                        filename + ".new"), "the files should be the same: " + filename);
            System.IO.File.Delete(filename + ".new");
        }
예제 #3
0
        public void TestYMLBackSlashValue()
        {
            string      filename       = PathToTestData + "testBackslash.yml";
            string      backslashValue = "data\\Kontoauszuege\\test.csv";
            TYml2Xml    converterYml   = new TYml2Xml(filename);
            XmlDocument docFromYML     = converterYml.ParseYML2XML();

            XmlNode node = TXMLParser.FindNodeRecursive(docFromYML.DocumentElement, "testname");

            Assert.AreEqual(backslashValue, TXMLParser.GetAttribute(node, "Filename"));

            // does writing of the backslash value work as well?
            TXMLParser.SetAttribute(node, "Filename", backslashValue);
            TYml2Xml.Xml2Yml(docFromYML, filename + ".new");

            Assert.AreEqual(true, TTextFile.SameContent(filename,
                                                        filename + ".new"), "the files should be the same: " + filename);
            System.IO.File.Delete(filename + ".new");
        }
예제 #4
0
        private static void CreateLocalisedYamlFile(string ALanguageCode, string AYamlfile)
        {
            TLogging.Log(AYamlfile);

            string localisedYamlFile = AYamlfile.Replace(".yaml", "." + ALanguageCode + ".yaml");

            TYml2Xml    parser;
            XmlDocument localisedYamlFileDoc = new XmlDocument();

            if (File.Exists(localisedYamlFile))
            {
                // TODO parse the localised yaml file and add translations to the po file
                parser = new TYml2Xml(localisedYamlFile);
                localisedYamlFileDoc = parser.ParseYML2XML();
            }

            // parse the yaml file
            parser = new TYml2Xml(AYamlfile);
            XmlDocument yamlFile = parser.ParseYML2XML();

            SortedList   xmlNodes    = new SortedList();
            TCodeStorage CodeStorage = new TCodeStorage(yamlFile, xmlNodes);

            XmlNode RootNode = TXMLParser.FindNodeRecursive(yamlFile.DocumentElement, "RootNode");

            RootNode.Attributes.RemoveAll();
            TXMLParser.SetAttribute(RootNode, "BaseYaml", Path.GetFileName(AYamlfile));

            // get controls node
            XmlNode Controls = TXMLParser.FindNodeRecursive(yamlFile.DocumentElement, "Controls");

            if (Controls != null)
            {
                foreach (XmlNode control in Controls)
                {
                    AdjustLabel(control, CodeStorage, localisedYamlFileDoc);
                }
            }

            // get actions node
            XmlNode Actions = TXMLParser.FindNodeRecursive(yamlFile.DocumentElement, "Actions");

            if (Actions != null)
            {
                foreach (XmlNode action in Actions)
                {
                    AdjustLabel(action, CodeStorage, localisedYamlFileDoc);
                }
            }

            // menu items
            XmlNode menuitems = TXMLParser.FindNodeRecursive(yamlFile.DocumentElement, "Menu");

            if (menuitems != null)
            {
                foreach (XmlNode menu in menuitems)
                {
                    if (menu.Name.Contains("Separator"))
                    {
                        continue;
                    }

                    AdjustLabel(menu, CodeStorage, localisedYamlFileDoc);
                }
            }

            // toolbar buttons
            XmlNode tbbuttons = TXMLParser.FindNodeRecursive(yamlFile.DocumentElement, "Toolbar");

            if (tbbuttons != null)
            {
                foreach (XmlNode tbb in tbbuttons)
                {
                    if (tbb.Name.Contains("Separator"))
                    {
                        continue;
                    }

                    AdjustLabel(tbb, CodeStorage, localisedYamlFileDoc);
                }
            }

            // TODO parse the cs file for string constants
            // TODO warn about Catalog.GetString calls in manualcode file
            // TODO add constants to localised yaml file

            TYml2Xml.Xml2Yml(yamlFile, localisedYamlFile);
        }
예제 #5
0
        public static void Main(string[] args)
        {
            try
            {
                // establish connection to database
                TCmdOpts settings = new TCmdOpts();

                if (!settings.IsFlagSet("Server.ODBC_DSN"))
                {
                    Console.WriteLine(
                        "sample call: " +
                        "ExportDataProgress.exe -Server.ODBC_DSN:Petra2_2sa -username:demo_sql -password:demo -sql:\"SELECT * from pub.a_account\" -output:test.xml");
                    Environment.Exit(-1);
                }

                new TLogging("debug.log");

                TDataBase db = new TDataBase();

                TDBType dbtype = TDBType.ProgressODBC;

                if (settings.IsFlagSet("Server.RDBMSType"))
                {
                    dbtype = CommonTypes.ParseDBType(settings.GetOptValue("Server.RDBMSType"));
                }

                if (dbtype != TDBType.ProgressODBC)
                {
                    throw new Exception("at the moment only Progress ODBC db is supported");
                }

                db.EstablishDBConnection(dbtype,
                                         settings.GetOptValue("Server.ODBC_DSN"),
                                         "",
                                         "",
                                         settings.GetOptValue("username"),
                                         settings.GetOptValue("password"),
                                         "");
                DBAccess.GDBAccessObj = db;

                TLogging.DebugLevel = 10;

                string sqlText = "";

                if (!settings.IsFlagSet("sql"))
                {
                    Console.WriteLine("Please enter sql and finish with semicolon: ");

                    while (!sqlText.Trim().EndsWith(";"))
                    {
                        sqlText += " " + Console.ReadLine();
                    }

                    sqlText = sqlText.Substring(0, sqlText.Length - 1);
                }
                else
                {
                    sqlText = settings.GetOptValue("sql");
                    Console.WriteLine(sqlText);
                }

                TDBTransaction transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadUncommitted);

                DataTable table = db.SelectDT(sqlText, "temp", transaction);

                XmlDocument doc = TDataBase.DataTableToXml(table);

                if (settings.IsFlagSet("output"))
                {
                    if (settings.GetOptValue("output").EndsWith("yml"))
                    {
                        TYml2Xml.Xml2Yml(doc, settings.GetOptValue("output"));
                    }
                    else if (settings.GetOptValue("output").EndsWith("csv"))
                    {
                        TCsv2Xml.Xml2Csv(doc, settings.GetOptValue("output"));
                    }
                    else if (settings.GetOptValue("output").EndsWith("xml"))
                    {
                        StreamWriter sw = new StreamWriter(settings.GetOptValue("output"));
                        sw.Write(TXMLParser.XmlToString2(doc));
                        sw.Close();
                    }
                }
                else
                {
                    TYml2Xml.Xml2Yml(doc, "temp.yml");
                    StreamReader sr = new StreamReader("temp.yml");
                    Console.WriteLine(sr.ReadToEnd());
                    sr.Close();
                }

                db.RollbackTransaction();
                db.CloseDBConnection();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }