Example #1
0
        public OutlookItem Create(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            OutlookItem retVal = null;

            Outlook._AppointmentItem appItem = obj as Outlook._AppointmentItem;
            if (obj is Outlook._AppointmentItem)
            {
                retVal = new OutlookAppointment(_listener, (Outlook._AppointmentItem)obj);
            }
            else if (obj is Outlook.RecurrencePattern)
            {
                retVal = new OutlookRecurrencePattern(_listener, (Outlook.RecurrencePattern)obj);
            }
            else if (obj is Outlook.Exception)
            {
                retVal = new OutlookException(_listener, (Outlook.Exception)obj);
            }
            else if (obj is Outlook.Recipient)
            {
                retVal = new OutlookRecipient(_listener, (Outlook.Recipient)obj);
            }
            else if (obj is Outlook.MAPIFolder)
            {
                retVal = new OutlookFolder(_listener, (Outlook.MAPIFolder)obj);
            }

            return(retVal);
        }
Example #2
0
 /// <summary>
 /// Appointments the save.
 /// </summary>
 /// <param name="oAppItem">The o app item.</param>
 public void AppointmentSave(Outlook._AppointmentItem oAppItem)
 {
     if (oAppItem == null)
     {
         throw new ArgumentNullException("oAppItem");
     }
     if (this.InvokeRequired)
     {
         VoidFunc <Outlook._AppointmentItem> func = AppointmentSave;
         this.Invoke(func, oAppItem);
     }
     else
     {
         oAppItem.Save();
     }
 }
Example #3
0
 /// <summary>
 /// Appointments the clear recurrence pattern.
 /// </summary>
 /// <param name="oAppItem">The o app item.</param>
 public void AppointmentClearRecurrencePattern(Outlook._AppointmentItem oAppItem)
 {
     if (oAppItem == null)
     {
         throw new ArgumentNullException("oAppItem");
     }
     if (this.InvokeRequired)
     {
         VoidFunc <Outlook._AppointmentItem> func = AppointmentClearRecurrencePattern;
         this.Invoke(func, oAppItem);
     }
     else
     {
         oAppItem.ClearRecurrencePattern();
     }
 }
Example #4
0
        /// <summary>
        /// Adds the appointment recipient.
        /// </summary>
        /// <param name="oAppItem">The o app item.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public OutlookRecipient AddAppointmentRecipient(Outlook._AppointmentItem oAppItem, string name)
        {
            OutlookRecipient retVal = null;

            if (this.InvokeRequired)
            {
                Func <Outlook._AppointmentItem, string, OutlookRecipient> func = AddAppointmentRecipient;
                retVal = this.Invoke(func, oAppItem, name) as OutlookRecipient;
            }
            else
            {
                Outlook.Recipient oRecipient = oAppItem.Recipients.Add(name);
                retVal = _factory.Create <OutlookItem>(oRecipient) as OutlookRecipient;
            }
            return(retVal);
        }
