예제 #1
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            string text = textBox1.Text;
            string date = Convert.ToString(dateTimePicker1.Value);

            this.Hide();
            var eventCounter = Dic1.Count + Dic2.Count + 2;


            //Write to xml file
            WriteToXML(text, date, eventCounter + 1, eve_type, X, Y);

            //Set event information into Events1 class
            Events1 obj = new Events1();

            obj.setText(text);
            obj.setDateTimeStamp(date);
            obj.setEventID(("ID" + (eventCounter + 1)));
            obj.setEventType(eve_type);
            obj.setLatitude(Convert.ToString(X));
            obj.setLongitude(Convert.ToString(Y));

            Dic1.Add(("ID" + (eventCounter + 1)), obj);

            ChoiceForm f2 = new ChoiceForm();

            //Set values into dictionary
            Database db = new Database();

            db.setDictionaries(Dic1, Dic2);

            f2.setTwitterFBFlag(true);
        }
예제 #2
0
        //Loading events from XML file into Dictionaries
        public void LoadEventsFromFile()
        {
            document = new XmlDocument();
            document.Load(filePath);

            //Source:  https://docs.microsoft.com/en-us/dotnet/api/system.xml.linq.xdocument.parse?view=netframework-4.8
            xDocument = XDocument.Parse(document.InnerXml);

            bool   app          = false;
            bool   flagTime1    = true;
            bool   flag1        = false;
            bool   flag2        = false;
            string eventid      = "";
            int    eventCounter = 0;

            //Use of LINQ to XML
            foreach (XElement sr in xDocument.Descendants())
            {
                string key = sr.Name.LocalName;

                if (key.Equals("eventid"))
                {
                    if (eventCounter > 0)
                    {
                        app = true;
                    }

                    if (flag1 == true)
                    {
                        Dic1.Add(("ID" + eventCounter), obj1);
                    }
                    else if (flag2 == true)
                    {
                        Dic2.Add(("ID" + eventCounter), obj2);
                    }

                    flag1 = false;
                    flag2 = false;

                    eventid = sr.Value;
                }


                /**** For tweet, fb events *****/
                if (key.Equals("tweet") || key.Equals("facebook-status-update"))
                {
                    eventCounter++;

                    if (app == true)
                    {
                        obj1 = new Events1();
                        obj1.setEventType(key);
                    }
                    app   = false;
                    flag1 = true;
                }

                /*** For photo, video, tracklog events ***/
                if (key.Equals("photo") || key.Equals("video") || key.Equals("tracklog"))
                {
                    eventCounter++;

                    if (app == true)
                    {
                        obj2 = new Events2();
                        obj2.setEventType(key);
                    }

                    app   = false;
                    flag2 = true;
                }


                if (flag1 == true)
                {
                    obj1.setEventID(eventid);
                    SetEvents1(key, sr);
                }


                if (flag2 == true)
                {
                    obj2.setEventID(eventid);
                    SetEvents2(key, sr, flagTime1);
                    flagTime1 = true;
                }
            }

            /***** Adding last event into dictionary*******/
            if (flag1 == true)
            {
                Dic1.Add(("ID" + eventCounter), obj1);
            }
            else if (flag2 == true)
            {
                Dic2.Add(("ID" + eventCounter), obj2);
            }
        }