Esempio n. 1
0
        public string processDataRestoreMessageRequest()
        {
            string content = "";

            try
            {
                PersistData <string, List <string> > persistEngine = new PersistData <string, List <string> >();
                DBEngine <string, DBElement <string, List <string> > > restoreData = new DBEngine <string, DBElement <string, List <string> > >();
                persistEngine.restoreData(restoreData, "PersistData.xml");

                if (restoreData.Keys().Count() > 0)
                {
                    content = "\nDatabase restored successfully from PersistData.xml";
                }
                else
                {
                    content = "\nDatabase restore failed";
                }
            }
            catch (Exception e)
            {
                Console.Write(" Exception : " + e.StackTrace);
                content = "\nDatabase restore failed";
            }
            return(content);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            "Testing Persist Engine Package".title('=');
            DBEngine <int, DBElement <int, ListOfStrings> > db1 = new DBEngine <int, DBElement <int, ListOfStrings> >();
            PersistData <int, ListOfStrings> persistEngine1     = new PersistData <int, ListOfStrings>();

            "Write in-memory database in XML file, please check DataPersistTest.xml file.".title('-');
            persistEngine1.loadXmlFile("DataPersistTest.xml", typeof(int).Name, typeof(ListOfStrings).Name);
            if (!persistEngine1.addRecord(1, db1.Dictionary[1]))
            {
                WriteLine("Key 1 is already in xml file.");
            }
            else
            {
                WriteLine("Key 1 is inserted in xml file.");
            }
            if (!persistEngine1.addRecord(2, db1.Dictionary[2]))
            {
                WriteLine("Key 2 is already in xml file.");
            }
            else
            {
                WriteLine("Key 2 is inserted in xml file.");
            }
            if (!persistEngine1.addRecord(4, db1.Dictionary[4]))
            {
                WriteLine("Key 4 is already in xml file.");
            }
            else
            {
                WriteLine("Key 4 is inserted in xml file.");
            }
            if (!persistEngine1.addRecord(2, db1.Dictionary[4]))
            {
                WriteLine("Key 4 is already in xml file.");
            }
            else
            {
                WriteLine("Key 4 is inserted in xml file.");
            }

            "Database restored or augmented from an existing XML (Data1.xml) file".title('-');

            DBEngine <int, DBElement <int, ListOfStrings> > augmentData = new DBEngine <int, DBElement <int, ListOfStrings> >();

            persistEngine1.retrieveDataFromXML(augmentData, "DataPersistTest.xml");
            augmentData.showDB();

            WriteLine();
        }
Esempio n. 3
0
        //----< persist data to file when request came from client.>-----
        private void persistDatatToFile()
        {
            PersistData <string, List <string> > persistEngine = new PersistData <string, List <string> >();

            persistEngine.restoreDataToXML("PersistData.xml", db);
        }