示例#1
0
        public void processQuery4(XDocument xdoc, Sender sndr, Message msg)
        {
            string pattern = getMetadataPat(xdoc);
            DBElement <string, List <string> > element = new DBElement <string, List <string> >();
            QueryEngine <string, string>       QE1     = new QueryEngine <string, string>();
            Message testMsg = new Message();

            testMsg.toUrl   = msg.fromUrl;
            testMsg.fromUrl = msg.toUrl;
            List <string> values = new List <string>();

            values = QE1.metaDataPattern(pattern, db);
            if (values.Count() > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string str in values)
                {
                    sb.Append(str);
                    sb.Append("\n");
                }
                testMsg.content = "\n***********************\n" + "\nResult of Query4\n" + "Keys with pattern like " + pattern + " in the metadata are :\n" + sb + "\n";
            }
            else
            {
                testMsg.content = "\n**********************\n" + "\nKeys with date pattern like  " + pattern + " in the metadata not found\n";
            }
            sndr.sendMessage(testMsg);
        }
        static void Main(string[] args)
        {
            QueryEngine <int, string>    QE  = new QueryEngine <int, string>();
            QueryEngine <string, string> QE1 = new QueryEngine <string, string>();

            DBEngine <int, DBElement <int, List <string> > >       dbPay    = new DBEngine <int, DBElement <int, List <string> > >();
            DBEngine <string, DBElement <string, List <string> > > dbString = new DBEngine <string, DBElement <string, List <string> > >();
            DBElement <string, List <String> > elemString = new DBElement <string, List <String> >(); //Populating DBEngine

            elemString.name      = "Element2";                                                        //object dbString
            elemString.descr     = "testelement2";                                                    //for testing data string and list of string type.
            elemString.timeStamp = DateTime.Now;
            elemString.children.AddRange(new List <string> {
                "SMA1", "Syracuse2", "NY3"
            });
            elemString.payload = new List <string>();
            elemString.payload.AddRange(new List <string> {
                "we", "rock", "the ", "world"
            });
            dbString.insert("Prohject2", elemString);
            DBElement <string, List <String> > elemString2 = new DBElement <string, List <String> >(); //Populating DBEngine

            elemString2.name      = "Element3";                                                        //object dbString
            elemString2.descr     = "test element3";                                                   //for testing data string and list of string type.
            elemString2.timeStamp = DateTime.Now;
            elemString2.children.AddRange(new List <string> {
                "SMA2", "Syracuse22", "NY33"
            });
            elemString2.payload = new List <string>();
            elemString2.payload.AddRange(new List <string> {
                "Thug", "Life"
            });
            dbString.insert("Thug3", elemString2);
            DBElement <int, List <string> > elemPayload = new DBElement <int, List <string> >();    //Populating DBEngine

            elemPayload.name      = "Element4";                                                     //object dbPay
            elemPayload.descr     = "test element4";                                                //for testing data int and list of string type.
            elemPayload.timeStamp = DateTime.Now;
            elemPayload.children.AddRange(new List <int> {
                1, 2, 3
            });
            elemPayload.payload = new List <string>();
            elemPayload.payload.AddRange(new List <string> {
                "Project 2", " ", "demo", " ", "starts"
            });
            dbPay.insert(1, elemPayload);
            DBElement <int, List <string> > elemPayload2 = new DBElement <int, List <string> >();   //Populating DBEngine

            elemPayload2.name      = "Element5";                                                    //object dbPay
            elemPayload2.descr     = "test element5";                                               //for testing data int and list of string type.
            elemPayload2.timeStamp = DateTime.Now;
            elemPayload2.children.AddRange(new List <int> {
                98, 22, 35
            });
            elemPayload2.payload = new List <string>();
            elemPayload2.payload.AddRange(new List <string> {
                "we", "rock", "the", "world"
            });
            dbPay.insert(2, elemPayload2);

            QE.valueByKey(1, dbPay);
            WriteLine();

            QE.childrenByKey(1, dbPay);


            WriteLine();
            QE1.keyPattern(".*hjbbj.*", dbString);
            WriteLine();
            QE.metaDataPattern("t2", dbString);


            DateTime toDate   = new DateTime(2015, 10, 7);
            DateTime fromDate = new DateTime(2015, 10, 1);


            QE.dateTimeSearch(fromDate, toDate, dbString);
        }