示例#1
0
        //METHOD FOR ADD TO JSON FILE BUTTON CLICK
        private void addtoJsonBtn_Click(object sender, RoutedEventArgs e)
        {
            //WRITE MESSAGES TO JSON
            MsgList      list          = MsgList.Instance();
            int          length        = list.getSize();
            StreamWriter writeMessages = new StreamWriter(@"jsonMessages.txt");

            for (int i = 0; i < length; i++)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(list.getMessage(i));
                writeMessages.WriteLine(json);
            }
            writeMessages.Close();
            //WRITE URLS TO JSON
            StreamWriter      writeUrls = new StreamWriter(@"jsonUrls.txt");
            urlQuarantineList u         = urlQuarantineList.Instance();

            for (int i = 0; i < u.getSize(); i++)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(u.getUrl(i));
                writeUrls.WriteLine(json);
            }
            writeUrls.Close();
            //WRITE HASH TAGS TO JSON
            StreamWriter writeTags = new StreamWriter(@"jsonTags.txt");
            HashTags     hashTag   = HashTags.Instance();

            for (int i = 0; i < hashTag.getSize(); i++)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(hashTag.getTag(i));
                writeTags.WriteLine(json);
            }
            writeTags.Close();
            //WRITE MENTIONS TO JSON
            StreamWriter writeMen = new StreamWriter(@"jsonMen.txt");
            Mentions     men      = Mentions.Instance();

            for (int i = 0; i < men.getSize(); i++)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(men.getTid(i));
                writeMen.WriteLine(json);
            }
            writeMen.Close();
            //WRITE SIR MESSAGES TO JSON
            StreamWriter writeSir = new StreamWriter(@"jsonSir.txt");
            SirList      sir      = SirList.Instance();

            for (int i = 0; i < sir.getSize(); i++)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(sir.getSir(i));
                writeSir.WriteLine(json);
            }
            writeSir.Close();

            statusBox.Text = "Data writen to Json.";
        }