示例#1
0
 /// <summary>
 /// Adds a recipient to an existing appointment
 /// </summary>
 /// <param name="PobjRecipient"></param>
 public void AddRecipient(ExtendedRecipient PobjRecipient)
 {
     try
     {
         Recipients.Add(PobjRecipient);
     }
     catch (Exception PobjEx)
     {
         throw new Exception("Failed to add " + PobjRecipient.RecipientName + " to a common appointment item. " +
                             PobjEx.Message);
     }
 }
示例#2
0
 /// <summary>
 /// Created a new Extended appointment from an existing appointment
 /// </summary>
 /// <param name="PobjItem"></param>
 public ExtendedAppointment(Outlook.AppointmentItem PobjItem, ExtendedRecipient PobjRecipient)
 {
     try
     {
         Start      = PobjItem.Start;
         End        = PobjItem.End;
         Subject    = PobjItem.Subject;
         Location   = PobjItem.Location;
         Guid       = PobjItem.GlobalAppointmentID;
         Recurring  = PobjItem.IsRecurring;
         IsMeeting  = (PobjItem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting);
         Recipients = new ExtendedRecipientList();
         Recipients.Add(PobjRecipient);
     }
     catch (Exception PobjEx)
     {
         throw new Exception("Unable to add appointment " + PobjItem.Subject + " from " +
                             PobjRecipient.RecipientName + "'s calendar. " + PobjEx.Message);
     }
 }
示例#3
0
        /// <summary>
        /// User selected a different name in the list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(listBox1.Text))
            {
                return;
            }
            // there are unsaved changes - ask the user first
            if (buttonUpdate.Enabled)
            {
                // change back to previous item - turn off event for this
                // then turn it back on
                listBox1.SelectedIndexChanged -= listBox1_SelectedIndexChanged;
                listBox1.SelectedIndex         = MintLastSelectedIndex;
                listBox1.SelectedIndexChanged += listBox1_SelectedIndexChanged;

                // ask the user
                DialogResult LobjResult = MessageBox.Show("Do you want to save changes to the name display options?", Common.APPNAME, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (LobjResult == DialogResult.Yes)
                {
                    buttonUpdate_Click(sender, e);
                    return;
                }
                else if (LobjResult == DialogResult.Cancel)
                {
                    return; // stop
                }
            }

            // now set the last index to this item
            MintLastSelectedIndex = listBox1.SelectedIndex;

            // update the recipient
            ExtendedRecipient LobjRecipient = MobjRecipients[listBox1.Text];

            comboBoxSymbol.Text   = LobjRecipient.Symbol;
            buttonColor.BackColor = LobjRecipient.HighlightColor.FromRGBColorString();
            textBoxDisplayAs.Text = LobjRecipient.DisplayName;
            checkBoxShow.Checked  = !LobjRecipient.ShowName;
            groupBox1.Enabled     = true;
            buttonUpdate.Enabled  = false;
        }
        /// <summary>
        /// Adds new appointment for the specified date range
        /// </summary>
        /// <param name="PobjItem"></param>
        private void getAppointments(ExtendedRecipient PobjRecipient,
                                     DateTime PobjDay,
                                     bool PbolMeetingsOnly,
                                     bool PbolExcludePrivate)
        {
            try
            {
                // Start filling in the rest...
                Outlook.MAPIFolder LobjFolder = null;
                try
                {
                    LobjFolder = Common.IsRecipientValid(PobjRecipient.InteropRecipient);
                    if (LobjFolder == null)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception PobjEx)
                {
                    throw new Exception("Recipient calendar folder cannot be found. " +
                                        "This might be because you have not added them as a shared calendar. " +
                                        PobjEx.Message);
                }

                Outlook.Items LobjItems = LobjFolder.Items;
                if (LobjItems == null)
                {
                    throw new Exception("Unable to access recipient items. You may not have permission.");
                }

                try
                {
                    LobjItems.Sort("[Start]"); // sort the items
                }
                catch (Exception PobjEx)
                {
                    throw new Exception("Recipient calendar folder cannot be accessed or sorted. " +
                                        "This might be because you might not have permission. " +
                                        PobjEx.Message);
                }
                LobjItems.IncludeRecurrences = true; // be sure to include recurrences

                string LstrDay = PobjDay.ToShortDateString();
                // set the find string to today 0:00 to 23:59:59
                string LstrFind = "[Start] <= \"" + LstrDay + " 11:59 PM\"" +
                                  " AND [End] > \"" + LstrDay + " 12:00 AM\"";
                // find the first appointment for the day
                Outlook.AppointmentItem LobjAppt = LobjItems.Find(LstrFind);

                while (LobjAppt != null)
                {
                    if (LobjAppt.MeetingStatus == Outlook.OlMeetingStatus.olNonMeeting &&
                        PbolMeetingsOnly)
                    {
                        // skip - this is an appointment only
                        // and we are limiting to only meetings
                    }
                    else if (PbolExcludePrivate == true &&
                             LobjAppt.Sensitivity == Microsoft.Office.Interop.Outlook.OlSensitivity.olPrivate)
                    {
                        // skip - this is an private item
                        // and we are not includeing private items
                    }
                    else
                    {
                        ExtendedAppointment LobjNew = new ExtendedAppointment(LobjAppt, PobjRecipient);
                        if (!Appointments.Contains(LobjNew))
                        {
                            // now add the appointment
                            Appointments.Add(LobjNew);
                        }
                        else
                        {
                            Appointments.FindItem(LobjNew).AddRecipient(PobjRecipient);
                        }
                    }
                    // get the next item
                    LobjAppt = LobjItems.FindNext();
                }
            }
            catch (Exception PobjEx)
            {
                throw new Exception("Failed while processing " + PobjDay.ToLongDateString() + " for " +
                                    PobjRecipient.RecipientName + ". " + PobjEx.Message);
            }
        }