Example #1
0
 public static void SubmitStats(Session session)
 {
     //// POST it to the server
     //var request = (HttpWebRequest)WebRequest.Create("http://jewllama.arborvs.co.uk/api/submit.php");
     //request.Method = "POST";
     //request.ContentType = "application/octet-stream";
     //request.ContentLength = json.Length;
     //Stream dataStream = null;
     //try
     //{
     //    dataStream = request.GetRequestStream();
     //    dataStream.Write(json.GetBuffer(), 0, (int)json.Length);
     //}
     //catch (WebException)
     //{
     //    return;
     //}
     //finally
     //{
     //    if (dataStream != null)
     //        dataStream.Close();
     //    json.Close();
     //}
 }
Example #2
0
        private void btnDoTwitterAnalysis_Click(object sender, EventArgs e)
        {
            var timeInSeconds = Convert.ToInt32(txtGametypeLength.Text) * 60;
            var twitterStreamer = new Streamer(_cityA, _cityB);
            var i = 0;
            var max = timeInSeconds / 5;
            _session = new Session
            {
                CityA = _cityA,
                CityB = _cityB
            };

            var timer = new Timer { Interval = 5000 };
            timer.Tick += (o, args) =>
            {
                if (i > max)
                {
                    File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "/city_data.json.new", JsonConvert.SerializeObject(_session));

                    // finishing up code
                    timer.Stop();
                    MessageBox.Show("Tweets Analysis Done");
                }
                else
                {
                    var response = twitterStreamer.CalculateShittyCity();
                    _session.DataPoints.Add(new DataPoint
                    {
                        CityARating = response.Item1,
                        CityBRating = response.Item2
                    });
                }

                i++;
            };
            timer.Start();
        }
Example #3
0
        private void btnLoadJsonFromLocal_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();
            if (ofd.ShowDialog() != DialogResult.OK) return;

            _session = JsonConvert.DeserializeObject<Session>(File.ReadAllText(ofd.FileName));
            MessageBox.Show("Loaded Local JSON");
        }