public ConflictResolution Resolve(string message, Microsoft.Office.Interop.Outlook.AppointmentItem outlookAppointment, Event googleAppointment, Synchronizer sync, bool keepOutlook, bool keepGoogle)
        {
            string name = string.Empty;

            _form.OutlookItemTextBox.Text = string.Empty;
            _form.GoogleItemTextBox.Text  = string.Empty;
            if (outlookAppointment != null)
            {
                name = outlookAppointment.Subject + " - " + outlookAppointment.Start;
                _form.OutlookItemTextBox.Text += outlookAppointment.Body;
            }

            if (googleAppointment != null)
            {
                name = googleAppointment.Summary + " - " + Synchronizer.GetTime(googleAppointment);
                _form.GoogleItemTextBox.Text += googleAppointment.Description;
            }

            //ToDo: Make it more flexible
            _form.keepGoogle.Enabled  = keepGoogle;
            _form.keepOutlook.Enabled = keepOutlook;
            _form.AllCheckBox.Visible = true;
            _form.messageLabel.Text   = message;

            return(Resolve());
        }
Exemple #2
0
 private void setupEvent(string bidNumber, string name, DateTime due)
 {
     Microsoft.Office.Interop.Outlook.Application     app         = new Microsoft.Office.Interop.Outlook.Application();
     Microsoft.Office.Interop.Outlook.AppointmentItem appointment =
         (Microsoft.Office.Interop.Outlook.AppointmentItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
     appointment.Subject = bidNumber + " - " + name;
     appointment.Start   = due;
     appointment.End     = due;
     appointment.Save();
 }
        /// <summary>
        /// Gets a list of all events in outlook
        /// </summary>
        public static List <CalendarEvent> GetAllEvents()
        {
            List <CalendarEvent> events = new List <CalendarEvent>();

            Microsoft.Office.Interop.Outlook.Application oApp                 = null;
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNamespace        = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder  CalendarFolder       = null;
            Microsoft.Office.Interop.Outlook.Items       outlookCalendarItems = null;

            oApp           = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace  = oApp.GetNamespace("MAPI");
            CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            CalendarEvent cEvent = null;

            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                cEvent = null;

                if (item.IsRecurring)
                {
                    Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    DateTime last  = new DateTime(2008, 10, 1);
                    Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;

                    for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    {
                        try
                        {
                            recur  = rp.GetOccurrence(cur);
                            cEvent = new CalendarEvent(recur.GlobalAppointmentID, recur.Start, recur.End, recur.Location, recur.Subject, recur.Body);
                        }
                        catch
                        { }
                    }
                }
                else
                {
                    cEvent = new CalendarEvent(item.GlobalAppointmentID, item.Start, item.End, item.Location, item.Subject, item.Body);
                }

                if (cEvent != null)
                {
                    events.Add(cEvent);
                }
            }

            return(events);
        }
Exemple #4
0
        private void buttonMakeReservation_Click(object sender, EventArgs e)
        {
            #region Validate Data
            // Validate Data

            if (listBoxControlVehicles.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a vehicle.");
                listBoxControlVehicles.Focus();
                return;
            }

            if (string.IsNullOrEmpty(textBoxWhere.Text))
            {
                MessageBox.Show("'Where are you going?' cannot be empty.");
                textBoxWhere.Focus();
                return;
            }

            TimeSpan span         = dateTimePickerDateReturned.Value - dateTimePickerDateOut.Value;
            int      totalMinutes = (int)Math.Round(span.TotalMinutes, 0);
            if (totalMinutes <= 0)
            {
                MessageBox.Show("Return Time must be later than Time Out.");
                dateTimePickerDateOut.Focus();
                return;
            }

            #endregion

            Microsoft.Office.Interop.Outlook.AppointmentItem vehicleReservationMeeting = (Microsoft.Office.Interop.Outlook.AppointmentItem)
                                                                                         Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

            if (vehicleReservationMeeting != null)
            {
                vehicleReservationMeeting.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;
                vehicleReservationMeeting.Body          = string.IsNullOrEmpty(textBoxWho.Text) ? textBoxWhere.Text : string.Format("{0} (With {1})", textBoxWhere.Text, textBoxWho.Text);
                vehicleReservationMeeting.Start         = dateTimePickerDateOut.Value;
                vehicleReservationMeeting.Duration      = totalMinutes;
                vehicleReservationMeeting.Subject       = "Vehicle Checkout";
                vehicleReservationMeeting.ReminderSet   = false;
                var vehicle = listBoxControlVehicles.SelectedValue.ToString();
                Microsoft.Office.Interop.Outlook.Recipient recipient = vehicleReservationMeeting.Recipients.Add(vehicle);
                recipient.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olResource;
                vehicleReservationMeeting.Recipients.ResolveAll();
                vehicleReservationMeeting.Send();
                Close();
            }
        }
        public DeleteResolution ResolveDelete(Microsoft.Office.Interop.Outlook.AppointmentItem outlookAppointment)
        {
            _form.Text = "Google appointment deleted";
            _form.messageLabel.Text =
                "Google appointment \"" + outlookAppointment.Subject + " - " + outlookAppointment.Start +
                "\" doesn't exist aynmore. Do you want to delete it also on Outlook side?";

            _form.GoogleItemTextBox.Text   = String.Empty;
            _form.OutlookItemTextBox.Text += outlookAppointment.Body;



            _form.keepOutlook.Text = "Keep Outlook";
            _form.keepGoogle.Text  = "Delete Outlook";
            _form.skip.Enabled     = false;

            return(ResolveDeletedGoogle());
        }
