public string matchCalc(JObject match) { this.match = match; String total; try { total = this.match["team"] + "," + this.match["matchNum"] + "," + MatchFormat.matchSideFromEnum((int)this.match["side"]) + ","; //Side } catch { total = ",,,"; } total += pickCalc((int)MatchFormat.CHOOSE_RANK_TYPE.pick1) + "," + //Hatch numCalc((int)MatchFormat.CHOOSE_RANK_TYPE.pick1) + ","; total += climbCalc() + ","; total += dropCalc((int)MatchFormat.CHOOSE_RANK_TYPE.drop1) + "," + dropCalc((int)MatchFormat.CHOOSE_RANK_TYPE.drop2) + "," + dropCalc((int)MatchFormat.CHOOSE_RANK_TYPE.drop3); return(total); }
private async Task addMatchItemsChecker(JObject data, JObject importJSON) { JArray temp = (JArray)data["Matches"]; JArray importTemp = (JArray)importJSON["Matches"]; var tempList = temp.ToList(); foreach (var match in importTemp.ToList()) { if (tempList.Exists(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"]))) { var item = tempList.Find(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"])); if (!item["team"].Equals(match["team"])) { var add = await DisplayAlert("Warning!", "Match: " + item["matchNum"] + "\nTeam: " + item["team"] + "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) + "\nConflicts with Existing Match", "Overwite", "Ignore"); if (add) { temp.Remove(item); temp.Add(match); } } } else { temp.Add(match); } } }
void populateMatchesList() { JObject x; string currentEvent = Preferences.Get(ConstantVars.CURRENT_EVENT_NAME, ""); if (!String.IsNullOrWhiteSpace(Preferences.Get(ConstantVars.APP_DATA_STORAGE, ""))) { try { x = (JObject)JObject.Parse(Preferences.Get(ConstantVars.APP_DATA_STORAGE, "")); if (x.ContainsKey(currentEvent)) { x = (JObject)x[currentEvent]; } else { x = new JObject(); } } catch { Console.WriteLine("Caught NullRepEx for populateMatchesList"); x = new JObject(); } } else { x = new JObject(); } if (!x.HasValues) { matchesList = null; listView.ItemsSource = null; } else { JObject matchesJSON = (JObject)JObject.Parse(Preferences.Get(ConstantVars.APP_DATA_STORAGE, ""))[currentEvent]; JArray temp = (JArray)matchesJSON["Matches"]; //Will Contain all items for matches list matchesList = new List <MatchesListFormat> (); int count; try { count = temp.Count; } catch { count = -1; } for (int i = 0; i < count; i++) { JObject match = (JObject)temp[i]; string teamTemp = ""; try { teamTemp = match["team"].ToString(); } catch {} String teamIdentifier = teamTemp; //try //{ // teamIdentifier = teamTemp.Split("-", 2)[MatchFormat.teamNameOrNum].Trim(); //} //catch { // teamIdentifier = teamTemp; //} matchesList.Add(new MatchesListFormat { matchNum = "Match " + match["matchNum"], teamNameAndSide = teamIdentifier + " - " + MatchFormat.matchSideFromEnum((int)match["side"]) }); } listView.ItemsSource = matchesList; } try { matchesView.IsVisible = matchesList.Count > 0; sadNoMatch.IsVisible = !matchesView.IsVisible; } catch { matchesView.IsVisible = false; sadNoMatch.IsVisible = true; } }
private async Task addMatchItemsChecker(JObject data, JObject importJSON, string comp) { int tooMuch = 0; int mode = 0; // 1 for overwite all, 2 for ignore all JArray importTemp = (JArray)importJSON["Matches"]; List <JToken> tempList = new List <JToken>(); if (data.ContainsKey(comp) && (JArray)data[comp]["Matches"] != null) { tempList = ((JArray)data[comp]["Matches"]).ToList(); } else if (!data.ContainsKey(comp)) { data[comp] = new JObject(); data[comp]["Matches"] = new JArray(); } else { data[comp]["Matches"] = new JArray(); } JArray temp = (JArray)data[comp]["Matches"]; foreach (var match in importTemp.ToList()) { Debug.WriteLine("hi" + match); if (tempList.Exists(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"]))) { var item = tempList.Find(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"])); if (!item["team"].Equals(match["team"])) { if (mode == 1) { temp.Remove(item); temp.Add(match); } else if (mode == 0) { tooMuch++; if (tooMuch <= 1) { var add = await DisplayAlert("Warning!", "\nEvent: " + AdapterMethods.getEventName(comp) + "Match: " + item["matchNum"] + "\nTeam: " + item["team"] + "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) + "\nConflicts with Existing Match", "Overwite", "Ignore"); if (add) { temp.Remove(item); temp.Add(match); } } else { var add = await DisplayActionSheet("Warning!", "Event: " + AdapterMethods.getEventName(comp) + "\nMatch: " + item["matchNum"] + "\nTeam: " + item["team"] + "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) + "\nConflicts with Existing Match", null, null, "Overwite", "Ignore", "Overwite All", "Ignore All"); if (add.Equals("Overwite")) { temp.Remove(item); temp.Add(match); } else if (add.Equals("Overwite All")) { temp.Remove(item); temp.Add(match); mode = 1; } else if (add.Equals("Ignore All")) { mode = 2; } } } } } else { temp.Add(match); } } //return data; }
void populateMatchesList() { JObject x; if (!String.IsNullOrWhiteSpace(Preferences.Get("matchEventsString", ""))) { try { x = JObject.Parse(Preferences.Get("matchEventsString", "")); } catch (NullReferenceException) { Console.WriteLine("Caught NullRepEx for populateMatchesList"); x = new JObject(); } } else { x = new JObject(); } if (!x.HasValues) { matchesList = null; listView.ItemsSource = null; } else { JObject matchesJSON = JObject.Parse(Preferences.Get("matchEventsString", "")); JArray temp = (JArray)matchesJSON["Matches"]; //Will Contain all items for matches list matchesList = new List <MatchesListFormat> (); int count; try { count = temp.Count; } catch (System.NullReferenceException) { count = -1; } for (int i = 0; i < count; i++) { JObject match = (JObject)temp[i]; String teamIdentifier = match["team"].ToString().Split('-') [MatchFormat.teamNameOrNum]; if (MatchFormat.teamNameOrNum == 0) { teamIdentifier = teamIdentifier.Substring(0, teamIdentifier.Length - 1); } else { teamIdentifier = teamIdentifier.Substring(1); } matchesList.Add(new MatchesListFormat { matchNum = "Match " + match["matchNum"].ToString(), teamNameAndSide = teamIdentifier + " - " + MatchFormat.matchSideFromEnum((int)match["side"]) }); } listView.ItemsSource = matchesList; } try { matchesView.IsVisible = matchesList.Count > 0; sadNoMatch.IsVisible = !matchesView.IsVisible; } catch (NullReferenceException) { matchesView.IsVisible = false; sadNoMatch.IsVisible = true; } }
private async Task addMatchItemsChecker(JObject data, JObject importJSON) { int tooMuch = 0; int mode = 0; // 1 for overwite all, 2 for ignore all JArray temp = (JArray)data["Matches"]; JArray importTemp = (JArray)importJSON["Matches"]; var tempList = temp.ToList(); foreach (var match in importTemp.ToList()) { if (tempList.Exists(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"]))) { var item = tempList.Find(x => x["matchNum"].Equals(match["matchNum"]) && x["side"].Equals(match["side"])); if (!item["team"].Equals(match["team"])) { if (mode == 1) { temp.Remove(item); temp.Add(match); } else if (mode == 0) { tooMuch++; if (tooMuch <= 1) { var add = await DisplayAlert("Warning!", "Match: " + item["matchNum"] + "\nTeam: " + item["team"] + "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) + "\nConflicts with Existing Match", "Overwite", "Ignore"); if (add) { temp.Remove(item); temp.Add(match); } } else { var add = await DisplayActionSheet("Warning!" + "\nMatch: " + item["matchNum"] + "\nTeam: " + item["team"] + "\nSide: " + MatchFormat.matchSideFromEnum(Convert.ToInt32(item["side"])) + "\nConflicts with Existing Match", null, null, "Overwite", "Ignore", "Overwite All", "Ignore All"); if (add.Equals("Overwite")) { temp.Remove(item); temp.Add(match); } else if (add.Equals("Overwite All")) { temp.Remove(item); temp.Add(match); mode = 1; } else if (add.Equals("Ignore All")) { mode = 2; } } } } } else { temp.Add(match); } } }