/*<summary> * Web API call and SignalR setUp * </summary> * <returns> * Json data of StaffLoaction to track staff. * </returns>*/ /// <param name="number"></param> public async Task <JsonResult> GetLocations(int number) { string Baseurl = System.Configuration.ConfigurationManager.AppSettings["WebApiUrl"]; int EventID = Convert.ToInt32(Session["eventId"]); List <TeamLocation> teamInfo = new List <TeamLocation>(); List <StaffLocation> staffInfo = new List <StaffLocation>(); TeamLocation teamLocation = new TeamLocation(); StaffLocation staffLocation = new StaffLocation(); using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); //Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllEmployees using HttpClient //HttpResponseMessage Res = await client.GetAsync("api/values/" + number); String StaffLocation = await client.GetStringAsync("api/staff/" + number); String MemberLocation = await client.GetStringAsync("api/values/" + number); //Checking the response is successful or not which is sent using HttpClient if (MemberLocation != null) { JArray teamJson = JArray.Parse(MemberLocation); //JArray staffJson = JArray.Parse(StaffLocation); for (int i = 0; i < 3; i++) { TeamLocation teamLoc = JsonConvert.DeserializeObject <TeamLocation>(teamJson[i].ToString()); //staffLocation = JsonConvert.DeserializeObject<StaffLocation>(staffJson[i].ToString()); teamLocations.Add(teamLoc); //staffInfo.Add(staffLocation); } teamBAL.updateTeamLocation(teamLocations, EventID); } else { return(Json("error", JsonRequestBehavior.AllowGet)); } // //Deserializing the response recieved from web api and storing into the Employee list hubController.CallSignalR(EventID); return(Json(StaffLocation, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Gets result image /// </summary> /// <param name="homeGoals">Home team's goals</param> /// <param name="awayGoals">Away team's goals</param> /// <param name="location">User team's location</param> /// <returns>Image object</returns> public static Image GetResultImage(byte homeGoals, byte awayGoals, TeamLocation location) { Image resultImage = null; try { if (homeGoals == awayGoals) { resultImage = Properties.Resources.Yellow; } else { switch (location) { case TeamLocation.Home: if (homeGoals > awayGoals) { resultImage = Properties.Resources.Green; } else { resultImage = Properties.Resources.Red; } break; case TeamLocation.Away: if (awayGoals > homeGoals) { resultImage = Properties.Resources.Green; } else { resultImage = Properties.Resources.Red; } break; } } } catch (Exception ex) { throw ex; } return(resultImage); }
private void UpdateLineupName(int slotNum, string name, TeamLocation loc) { string controlName; string containerName; Control displayControl = null; Control container = null; containerName = loc == TeamLocation.Home ? "grpHomelineup" : "grpVislineup"; controlName = string.Format("lbl{0}{1}", loc == TeamLocation.Home ? "Home" : "Visitor", slotNum + 1); container = this.Controls[containerName]; if (container != null) { if (slotNum == -1) { container.Text = name; } else { displayControl = container.Controls[controlName]; if (displayControl != null) { displayControl.Text = name; } } } }
private void UpdateInningScore(int inning, int score, TeamLocation loc) { Label lbl; // if extra innings past 10, always update the last score box since innings will have shifted if (inning > 10) { inning = 10; } if (loc == TeamLocation.Home) { lbl = homeScores[inning - 1]; } else { lbl = visScores[inning - 1]; } lbl.Text = score == -1 ? "" : score.ToString(); }
override public void Tick(Object source, ElapsedEventArgs e) { try { if (Program.GameData.MatchInfo.isFreezeTime) { return; } if (base.CanActivate() == false) { return; } if (Player.IsAlive()) { if (CheaterLocation != Player.Location.ToLower()) { CheaterLocation = Player.Location; if (CheaterLocation.ToLower() != "" && !Helper.PlayerIsInSpawn()) { CheaterLocation = CheaterLocation.Replace("BombsiteA", "Bombsite A"); CheaterLocation = CheaterLocation.Replace("BombsiteB", "Bombsite B"); int rnd = rng.Next(selfMsgs.Count); ActivatePunishment(selfMsgs[rnd].Replace("#location#", CheaterLocation)); } } } else { // go through entities foreach (var entity in GameData.Entities) { if (!entity.IsAlive() || entity.AddressBase == Player.AddressBase) { continue; } if (entity.Team == Player.Team) { TeamLocation = entity.Location; if (entity.Location.ToLower() != TeamLocation.ToLower()) { TeamLocation = CheaterLocation.Replace("BombsiteA", "Bombsite A"); TeamLocation = CheaterLocation.Replace("BombsiteB", "Bombsite B"); int rnd = rng.Next(teamMsgs.Count); ActivatePunishment(teamMsgs[rnd].Replace("#location#", TeamLocation)); } } Thread.Sleep(10); break; } } } catch (Exception ex) { Log.AddEntry(new LogEntry() { LogTypes = new List <LogTypes> { LogTypes.Analytics }, AnalyticsCategory = "Error", AnalyticsAction = "ToxicMateException", AnalyticsLabel = ex.Message }); } }
private void InitializeGameStats() { string result; battingTeam = visitingTeam; fieldingTeam = homeTeam; battingLocation = TeamLocation.Visitor; score.Reset(); winningPitcher = null; losingPitcher = null; savePitcher = null; runnerOnFirst = null; runnerOnSecond = null; runnerOnThird = null; currentHitter = null; currentPitcher = null; outs = 0; RaiseLineScoreUpdateEvent(LineScoreUpdateType.Outs, -1, outs, battingLocation, ""); inning = 1; RaiseLineScoreUpdateEvent(LineScoreUpdateType.Inning, inning, -1, battingLocation, ""); RaiseInningChangeEvent(inning); teamAtBat = VISITING_TEAM; teamInField = HOME_TEAM; atBatIndex[VISITING_TEAM] = 0; atBatIndex[HOME_TEAM] = 0; runs[VISITING_TEAM] = 0; hits[VISITING_TEAM] = 0; errors[VISITING_TEAM] = 0; runs[HOME_TEAM] = 0; hits[HOME_TEAM] = 0; errors[HOME_TEAM] = 0; gameLog = new StringBuilder(); result = string.Format("{0} {1}:\r\n\r\n", (teamAtBat == VISITING_TEAM) ? "TOP" : "BOTTOM", inning); gameLog.Append(result); for (int i = 0; i < 30; i++) { inningScores[HOME_TEAM, i] = inningScores[VISITING_TEAM, i] = -1; } }
void SwapTeams() { int tmp; Team tmpTeam; tmp = teamAtBat; teamAtBat = teamInField; teamInField = tmp; tmpTeam = fieldingTeam; fieldingTeam = battingTeam; battingTeam = tmpTeam; battingLocation = battingLocation == TeamLocation.Home ? TeamLocation.Visitor : TeamLocation.Home; }
private void RaiseLineupUpdateEvent(LineupRoleType roleType, int slotNumber, TeamLocation loc, string name) { if (LineupUpdate != null) { LineupUpdateArgs args = new LineupUpdateArgs(); args.RoleType = roleType; args.SlotNumber = slotNumber; args.Location = loc; args.Name = name; LineupUpdate(this, args); } }
private void RaiseLineScoreUpdateEvent(LineScoreUpdateType updateType, int inning, int iValue, TeamLocation loc, string sValue) { if (LineScoreUpdate != null) { LineScoreUpdateArgs args = new LineScoreUpdateArgs(); args.UpdateType = updateType; args.SValue = sValue; args.Location = loc; args.Inning = inning; args.IValue = iValue; LineScoreUpdate(this, args); } }
/// <summary> /// Gets result image /// </summary> /// <param name="homeGoals">Home team's goals</param> /// <param name="awayGoals">Away team's goals</param> /// <param name="location">User team's location</param> /// <returns>Image object</returns> public static Image GetResultImage(byte homeGoals, byte awayGoals, TeamLocation location) { Image resultImage = null; try { if (homeGoals == awayGoals) { resultImage = Properties.Resources.Yellow; } else { switch (location) { case TeamLocation.Home: if (homeGoals > awayGoals) { resultImage = Properties.Resources.Green; } else { resultImage = Properties.Resources.Red; } break; case TeamLocation.Away: if (awayGoals > homeGoals) { resultImage = Properties.Resources.Green; } else { resultImage = Properties.Resources.Red; } break; } } } catch (Exception ex) { throw ex; } return resultImage; }