Exemple #6
0
        public static void GetAllCalendarItems()
        {
            Microsoft.Office.Interop.Outlook.Application oApp                 = null;
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNamespace        = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder  CalendarFolder       = null;
            Microsoft.Office.Interop.Outlook.Items       outlookCalendarItems = null;

            oApp          = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace = oApp.GetNamespace("MAPI");
            ;
            CalendarFolder =
                mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
            outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                if (item.IsRecurring)
                {
                    Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    DateTime last  = new DateTime(2008, 10, 1);
                    Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;



                    for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    {
                        try
                        {
                            recur = rp.GetOccurrence(cur);
                            Console.WriteLine(recur.Subject + " -> " + cur.ToLongDateString());
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    Console.WriteLine(item.Subject + " -> " + item.Start.ToLongDateString());
                }
            }
        }
Exemple #7
0
        void schedulingDataChanged(object sender, EventArgs a)
        {
            TimeSpan span         = dateTimePickerDateReturned.Value - dateTimePickerDateOut.Value;
            int      totalMinutes = (int)Math.Round(span.TotalMinutes, 0);

            if (listBoxControlVehicles.SelectedValue == null || listBoxControlVehicles.Items.Count == 0)
            {
                return;
            }
            var vehicleName = ((Vehicle)listBoxControlVehicles.SelectedItem).Name;

            Microsoft.Office.Interop.Outlook.AppointmentItem vehicleReservationMeeting = (Microsoft.Office.Interop.Outlook.AppointmentItem)
                                                                                         Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

            Microsoft.Office.Interop.Outlook.Recipient recipient = vehicleReservationMeeting.Recipients.Add(vehicleName);
            recipient.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olResource;

            var freeBusyInfo = recipient.FreeBusy(dateTimePickerDateOut.Value, 1);
            var startminute  = new TimeSpan(dateTimePickerDateOut.Value.Hour, dateTimePickerDateOut.Value.Minute, 0).TotalMinutes;

            labelScheduleConflict.Visible = freeBusyInfo.Substring((int)startminute, totalMinutes).Contains("1");
        }
        public ConflictResolution Resolve(Microsoft.Office.Interop.Outlook.AppointmentItem outlookAppointment, Event googleAppointment, Synchronizer sync, bool isNewMatch)
        {
            string name = string.Empty;

            _form.OutlookItemTextBox.Text = string.Empty;
            _form.GoogleItemTextBox.Text  = string.Empty;
            if (outlookAppointment != null)
            {
                name = outlookAppointment.Subject + " - " + outlookAppointment.Start;
                _form.OutlookItemTextBox.Text += outlookAppointment.Body;
            }

            if (googleAppointment != null)
            {
                name = googleAppointment.Summary + " - " + Synchronizer.GetTime(googleAppointment);
                _form.GoogleItemTextBox.Text += googleAppointment.Description;
            }

            if (isNewMatch)
            {
                _form.messageLabel.Text =
                    "This is the first time these appointments \"" + name +
                    "\" are synced. Choose which you would like to keep.";
                _form.skip.Text = "Keep both";
            }
            else
            {
                _form.messageLabel.Text =
                    "Both the Outlook and Google Appointment \"" + name +
                    "\" have been changed. Choose which you would like to keep.";
            }



            return(Resolve());
        }
 public ConflictResolution Resolve(string message, Event googleAppointment, Microsoft.Office.Interop.Outlook.AppointmentItem outlookAppointment, Synchronizer sync)
 {
     return(Resolve(message, outlookAppointment, googleAppointment, sync, false, true));
 }