Example #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);
            }
        }
Example #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),
            });
        }
Example #3
0
        private string GenerateTitle(Track track)
        {
            var textGenerator = new SampleTextGenerator();
            var title         = textGenerator.GenWords(2) + " " + track.Name + " " + textGenerator.GenWords(3);
            var c             = title[1];
            var sb            = new StringBuilder();

            sb.Append(char.ToUpper(c));
            sb.Append(title.Substring(1));
            return(sb.ToString());
        }
Example #4
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();
        }
Example #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();
            }
        }