Beispiel #1
0
        public async Task <ObservableCollection <HomePageViewModel> > getAllTeams()
        {
            string uri         = "http://71.92.131.203/db/data/cypher/";
            string query       = "MATCH (a:Team) RETURN a";
            string responseStr = await SendAndReceiveJsonRequest(uri, query);

            var results = new ObservableCollection <HomePageViewModel>();

            try
            {
                neo4jData val = Newtonsoft.Json.JsonConvert.DeserializeObject <neo4jData>(responseStr);

                foreach (var kvp in val.data)               // process column 'a'
                {
                    foreach (var kv in kvp)
                    {
                        foreach (var k in kv)
                        {
                            if (k.Key == "data")                           // these are the events
                            {
                                string values = Newtonsoft.Json.JsonConvert.SerializeObject(k.Value);

                                string            ds    = Newtonsoft.Json.JsonConvert.SerializeObject(k.Value);
                                JToken            token = JObject.Parse(ds);
                                HomePageViewModel data  = new HomePageViewModel(typeof(HomePage));
                                data.teamName = (string)token.SelectToken("name");

                                if (token.SelectToken("number") != null)
                                {
                                    data.teamNumber = (int)token.SelectToken("number");
                                }
                                else
                                {
                                    data.teamNumber = -1;
                                }

                                data.score = (string)token.SelectToken("score");
                                try
                                {
                                    data.toteScore   = (int)token.SelectToken("toteScore");
                                    data.canScore    = (int)token.SelectToken("canScore");
                                    data.auto        = (string)token.SelectToken("auto");
                                    data.reliability = (string)token.SelectToken("reliability");
                                    data.reports     = (int)token.SelectToken("reports");
                                    data.coopScore   = (int)token.SelectToken("coopScore");
                                    data.noodleScore = (int)token.SelectToken("noodleScore");
                                    data.swich       = (bool)token.SelectToken("switch");
                                }

                                catch (Exception ex)
                                {
                                }
                                if (data.video == null)
                                {
                                    data.video = "https://www.youtube.com/watch?v=W6UYFKNGHJ8";                                  //https://www.youtube.com/watch?v=-2NhcAbinDg
                                }
                                results.Add(data);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(results);
        }
Beispiel #2
0
        public async Task <ObservableCollection <ReportViewModel> > getReports(int teamNum)
        {
            string uri         = "http://71.92.131.203/db/data/cypher/";
            string query       = "MATCH (a:Team)-[HAS_REPORT]->(b:Report) where b.timestamp>1427563749528 AND a.number=" + teamNum.ToString() + " RETURN b";
            string responseStr = await SendAndReceiveJsonRequest(uri, query);

            var results = new ObservableCollection <ReportViewModel>();

            try
            {
                neo4jData val = Newtonsoft.Json.JsonConvert.DeserializeObject <neo4jData>(responseStr);

                foreach (var kvp in val.data)               // process column 'a'
                {
                    foreach (var kv in kvp)
                    {
                        foreach (var k in kv)
                        {
                            if (k.Key == "data")                           // these are the events
                            {
                                string          values = Newtonsoft.Json.JsonConvert.SerializeObject(k.Value);
                                string          ds     = Newtonsoft.Json.JsonConvert.SerializeObject(k.Value);
                                JToken          token  = JObject.Parse(ds);
                                ReportViewModel data   = new ReportViewModel();

                                try
                                {
                                    data.timestamp   = (double)token.SelectToken("timestamp");
                                    data.matchNumber = (string)token.SelectToken("matchNumber");
                                    data.notes       = (string)token.SelectToken("notes");

                                    data.allianceScore  = (string)token.SelectToken("score");
                                    data.canScore       = (int)token.SelectToken("canScore");
                                    data.toteScore      = (int)token.SelectToken("toteScore");
                                    data.brokeDown      = (bool)token.SelectToken("brokeDown");
                                    data.autoCapability = (string)token.SelectToken("autoCapability");
                                    data.coopScore      = (int)token.SelectToken("coopScore");
                                    data.noodleScore    = (int)token.SelectToken("noodleScore");
                                }
                                catch (Exception ex)
                                {
                                }

                                /*
                                 * if (token.SelectToken("score")!=null)
                                 *      data.score =(int)token.SelectToken("score");
                                 * else
                                 *      data.score=-1;
                                 */
                                results.Add(data);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(results);
        }