コード例 #1
0
        /// <summary>
        /// Called one at startup, after an initial delay to let outlook finish loading
        /// </summary>
        void performDelayedStartupTasks()
        {
            // This code is only for diagnosing tricky problems and won't be executed in a normal deployment
            if (!logger.Enabled)
            {
                return;
            }

            // iterate over all of today's items
            logger.Debug("Advanced diagnostics: logging data on items in today's calendar...");
            Outlook.Items calItems = findCalendarItems(
                "[Start] >= '" + (DateTime.Today).ToString("g") + "'"
                + " AND [Start] <= '" + (DateTime.Today + OneDay).ToString("g") + "'"
                + " AND [End] >= '" + (DateTime.Today).ToString("g") + "'"
                // not really necessary but
                + " AND [End] <= '" + (DateTime.Today + OneDay).ToString("g") + "'"
                );
            var subjectExcludeRegex = getSubjectExcludeRegex();
            int count = 0;

            foreach (Outlook.AppointmentItem item in calItems)
            {
                count++;
                if (string.IsNullOrWhiteSpace(item.Subject))
                {
                    logger.Debug("Found meeting with subject '" + item.Subject + "' at " + item.Start);
                }

                if (item.AllDayEvent)
                {
                    continue;                                   // else constructor will throw
                }
                var meeting = new UpcomingMeeting(item, item.Start - DefaultReminderTime);
                if (meeting.GetMeetingUrl() != "")
                {
                    logger.Debug("Extracted meeting URL from '" + meeting.Subject + "': '" + meeting.GetMeetingUrl() + "'");
                }
                else if (meeting.Body.Trim() != "")
                {
                    // This is a bit verbose but may be needed sometimes for debugging URL regexes (at least until we build a proper UI for that task)
                    logger.Info("No meeting URL found in '" + meeting.Subject + "': \n-------------------------------------\n" + meeting.Body + "\n-------------------------------------\n");
                }
                if (subjectExcludeRegex != null && subjectExcludeRegex.IsMatch(item.Subject ?? ""))
                {
                    logger.Info("This item will be ignored due to subject exclude regex: '" + item.Subject + "'");
                }
            }
            logger.Debug("Completed advanced diagnostics - checked " + count + " calendar items for today\n\n");
        }
コード例 #2
0
        public ReminderForm(UpcomingMeeting meeting)
        {
            this.meeting = meeting;
            this.joinUrl = meeting.GetMeetingUrl();
            InitializeComponent();

            // populate the combo with a hardcoded list of items whose primary purpose is to illustrate the
            // syntax of all possible values
            timeCombo.Items.Add(new SnoozeTime(20, false));
            timeCombo.Items.Add(new SnoozeTime(-20, false));
            timeCombo.Items.Add(new SnoozeTime(30, true));
            timeCombo.Items.Add(new SnoozeTime(60, true));

            // set labels for this meeting
            nameLabel.Text      = meeting.Subject;
            extraInfoLabel.Text = "";
            if (meeting.Location.Length > 0)
            {
                extraInfoLabel.Text = "Location: " + meeting.Location + "; ";
            }
            extraInfoLabel.Text += "Duration " + meeting.OutlookItem.Duration + " mins";

            if (meeting.getOrganizer() != null)
            {
                extraInfoLabel.Text += "; organizer: " + meeting.getOrganizer();
            }
            IEnumerable <string> attendees = meeting.GetAttendees();

            if (attendees.Count() == 1)
            {
                extraInfoLabel.Text += "; with: " + string.Join(", ", attendees);
            }
            else
            {
                extraInfoLabel.Text += "; " + attendees.Count() + " attendees";
            }
            extraInfoLabel.Text += "";

            toolTip.SetToolTip(nameLabel, nameLabel.Text);             // in case it's too long
            toolTip.SetToolTip(extraInfoLabel, meeting.Body);

            joinButton.Visible = joinUrl.Length > 0;

            // start time timer
            timer.Enabled = true;
            updateStartTime();

            // reminder times list. stored in MRU order but sorted in time order
            timeList.Items.Clear();

            var list = SnoozeTime.ParseList(Properties.Settings.Default.mruSnoozeTimes);

            if (list.Count == 0)
            {
                // initialize default list of snooze times
                list.Add(new SnoozeTime(-2 * 60, false));
                list.Add(new SnoozeTime(-30, false));
                list.Add(new SnoozeTime(30, true));
                list.Add(new SnoozeTime(60, true));
                list.Add(new SnoozeTime(60 * 5, true));
                Properties.Settings.Default.mruSnoozeTimes = SnoozeTime.ListToString(list);
                Properties.Settings.Default.Save();
            }
            list.Sort();
            list.ForEach(st => timeList.Items.Add(st));

            // by default, dismiss when dialog is closed. unless snooze is selected
            meeting.Dismiss();

            reactivateTime = DateTime.Now + reactivateTimeSpan;
        }