Example #5
0
        public override bool AddAppointment()
        {
            try
            {
                Outlook._AppointmentItem appointmentItem = (Outlook._AppointmentItem)
                                                           OutlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem);

                appointmentItem.Subject = subject;
                appointmentItem.Start   = startDate;
                appointmentItem.End     = endDate;
                appointmentItem.Body    = String.Format(CultureConstants.DefaultCulture, "Added: {0}", DateTime.Now);

                appointmentItem.ReminderSet = reminder;

                appointmentItem.BusyStatus  = Outlook.OlBusyStatus.olBusy;
                appointmentItem.AllDayEvent = false;
                appointmentItem.Location    = String.Empty;

                if (alternateReminder)
                {
                    earlyReminder = new DateTime(startDate.Year, startDate.Month, startDate.Day, earlyReminder.Hour, earlyReminder.Minute, earlyReminder.Second);
                    lateReminder  = new DateTime(startDate.Year, startDate.Month, startDate.Day, lateReminder.Hour, lateReminder.Minute, lateReminder.Second);

                    DateTime dtReminder = WorkOutAlternateReminders();
                    // Subtract the reminder time from the appointment time.
                    TimeSpan timeSpan = appointmentItem.Start.Subtract(dtReminder);
                    appointmentItem.ReminderMinutesBeforeStart = Math.Abs((timeSpan.Hours * 60) + timeSpan.Minutes);
                    minutes = appointmentItem.ReminderMinutesBeforeStart;
                }

                if (reminder)
                {
                    appointmentItem.ReminderMinutesBeforeStart = minutes;
                }
                else
                {
                    appointmentItem.ReminderMinutesBeforeStart = 0;
                }

                appointmentItem.Save();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        /// <summary>
        /// Gets the recurrence occurence.
        /// </summary>
        /// <param name="orPattern">The or pattern.</param>
        /// <param name="recurrenceId">The recurrence id.</param>
        /// <returns></returns>
        public OutlookAppointment GetRecurrenceOccurence(Outlook.RecurrencePattern orPattern, DateTime recurrenceId)
        {
            OutlookAppointment retVal = null;

            if (this.InvokeRequired)
            {
                Func <Outlook.RecurrencePattern, DateTime, OutlookAppointment> func = GetRecurrenceOccurence;
                retVal = this.Invoke(func, orPattern, recurrenceId) as OutlookAppointment;
            }
            else
            {
                Outlook._AppointmentItem oOcurrence = orPattern.GetOccurrence(recurrenceId);
                if (oOcurrence != null)
                {
                    retVal = _factory.Create <OutlookItem>(oOcurrence) as OutlookAppointment;
                }
            }
            return(retVal);
        }
Example #7
0
        public void AppointmentRemoveRecipient(Outlook._AppointmentItem oAppItem, int index)
        {
            if (oAppItem == null)
            {
                throw new ArgumentNullException("oAppItem");
            }
            if (index >= oAppItem.Recipients.Count)
            {
                throw new ArgumentException("index greather that indexed collection");
            }

            if (this.InvokeRequired)
            {
                VoidFunc <Outlook._AppointmentItem, int> func = AppointmentRemoveRecipient;
                this.Invoke(func, oAppItem, index);
            }
            else
            {
                oAppItem.Recipients.Remove(index);
            }
        }
Example #8
0
        /// <summary>
        /// Gets the appointment recipients.
        /// </summary>
        /// <param name="oAppItem">The o app item.</param>
        /// <returns></returns>
        public List <OutlookRecipient> GetAppointmentRecipients(Outlook._AppointmentItem oAppItem)
        {
            List <OutlookRecipient> retVal = new List <OutlookRecipient>();

            if (this.InvokeRequired)
            {
                Func <Outlook._AppointmentItem, List <OutlookRecipient> > func = this.GetAppointmentRecipients;
                retVal = (List <OutlookRecipient>) this.Invoke(func, oAppItem);
            }
            else
            {
                for (int i = 1; i <= oAppItem.Recipients.Count; i++)
                {
                    OutlookRecipient recipient = _factory.Create <OutlookItem>(oAppItem.Recipients.Item(i)) as OutlookRecipient;
                    if (recipient != null)
                    {
                        retVal.Add(recipient);
                    }
                }
            }

            return(retVal);
        }
Example #9
0
        /// <summary>
        /// Gets the recurrence pattern.
        /// </summary>
        /// <param name="oAppItem">The o app item.</param>
        /// <returns></returns>
        public OutlookRecurrencePattern GetRecurrencePattern(Outlook._AppointmentItem oAppItem)
        {
            if (oAppItem == null)
            {
                throw new ArgumentNullException("oAppItem");
            }

            OutlookRecurrencePattern retVal = null;

            if (this.InvokeRequired)
            {
                Func <Outlook.AppointmentItem, OutlookRecurrencePattern> func = GetRecurrencePattern;
                retVal = this.Invoke(func, oAppItem) as OutlookRecurrencePattern;
            }
            else
            {
                Outlook.RecurrencePattern oRecPattern = oAppItem.GetRecurrencePattern();
                if (oRecPattern != null)
                {
                    retVal = _factory.Create <OutlookItem>(oRecPattern) as OutlookRecurrencePattern;
                }
            }
            return(retVal);
        }
Example #10
0
        private void BtAgregar_Click(object sender, EventArgs e)
        {
            {
                if (CapaEntidad.Boton.Btn)
                {
                    try
                    {
                        string rpta = "";
                        if (this.CbNombre.Text == string.Empty || this.DtFecha.Text == string.Empty || this.CbElectrico.Text == string.Empty)
                        {
                            MensajeError("Falta ingresar datos, Los datos con * son Obligatorios");
                        }
                        else
                        {
                            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            //this.PbFolio.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            //byte[] image = ms.GetBuffer();
                            FileStream pdf          = File.OpenRead(ruta);
                            byte[]     contenidoPdf = new byte[pdf.Length];
                            pdf.Read(contenidoPdf, 0, (int)pdf.Length);
                            pdf.Close();

                            rpta = NAgInspeccion.Editar(Convert.ToInt32(this.LbID.Text), Convert.ToInt16(this.CbNombre.SelectedValue),
                                                        Convert.ToInt32(this.CbElectrico.SelectedValue), Convert.ToDateTime(this.DtFecha.Value), contenidoPdf);

                            if (rpta.Equals("OK"))
                            {
                                this.MensajeOk("Se Modificó el registro correctamente");
                            }

                            else
                            {
                                this.MensajeError(rpta);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    try
                    {
                        string rpta = "";
                        if (this.CbNombre.Text == string.Empty || this.DtFecha.Text == string.Empty || this.CbElectrico.Text == string.Empty)
                        {
                            MensajeError("Falta ingresar datos, Los datos con * son Obligatorios");
                        }
                        else
                        {
                            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            ////System.IO.MemoryStream ms2 = new System.IO.MemoryStream();
                            //this.PbFolio.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                            FileStream pdf          = File.OpenRead(ruta);
                            byte[]     contenidoPdf = new byte[pdf.Length];
                            pdf.Read(contenidoPdf, 0, (int)pdf.Length);
                            pdf.Close();
                            //byte[] image = ms.GetBuffer();

                            rpta = NAgInspeccion.Agregar(Convert.ToInt16(this.CbNombre.SelectedValue),
                                                         Convert.ToInt32(this.CbElectrico.SelectedValue), Convert.ToDateTime(this.DtFecha.Value), contenidoPdf);

                            if (this.CkOutlook.Checked == true)
                            {
                                // usar el objeto de outlook para crear el recordatorio
                                Outlook._Application     App = (Outlook._Application) new Outlook.Application();
                                Outlook._AppointmentItem apt = (Outlook._AppointmentItem)
                                                               App.CreateItem(Outlook.OlItemType.olAppointmentItem);
                                // algunas propiedades
                                apt.Subject = "Inspeccion obra" + this.CbNombre.Text;
                                apt.Body    = "reminderComment";
                                apt.Start   = this.DtFecha.Value;
                                apt.End     = this.DtFecha.Value.AddHours(6);
                                apt.ReminderMinutesBeforeStart = 1;
                                apt.BusyStatus  = Outlook.OlBusyStatus.olTentative;
                                apt.AllDayEvent = false;
                                apt.Save();
                            }
                            if (rpta.Equals("OK"))
                            {
                                this.MensajeOk("Se Agregó el registro correctamente");
                            }
                            else
                            {
                                this.MensajeError(rpta);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
            }
        }
Example #11
0
 public OutlookAppointment(OutlookListener outlookListener, Outlook._AppointmentItem oAppItem)
     : base(outlookListener)
 {
     _oAppItem = oAppItem;
 }
Example #12
0
 public OutlookAppointment(OutlookListener outlookListener, Outlook._AppointmentItem oAppItem)
     : base(outlookListener)
 {
     _oAppItem = oAppItem;
 }