예제 #1
0
 public void Save(MeetingTimes mtgTimes)
 {
     using (var ctx = new LocalDatabaseContext(_localDbFilePath))
     {
         var timings = ctx.Db.GetCollection <MeetingTimes>(CollectionNameMtgTimes);
         timings.Insert(mtgTimes);
     }
 }
        private MeetingTimes BuildRequestBody(Meeting meeting, string startTime, string endTime)
        {
            var result = new MeetingTimes
            {
                MeetingDuration = "PT30M",
                Attendees       = new List <MeetingTimes.Attendee>(),
                TimeConstraint  = new TimeConstraint
                {
                    Timeslots = new List <MeetingTimeSlot>()
                },
                LocationConstraint = new LocationConstraint()
                {
                    Locations = new List <Location>()
                }
            };

            foreach (var a in meeting.Attendees)
            {
                if (!a.EmailAddress.IsEqualTo(meeting.Organizer.EmailAddress))
                {
                    result.Attendees.Add(new MeetingTimes.Attendee
                    {
                        EmailAddress = a.EmailAddress
                    });
                }
            }

            var date       = meeting.Start.ToLocalTime();
            var dateString = date.DateToApiString();

            var timeSlot = new MeetingTimeSlot
            {
                Start = new MeetingTimeSlot.TimeDescriptor
                {
                    Date     = dateString,
                    Time     = startTime,
                    TimeZone = TimeZoneInfo.Local.Id
                },
                End = new MeetingTimeSlot.TimeDescriptor
                {
                    Date     = dateString,
                    Time     = endTime,
                    TimeZone = TimeZoneInfo.Local.Id
                }
            };

            result.TimeConstraint.Timeslots.Add(timeSlot);

            if (!string.IsNullOrEmpty(meeting.Location.DisplayName))
            {
                result.LocationConstraint.Locations.Add(new Location
                {
                    DisplayName = meeting.Location.DisplayName
                });
            }

            return(result);
        }
예제 #3
0
        private void WriteReport(DateTimeServiceForTests dateTimeService, MeetingTimes lastMtgTimes)
        {
            var service         = new LocalTimingDataStoreService(null, dateTimeService);
            var historicalTimes = service.GetHistoricalMeetingTimes();

            PdfTimingReport report = new PdfTimingReport(lastMtgTimes, historicalTimes, Path.GetTempPath());

            report.Execute();
        }
예제 #4
0
 public PdfTimingReport(
     MeetingTimes data,
     HistoricalMeetingTimes?historicalASummary,
     IQueryWeekendService queryWeekendService,
     bool weekendIncludesFriday,
     string outputFolder)
 {
     _data = data;
     _historicalASummary    = historicalASummary;
     _queryWeekendService   = queryWeekendService;
     _weekendIncludesFriday = weekendIncludesFriday;
     _outputFolder          = outputFolder;
 }
예제 #5
0
        public IEnumerable <string> GetUsers(string match, int count)
        {
#if MEETING_TIMES
            MeetingTimes times = new MeetingTimes();

            MeetingTimeSlot timeSlot = new MeetingTimeSlot();
            timeSlot.Start = new TimeDesc("2015-10-08", "1:00:00", "GMT Standard Time");
            timeSlot.End   = new TimeDesc("2015-10-08", "23:00:00", "GMT Standard Time");

            AttendeeBase att1 = new AttendeeBase();
//            att1.EmailAddress.Address = "*****@*****.**";
            att1.EmailAddress.Address = "*****@*****.**";

            AttendeeBase att2 = new AttendeeBase();
            att2.EmailAddress.Address = "*****@*****.**";

            times.TimeConstraint.Timeslots.Add(timeSlot);
            times.LocationConstraint = new LocationConstraint();

            times.Attendees.Add(att1);
//            times.Attendees.Add(att2);

            var    httpProxy = new HttpUtilSync(Constants.OfficeResourceId);
            String uri       = "https://outlook.office365.com/api/beta/me/findmeetingtimes";

            var res = httpProxy.PostItem2 <MeetingTimes, MeetingTimeCandidates>(uri, times);

            return(null);
#else
            string uri = BaseUri + "users";
            uri += '?';     // we always have at least api version parameter

            if (string.IsNullOrEmpty(match) == false)
            {
                uri = AddFilters(uri, match,
                                 "userPrincipalName",
                                 "displayName",
                                 "givenName" /*, "surName"*/);

                uri += '&';
            }

            uri += ApiVersion;

            var users = new HttpUtilSync(Constants.AadServiceResourceId)
                        .GetItems <UserHttp>(uri, count);

            return(users.Select(x => x.UserPrincipalName));
#endif
        }
