コード例 #1
0
        private async Task <WebApiTeam> EnsureTeamExists(
            BuildDefinition pipeline,
            string suffix,
            TeamPurpose purpose,
            IEnumerable <WebApiTeam> teams,
            bool persistChanges)
        {
            var result = teams.FirstOrDefault(
                team =>
            {
                // Swallowing exceptions because parse errors on
                // free form text fields which might be non-yaml text
                // are not exceptional
                var metadata = YamlHelper.Deserialize <TeamMetadata>(team.Description, swallowExceptions: true);
                return(metadata?.PipelineId == pipeline.Id && metadata?.Purpose == purpose);
            });

            if (result == default)
            {
                logger.LogInformation("Team Not Found Suffix = {0}", suffix);
                var teamMetadata = new TeamMetadata
                {
                    PipelineId = pipeline.Id,
                    Purpose    = purpose,
                };
                var newTeam = new WebApiTeam
                {
                    Description = YamlHelper.Serialize(teamMetadata),
                    // Ensure team name fits within maximum 64 character limit
                    // https://docs.microsoft.com/en-us/azure/devops/organizations/settings/naming-restrictions?view=azure-devops#teams
                    Name = StringHelper.MaxLength($"{pipeline.Name} -- {suffix}", MaxTeamNameLength),
                };

                logger.LogInformation("Create Team for Pipeline PipelineId = {0} Purpose = {1}", pipeline.Id, purpose);
                if (persistChanges)
                {
                    result = await service.CreateTeamForProjectAsync(pipeline.Project.Id.ToString(), newTeam);
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: GameLogic.cs プロジェクト: ramanasha/The_Dims
    public void SelectRow(int rowNum)
    {
        GameMatch match = allMatches[rowNum];

        homeTeam  = match.HomeTeam;
        guestTeam = match.GuestTeam;

        homeTeamMetadata  = allTeams[homeTeam.alias];
        guestTeamMetadata = allTeams[guestTeam.alias];

        homeTeamScoreLabel.GetComponent <TextMesh>().text  = homeTeam.points.ToString();
        guestTeamScoreLabel.GetComponent <TextMesh>().text = guestTeam.points.ToString();

        homeTeamNameLabel.GetComponent <TextMesh>().text  = homeTeam.alias;
        guestTeamNameLabel.GetComponent <TextMesh>().text = guestTeam.alias;

        leftHelmet.GetComponent <Renderer>().sharedMaterial  = homeTeamMetadata.helmet;
        rightHelmet.GetComponent <Renderer>().sharedMaterial = guestTeamMetadata.helmet;

        leftHelmetFace.GetComponent <Renderer>().sharedMaterial  = homeTeamMetadata.helmetRail;
        rightHelmetFace.GetComponent <Renderer>().sharedMaterial = guestTeamMetadata.helmetRail;

        leftHelmetFastener.GetComponent <Renderer>().sharedMaterial  = homeTeamMetadata.fasteners;
        rightHelmetFastener.GetComponent <Renderer>().sharedMaterial = guestTeamMetadata.fasteners;

        homeTeamBanner.GetComponent <Renderer>().sharedMaterial  = homeTeamMetadata.teamBanner;
        guestTeamBanner.GetComponent <Renderer>().sharedMaterial = guestTeamMetadata.teamBanner;

        homeTeamScoreboardLogo.GetComponent <Renderer>().sharedMaterial  = homeTeamMetadata.scoreboardLogo;
        guestTeamScoreboardLogo.GetComponent <Renderer>().sharedMaterial = guestTeamMetadata.scoreboardLogo;

        mainScreenPlayer.clip = superBowlClips [rowNum];

        for (var i = 0; i < 22; i++)
        {
            var playerPrefab = playerPrefabs[i];

            playerPrefab.GetComponent <FootballJerseyLogic>().frontNumber.GetComponent <TextMesh>().text      = i.ToString();
            playerPrefab.GetComponent <FootballJerseyLogic>().backNumber.GetComponent <TextMesh>().text       = i.ToString();
            playerPrefab.GetComponent <FootballJerseyLogic>().jersey.GetComponent <Renderer>().sharedMaterial = i % 2 == 0 ? homeTeamMetadata.jersey : guestTeamMetadata.jersey;
        }
    }
コード例 #3
0
        private async Task <WebApiTeam> EnsureTeamExists(
            BuildDefinition pipeline,
            string suffix,
            TeamPurpose purpose,
            IEnumerable <WebApiTeam> teams,
            bool persistChanges)
        {
            var result = teams.FirstOrDefault(
                team =>
            {
                // Swallowing exceptions because parse errors on
                // free form text fields which might be non-yaml text
                // are not exceptional
                var metadata = YamlHelper.Deserialize <TeamMetadata>(team.Description, swallowExceptions: true);
                return(metadata?.PipelineId == pipeline.Id && metadata?.Purpose == purpose);
            });

            if (result == default)
            {
                logger.LogInformation("Team Not Found Suffix = {0}", suffix);
                var teamMetadata = new TeamMetadata
                {
                    PipelineId = pipeline.Id,
                    Purpose    = purpose,
                };
                var newTeam = new WebApiTeam
                {
                    Description = YamlHelper.Serialize(teamMetadata),
                    Name        = $"{pipeline.Name} -- {suffix}",
                };

                logger.LogInformation("Create Team for Pipeline PipelineId = {0} Purpose = {1}", pipeline.Id, purpose);
                if (persistChanges)
                {
                    result = await service.CreateTeamForProjectAsync(pipeline.Project.Id.ToString(), newTeam);
                }
            }

            return(result);
        }
コード例 #4
0
ファイル: GameLogic.cs プロジェクト: ramanasha/The_Dims
    void SetupTeamMetadata()
    {
        allTeams = new Dictionary <string, TeamMetadata>();

        // hard-coded list of football teams (this should come from the SportsRadar API from the list of games currently available on a given day)
        List <string> allTeamsAliases = new List <string>()
        {
            "GBY",
            "MIA",
            "SFO",
            "DEN",
            "ATL",
            "NWE"
        };

        for (int i = 0; i < allTeamsAliases.Count; i++)
        {
            allTeams.Add(allTeamsAliases[i], new TeamMetadata(i, helmets, helmetFaces, helmetFasteners, teamBanners, scoreboardTeamLogos, teamJerseys));
        }

        allMatches = new List <GameMatch>
        {
            new GameMatch {
                HomeTeam = new Team {
                    alias = "MIA", points = "28"
                }, GuestTeam = new Team {
                    alias = "GBY", points = "10"
                }
            },
            new GameMatch {
                HomeTeam = new Team {
                    alias = "DEN", points = "18"
                }, GuestTeam = new Team {
                    alias = "SFO", points = "15"
                }
            },
            new GameMatch {
                HomeTeam = new Team {
                    alias = "NWE", points = "0"
                }, GuestTeam = new Team {
                    alias = "ATL", points = "14"
                }
            },
            new GameMatch {
                HomeTeam = new Team {
                    alias = "NYJ", points = "32"
                }, GuestTeam = new Team {
                    alias = "NYG", points = "16"
                }
            },
            new GameMatch {
                HomeTeam = new Team {
                    alias = "NWE", points = "20"
                }, GuestTeam = new Team {
                    alias = "MIN", points = "45"
                }
            }
        };

        homeTeamMetadata  = allTeams[allMatches[0].HomeTeam.alias];
        guestTeamMetadata = allTeams[allMatches[0].GuestTeam.alias];

        RandomizePlayers();
    }
コード例 #5
0
        private async Task <WebApiTeam> EnsureTeamExists(
            BuildDefinition pipeline,
            string suffix,
            TeamPurpose purpose,
            IEnumerable <WebApiTeam> teams,
            bool persistChanges)
        {
            // Ensure team name fits within maximum 64 character limit
            // https://docs.microsoft.com/en-us/azure/devops/organizations/settings/naming-restrictions?view=azure-devops#teams
            string teamName = StringHelper.MaxLength($"{pipeline.Name} -- {suffix}", MaxTeamNameLength);
            bool   updateMetadataAndName = false;
            var    result = teams.FirstOrDefault(
                team =>
            {
                // Swallowing exceptions because parse errors on
                // free form text fields which might be non-yaml text
                // are not exceptional
                var metadata         = YamlHelper.Deserialize <TeamMetadata>(team.Description, swallowExceptions: true);
                bool metadataMatches = (metadata?.PipelineId == pipeline.Id && metadata?.Purpose == purpose);
                bool nameMatches     = (team.Name == teamName);

                if (metadataMatches && nameMatches)
                {
                    return(true);
                }

                if (metadataMatches)
                {
                    logger.LogInformation("Found team with matching pipeline id {0} but different name '{1}', expected '{2}'. Purpose = '{3}'", metadata?.PipelineId, team.Name, teamName, metadata?.Purpose);
                    updateMetadataAndName = true;
                    return(true);
                }

                if (nameMatches)
                {
                    logger.LogInformation("Found team with matching name {0} but different pipeline id {1}, expected {2}. Purpose = '{3}'", team.Name, metadata?.PipelineId, pipeline.Id, metadata?.Purpose);
                    updateMetadataAndName = true;
                    return(true);
                }

                return(false);
            });

            if (result == default)
            {
                logger.LogInformation("Team Not Found Suffix = {0}", suffix);
                var teamMetadata = new TeamMetadata
                {
                    PipelineId = pipeline.Id,
                    Purpose    = purpose,
                };
                var newTeam = new WebApiTeam
                {
                    Description = YamlHelper.Serialize(teamMetadata),
                    Name        = teamName
                };

                logger.LogInformation("Create Team for Pipeline PipelineId = {0} Purpose = {1} Name = '{2}'", pipeline.Id, purpose, teamName);
                if (persistChanges)
                {
                    result = await service.CreateTeamForProjectAsync(pipeline.Project.Id.ToString(), newTeam);
                }
            }
            else if (updateMetadataAndName)
            {
                var teamMetadata = new TeamMetadata
                {
                    PipelineId = pipeline.Id,
                    Purpose    = purpose,
                };
                result.Description = YamlHelper.Serialize(teamMetadata);
                result.Name        = teamName;

                logger.LogInformation("Update Team for Pipeline PipelineId = {0} Purpose = {1} Name = '{2}'", pipeline.Id, purpose, teamName);
                if (persistChanges)
                {
                    result = await service.UpdateTeamForProjectAsync(pipeline.Project.Id.ToString(), result);
                }
            }

            return(result);
        }
コード例 #6
0
        public RepositoryActionResult <TeamMetadata> GetMetadata(int churchId, int userId)
        {
            var metadata = new TeamMetadata();

            using (var cn = new SqlConnection(_executor.ConnectionString))
            {
                using (var cmd = new SqlCommand("GetTeamProfileMetadata", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("churchId", churchId));
                    cmd.Parameters.Add(new SqlParameter("userId", userId));

                    cn.Open();

                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            // read enum types
                            while (reader.Read())
                            {
                                var appEnum = new AppEnum();
                                appEnum.ID                = reader.ValueOrDefault <int>("EnumID");
                                appEnum.Desc              = reader.ValueOrDefault <string>("EnumDesc");
                                appEnum.AppEnumTypeID     = reader.ValueOrDefault <int>("EnumTypeID");
                                appEnum.AppEnumTypeName   = reader.ValueOrDefault <string>("EnumTypeName");
                                appEnum.OptionsEnumTypeID = reader.ValueOrDefault <int>("OptionsEnumTypeID");

                                metadata.EnumTypes.Add(appEnum);
                            }

                            // read enums for above enum types
                            reader.NextResult();
                            while (reader.Read())
                            {
                                var appEnum = new AppEnum();
                                appEnum.ID                = reader.ValueOrDefault <int>("EnumID");
                                appEnum.Desc              = reader.ValueOrDefault <string>("EnumDesc");
                                appEnum.AppEnumTypeID     = reader.ValueOrDefault <int>("EnumTypeID");
                                appEnum.AppEnumTypeName   = reader.ValueOrDefault <string>("EnumTypeName");
                                appEnum.OptionsEnumTypeID = reader.ValueOrDefault <int>("OptionsEnumTypeID");

                                metadata.Enums.Add(appEnum);
                            }

                            // read churches
                            reader.NextResult();
                            while (reader.Read())
                            {
                                var church = new c.Church();
                                church.id   = reader.ValueOrDefault <int>("Id");
                                church.Name = reader.ValueOrDefault <string>("Name");

                                metadata.Churches.Add(church);
                            }

                            // read members
                            reader.NextResult();
                            while (reader.Read())
                            {
                                var member = new Core.Models.Members.Member();
                                member.id        = reader.ValueOrDefault <int>("Id");
                                member.FirstName = reader.ValueOrDefault <string>("FirstName");
                                member.LastName  = reader.ValueOrDefault <string>("LastName");

                                metadata.Members.Add(member);
                            }
                        }
                    }
                }
            }

            return(new RepositoryActionResult <TeamMetadata>(metadata, RepositoryActionStatus.Ok));
        }
コード例 #7
0
        private async Task <WebApiTeam> EnsureTeamExists(
            BuildDefinition pipeline,
            TeamPurpose purpose,
            IEnumerable <WebApiTeam> teams,
            GitHubToAADConverter gitHubToAADConverter,
            bool persistChanges)
        {
            string teamName = $"{pipeline.Id} ";

            if (purpose == TeamPurpose.ParentNotificationTeam)
            {
                // Ensure team name fits within maximum 64 character limit
                // https://docs.microsoft.com/en-us/azure/devops/organizations/settings/naming-restrictions?view=azure-devops#teams
                string fullTeamName = teamName + $"{pipeline.Name}";
                teamName = StringHelper.MaxLength(fullTeamName, MaxTeamNameLength);
                if (fullTeamName.Length > teamName.Length)
                {
                    logger.LogWarning($"Notification team name (length {fullTeamName.Length}) will be truncated to {teamName}");
                }
            }
            else if (purpose == TeamPurpose.SynchronizedNotificationTeam)
            {
                teamName += $"Code owners sync notifications";
            }

            bool updateMetadataAndName = false;
            var  result = teams.FirstOrDefault(
                team =>
            {
                // Swallowing exceptions because parse errors on
                // free form text fields which might be non-yaml text
                // are not exceptional
                var metadata         = YamlHelper.Deserialize <TeamMetadata>(team.Description, swallowExceptions: true);
                bool metadataMatches = (metadata?.PipelineId == pipeline.Id && metadata?.Purpose == purpose);
                bool nameMatches     = (team.Name == teamName);

                if (metadataMatches && nameMatches)
                {
                    return(true);
                }

                if (metadataMatches)
                {
                    logger.LogInformation("Found team with matching pipeline id {0} but different name '{1}', expected '{2}'. Purpose = '{3}'", metadata?.PipelineId, team.Name, teamName, metadata?.Purpose);
                    updateMetadataAndName = true;
                    return(true);
                }

                if (nameMatches)
                {
                    logger.LogInformation("Found team with matching name {0} but different pipeline id {1}, expected {2}. Purpose = '{3}'", team.Name, metadata?.PipelineId, pipeline.Id, metadata?.Purpose);
                    updateMetadataAndName = true;
                    return(true);
                }

                return(false);
            });

            if (result == default)
            {
                logger.LogInformation("Team Not Found purpose = {0}", purpose);
                var teamMetadata = new TeamMetadata
                {
                    PipelineId   = pipeline.Id,
                    Purpose      = purpose,
                    PipelineName = pipeline.Name,
                };
                var newTeam = new WebApiTeam
                {
                    Description = YamlHelper.Serialize(teamMetadata),
                    Name        = teamName
                };

                logger.LogInformation("Create Team for Pipeline PipelineId = {0} Purpose = {1} Name = '{2}'", pipeline.Id, purpose, teamName);
                if (persistChanges)
                {
                    result = await service.CreateTeamForProjectAsync(pipeline.Project.Id.ToString(), newTeam);

                    if (purpose == TeamPurpose.ParentNotificationTeam)
                    {
                        await EnsureScheduledBuildFailSubscriptionExists(pipeline, result, true);
                    }
                }
            }
            else if (updateMetadataAndName)
            {
                var teamMetadata = new TeamMetadata
                {
                    PipelineId = pipeline.Id,
                    Purpose    = purpose,
                };
                result.Description = YamlHelper.Serialize(teamMetadata);
                result.Name        = teamName;

                logger.LogInformation("Update Team for Pipeline PipelineId = {0} Purpose = {1} Name = '{2}'", pipeline.Id, purpose, teamName);
                if (persistChanges)
                {
                    result = await service.UpdateTeamForProjectAsync(pipeline.Project.Id.ToString(), result);

                    if (purpose == TeamPurpose.ParentNotificationTeam)
                    {
                        await EnsureScheduledBuildFailSubscriptionExists(pipeline, result, true);
                    }
                }
            }

            if (purpose == TeamPurpose.SynchronizedNotificationTeam)
            {
                await SyncTeamWithCodeOwnerFile(pipeline, result, gitHubToAADConverter, gitHubService, persistChanges);
            }
            return(result);
        }