public string CreateTeam(string teamname, string userid, string agentid, string clientid) { string teamid = Guid.NewGuid().ToString(); bool bl = SystemDAL.BaseProvider.CreateTeam(teamid, teamname, userid, agentid, clientid); if (bl) { if (!Teams.ContainsKey(agentid)) { GetTeams(agentid); } Teams[agentid].Add(new TeamEntity() { TeamID = teamid.ToLower(), TeamName = teamname, Status = 1, CreateTime = DateTime.Now, CreateUserID = userid, ClientID = clientid, Users = new List <Users>() }); return(teamid); } return(""); }
public void Handle(TeamGameCompleted e) { var teamId = e.TeamId; //HACK: Old TeamGameCompleted events used teamid instead of bowlerid for POA singles 8'( if ((e.Division.Contains("Teaching") || e.Division.Contains("Senior")) && e.Division.Contains("Single")) { teamId = PoaSingles[e.TeamId]; } if (!Teams.ContainsKey(teamId)) { Teams.Add(teamId, new Team { Id = teamId, Name = e.Division, Province = e.Contingent }); } var team = Teams[teamId]; //Remove any previous entries as they could re-enter the scores team.Scores.RemoveAll(x => x.MatchId == e.Id); team.Scores.Add(new Score { MatchId = e.Id, Number = e.Number, Scratch = e.Score, POA = e.POA, WinLossTie = e.TotalPoints > e.OpponentPoints ? "W" : e.TotalPoints < e.OpponentPoints ? "L" : "T", Lane = e.Lane, Centre = e.Centre, Opponent = e.Opponent, OpponentScratch = e.OpponentScore, OpponentPOA = e.OpponentPOA, OpponentPoints = e.OpponentPoints, IsPOA = e.IsPOA, Points = e.TotalPoints }); team.TotalGames = team.Scores.Count; team.TotalWins = team.Scores.Sum(x => x.Points); team.TotalLoss = team.Scores.Sum(x => x.OpponentPoints); team.TotalScratch = team.Scores.Sum(x => x.Scratch); team.TotalOpponentScratch = team.Scores.Sum(x => x.OpponentScratch); team.TotalPOA = team.Scores.Sum(x => x.POA); team.TotalOpponentPOA = team.Scores.Sum(x => x.OpponentPOA); team.AverageWinsPerGame = (decimal)team.TotalWins / team.TotalGames; team.AverageLossPerGame = (decimal)team.TotalLoss / team.TotalGames; team.AverageScratch = (decimal)team.TotalScratch / team.TotalGames; team.AveragePOA = (decimal)team.TotalPOA / team.TotalGames; team.AverageOpponentScratch = (decimal)team.TotalOpponentScratch / team.TotalGames; team.AverageOpponentPOA = (decimal)team.TotalOpponentPOA / team.TotalGames; }
protected string GetTeamNameNational(string code) { if (Teams.ContainsKey(code)) { return(Teams[code]); } else { OutputStream.AppendLine($"Squadra non trovata ({code})"); } return(string.Empty); }
public virtual void UnsetControllerFromTeam(IDNumber ctrl, IDNumber team) { if (!controllers.ContainsKey(ctrl)) { throw new ArgumentException("Controller ID number " + ctrl + " does not exist in the current match."); } if (!Teams.ContainsKey(team)) { throw new ArgumentException("Team ID number " + team + " does not exist in the current match."); } ApplyEvent(new PlayerTeamUnassignEvent(ctrl, team)); }
public void MasterDictionary(int[] DicpView, string[] DicTeam, bool[] DicPlayer, int[] DicHero, int pViewID) { int pVID = pViewID / 1000; if (myID == 0) { myID = pVID; } for (int i = 0; i < DicpView.Length; i++) { if (!Players.ContainsKey(DicpView[i])) { Players.Add(DicpView[i], DicPlayer[i]); } else { Players[DicpView[i]] = DicPlayer[i]; } if (!Teams.ContainsKey(DicpView[i])) { Teams.Add(DicpView[i], DicTeam[i]); } else { Teams[DicpView[i]] = DicTeam[i]; } if (!Heros.ContainsKey(DicpView[i])) { Heros.Add(DicpView[i], (hcp.E_HeroType)DicHero[i]); } else { Heros[DicpView[i]] = (hcp.E_HeroType)DicHero[i]; } } PlayerTeam[] objs = FindObjectsOfType <PlayerTeam>(); foreach (PlayerTeam items in objs) { if (items.photonView.IsMine) { //Debug.Log("HI"); } items.PosAfterDictionary(); } }
protected internal IDNumber GetTeam(string name, bool internalTeam) { foreach (var team in Teams) { if (team.Value.Name == name) { team.Value.Members.Clear(); return(team.Key); } } for (int i = 0; i <= Teams.Count; i++) { if (!Teams.ContainsKey(i)) { ApplyEvent(new MatchTeamCreateEvent(new Team(i, name, internalTeam))); return(i); } } throw new InvalidProgramException("Not supposed to happen."); }
public List <TeamEntity> GetTeams(string agentid) { if (Teams.ContainsKey(agentid)) { return(Teams[agentid]); } List <TeamEntity> list = new List <TeamEntity>(); DataTable dt = SystemDAL.BaseProvider.GetTeams(agentid); foreach (DataRow dr in dt.Rows) { TeamEntity model = new TeamEntity(); model.FillData(dr); model.Users = OrganizationBusiness.GetUsers(agentid).Where(m => m.TeamID == model.TeamID).ToList(); list.Add(model); } Teams.Add(agentid, list); return(list); }
//플레이어가 나갈 경우 딕셔너리 제거 성공 여부 public void RemoveDictionary(int pViewID) { bool RemoveSuccess = true; if (Players.ContainsKey(pViewID)) { RemoveSuccess = RemoveSuccess && Players.Remove(pViewID); } if (Teams.ContainsKey(pViewID)) { RemoveSuccess = RemoveSuccess && Teams.Remove(pViewID); } if (Heros.ContainsKey(pViewID)) { RemoveSuccess = RemoveSuccess && Heros.Remove(pViewID); } if (Names.ContainsKey(pViewID)) { RemoveSuccess = RemoveSuccess && Names.Remove(pViewID); } //Debug.Log(RemoveSuccess); }
protected async Task LoadTeamDataAsync() { List <Team> allTeams = await(from team in _context.Teams where team.Event == Event select team).ToListAsync(); Teams = await(from team in _context.Teams where team.Event == Event join teamMember in _context.TeamMembers on team equals teamMember.Team group teamMember by teamMember.Team into teamCounts select new { Team = teamCounts.Key, Count = teamCounts.Count() }).ToDictionaryAsync(x => x.Team, x => x.Count); foreach (Team team in allTeams) { if (!Teams.ContainsKey(team)) { Teams[team] = 0; } else { PlayerCount += Teams[team]; } } }
public static void AssignMatches() { var lines = File.ReadAllLines(Data); // Load Teams and Matches foreach (var l in lines) { var line = l.Split(','); var dateData = line[0].Split('.'); var date = new DateTime(int.Parse(dateData[2]), int.Parse(dateData[1]), int.Parse(dateData[0])); // date has incorrect format //Create team // check for existing teams, create them if (!Teams.ContainsKey(line[2])) { Teams.Add(line[2], new Team(line[2])); } if (!Teams.ContainsKey(line[3])) { Teams.Add(line[3], new Team(line[3])); } // assign goals var homeTeam = Teams.FirstOrDefault(x => x.Key == line[2]); var awayTeam = Teams.FirstOrDefault(x => x.Key == line[3]); var goalsHome = int.Parse(line[4].Split(':')[0]); var goalsAway = int.Parse(line[4].Split(':')[1].Split('(')[0]); homeTeam.Value.GoalsGivenHome += goalsHome; homeTeam.Value.GoalsTakenHome += goalsAway; awayTeam.Value.GoalsGivenAway += goalsAway; awayTeam.Value.GoalsTakenAway += goalsHome; // calculate points - normal win 3p, PP/SN win 2p, PP/SN lose 1p, normal lose 0p if (goalsHome > goalsAway) { if (line[4].Contains("PP") || line[4].Contains("SN")) { homeTeam.Value.Points += 2; awayTeam.Value.Points += 1; } else { homeTeam.Value.Points += 3; } } else { if (line[4].Contains("PP") || line[4].Contains("SN")) { homeTeam.Value.Points += 1; awayTeam.Value.Points += 2; } else { awayTeam.Value.Points += 3; } } // create Match var type = "N"; if (line[4].Contains("PP")) { type = "PP"; } else if (line[4].Contains("SN")) { type = "SN"; } Matches.Add(new Match(date, int.Parse(line[1]), line[2], line[3], int.Parse(line[4].Split(':')[0]), int.Parse(line[4].Split(':')[1].Split('(')[0]), type)); } }
public void Join(int pViewID) { int pVID = pViewID / 1000; if (!Players.ContainsKey(pVID)) { if (myID == 0) { myID = pVID; } Players.Add(pVID, false); //Debug.Log(" ID : " + pVID + " Joined"); } if (!Heros.ContainsKey(pVID)) { Heros.Add(pVID, hcp.E_HeroType.Soldier); //Debug.Log("My Hero is Soldier"); } if (!Teams.ContainsKey(pVID)) { TeamACount = 0; TeamBCount = 0; foreach (KeyValuePair <int, string> pair in Teams) { if (pair.Value == hcp.Constants.teamA_LayerName) { TeamACount++; } else if (pair.Value == hcp.Constants.teamB_LayerName) { TeamBCount++; } } if ((TeamACount <= TeamBCount)) { //Debug.Log("Assigned A"); Teams.Add(pVID, hcp.Constants.teamA_LayerName); } else { //Debug.Log("Assigned B"); Teams.Add(pVID, hcp.Constants.teamB_LayerName); } } int[] DicpView = new int[Players.Count]; Players.Keys.CopyTo(DicpView, 0); string[] DicTeam = new string[Teams.Count]; Teams.Values.CopyTo(DicTeam, 0); bool[] DicPlayer = new bool[Players.Count]; Players.Values.CopyTo(DicPlayer, 0); int[] DicHero = new int[Heros.Count]; int count = 0; foreach (KeyValuePair <int, hcp.E_HeroType> items in Heros) { DicHero[count] = (int)items.Value; count++; } photonView.RPC("MasterDictionary", RpcTarget.Others, DicpView, DicTeam, DicPlayer, DicHero, pViewID); }
private async Task ResolveScans() { var policyTask = PopulatePolicies(); var presetsTask = PopulatePresets(); var teamsTask = PopulateTeams(); _log.Debug("Resolving projects."); var projects = await Task.Run(() => CxProjects.GetProjects(RestContext, CancelToken), CancelToken); Policies = await policyTask; Teams = await teamsTask; Presets = await presetsTask; Parallel.ForEach(projects, new ParallelOptions { CancellationToken = CancelToken }, (p) => { if (p.ProjectName == null) { return; } String combinedPolicyNames = String.Empty; if (Policies != null) { try { IEnumerable <int> projectPolicyList = CxMnoPolicies.GetPolicyIdsForProject (RestContext, CancelToken, p.ProjectId); if (projectPolicyList != null) { Policies.CorrelateProjectToPolicies(p.ProjectId, projectPolicyList); combinedPolicyNames = GetFlatPolicyNames(Policies, projectPolicyList); } } catch (Exception ex) { _log.Warn($"Unable to correlate policies to project {p.ProjectId}: {p.ProjectName}. " + $"Policy statistics will be unavalable.", ex); } } var cfDict = new SortedDictionary <String, String>(); p.CustomFields.ForEach((cf) => cfDict.Add(cf.FieldName, cf.FieldValue)); // Load the projects String teamName = Teams.ContainsKey(p.TeamId) ? Teams[p.TeamId] : String.Empty; if (String.Empty == teamName) { _log.ErrorFormat("Unable to find a team name for team id [{0}] when adding project {1}:{2}", p.TeamId, p.ProjectId, p.ProjectName); return; } String presetName = Presets.ContainsKey(p.PresetId) ? Presets[p.PresetId] : String.Empty; if (String.Empty == presetName) { _log.ErrorFormat("Unable to find a preset name for preset id [{0}] " + "when adding project {1}:{2}; project may be assigned an invalid preset.", p.PresetId, p.ProjectId, p.ProjectName); return; } if (!Filter.Matches(teamName, p.ProjectName)) { if (_log.IsDebugEnabled) { _log.Debug($"FILTERED: Team: [{teamName}] Project: [{p.ProjectName}]"); } return; } if (!_loadedProjects.TryAdd(p.ProjectId, new ProjectDescriptor() { ProjectId = p.ProjectId, ProjectName = p.ProjectName, TeamName = teamName, TeamId = p.TeamId, PresetId = p.PresetId, PresetName = presetName, Policies = combinedPolicyNames, CustomFields = cfDict } )) { _log.WarnFormat("Rejected changed when adding new project with duplicate id {0}: New name: [{1}] current name: [{2}].", p.ProjectId, p.ProjectName, _loadedProjects[p.ProjectId].ProjectName); return; } }); // _loadedProjects has a collection of projects loaded from the SAST system _state.ConfirmProjects(new List <ProjectDescriptor>(_loadedProjects.Values)); _log.Info($"{_state.ProjectCount} projects are targets to check for new scans. Since last scan: {_state.DeletedProjects}" + $" projects removed, {_state.NewProjects} new projects."); _log.Debug("Resolving scans."); // Load the scans for each project Parallel.ForEach(_state.Projects, new ParallelOptions { CancellationToken = CancelToken }, (p) => { // SAST Scans var sastScans = CxSastScans.GetScans(RestContext, CancelToken, CxSastScans.ScanStatus.Finished, p.ProjectId); foreach (var s in sastScans) { // Add to crawl state. if (_log.IsTraceEnabled()) { _log.Trace($"SAST scan record: {s}"); } _state.AddScan(s.ProjectId, s.ScanType, ScanProductType.SAST, s.ScanId, s.FinishTime); SastScanCache.TryAdd(s.ScanId, s); } // OSA scans var osaScans = CxOsaScans.GetScans(RestContext, CancelToken, p.ProjectId); foreach (var s in osaScans) { // Add to crawl state. if (_log.IsTraceEnabled()) { _log.Trace($"OSA scan record: {s}"); } _state.AddScan(s.ProjectId, "Composition", ScanProductType.SCA, s.ScanId, s.FinishTime); ScaScanCache.TryAdd(s.ScanId, s); } }); }