Beispiel #1
0
 public async Task scoreTeam(Team t, Score s, int scoringTeam, string scoredBy)
 {
     string uri = "http://71.92.131.203:7475/db/data/cypher/";
     string query = "MATCH (n: Team { number:" + t.number + " })" +
                    "MERGE (s: Score { tNum: " + t.number + ", scoringTeam: " + scoringTeam + " }) WITH n, s " +
                    "MERGE (n)-[r:HAS]->(s)" + //: Score { tNum:" + t.number + " }
                    " ON MATCH SET s.scorer=\"" + scoredBy + "\", s.upScore0=" + s.upScore[0] + ", s.upScore1=" + s.upScore[1] + ", s.upScore2=" + s.upScore[2] + ", s.upScore3=" + s.upScore[3] + ", s.upScore4=" + s.upScore[4] + ", s.upScore5=" + s.upScore[5] + ", s.upScore6=" + s.upScore[6] + ", s.upScore7=" + s.upScore[7] + ", s.upScore8=" + s.upScore[8] +
                    ", s.dnScore0=" + s.dnScore[0] + ", s.dnScore1=" + s.dnScore[1] + ", s.dnScore2=" + s.dnScore[2] + ", s.dnScore3=" + s.dnScore[3] + ", s.dnScore4=" + s.dnScore[4] + ", s.dnScore5=" + s.dnScore[5] + ", s.dnScore6=" + s.dnScore[6] + ", s.dnScore7=" + s.dnScore[7] + ", s.dnScore8=" + s.dnScore[8] +
                    " ON CREATE SET s.scorer=\"" + scoredBy + "\", s.upScore0=" + s.upScore[0] + ", s.upScore1=" + s.upScore[1] + ", s.upScore2=" + s.upScore[2] + ", s.upScore3=" + s.upScore[3] + ", s.upScore4=" + s.upScore[4] + ", s.upScore5=" + s.upScore[5] + ", s.upScore6=" + s.upScore[6] + ", s.upScore7=" + s.upScore[7] + ", s.upScore8=" + s.upScore[8] +
                    ", s.dnScore0=" + s.dnScore[0] + ", s.dnScore1=" + s.dnScore[1] + ", s.dnScore2=" + s.dnScore[2] + ", s.dnScore3=" + s.dnScore[3] + ", s.dnScore4=" + s.dnScore[4] + ", s.dnScore5=" + s.dnScore[5] + ", s.dnScore6=" + s.dnScore[6] + ", s.dnScore7=" + s.dnScore[7] + ", s.dnScore8=" + s.dnScore[8] +
                    ", s.time=timestamp() RETURN s"; // Attach sender to Entr and return all diary entries for this timeline
     var r = SendAndReceiveJsonRequest(uri, query);
     string responseStr = await r;
 }
Beispiel #2
0
        public async Task<Score> getScore(int tN, int stNum)
        {
            string uri = "http://71.92.131.203:7475/db/data/cypher/";
            string query = "MATCH (n: Score { tNum: " + tN + ", scoringTeam: " + stNum + " }) RETURN n"; // Attach sender to Entr and return all diary entries for this timeline
            var r = SendAndReceiveJsonRequest(uri, query);
            string responseStr = await r;
            Score data = new Score();
            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);

                                try
                                {

                                    data.scoringTeam = (int)token.SelectToken("scoringTeam");
                                    data.tNum = (int)token.SelectToken("tNum");
                                    data.upScore[0] = (int)token.SelectToken("upScore0");
                                    data.upScore[1] = (int)token.SelectToken("upScore1");
                                    data.upScore[2] = (int)token.SelectToken("upScore2");
                                    data.upScore[3] = (int)token.SelectToken("upScore3");
                                    data.upScore[4] = (int)token.SelectToken("upScore4");
                                    data.upScore[5] = (int)token.SelectToken("upScore5");
                                    data.upScore[6] = (int)token.SelectToken("upScore6");
                                    data.upScore[7] = (int)token.SelectToken("upScore7");
                                    data.upScore[8] = (int)token.SelectToken("upScore8");
                                    data.dnScore[0] = (int)token.SelectToken("dnScore0");
                                    data.dnScore[1] = (int)token.SelectToken("dnScore1");
                                    data.dnScore[2] = (int)token.SelectToken("dnScore2");
                                    data.dnScore[3] = (int)token.SelectToken("dnScore3");
                                    data.dnScore[4] = (int)token.SelectToken("dnScore4");
                                    data.dnScore[5] = (int)token.SelectToken("dnScore5");
                                    data.dnScore[6] = (int)token.SelectToken("dnScore6");
                                    data.dnScore[7] = (int)token.SelectToken("dnScore7");
                                    data.dnScore[8] = (int)token.SelectToken("dnScore8");
                                }
                                catch (Exception ex)
                                {
                                    System.Diagnostics.Debug.WriteLine("Bad token: " + ex.Message);
                                }
                                return data;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return data;
        }
Beispiel #3
0
        public async void getTeams()
        {
            blueAlliance.Clear();
            redAlliance.Clear();
            blueScore.Clear();
            redScore.Clear();
            try
            {
                REST neo = new REST();
                // Get Team's for this match
                var result = neo.getTeam(int.Parse(match.blue1));
                Team t = await result;
                blueAlliance.Insert(0, t);

                result = neo.getTeam(int.Parse(match.blue2));
                t = await result;
                blueAlliance.Insert(1, t);

                result = neo.getTeam(int.Parse(match.blue3));
                t = await result;
                blueAlliance.Insert(2, t);


                result = neo.getTeam(int.Parse(match.red1));
                t = await result;
                redAlliance.Insert(0, t);

                result = neo.getTeam(int.Parse(match.red2));
                t = await result;
                redAlliance.Insert(1, t);

                result = neo.getTeam(int.Parse(match.red3));
                t = await result;
                redAlliance.Insert(2, t);

                // Get Score's recorded by this team
                var res = neo.getScore(int.Parse(match.blue1), MatchListPage.opt.teamNumber);
                Score s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(0, s);
                if (s.tNum == 0)
                {
                    blueScore[0].tNum = int.Parse(match.blue1);
                    blueScore[0].scoringTeam = MatchListPage.opt.teamNumber;
                }
                
                res = neo.getScore(int.Parse(match.blue2), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(1, s);
                if (s.tNum == 0)
                {
                    blueScore[1].tNum = int.Parse(match.blue2);
                    blueScore[1].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.blue3), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                blueScore.Insert(2, s);
                if (s.tNum == 0)
                {
                    blueScore[2].tNum = int.Parse(match.blue3);
                    blueScore[2].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red1), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(0, s);
                if (s.tNum == 0)
                {
                    redScore[0].tNum = int.Parse(match.red1);
                    redScore[0].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red2), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(1, s);
                if (s.tNum == 0)
                {
                    redScore[1].tNum = int.Parse(match.red2);
                    redScore[1].scoringTeam = MatchListPage.opt.teamNumber;
                }

                res = neo.getScore(int.Parse(match.red3), MatchListPage.opt.teamNumber);
                s = await res;
                if (s == null)
                    s = new Score();
                redScore.Insert(2, s);
                if (s.tNum == 0)
                {
                    redScore[2].tNum = int.Parse(match.red3);
                    redScore[2].scoringTeam = MatchListPage.opt.teamNumber;
                }


                whatColor();


            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }