示例#1
0
        public MeetupsPage()
        {
            this.InitializeComponent();
            this.BindingContext = new MeetupsViewModel(this.Navigation);

            this.ListViewEvents.ItemTapped   += (sender, e) => this.ListViewEvents.SelectedItem = null;
            this.ListViewEvents.ItemSelected += async(sender, e) =>
            {
                if (!(this.ListViewEvents.SelectedItem is MeetupModel ev))
                {
                    return;
                }

                var eventSessions = new MeetupPage(ev);
                await NavigationService.PushAsync(this.Navigation, eventSessions);

                this.ListViewEvents.SelectedItem = null;
            };
        }
示例#2
0
        public static async Task Run(
            [QueueTrigger(QueueName.CollectCalendarPage)] CollectCalendarPageData command,

            [Table(TableName.Meetup)] CloudTable meetupTable,
            [Table(TableName.MeetupSession)] CloudTable meetupSessionTable,
            [Table(TableName.Session)] CloudTable sessionTable,
            [Table(TableName.Speaker)] CloudTable speakerTable,
            [Table(TableName.Venue)] CloudTable venueTable,

            [Blob(ContainerName.PageData + PageDataBlobUrl, FileAccess.Write)] CloudBlockBlob calendarPageDataBlob,
            [Queue(QueueName.RenderPage)] CloudQueue renderQueue,

            ILogger log)
        {
            var meetupService        = new MeetupService(meetupTable);
            var venueService         = new VenueService(venueTable);
            var meetupSessionService = new MeetupSessionService(meetupSessionTable);
            var sessionService       = new SessionService(sessionTable);
            var speakerService       = new SpeakerService(speakerTable);

            var renderService = new CommandQueueService(renderQueue);


            var calendarPageModel = new CalendarPage();

            var meetups = (await meetupService.GetMeetupsAsync())
                          .GroupBy(x => x.Year, (key, elements) => new
            {
                year    = key,
                meetups = elements
                          .OrderBy(x => x.Year)
                          .ThenBy(x => x.Month)
                          .ThenBy(x => x.Day)
            })
                          .OrderBy(x => x.year)
                          .ToDictionary(x => x.year, element => element.meetups);

            var meetupSessions = await meetupSessionService.GetMeetupSessionsAsync();

            var sessions = await sessionService.GetSessionsAsync();

            var speakers = await speakerService.GetSpeakersAsync();

            var venues = await venueService.GetVenuesAsync();

            calendarPageModel.Years         = meetups.Keys.ToArray();
            calendarPageModel.CalendarYears = meetups.Values.Select(x =>
            {
                var calendarYear = new CalendarYear();

                calendarYear.Year    = x.First().Year;
                calendarYear.Meetups = x.Select(y =>
                {
                    var meetupPage = new MeetupPage();

                    meetupPage.Meetup = y;

                    meetupPage.Venue = venues
                                       .Single(z => z.Id == meetupPage.Meetup.VenueId);

                    meetupPage.Sessions = meetupSessions
                                          .Where(z => z.MeetupId == meetupPage.Meetup.Id)
                                          .OrderBy(z => z.OrderN)
                                          .Select(z =>
                    {
                        var agenda = new MeetupAgenda();

                        agenda.MeetupSession = z;

                        agenda.Session = sessions
                                         .Single(q => q.Id == agenda.MeetupSession.SessionId);

                        agenda.Speaker = speakers
                                         .Single(q => q.Id == agenda.Session.SpeakerId);

                        return(agenda);
                    })
                                          .ToArray();

                    return(meetupPage);
                })
                                       .ToArray();

                return(calendarYear);
            })
                                              .ToArray();


            await calendarPageDataBlob.UploadTextAsync(JsonConvert.SerializeObject(calendarPageModel));

            var renderCommand = new RenderPage
            {
                DataInstanceId = command.DataInstanceId,
                PublicUrl      = calendarPageModel.PublicUrl,
                TemplateId     = CalendarPage.TemplateId
            };
            await renderService.SubmitCommandAsync(renderCommand);
        }
示例#3
0
        public static async Task Run(
            [QueueTrigger(QueueName.CollectHomePage)] CollectHomePageData command,

            [Table(TableName.Meetup)] CloudTable meetupTable,
            [Table(TableName.MeetupSession)] CloudTable meetupSessionTable,
            [Table(TableName.Session)] CloudTable sessionTable,
            [Table(TableName.Speaker)] CloudTable speakerTable,
            [Table(TableName.Venue)] CloudTable venueTable,
            [Table(TableName.Partner)] CloudTable partnerTable,

            [Blob(ContainerName.PageData + "/index.json", FileAccess.Write)] CloudBlockBlob homePageDataBlob,
            [Queue(QueueName.RenderPage)] CloudQueue renderQueue,

            ILogger log)
        {
            var meetupService        = new MeetupService(meetupTable);
            var venueService         = new VenueService(venueTable);
            var meetupSessionService = new MeetupSessionService(meetupSessionTable);
            var sessionService       = new SessionService(sessionTable);
            var speakerService       = new SpeakerService(speakerTable);
            var partnerService       = new PartnerService(partnerTable);

            var renderService = new CommandQueueService(renderQueue);


            var homePageModel = new HomePage();

            var date    = DateTime.UtcNow.AddHours(TimeZoneOffset);
            var meetups = (await meetupService.GetMeetupsUpcomingAsync(TopMeetups, date))
                          .OrderBy(x => x.Year)
                          .ThenBy(x => x.Month)
                          .ThenBy(x => x.Day);

            var venues = await venueService.GetVenuesByIdsAsync(meetups.Select(x => x.VenueId));

            var agendaItems = await meetupSessionService.GetMeetupSessionsByMeetupIdsAsync(meetups.Select(x => x.Id));

            var sessions = await sessionService.GetSessionsByIdsAsync(agendaItems.Select(x => x.SessionId));

            var speakers = await speakerService.GetSpeakersByIdsAsync(sessions.Select(x => x.SpeakerId));

            var meetupPages = new List <MeetupPage>();

            foreach (var meetup in meetups)
            {
                var meetupPage = new MeetupPage();
                meetupPages.Add(meetupPage);

                meetupPage.Meetup = meetup;

                meetupPage.Registration = new MeetupRegistration
                {
                    IsOpened = true,
                    Url      = null
                };

                meetupPage.Venue = venues.Single(x => x.Id == meetup.VenueId);

                var agenda = agendaItems
                             .Where(x => x.MeetupId == meetup.Id)
                             .Select(a =>
                {
                    var y = new MeetupAgenda
                    {
                        MeetupSession = a,
                        Session       = sessions.Single(x => x.Id == a.SessionId)
                    };

                    y.Speaker = speakers.Single(x => x.Id == y.Session.SpeakerId);

                    return(y);
                });

                meetupPage.Sessions = agenda.ToArray();

                meetupPage.Partners = new IPartner[0];
            }

            homePageModel.Meetups = meetupPages.ToArray();

            homePageModel.Speakers = (await speakerService.GetSpeakersHighlightedAsync())
                                     .ToArray();

            homePageModel.Partners = (await partnerService.GetPartnersHighlightedAsync())
                                     .ToArray();

            await homePageDataBlob.UploadTextAsync(JsonConvert.SerializeObject(homePageModel));

            var renderCommand = new RenderPage
            {
                DataInstanceId = command.DataInstanceId,
                PublicUrl      = homePageModel.PublicUrl,
                TemplateId     = HomePage.TemplateId
            };
            await renderService.SubmitCommandAsync(renderCommand);
        }
示例#4
0
        public static async Task Run(
            [QueueTrigger(QueueName.CollectMeetupPage)] CollectMeetupPageData command,

            [Table(TableName.Meetup)] CloudTable meetupTable,
            [Table(TableName.MeetupSession)] CloudTable meetupSessionTable,
            [Table(TableName.Session)] CloudTable sessionTable,
            [Table(TableName.MeetupSessionMaterial)] CloudTable sessionMaterialTable,
            [Table(TableName.Speaker)] CloudTable speakerTable,
            [Table(TableName.Venue)] CloudTable venueTable,

            [Blob(ContainerName.PageData + PageDataBlobUrl, FileAccess.Write)] CloudBlockBlob meetupPageDataBlob,
            [Queue(QueueName.RenderPage)] CloudQueue renderQueue,

            ILogger log)
        {
            var meetupService                = new MeetupService(meetupTable);
            var venueService                 = new VenueService(venueTable);
            var meetupSessionService         = new MeetupSessionService(meetupSessionTable);
            var meetupSessionMaterialService = new MeetupSessionMaterialService(sessionMaterialTable);
            var sessionService               = new SessionService(sessionTable);
            var speakerService               = new SpeakerService(speakerTable);

            var renderService = new CommandQueueService(renderQueue);

            var meetupPageViewModel = new MeetupPage();

            meetupPageViewModel.Meetup = await meetupService.GetMeetupByIdAsync(command.MeetupId);

            meetupPageViewModel.Venue = await venueService.GetVenueByIdAsync(meetupPageViewModel.Meetup.VenueId);

            var openedMeetups = new List <string>
            {
                //Guid.Parse("059b6187352c4b718e5626e56f6d84a1").ToString("N")
            };

            meetupPageViewModel.Registration = new MeetupRegistration
            {
                IsOpened = openedMeetups.Contains(command.MeetupId),
                Url      = null
            };

            var meetupAgendaItems = await meetupSessionService.GetMeetupSessionsByMeetupIdAsync(meetupPageViewModel.Meetup.Id);

            var sessions = await sessionService.GetSessionsByIdsAsync(meetupAgendaItems.Select(x => x.SessionId));

            var speakers = await speakerService.GetSpeakersByIdsAsync(sessions.Select(x => x.SpeakerId));

            var materials = await meetupSessionMaterialService.GetMeetupSessionsMaterialsByMeetupIdAsync(command.MeetupId);

            meetupPageViewModel.Sessions = meetupAgendaItems.Select(x =>
            {
                var agenda = new MeetupAgenda
                {
                    MeetupSession = x,
                    Session       = sessions.Single(s => s.Id == x.SessionId),
                    Materials     = materials.Where(m => m.SessionId == x.SessionId).ToArray()
                };

                agenda.Speaker = speakers.Single(s => s.Id == agenda.Session.SpeakerId);

                return(agenda);
            }).ToArray();

            meetupPageViewModel.Partners = new IPartner[0];

            await meetupPageDataBlob.UploadTextAsync(JsonConvert.SerializeObject(meetupPageViewModel));

            var renderCommand = new RenderPage
            {
                DataInstanceId = command.DataInstanceId,
                PublicUrl      = meetupPageViewModel.PublicUrl,
                TemplateId     = MeetupPage.TemplateId
            };
            await renderService.SubmitCommandAsync(renderCommand);
        }