private void ReserveButton_Click(object sender, RibbonControlEventArgs e)
        {
            Inspector       inspector = (sender as RibbonButton).Ribbon.Context as Inspector;
            AppointmentItem appt      = inspector.CurrentItem as AppointmentItem;

            _processWrite = false;
            if (OutlookManager.AddReservation(appt))
            {
                ReserveButton.Visible = false;
                ModifyButton.Visible  = true;
            }
            _processWrite = true;
        }
        private void Monitor_AppointmentDeleting(object sender, CancelEventArgs <AppointmentItem> e)
        {
            var creator = e.Value.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1A001E");

            if ((e.Value.Organizer != Application.Session.CurrentUser.Name) && (creator != Application.Session.CurrentUser.Name))
            {
                return;
            }

            if (e.Value.UserProperties.Find("MJ-MRBS-ID") != null)
            {
                e.Cancel = !OutlookManager.RemoveReservation(e.Value);
            }
        }
        private void Appt_BeforeDelete(object Item, ref bool Cancel)
        {
            AppointmentItem appt    = Item as AppointmentItem;
            var             creator = appt.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1A001E");

            if ((appt.Organizer != Globals.ThisAddIn.Application.Session.CurrentUser.Name) && (creator != Globals.ThisAddIn.Application.Session.CurrentUser.Name))
            {
                return;
            }

            if (appt.UserProperties.Find("MJ-MRBS-ID") != null)
            {
                Cancel = !OutlookManager.RemoveReservation(appt);
            }
        }
        private void ModifyButton_Click(object sender, RibbonControlEventArgs e)
        {
            Inspector       inspector = (sender as RibbonButton).Ribbon.Context as Inspector;
            AppointmentItem appt      = inspector.CurrentItem as AppointmentItem;
            var             creator   = appt.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1A001E");

            if ((appt.Organizer != inspector.Session.CurrentUser.Name) && (creator != inspector.Session.CurrentUser.Name))
            {
                DisplayManager.ShowErrorWindow("Modifying this resvervation is not allowed.", "Only the meeting organizer can modify the reservation in MRBS.");
                return;
            }

            _processWrite = false;
            OutlookManager.ModifyReservation(appt);
            _processWrite = true;
            ConferenceRoomRibbon_Load((sender as RibbonButton).Ribbon, null);
        }
        private void Appt_Write(ref bool Cancel)
        {
            Inspector       inspector = Globals.ThisAddIn.Application.ActiveInspector();
            AppointmentItem appt      = inspector.CurrentItem as AppointmentItem;
            var             creator   = appt.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1A001E");

            if ((appt.Organizer != Globals.ThisAddIn.Application.Session.CurrentUser.Name) && (creator != Globals.ThisAddIn.Application.Session.CurrentUser.Name))
            {
                return;
            }
            if (!_processWrite)
            {
                return;
            }

            if (appt.UserProperties.Find("MJ-MRBS-ID") != null)
            {
                OutlookManager.SaveChangesToReservation(appt);
            }
        }