예제 #1
0
        public void newFRCTeam(int number, string name, bool sw)
        {
            // get the current data source
            ObservableCollection <HomePageViewModel> home = listView.ItemsSource as ObservableCollection <HomePageViewModel>;

            // make a new team object
            HomePageViewModel m = new HomePageViewModel(typeof(NewTeamPage));

            // set the name and team number
            m.teamName   = name;
            m.teamNumber = number;
            m.PageName   = name + " : " + number.ToString();
            m.index      = models.Count + 1;
            m.swich      = sw;
            // add this to our Home Page ListView
            home.Add(m);

            listView.ItemsSource = models;
        }
예제 #2
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);
        }