Example #1
0
        /// <summary>
        /// Process the queue into MS Outlook.
        /// </summary>
        /// <param name="queuedSkill">The queued skill.</param>
        /// <param name="queuePosition">The queue position.</param>
        /// <param name="lastSkillInQueue">if set to <c>true</c> skill is the last in queue.</param>
        private static async Task DoOutlookAppointmentAsync(QueuedSkill queuedSkill, int queuePosition, bool lastSkillInQueue)
        {
            // Get the calendar
            if (!OutlookCalendarEvent.OutlookCalendarExist(Settings.Calendar.UseOutlookDefaultCalendar))
            {
                MessageBox.Show(@"Outlook calendar does not exist. Please check your settings.", @"Outlook Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Set the subject to the character name and the skill and level in queue for uniqueness sake
            OutlookCalendarEvent outlookAppointmentFilter = new OutlookCalendarEvent
            {
                StartDate = DateTime.Now.AddDays(-40),
                EndDate   = DateTime.Now.AddDays(100),
                Subject   = string.Format(
                    CultureConstants.DefaultCulture,
                    "{0} - {1} {2}",
                    queuedSkill.Owner.Name,
                    queuedSkill.SkillName,
                    Skill.GetRomanFromInt(queuedSkill.Level))
            };


            // Pull the list of appointments, hopefully we should either get 1 or none back
            await outlookAppointmentFilter.ReadEventsAsync();

            // If there is an appointment, get the first one
            bool foundAppointment = false;

            if (outlookAppointmentFilter.ItemCount > 0)
            {
                foundAppointment = outlookAppointmentFilter.GetEvent();
            }

            // Update the appointment we may have pulled or the new one
            // Set the appointment length to 5 minutes, starting at the estimated completion date and time
            // Reminder value was already validated
            // Use the values from the screen as these may differ what the user has set for defaults
            outlookAppointmentFilter.StartDate         = queuedSkill.EndTime.ToLocalTime();
            outlookAppointmentFilter.EndDate           = queuedSkill.EndTime.ToLocalTime().AddMinutes(5);
            outlookAppointmentFilter.ItemReminder      = Settings.Calendar.UseReminding;
            outlookAppointmentFilter.AlternateReminder = Settings.Calendar.UseAlternateReminding;
            outlookAppointmentFilter.EarlyReminder     = Settings.Calendar.EarlyReminding;
            outlookAppointmentFilter.LateReminder      = Settings.Calendar.LateReminding;
            outlookAppointmentFilter.Minutes           = Settings.Calendar.RemindingInterval;

            await outlookAppointmentFilter.AddOrUpdateEventAsync(foundAppointment, queuePosition, lastSkillInQueue);
        }
Example #2
0
        /// <summary>
        /// Process the queue into MS Outlook.
        /// </summary>
        /// <param name="queuedSkill">The queued skill.</param>
        /// <param name="queuePosition">The queue position.</param>
        /// <param name="lastSkillInQueue">if set to <c>true</c> skill is the last in queue.</param>
        private static async Task DoOutlookAppointmentAsync(QueuedSkill queuedSkill, int queuePosition, bool lastSkillInQueue)
        {
            // Get the calendar
            if (!OutlookCalendarEvent.OutlookCalendarExist(Settings.Calendar.UseOutlookDefaultCalendar))
            {
                MessageBox.Show(@"Outlook calendar does not exist. Please check your settings.", @"Outlook Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Set the subject to the character name and the skill and level in queue for uniqueness sake
            OutlookCalendarEvent outlookAppointmentFilter = new OutlookCalendarEvent
            {
                StartDate = DateTime.Now.AddDays(-40),
                EndDate = DateTime.Now.AddDays(100),
                Subject = String.Format(
                    CultureConstants.DefaultCulture,
                    "{0} - {1} {2}",
                    queuedSkill.Owner.Name,
                    queuedSkill.SkillName,
                    Skill.GetRomanFromInt(queuedSkill.Level))
            };


            // Pull the list of appointments, hopefully we should either get 1 or none back
            await outlookAppointmentFilter.ReadEventsAsync();

            // If there is an appointment, get the first one
            bool foundAppointment = false;
            if (outlookAppointmentFilter.ItemCount > 0)
                foundAppointment = outlookAppointmentFilter.GetEvent();

            // Update the appointment we may have pulled or the new one
            // Set the appointment length to 5 minutes, starting at the estimated completion date and time
            // Reminder value was already validated
            // Use the values from the screen as these may differ what the user has set for defaults
            outlookAppointmentFilter.StartDate = queuedSkill.EndTime.ToLocalTime();
            outlookAppointmentFilter.EndDate = queuedSkill.EndTime.ToLocalTime().AddMinutes(5);
            outlookAppointmentFilter.ItemReminder = Settings.Calendar.UseReminding;
            outlookAppointmentFilter.AlternateReminder = Settings.Calendar.UseAlternateReminding;
            outlookAppointmentFilter.EarlyReminder = Settings.Calendar.EarlyReminding;
            outlookAppointmentFilter.LateReminder = Settings.Calendar.LateReminding;
            outlookAppointmentFilter.Minutes = Settings.Calendar.RemindingInterval;

            await outlookAppointmentFilter.AddOrUpdateEventAsync(foundAppointment, queuePosition, lastSkillInQueue);
        }
Example #3
0
 /// <summary>
 /// Gets true if the Outlook calendar exist.
 /// </summary>
 /// <param name="useDefaultCalendar">if set to <c>true</c> [use default].</param>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 public static bool OutlookCalendarExist(bool useDefaultCalendar, string path)
 => OutlookCalendarEvent.OutlookCalendarExist(useDefaultCalendar, path);