Ejemplo n.º 1
0
        private void DoGoogleAppointment()
        {
            try
            {
                SNCalendar.GoogleAppointmentFilter googleAppointmentFilter = new SNCalendar.GoogleAppointmentFilter("serviceName");

                googleAppointmentFilter.UserName = Settings.Calendar.GoogleEmail;
                googleAppointmentFilter.Password = Settings.Calendar.GooglePassword;
                googleAppointmentFilter.URI      = Settings.Calendar.GoogleURL;
                googleAppointmentFilter.Logon();

                // Check whether this is a new appointment or an update.
                googleAppointmentFilter.StartDate = DateTime.Now.AddDays(-40);
                googleAppointmentFilter.EndDate   = DateTime.Now.AddDays(100);
                // Set the subject to the chanracter name and the skill being trained for uniqueness sakes.
                googleAppointmentFilter.Subject = String.Format(CultureConstants.DefaultCulture, "{0} - {1}", m_character.Name, m_character.CurrentlyTrainingSkill.SkillName);
                // Pull the list of appointments. Hopefully we should either get 1 or none back.
                googleAppointmentFilter.ReadAppointments();

                // If there is are appointments, see if any match the subject.
                bool foundAppointment = false;
                if (googleAppointmentFilter.ItemCount > 0)
                {
                    if (googleAppointmentFilter.GetAppointment(-1))
                    {
                        foundAppointment = true;
                    }
                }

                // 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.
                googleAppointmentFilter.StartDate         = m_character.CurrentlyTrainingSkill.EndTime;
                googleAppointmentFilter.EndDate           = m_character.CurrentlyTrainingSkill.EndTime.AddMinutes(5);
                googleAppointmentFilter.ItemReminder      = Settings.Calendar.UseReminding;
                googleAppointmentFilter.AlternateReminder = Settings.Calendar.UseRemindingRange;
                googleAppointmentFilter.EarlyReminder     = Settings.Calendar.EarlyReminding;
                googleAppointmentFilter.LateReminder      = Settings.Calendar.LateReminding;
                googleAppointmentFilter.Minutes           = Settings.Calendar.RemindingInterval;
                googleAppointmentFilter.ReminderMethod    = (int)Settings.Calendar.GoogleReminder;
                if (foundAppointment)
                {
                    try
                    {
                        googleAppointmentFilter.UpdateAppointment(0);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        googleAppointmentFilter.AddAppointment();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void DoGoogleAppointment()
        {
            try
            {
                SNCalendar.GoogleAppointmentFilter googleAppointmentFilter = new SNCalendar.GoogleAppointmentFilter("serviceName");

                googleAppointmentFilter.UserName = Settings.Calendar.GoogleEmail;
                googleAppointmentFilter.Password = Settings.Calendar.GooglePassword;
                googleAppointmentFilter.URI = Settings.Calendar.GoogleURL;
                googleAppointmentFilter.Logon();

                // Check whether this is a new appointment or an update.
                googleAppointmentFilter.StartDate = DateTime.Now.AddDays(-40);
                googleAppointmentFilter.EndDate = DateTime.Now.AddDays(100);
                // Set the subject to the chanracter name and the skill being trained for uniqueness sakes.
                googleAppointmentFilter.Subject = String.Format(CultureConstants.DefaultCulture, "{0} - {1}", m_character.Name, m_character.CurrentlyTrainingSkill.SkillName);
                // Pull the list of appointments. Hopefully we should either get 1 or none back.
                googleAppointmentFilter.ReadAppointments();

                // If there is are appointments, see if any match the subject.
                bool foundAppointment = false;
                if (googleAppointmentFilter.ItemCount > 0)
                    if (googleAppointmentFilter.GetAppointment(-1))
                        foundAppointment = true;

                // 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.
                googleAppointmentFilter.StartDate = m_character.CurrentlyTrainingSkill.EndTime;
                googleAppointmentFilter.EndDate = m_character.CurrentlyTrainingSkill.EndTime.AddMinutes(5);
                googleAppointmentFilter.ItemReminder = Settings.Calendar.UseReminding;
                googleAppointmentFilter.AlternateReminder = Settings.Calendar.UseRemindingRange;
                googleAppointmentFilter.EarlyReminder = Settings.Calendar.EarlyReminding;
                googleAppointmentFilter.LateReminder = Settings.Calendar.LateReminding;
                googleAppointmentFilter.Minutes = Settings.Calendar.RemindingInterval;
                googleAppointmentFilter.ReminderMethod = (int)Settings.Calendar.GoogleReminder;
                if (foundAppointment)
                {
                    try
                    {
                        googleAppointmentFilter.UpdateAppointment(0);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        googleAppointmentFilter.AddAppointment();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }