Example #1
0
        public SkillDto(Skill skill)
        {
            SkillDefinitionId = skill.SkillDefinition.Id;

            Value = skill.Value;

            LearnRate = skill.LearnRate;

            ForgetRate = skill.ForgetRate;
        }
Example #2
0
        public static IEnumerable<Person> GeneratePeople(string connectionString, int gameId, int count = 1)
        {
            var personInsert = new SqlInsertStatement(connectionString)
                                    .InsertInto("dbo.BZ_Person")
                                        .Column("GameId", gameId)
                                        .Column("GenderId")
                                        .Column("FirstName")
                                        .Column("LastName")
                                        .Column("Birthday")
                                        .Column("RetirementDate")
                                        .Column("PersonalityId", 1);

            for (var index = 0; index < count; index++)
            {
                var gender = (int)Utilities.GetRandomValue(Gender.None);

                var first = Utilities.GetRandomString(16).Replace("'", "''");

                var last = Utilities.GetRandomString(16).Replace("'", "''");

                var birthday = Utilities.GetRandomDate();

                var retirement = birthday.AddYears(Utilities.GetRandomInt(65, 85));

                var intensity = Utilities.GetRandomDecimal(0, 1);

                personInsert.Values()
                            .Value("GenderId", gender)
                            .Value("FirstName", first)
                            .Value("LastName", last)
                            .Value("Birthday", birthday)
                            .Value("RetirementDate", retirement);
            }

            personInsert.Execute();

            var select = new SqlSelectStatement(connectionString);

            select.Select("Id")
                    .Select("GenderId")
                    .Select("FirstName")
                    .Select("LastName")
                    .Select("Birthday")
                  .From("BZ_Person")
                  .WhereEquals("GameId", gameId);

            var output = select.ExecuteComplex<Person>();

            var skillIds = new SqlSelectStatement(connectionString)
                                .Select("Id")
                                .From("dbo.BZ_Skill_Definition")
                                .Execute<int>();

            var skillInsert = new SqlInsertStatement(connectionString)
                                    .InsertInto("dbo.BZ_Person_Skill")
                                    .Column("PersonId")
                                    .Column("SkillDefinitionId")
                                    .Column("Value")
                                    .Column("LearnRate")
                                    .Column("ForgetRate");

            var skillsProperty = typeof(Person).GetProperty("Skills");

            foreach (var person in output)
            {
                var remainingSkillIds = new List<int>(skillIds);

                var skills = new List<Skill>();

                var skillCount = Utilities.GetRandomInt(1, remainingSkillIds.Count);

                while (skillCount-- > 0)
                {
                    var skill = new Skill
                    {
                        ForgetRate = Utilities.GetRandomDecimal(0, 10),
                        LearnRate = Utilities.GetRandomDecimal(0, 10),
                        Value = Utilities.GetRandomDecimal(0, 255),
                        SkillDefinition = new SkillDefinition
                        {
                            Id = (byte)remainingSkillIds.Random()
                        }
                    };

                    remainingSkillIds.Remove(skill.SkillDefinition.Id);

                    skillInsert.Values()
                                .Value("PersonId", person.Id)
                                .Value("SkillDefinitionId", skill.SkillDefinition.Id)
                                .Value("Value", skill.Value)
                                .Value("LearnRate", skill.LearnRate)
                                .Value("ForgetRate", skill.ForgetRate);

                    skills.Add(skill);
                }

                skillsProperty.SetValue(person, skills);
            }

            skillInsert.Execute();

            return output;
        }
        protected decimal CalculateEmployeeSkillValue(Employee employee, Skill skill)
        {
            var output = skill.Value;

            return output;
        }
Example #4
0
        public static PersonServiceData GeneratePersonServiceData(int numberOfPeople, IEnumerable<Personality> validPersonalities, IEnumerable<SkillDefinition> validSkills = null, IEnumerable<Company> validCompanies = null)
        {
            var people = new List<Person>();

            for (var personIndex = 0; personIndex < numberOfPeople; personIndex++)
            {
                List<Skill> skills = null;

                if (validSkills != null)
                {
                    var remainingSkills = new List<SkillDefinition>(validSkills);

                    var skillCount = Utilities.GetRandomInt(1, remainingSkills.Count);

                    skills = new List<Skill>(skillCount);

                    for (var skillIndex = 0; skillIndex < skillCount; skillIndex++)
                    {
                        var skill = new Skill
                        {
                            ForgetRate = Utilities.GetRandomDecimal(0, 1),
                            LearnRate = Utilities.GetRandomDecimal(0, 1),
                            Value = Utilities.GetRandomDecimal(0, 255),
                            SkillDefinition = remainingSkills.Random()
                        };

                        remainingSkills.Remove(skill.SkillDefinition);

                        skills.Add(skill);
                    }
                }
                else
                {
                    skills = new List<Skill>();
                }

                var person = new Person(skills)
                {
                    Id = Utilities.InvalidId,
                    FirstName = Utilities.GetRandomString(16),
                    LastName = Utilities.GetRandomString(16),
                    Birthday = Utilities.GetRandomDate().Date,
                    Gender = Utilities.GetRandomValue(Gender.None),
                    Personality = validPersonalities.Random()
                };

                person.RetirementDate = person.Birthday.AddYears(Utilities.GetRandomInt(60, 100)).AddDays(Utilities.GetRandomInt(1, 360));

                if (validCompanies != null)
                {
                    var remainingCompanies = new List<Company>(validCompanies);

                    var rollingDate = new DateTime(Utilities.GetRandomInt(person.Birthday.Year + 10, person.Birthday.Year + 20), Utilities.GetRandomInt(1, 12), Utilities.GetRandomInt(1, 28));

                    while (remainingCompanies.Any())
                    {
                        var workHistory = new WorkHistory
                        {
                            Company = remainingCompanies.Random(),
                            StartDate = rollingDate,
                            EndDate = rollingDate = rollingDate.AddMonths(Utilities.GetRandomInt(1, 6)),
                            StartingSalary = Utilities.GetRandomDecimal(10, 100),
                            EndingSalary = Utilities.GetRandomDecimal(100, 250)
                        };

                        remainingCompanies.Remove(workHistory.Company);

                        person.WorkHistory.Add(workHistory);
                    }
                }

                people.Add(person);
            }

            return new PersonServiceData
            {
                People = people
            };
        }