Exemple #1
0
        /// <summary>Add everyone else, some of whom may be speakers.</summary>
        private void AddTheCrowd(int count, List <Person> persons)
        {
            var          enumerator       = PeopleNames.RandomNameEnumerator();
            const string netNameFmt       = "{0}.{1}{2}";
            var          netNameCounter   = 1;
            var          bioTextGenerator = new SampleTextGenerator();
            const SampleTextGenerator.SourceNames bioTextSource =
                SampleTextGenerator.SourceNames.TheRaven;

            while (count-- > 0)
            {
                enumerator.MoveNext();
                var name = enumerator.Current;

                var netName = string.Format(netNameFmt, name.First, name.Last, netNameCounter++);
                var item    =
                    new Person
                {
                    FirstName = name.First,
                    LastName  = name.Last,
                    Email     = netName + "@contoso.com",
                    Blog      = "http://" + netName + "/contoso.com",
                    Twitter   = "@" + netName,
                    Gender    = name.Gender,
                    Bio       = bioTextGenerator.GenSentences(8, bioTextSource),
                };

                persons.Add(item);
            }
        }
Exemple #2
0
        /// <summary>Add the "well-known" attendees (who will not be speakers)</summary>
        private void AddKnownAttendees(List <Person> persons)
        {
            var bioTextGenerator = new SampleTextGenerator();
            const SampleTextGenerator.SourceNames bioTextSource =
                SampleTextGenerator.SourceNames.ChildHarold;

            persons.Add(new Person
            {
                FirstName   = "Landon",
                LastName    = "Papa",
                Email       = "*****@*****.**",
                Blog        = "http://johnpapa.net",
                Twitter     = "landonpapa",
                Gender      = "M",
                ImageSource = "felix_fanboi.jpg",
                Bio         = bioTextGenerator.GenSentences(12, bioTextSource),
            });
            persons.Add(new Person
            {
                FirstName   = "Ella",
                LastName    = "Papa",
                Email       = "*****@*****.**",
                Blog        = "http://contoso.com/",
                Twitter     = "ellapapa",
                Gender      = "F",
                ImageSource = "sue_menot.jpg",
                Bio         = bioTextGenerator.GenSentences(20, bioTextSource),
            });
        }
Exemple #3
0
        private void AddAttendance(CodeCamperDbContext context, IEnumerable <Person> attendees)
        {
            var attendanceList = new List <Attendance>();

            var textGenerator = new SampleTextGenerator();
            const SampleTextGenerator.SourceNames textSource = SampleTextGenerator.SourceNames.Faust;

            // NEEDED FOR RANDOMIZING WHICH WE NO LONGER DO
            // Unique TimeSlot.Ids and Ids of Sessions in those slots
            //var slotAndSessionIds = GetSlotAndSessionIds(sessions);
            //var numberOfAttendedSessions = Math.Min(slotAndSessionIds.Count(), 8);

            var sids = TheChosen.ChoosenAttendeeSessions
                       .Select(s => s.Id).ToList();

            foreach (var person in attendees)
            {
                // NO LONGER RANDOMIZING ASSIGNMENTS
                //var sids = GetRandomAttendeeSessionIds(
                //    numberOfAttendedSessions,
                //    slotAndSessionIds);

                var evalCount = 4; // person evals the first 'n' sessions attended
                foreach (var sid in sids)
                {
                    var attendance =
                        new Attendance
                    {
                        PersonId  = person.Id,
                        SessionId = sid,
                    };
                    attendanceList.Add(attendance);

                    if (evalCount <= 0)
                    {
                        continue;
                    }

                    attendance.Rating = Rand.Next(1, 6);// rating in 1..5
                    attendance.Text   = textGenerator.GenSentences(10, textSource);
                    evalCount--;
                }
            }

            // Done populating Attendance
            attendanceList.ForEach(ps => context.Attendance.Add(ps));
            context.SaveChanges();
        }
        public static void AddAuthors(List <Author> authors)
        {
            var descriptionTextGenerator = new SampleTextGenerator();
            const SampleTextGenerator.SourceNames bioTextSource =
                SampleTextGenerator.SourceNames.ChildHarold;
            int countSentences = 10;

            sampleAuthors             = new List <Author>();
            sampleAuthors.Add(Vicente = new Author
            {
                Name        = "Vicente d'Avila Melo Sarmento",
                FacebookId  = "1199458233",
                Title       = "Arquiteto da Informação",
                LinkedIn    = "58230796",
                GooglePlus  = "116134093095093079398",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "*****@*****.**"
            });
            sampleAuthors.Add(Bernardo = new Author
            {
                Name        = "Bernardo Leite Pereira Castanheira",
                FacebookId  = "100002094308007",
                Title       = "Analista Pleno",
                LinkedIn    = "91197116",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "*****@*****.**"
            });
            sampleAuthors.Add(Roberto = new Author
            {
                Name        = "Roberto Barreto de Melo Campos",
                FacebookId  = "100000882665737",
                Title       = "Analista Pleno",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "*****@*****.**"
            });
            sampleAuthors.Add(Henrique = new Author
            {
                Name        = "Henrique Rabello",
                FacebookId  = "100001245811711",
                Title       = "Analista Sênior",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "henrique.rabello@izzui,com"
            });
            sampleAuthors.Add(Andrey = new Author
            {
                Name        = "Andrey Britto",
                FacebookId  = "100000856290659",
                Title       = "Analista Sênior",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "*****@*****.**"
            });
            sampleAuthors.Add(Demetrius = new Author
            {
                Name        = "Demetrius Nunes",
                FacebookId  = "790128571",
                Title       = "Chief Technology Officer",
                Description = descriptionTextGenerator.GenSentences(countSentences, bioTextSource),
                Email       = "*****@*****.**"
            });

            authors.AddRange(sampleAuthors);
        }
