async Task getTeamList() { Console.WriteLine("Begin"); if (CheckInternetConnectivity.InternetStatus()) { try { var list = new List <TeamData>(); var db = new FirebaseClient(GlobalVariables.firebaseURL); //var tbaTeams = Events.GetEventTeamsListHttp("2017calb"); var fbTeams = await db .Child(GlobalVariables.regionalPointer) .Child("teamData") .OnceAsync <TeamData>(); foreach (var team in fbTeams) { Console.WriteLine("TeamNo: " + team.Object.teamNumber); list.Add(team.Object); } teamList = list; } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } Console.WriteLine("End"); }
async Task saveData() { if (CheckInternetConnectivity.InternetStatus()) { //data.volumeConfig = config; //data.maxFuelCapacity = Convert.ToInt32(fuelCapacityEntry.Text); //data.gearMechanism = checkBoxes[0].Checked; //data.fuelLowMechanism = checkBoxes[1].Checked; //data.fuelHighMechanism = checkBoxes[2].Checked; //data.climbingMechanism = checkBoxes[3].Checked; data.gearGroundIntakeMechanism = gearGroundIntake.Checked; //data.fuelGroundIntakeMechanism = checkBoxes[5].Checked; //data.pitAutoCross = checkBoxes[6].Checked; //data.pitAutoGear = checkBoxes[7].Checked; //data.pitAutoFuelLow = checkBoxes[8].Checked; //data.pitAutoFuelHigh = checkBoxes[9].Checked; //data.notes = notesEditor.Text; var db = new FirebaseClient(GlobalVariables.firebaseURL); var upload = db.Child(GlobalVariables.regionalPointer) .Child("teamData") .Child(data.teamNumber.ToString()) .PutAsync(data); await DisplayAlert("Success", "Data Saved", "OK").ContinueWith((a) => { Navigation.PopAllPopupAsync(); }); } }
async Task saveData() { if (CheckInternetConnectivity.InternetStatus()) { matchData.successfulClimb = climbSuccessBtn.getBtnStatus(); matchData.pilotError = pilotErrorBtn.getBtnStatus(); matchData.good = goodCheck.Checked; matchData.fullDisable = fullDisableBtn.getBtnStatus(); matchData.partialDisables = partialDisablesCounter.getValue(); matchData.fouls = foulCounter.getValue(); matchData.foulNote = foulNotes.Text; matchData.sendTime = DateTimeOffset.Now.ToUnixTimeSeconds(); matchData.dataIsReady = true; var db = new FirebaseClient(GlobalVariables.firebaseURL); string path = "ERROR"; if (mType == -1) { path = "practiceMatchData/" + matchData.matchID; } else { path = "matchData/" + matchData.matchID; } FirebaseAccess.saveData(db, path, matchData); /* * if (mType == -1) { * var send = db * .Child(GlobalVariables.regionalPointer) * .Child("PracticeMatches") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } else { * var fbTeam = db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } */ } }
async Task FetchTeamData(int i) { Console.WriteLine("Start"); if (CheckInternetConnectivity.InternetStatus()) { var db = new FirebaseClient(GlobalVariables.firebaseURL); teams[i] = new TeamData(); if (i < 3) { try { var fbTeams = await db .Child(GlobalVariables.regionalPointer) .Child("teamData") .Child(matchData.Red[i].ToString()) .OnceSingleAsync <TeamData>(); teams[i] = fbTeams; } catch (Exception ex) { Console.Write("Fetch Error: " + ex.Message); } } else { try { var fbTeams = await db .Child(GlobalVariables.regionalPointer) .Child("teamData") .Child(matchData.Blue[i % 3].ToString()) .OnceSingleAsync <TeamData>(); teams[i] = fbTeams; } catch (Exception ex) { Console.Write("Fetch Error: " + ex.Message); teamDataView[i].Content = errorStack[i]; } } Console.WriteLine("Team: " + teams[i].teamNumber); } semaphore[i] = true; }
async Task saveData() { if (CheckInternetConnectivity.InternetStatus()) { matchData.autoCross = inputs[0].getBtnStatus(); matchData.autoGearScored = inputs[1].getBtnStatus(); matchData.autoPressure = pressureCounter.getValue(); var db = new FirebaseClient(GlobalVariables.firebaseURL); string path = "ERROR"; if (mType == -1) { path = "practiceMatchData/" + matchData.matchID; } else { path = "matchData/" + matchData.matchID; } FirebaseAccess.saveData(db, path, matchData); /* * if (mType == -1) { * var send = db * .Child(GlobalVariables.regionalPointer) * .Child("PracticeMatches") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } else { * var fbTeam = db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } */ } }
public async Task UpdateTeamList() { busyIcon.IsRunning = true; busyIcon.IsVisible = true; if (CheckInternetConnectivity.InternetStatus()) { var teamList = await EventsHttp.GetEventTeamsListHttp(GlobalVariables.regionalPointer); var sorted = from Teams in teamList orderby Teams.team_number select Teams; var db = new FirebaseClient(GlobalVariables.firebaseURL); foreach (var team in sorted) { var fbTeam = await db .Child(GlobalVariables.regionalPointer) .Child("teamData") .Child(team.team_number.ToString()) .OnceSingleAsync <TeamData>(); if (fbTeam == null) { var send = db .Child(GlobalVariables.regionalPointer) .Child("teamData") .Child(team.team_number.ToString()) .PutAsync(new TeamData() { teamName = team.nickname, teamNumber = team.team_number }); } Console.WriteLine("Team Added: " + team.team_number); } await DisplayAlert("Done", "Team List Successfully Updated", "OK"); busyIcon.IsRunning = false; busyIcon.IsVisible = false; } }
public async Task UpdateTeamList() { if (CheckInternetConnectivity.InternetStatus()) { busyIcon.IsVisible = true; busyIcon.IsRunning = true; var db = new FirebaseClient(GlobalVariables.firebaseURL);; var fbTeams = await db .Child(GlobalVariables.regionalPointer) .Child("teamData") .OnceAsync <TeamData>(); //var sorted = fbTeams.OrderByDescending((arg) => arg.Key("team_number")); foreach (var team in fbTeams) { } busyIcon.IsVisible = false; busyIcon.IsRunning = false; } }
/* * void addAction(int v) { * bool t = false; * mActions[aIndex] = new ActionData(); * try { * foreach (var hopper in hopperCapacity.on) * if (hopper == true) { * t = true; * break; * } * if (t) * mActions[aIndex].hopperCapacity = hopperCapacity.getAvgPercentage() * robotMaxCapacity; * else * mActions[aIndex].hopperCapacity = 0; * } * catch{ * mActions[aIndex].hopperCapacity = 0; * } * * if (v == 0) // gear scored * mActions[aIndex].cyclePressure = 0; * else if (v == 1) // high shots * mActions[aIndex].cyclePressure = (int)Math.Floor((robotMaxCapacity * hopperCapacity.getAvgPercentage() * goalAccuracy.getAvgPercentage()) / 3); * else if (v == 2) { // low shots * mActions[aIndex].lowGoalDump = true; * mActions[aIndex].cyclePressure = (int)Math.Floor((robotMaxCapacity * hopperCapacity.getAvgPercentage()) / 9); * } else // no complete scoring action * mActions[aIndex].lowGoalDump = false; * * mActions[aIndex].gearsStationDrop = gearsStationDropped.getValue(); * mActions[aIndex].gearsTransitDrop = gearsTransitDropped.getValue(); * mActions[aIndex].gearSet = gearScoredBtn.on; * * if (gearScoredBtn.on) { * gearScoredBtn.on = false; * gearScoredBtn.BackgroundColor = Color.Red; * } * * lastActionLabels[0].Text = "Hopper Capacity: " + mActions[aIndex].hopperCapacity; * lastActionLabels[1].Text = "High Accuracy: " + mActions[aIndex].highGoalAccuracy; * lastActionLabels[2].Text = "Low Goal Dump: " + mActions[aIndex].lowGoalDump; * lastActionLabels[3].Text = "Cycle Pressure: " + mActions[aIndex].cyclePressure; * lastActionLabels[4].Text = "Gear Set: " + mActions[aIndex].gearSet; * lastActionLabels[5].Text = "Gear Station Drops: " + mActions[aIndex].gearsStationDrop; * lastActionLabels[6].Text = "Gear Transit Drops: " + mActions[aIndex].gearsTransitDrop; * clearValues(); * * if (v != 3) // aCount != aIndex in the event that the last 'action' the robot performs yeilds no score * aCount++; * aIndex++; * actionCounter.Text = aIndex.ToString(); * actionCounter.BackgroundColor = Color.Transparent; * cycleUndo.BackgroundColor = Color.Yellow; * } * * void undoAction() { * if (aIndex > 1) { * lastActionLabels[0].Text = "Hopper Capacity: " + mActions[aIndex - 1].hopperCapacity; * lastActionLabels[1].Text = "High Accuracy: " + mActions[aIndex - 1].highGoalAccuracy; * lastActionLabels[2].Text = "Low Goal Dump: " + mActions[aIndex - 1].lowGoalDump; * lastActionLabels[3].Text = "Cycle Pressure: " + mActions[aIndex - 1].cyclePressure; * lastActionLabels[4].Text = "Gear Set: " + mActions[aIndex - 1].gearSet; * lastActionLabels[5].Text = "Gear Station Drops: " + mActions[aIndex - 1].gearsStationDrop; * lastActionLabels[6].Text = "Gear Transit Drops: " + mActions[aIndex - 1].gearsTransitDrop; * aIndex--; * } else { * lastActionLabels[0].Text = "Hopper Capacity: " + 0; * lastActionLabels[1].Text = "High Accuracy: " + 0; * lastActionLabels[2].Text = "Low Goal Dump: " + false; * lastActionLabels[3].Text = "Cycle Pressure: " + 0; * lastActionLabels[4].Text = "Gear Set: " + false; * lastActionLabels[5].Text = "Gear Station Drops: " + 0; * lastActionLabels[6].Text = "Gear Transit Drops: " + 0; * } * * actionCounter.Text = aCount.ToString(); * actionCounter.BackgroundColor = Color.Orange; * lastActionView.BackgroundColor = Color.Orange; * } * */ async Task saveData() { matchData.actionCount = actionCounter.getValue(); matchData.teleOpPressure = pressureCounter.getValue(); matchData.teleOpGearsScored = gearCounter.getValue(); if (CheckInternetConnectivity.InternetStatus()) { /* * matchData.actionCount = aCount; * matchData.teleOpTotalPressure = teleOpPressure; * matchData.teleOpGearsDeposit = teleOpGears; * * int stationDropped = 0, transitDropped = 0; * double hAcc = 0; * for (int i = 0; i < aIndex; i++) { * hAcc += mActions[i].highGoalAccuracy; * stationDropped += mActions[i].gearsStationDrop; * transitDropped += mActions[i].gearsTransitDrop; * } * matchData.teleOpHighAcc = hAcc / aCount; * matchData.teleOpGearsStationDropped = stationDropped; * matchData.teleOpGearsTransitDropped = transitDropped; */ var db = new FirebaseClient(GlobalVariables.firebaseURL); string path = "ERROR"; if (mType == -1) { path = "practiceMatchData/" + matchData.matchID; } else { path = "matchData/" + matchData.matchID; FirebaseAccess.saveData(db, "matchActionData/" + matchData.matchID, matchData); } FirebaseAccess.saveData(db, path, matchData); /* * if (mType == -1) { * var send = db * .Child(GlobalVariables.regionalPointer) * .Child("PracticeMatches") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } else { * var matchBreakDown = db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchActionData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(mActions); * * var fbTeam = db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber.ToString()) * .PutAsync(matchData); * } */ } }
public PreMatchScoutingPage(string scouterName) { //Page Title Title = "Match Scouting"; if (!string.IsNullOrEmpty(scouts.scouterName)) { scouts.lineEntry.Text = scouterName; matchNoLineEntry.inputEntry.Text = ""; matchNumber = ""; } var checkBoxLayout = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal }; for (int i = 0; i < matchPhaseCheckboxes.Length; i++) { matchPhaseCheckboxes[i] = new CheckBox() { DefaultText = matchPhase[i], FontSize = GlobalVariables.sizeSmall } } ; foreach (var box in matchPhaseCheckboxes) { box.CheckedChanged += (sender, e) => { if (!semaphore) { checkBoxChanged(box); } }; checkBoxLayout.Children.Add(box); } getDefaultMatchType(); setNoLbl = new Label { Text = "Set Number:", FontSize = GlobalVariables.sizeSmall, FontAttributes = FontAttributes.Bold, }; setNoPicker.Title = "[Select Set No.]"; setNoPicker.SelectedIndexChanged += (sender, e) => { try { setNumber = Convert.ToInt32(setNoPicker.Items[setNoPicker.SelectedIndex]); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } setMatchNumber(); }; matchNoLineEntry = new LineEntry("Match Number:"); matchNoLineEntry.inputEntry.Keyboard = Keyboard.Numeric; matchNoLineEntry.inputEntry.TextChanged += (sender, e) => { setMatchNumber(); }; matchNoLayout = new StackLayout() { Orientation = StackOrientation.Horizontal, Spacing = 10, Children = { new StackLayout() { Children = { setNoLbl, setNoPicker } }, matchNoLineEntry } }; matchNoView = new ContentView() { Content = matchNoLineEntry }; Label allianceLabel = new Label { Text = "Alliance:", FontSize = GlobalVariables.sizeSmall, FontAttributes = FontAttributes.Bold }; alliancePicker = new Picker(); alliancePicker.Title = "[Choose an Option]"; foreach (var i in alliances) { alliancePicker.Items.Add(i); } alliancePicker.SelectedIndexChanged += (sender, e) => { setMatchNumber(); }; var teamNoLbl = new Label { Text = "Team Number:", FontSize = GlobalVariables.sizeSmall, FontAttributes = FontAttributes.Bold }; teamNoPicker = new Picker(); teamNoPicker.Title = "[Select Match No. and Alliance first]"; teamNoPicker.SelectedIndexChanged += (sender, e) => { try { teamNumber = Convert.ToInt32(teamNoPicker.Items[teamNoPicker.SelectedIndex]); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }; teamNoPickerLayout = new StackLayout() { Children = { teamNoLbl, teamNoPicker } }; teamNoView = new ContentView() { Content = teamNoPickerLayout }; teamNoLineEntry = new LineEntry("Team Number:"); teamNoLineEntry.inputEntry.Placeholder = "[Enter Team Number]"; teamNoLineEntry.inputEntry.Keyboard = Keyboard.Numeric; teamNoLineEntry.inputEntry.TextChanged += (sender, e) => { try { teamNumber = Convert.ToInt32(teamNoLineEntry.data); } catch { teamNumber = 0; } }; Label positionLabel = new Label { Text = "Starting Position:", FontSize = GlobalVariables.sizeSmall, FontAttributes = FontAttributes.Bold }; positionPicker = new Picker(); positionPicker.Title = "Choose an Option"; foreach (var i in startPos) { positionPicker.Items.Add(i); } positionPicker.SelectedIndexChanged += (sender, e) => { positionPicker.Title = positionPicker.Items[positionPicker.SelectedIndex]; }; var beginMatchBtn = new Button() { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.FillAndExpand, Text = "Begin Match", TextColor = Color.Green, BackgroundColor = Color.Black, FontSize = GlobalVariables.sizeMedium }; beginMatchBtn.Clicked += (sender, e) => { bool inputFlag = false; if (string.IsNullOrEmpty(scouts.lineEntry.Text)) { inputFlag = true; } if (string.IsNullOrEmpty(matchNoLineEntry.inputEntry.Text)) { inputFlag = true; } if ((teamNoPicker.SelectedIndex == -1 && (competitionPhase == "F" || competitionPhase == "QM")) || (teamNoPicker.SelectedIndex == -1 && setNoPicker.SelectedIndex == -1 && (competitionPhase == "QF" || competitionPhase == "SF")) || (string.IsNullOrEmpty(teamNoLineEntry.inputEntry.Text) && competitionPhase == "P")) { inputFlag = true; } if (positionPicker.SelectedIndex == -1 || alliancePicker.SelectedIndex == -1 || inputFlag) { DisplayAlert("Error", "Fill out all inputs", "OK"); } else { initializeTeamData(); } }; var navigationBtns = new NavigationButtons(false, new Button[] { beginMatchBtn }); navigationBtns.backBtn.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; var pageLayout = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Children = { busyIcon, scouts, checkBoxLayout, matchNoView, allianceLabel, alliancePicker, teamNoView, positionLabel, positionPicker } }; var dataScroll = new ScrollView() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Content = pageLayout }; var grid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Star }, new RowDefinition { Height = GridLength.Auto } } }; grid.Children.Add(dataScroll, 0, 0); grid.Children.Add(navigationBtns, 0, 1); Content = grid; } async Task getDefaultMatchType() { if (CheckInternetConnectivity.InternetStatus()) { var db = new FirebaseClient(GlobalVariables.firebaseURL); var phaseGet = await db .Child(GlobalVariables.regionalPointer) .Child("competitionPhase") .OnceSingleAsync <string>(); int i = 0; foreach (var phase in matchPhase) { if (phase == phaseGet) { break; } i++; } checkBoxChanged(matchPhaseCheckboxes[i]); } } void checkBoxChanged(CheckBox c) { semaphore = true; for (int i = 0; i < matchPhaseCheckboxes.Length; i++) { if (matchPhaseCheckboxes[i] != c) { matchPhaseCheckboxes[i].Checked = false; } else { matchPhaseCheckboxes[i].Checked = true; competitionPhase = matchPhase[i]; } } setMatchTeamNumberLayout(); if (competitionPhase != "QF" || competitionPhase != "SF") { teamNoPicker.Items.Clear(); teamNoPicker.SelectedIndex = -1; teamNoPicker.Title = "[Select A Team]"; } else { setMatchNumber(); } semaphore = false; } void setMatchTeamNumberLayout() { if (competitionPhase == "P") { teamNoView.Content = teamNoLineEntry; matchNoLayout.Children.Remove(matchNoLineEntry); } else { teamNoView.Content = teamNoPickerLayout; if (competitionPhase == "QM" || competitionPhase == "F") { matchNoView.Content = matchNoLineEntry; matchNoLayout.Children.Remove(matchNoLineEntry); } else { matchNoView.Content = matchNoLayout; matchNoLayout.Children.Add(matchNoLineEntry); setNoPicker.Items.Clear(); int items = 0; if (competitionPhase == "QF") { items = 4; } else { items = 2; } for (int i = 1; i <= items; i++) { setNoPicker.Items.Add(i.ToString()); } } } } async Task setMatchNumber() { if (competitionPhase == "QF" || competitionPhase == "SF") { matchNumber = competitionPhase + (setNoPicker.SelectedIndex + 1) + "M" + matchNoLineEntry.inputEntry.Text; } else if (competitionPhase == "F") { matchNumber = competitionPhase + matchNoLineEntry.inputEntry.Text; } else { matchNumber = competitionPhase + (Convert.ToInt64(matchNoLineEntry.inputEntry.Text) < 10 ? "0" + matchNoLineEntry.inputEntry.Text : matchNoLineEntry.inputEntry.Text); } if (!matchPhaseCheckboxes[0].Checked) { await getTeamNoPickerOptions(); } } async Task getTeamNoPickerOptions() { if (CheckInternetConnectivity.InternetStatus()) { try { busyIcon.IsVisible = true; busyIcon.IsRunning = true; var db = new FirebaseClient(GlobalVariables.firebaseURL); EventMatchData matchGet = new EventMatchData(); matchGet = await db .Child(GlobalVariables.regionalPointer) .Child("matchList") .Child(matchNumber.ToString()) .OnceSingleAsync <EventMatchData>(); Console.WriteLine("Match: " + matchNoLineEntry.inputEntry.Text + " , Alliance: " + alliancePicker.Items[alliancePicker.SelectedIndex]); teamNoPicker.Items.Clear(); if (string.IsNullOrEmpty(matchGet.matchNumber)) { teamNoPicker.Title = "[Select Match No. and Alliance first]"; } else { teamNoPicker.Title = "[Select A Team]"; if (alliancePicker.SelectedIndex == 0) { foreach (var item in matchGet.Red) { teamNoPicker.Items.Add(item.ToString()); } } else if (alliancePicker.SelectedIndex == 1) { foreach (var item in matchGet.Blue) { teamNoPicker.Items.Add(item.ToString()); } } } busyIcon.IsVisible = false; busyIcon.IsRunning = false; } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } } } async Task initializeTeamData() { busyIcon.IsVisible = true; busyIcon.IsRunning = true; int matchType = 0; matchData.scouterName = scouts.lineEntry.Text;; matchData.matchNumber = matchNumber; matchData.teamNumber = teamNumber; matchData.matchID = teamNumber + "-" + matchNumber; matchData.alliance = alliancePicker.Items[alliancePicker.SelectedIndex]; matchData.startPos = positionPicker.Items[positionPicker.SelectedIndex]; if (CheckInternetConnectivity.InternetStatus()) { bool test = true; var db = new FirebaseClient(GlobalVariables.firebaseURL); string path = "NULL"; if (competitionPhase != "P") { path = "matchData/" + matchData.matchID; matchType = 0; } else { path = "practiceMatchData/" + matchData.matchID; matchType = -1; } if (await FirebaseAccess.checkExistingMatchData(db, path)) { if (!await DisplayAlert("Error", "Match Data already exists for this team-match. Do you want to overwrite it?", "OK", "Cancel")) { test = false; } } if (test) { FirebaseAccess.saveData(db, path, matchData); await Navigation.PushModalAsync(new AutoMatchScoutingPage(matchData, matchType)); } /* * if (checkValue == 1) { * * var dataCheck = await db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber) * .OnceSingleAsync<TeamMatchData>(); * * if (dataCheck != null) * if (!await DisplayAlert("Error", "Match Data already exists for this team. Do you want to overwrite it?", "OK", "Cancel")) * test = false; * * if(test){ * var send = db * .Child(GlobalVariables.regionalPointer) * .Child("teamMatchData") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber) * .PutAsync(matchData); * * matchType = 0; * * await Navigation.PushAsync(new AutoMatchScoutingPage(matchData, matchType)); * } * } else { * var dataCheck = await db * .Child(GlobalVariables.regionalPointer) * .Child("PracticeMatches") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber) * .OnceSingleAsync<TeamMatchData>(); * * if (dataCheck != null) * if (!await DisplayAlert("Error", "Match Data already exists for this team. Do you want to overwrite it?", "OK", "Cancel")) * test = false; * * if(test) { * var send = db * .Child(GlobalVariables.regionalPointer) * .Child("PracticeMatches") * .Child(matchData.teamNumber.ToString()) * .Child(matchData.matchNumber) * .PutAsync(matchData); * * matchType = -1; * * await Navigation.PushAsync(new AutoMatchScoutingPage(matchData, matchType)); * } * * } */ } busyIcon.IsVisible = false; busyIcon.IsRunning = false; } }
public async Task UpdateMatchList() { if (CheckInternetConnectivity.InternetStatus()) { busyIcon.IsRunning = true; busyIcon.IsVisible = true; var matchList = await EventsHttp.GetEventMatchesHttp(GlobalVariables.regionalPointer); var sorted = from Match in matchList orderby Match.time select Match; string matchNumber; foreach (var match in sorted.ToArray()) { Console.WriteLine("Match: " + match.match_number); } var db = new FirebaseClient(GlobalVariables.firebaseURL); foreach (var match in sorted) { if (match.comp_level == "qm") { if (match.match_number < 10) { matchNumber = match.comp_level.ToUpper() + "0" + match.match_number; } else { matchNumber = match.comp_level.ToUpper() + match.match_number; } } else { matchNumber = match.comp_level.ToUpper() + match.set_number + "M" + match.match_number; } int m = 0, n = 0; int[] blueA = new int[match.alliances.blue.team_keys.Length + match.alliances.blue.surrogate_team_keys.Length], redA = new int[match.alliances.red.team_keys.Length + match.alliances.red.surrogate_team_keys.Length]; // remove the frc label from each team foreach (var team in match.alliances.blue.team_keys) { blueA[m++] = Convert.ToInt32(team.Remove(0, 3)); } foreach (var team in match.alliances.blue.surrogate_team_keys) { blueA[m++] = Convert.ToInt32(team.Remove(0, 3)); } foreach (var team in match.alliances.red.team_keys) { redA[n++] = Convert.ToInt32(team.Remove(0, 3)); } foreach (var team in match.alliances.red.surrogate_team_keys) { redA[n++] = Convert.ToInt32(team.Remove(0, 3)); } int i = 1; string matchID; foreach (var robot in blueA) { matchID = robot + "-" + matchNumber; await db .Child(GlobalVariables.regionalPointer) .Child("tableauMatchSchedule") .Child(matchID) .OnceSingleAsync <TableauMatchShedule>(); await db .Child(GlobalVariables.regionalPointer) .Child("tableauMatchSchedule") .Child(matchID) .PutAsync(new TableauMatchShedule() { matchID = matchID, matchNumber = matchNumber, alliance = "Blue", alliancePos = i++, teamNumber = robot, matchTime = match.time }); } i = 1; foreach (var robot in redA) { matchID = robot + "-" + matchNumber; await db .Child(GlobalVariables.regionalPointer) .Child("tableauMatchSchedule") .Child(matchID) .OnceSingleAsync <TableauMatchShedule>(); await db .Child(GlobalVariables.regionalPointer) .Child("tableauMatchSchedule") .Child(matchID) .PutAsync(new TableauMatchShedule() { matchID = matchID, matchNumber = matchNumber, alliance = "Red", alliancePos = i++, teamNumber = robot, matchTime = match.time }); } // Why is this needed? var fbMatch = await db .Child(GlobalVariables.regionalPointer) .Child("matchList") .Child(matchNumber) .OnceSingleAsync <EventMatchData>(); var send = db .Child(GlobalVariables.regionalPointer) .Child("matchList") .Child(matchNumber) .PutAsync(new EventMatchData() { matchNumber = matchNumber, Blue = blueA, Red = redA, matchTime = match.time }); Console.WriteLine("Completed Match: " + matchNumber); } await DisplayAlert("Done", "Match List Successfully Updated", "OK"); busyIcon.IsRunning = false; busyIcon.IsVisible = false; } }