예제 #6
0
        public IEnumerable<string> GetUsers(string match, int count)
        {
            #if MEETING_TIMES
            MeetingTimes times = new MeetingTimes();

            MeetingTimeSlot timeSlot = new MeetingTimeSlot();
            timeSlot.Start = new TimeDesc("2015-10-08", "1:00:00", "GMT Standard Time");
            timeSlot.End = new TimeDesc("2015-10-08", "23:00:00", "GMT Standard Time");

            AttendeeBase att1 = new AttendeeBase();
            //            att1.EmailAddress.Address = "*****@*****.**";
            att1.EmailAddress.Address = "*****@*****.**";

            AttendeeBase att2 = new AttendeeBase();
            att2.EmailAddress.Address = "*****@*****.**";

            times.TimeConstraint.Timeslots.Add(timeSlot);
            times.LocationConstraint = new LocationConstraint();

            times.Attendees.Add(att1);
            //            times.Attendees.Add(att2);

            var httpProxy = new HttpUtilSync(Constants.OfficeResourceId);
            String uri = "https://outlook.office365.com/api/beta/me/findmeetingtimes";

            var res = httpProxy.PostItem2<MeetingTimes, MeetingTimeCandidates>(uri, times);

            return null;
            #else
            string uri = BaseUri + "users";
            uri += '?';     // we always have at least api version parameter

            if (string.IsNullOrEmpty(match) == false)
            {
                uri = AddFilters(uri, match,
                            "userPrincipalName",
                            "displayName",
                            "givenName"/*, "surName"*/);

                uri += '&';
            }

            uri += ApiVersion;

            var users = new HttpUtilSync(Constants.AadServiceResourceId)
                    .GetItems<UserHttp>(uri, count);

            return users.Select(x => x.UserPrincipalName);
            #endif
        }
        private void Init()
        {
            try
            {
                string folder     = FileUtils.GetTimingReportsDatabaseFolder(_commandLineService?.OptionsIdentifier);
                string dbFilePath = Path.Combine(folder, "TimingData.db");

                _localData = new LocalData(dbFilePath);
                _mtgTimes  = new MeetingTimes(_dateTimeService);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Could not initialise store");
            }
        }
예제 #8
0
        public void TestReportGeneration()
        {
            var dateTimeService = new DateTimeServiceForTests();

            const int weekCount          = 20;
            var       dateOfFirstMeeting = GetNearestDayOnOrAfter(DateTime.Today.AddDays(-weekCount * 7), DayOfWeek.Sunday).Date;

            MeetingTimes lastMtgTimes = null;

            for (int wk = 0; wk < weekCount; ++wk)
            {
                var dateOfWeekendMtg = dateOfFirstMeeting.AddDays(wk * 7);
                var dateOfMidweekMtg = dateOfWeekendMtg.AddDays(4);

                StoreWeekendData(wk, dateOfWeekendMtg, dateTimeService);
                lastMtgTimes = StoreMidweekData(wk, weekCount, dateOfMidweekMtg, dateTimeService);
            }

            WriteReport(dateTimeService, new QueryWeekendService(), lastMtgTimes);
        }
        private MeetingTimes BuildRequestBody(Meeting meeting)
        {
            var result = new MeetingTimes
            {
                MeetingDuration = "PT30M",
                Attendees       = new List <MeetingTimes.Attendee>(),
                TimeConstraint  = new TimeConstraint
                {
                    Timeslots = new List <MeetingTimeSlot>()
                },
                LocationConstraint = new LocationConstraint()
                {
                    IsRequired = false,
                    Locations  = new List <Location>()
                },
                MaxCandidates = 20,
            };

            foreach (var a in meeting.Attendees ?? Enumerable.Empty <Attendee>())
            {
                if (meeting.Organizer == null || !a.EmailAddress.IsEqualTo(meeting.Organizer.EmailAddress))
                {
                    result.Attendees.Add(new MeetingTimes.Attendee
                    {
                        EmailAddress = a.EmailAddress
                    });
                }
            }

            var date = meeting.Start.DateTime;

            // From 8AM to 6PM local time
            var start = new DateTime(date.Year, date.Month, date.Day, 8, 0, 0, DateTimeKind.Local);
            var end   = new DateTime(date.Year, date.Month, date.Day, 18, 0, 0, DateTimeKind.Local);

            start = start.ToUniversalTime();
            end   = end.ToUniversalTime();

            var timeSlot = new MeetingTimeSlot
            {
                Start = new MeetingTimeSlot.TimeDescriptor
                {
                    Date     = start.DateToApiString(),
                    Time     = start.TimeOfDay.ToString(),
                    TimeZone = "UTC"
                },
                End = new MeetingTimeSlot.TimeDescriptor
                {
                    Date     = end.DateToApiString(),
                    Time     = end.TimeOfDay.ToString(),
                    TimeZone = "UTC"
                }
            };

            result.TimeConstraint.Timeslots.Add(timeSlot);

            if (!string.IsNullOrEmpty(meeting.Location.DisplayName))
            {
                result.LocationConstraint.Locations.Add(new Location
                {
                    DisplayName = meeting.Location.DisplayName
                });
            }

            return(result);
        }
예제 #10
0
 public PdfTimingReport(MeetingTimes data, HistoricalMeetingTimes historicalASummary, string outputFolder)
 {
     _data = data;
     _historicalASummary = historicalASummary;
     _outputFolder       = outputFolder;
 }