Exemple #5
0
        private void AddGeneratedSessions(List <Session> sessions, IList <Person> persons, IEnumerable <TimeSlot> timeSlots, IList <Track> tracks)
        {
            var textGenerator = new SampleTextGenerator();
            const SampleTextGenerator.SourceNames descTextSource =
                SampleTextGenerator.SourceNames.Decameron;

            // levels setup so "intermediate" sessions occur more frequently
            var levels     = new[] { _levels[0], _levels[1], _levels[1], _levels[1], _levels[2] };
            var levelCount = levels.Length;

            var trackCount = tracks.Count;
            var trackIx    = 0;

            var slots      = timeSlots.Where(t => t != _keyNoteTimeSlot).ToArray();
            var slotsCount = slots.Length;

            var       personsCount        = persons.Count;
            const int firstKnownSpeakerIx = 2; // skip the "reserved" attendees who we know are not speakers.
            const int firstCrowdIx        = 4; // first person in the crowd who could be a speaker

            var chosenCount = TheChosen._theChosen.Count();

            var speakerIxs = new List <int>(); // speakers assigned in the current timeslot


            // Populate sessions
            var slotIx = 0; // current slot

            while (slotIx < slotsCount)
            {
                var slot = slots[slotIx];

                // Assign sessions by track, looping through tracks
                var track = tracks[trackIx];
                var room  = _roomsForGeneratedSessions[trackIx]; // track sessions are in the same room

                // Weight the draw of speakers towards the "well-known" speakers
                // Ensure a person only speaks once in a timeslot
                //var speakerIx = Rand.Next(firstKnownSpeakerIx, firstCrowdIx+5);
                var speakerIx = Rand.Next(firstKnownSpeakerIx, firstKnownSpeakerIx + chosenCount);
                if (speakerIx >= firstCrowdIx || speakerIxs.Contains(speakerIx))
                {
                    do
                    {
                        speakerIx = Rand.Next(firstCrowdIx, Math.Min(75, personsCount)); //Max speakers allowed are 75
                    } while (speakerIxs.Contains(speakerIx));
                }
                speakerIxs.Add(speakerIx);

                var speaker = persons[speakerIx];
                var level   = levels[Rand.Next(0, levelCount)];
                var session =
                    new Session
                {
                    Title       = GenerateTitle(track),
                    Code        = GenSessionCode(track.Name, level),
                    SpeakerId   = speaker.Id,
                    TrackId     = track.Id,
                    TimeSlotId  = slot.Id,
                    RoomId      = room.Id,
                    Level       = level,
                    Tags        = TagsGenerator.GenTags(track.Name),
                    Description = textGenerator.GenSentences(40, descTextSource),
                };

                sessions.Add(session);

                // Limit to 110 sessions
                if (sessions.Count > 110)
                {
                    return;
                }

                if (++trackIx != trackCount)
                {
                    continue;
                }

                // Ran around the tracks; bump to next TimeSlot and reset
                slotIx++;
                trackIx = 0;
                speakerIxs.Clear();
            }
        }