Esempio n. 1
0
        public async Task <string> createNewReport(ReportViewModel vm)
        {
            string uri = "http://71.92.131.203/db/data/cypher/";
            string query;

            query = "CREATE (x:Report {timestamp:timestamp() , matchNumber:\"" + vm.matchNumber + "\"" +
                    " ,score:\"" + vm.allianceScore + "\"" +
                    " ,brokeDown:" + vm.brokeDown +
                    " ,toteScore:\"" + vm.toteScore + "\" ,canScore:\"" + vm.canScore + "\"" +
                    " ,coopScore:\"" + vm.coopScore + "\" ,noodleScore:\"" + vm.noodleScore + "\"" +
                    " ,notes:\"" + vm.notes + "\" , autoCapability:\"" + vm.autoCapability + "\"" +
                    "}) WITH x MATCH (a:Team) WHERE a.number = " + vm.teamNumber +
                    " WITH x,a CREATE (a)-[r:HAS_REPORT]->(x)" +
                    " WITH a SET  a.auto=\"" + vm.autoCapability + "\", a.reliability=\"" + vm.brokeDown + "\", a.score=\"" + vm.allianceScore + "\" ,a.toteScore=" + vm.toteScore + " ,a.canScore=" + vm.canScore + " ,a.coopScore=" + vm.coopScore + " ,a.noodleScore=" + vm.noodleScore + ", a.reports=1 ";
            string responseStr = await SendAndReceiveJsonRequest(uri, query);

            return(responseStr);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public ScoutReportPage(InfoPage ip, string number)
        {
            InitializeComponent();
            iPage  = ip;
            model0 = new ReportViewModel();
            model1 = new ReportViewModel();
            model2 = new ReportViewModel();

            model0.teamName = "???";
            model1.teamName = "???";
            model2.teamName = "???";

            int n;

            if (number != null)            // use the selected team number string
            {
                int.TryParse(number, out n);
                model0.teamNumber = n;
                team1.Text        = number;
                team2.Text        = "####";
                team3.Text        = "####";
            }
            else
            {
                model0.teamNumber = 0;
            }

            Random rand = new Random();

            //model.pointsScored = rand.Next().ToString();
            model0.matchNumber = 0.ToString();            //rand.Next().ToString();
            model1.matchNumber = 0.ToString();
            model2.matchNumber = 0.ToString();

            for (int i = 0; i < 400; ++i)
            {
                allianceScore.Items.Add(i.ToString());
            }

            team1.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                int.TryParse(e.NewTextValue, out n);
                model0.teamNumber = n;
            };

            team2.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                int.TryParse(e.NewTextValue, out n);
                model1.teamNumber = n;
            };

            team3.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                int.TryParse(e.NewTextValue, out n);
                model2.teamNumber = n;
            };

            canScore0.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                canScore0.Unfocus();
                model0.canScore        += canScore0.SelectedIndex * 4;
                canScoreTitle0.Text     = "Cans:" + model0.canScore.ToString();
                canScore0.SelectedIndex = 0;
            };

            toteScore0.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                toteScore0.Unfocus();
                model0.toteScore        += toteScore0.SelectedIndex * 2;
                toteScore0.SelectedIndex = 0;                //On the screen picker stay at the old value
                toteScoreTitle0.Text     = "Totes:" + model0.toteScore.ToString();
                toteScore0.SelectedIndex = 0;
            };

            noodleScore0.SelectedIndexChanged += (object sender, EventArgs e) => {
                noodleScore0.Unfocus();
                model0.noodleScore        += noodleScore0.SelectedIndex * 4;
                noodleScoreTitle0.Text     = "Noodles:" + model0.noodleScore.ToString();
                noodleScore0.SelectedIndex = 0;
            };

            coopScore0.SelectedIndexChanged += (object sender, EventArgs e) => {
                coopScore0.Unfocus();
                model0.coopScore        += coopScore0.SelectedIndex * 4;
                coopScoreTitle0.Text     = "Coop:" + model0.coopScore.ToString();
                coopScore0.SelectedIndex = 0;
            };

            canScore1.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                canScore1.Unfocus();
                model1.canScore        += canScore1.SelectedIndex * 4;
                canScoreTitle1.Text     = "Cans:" + model1.canScore.ToString();
                canScore1.SelectedIndex = 0;
            };

            toteScore1.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                toteScore1.Unfocus();
                model1.toteScore        += toteScore1.SelectedIndex * 2;
                toteScore1.SelectedIndex = 0;                //On the screen picker stay at the old value
                toteScoreTitle1.Text     = "Totes:" + model1.toteScore.ToString();
                toteScore1.SelectedIndex = 0;
            };

            noodleScore1.SelectedIndexChanged += (object sender, EventArgs e) => {
                noodleScore1.Unfocus();
                model1.noodleScore        += noodleScore1.SelectedIndex * 4;
                noodleScoreTitle1.Text     = "Noodles:" + model1.noodleScore.ToString();
                noodleScore1.SelectedIndex = 0;
            };

            coopScore1.SelectedIndexChanged += (object sender, EventArgs e) => {
                coopScore1.Unfocus();
                model1.coopScore        += coopScore1.SelectedIndex * 4;
                coopScoreTitle1.Text     = "Coop:" + model1.coopScore.ToString();
                coopScore1.SelectedIndex = 0;
            };

            canScore2.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                canScore2.Unfocus();
                model2.canScore        += canScore2.SelectedIndex * 4;
                canScoreTitle2.Text     = "Cans:" + model2.canScore.ToString();
                canScore2.SelectedIndex = 0;
            };

            toteScore2.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                toteScore2.Unfocus();
                model2.toteScore        += toteScore2.SelectedIndex * 2;
                toteScore2.SelectedIndex = 0;                //On the screen picker stay at the old value
                toteScoreTitle2.Text     = "Totes:" + model2.toteScore.ToString();
                toteScore2.SelectedIndex = 0;
            };

            noodleScore2.SelectedIndexChanged += (object sender, EventArgs e) => {
                noodleScore2.Unfocus();
                model2.noodleScore        += noodleScore2.SelectedIndex * 4;
                noodleScoreTitle2.Text     = "Noodles:" + model2.noodleScore.ToString();
                noodleScore2.SelectedIndex = 0;
            };

            coopScore2.SelectedIndexChanged += (object sender, EventArgs e) => {
                coopScore2.Unfocus();
                model2.coopScore        += coopScore2.SelectedIndex * 4;
                coopScoreTitle2.Text     = "Coop:" + model2.coopScore.ToString();
                coopScore2.SelectedIndex = 0;
            };
            //model.scoutName = "JOHNNY FIVE";
        }