Пример #1
0
 protected void lnkcommandevent_Click(object sender, EventArgs e)
 {
     try
     {
         string     motivo                 = hdfmotivos.Value;
         LinkButton lnk                    = sender as LinkButton;
         string     comand                 = lnk.CommandName.ToLower();
         string     usuario                = Session["usuario"] as string;
         int        id_recordatorio        = Convert.ToInt32(lnk.CommandArgument);
         datos.Model.recordatorios entidad = new datos.Model.recordatorios();
         entidad.id_recordatorio     = id_recordatorio;
         entidad.comentarios_borrado = motivo;
         entidad.usuario_borrado     = usuario;
         RecordatoriosCOM recordatorio = new RecordatoriosCOM();
         string           vmensaje     = "";
         DataTable        dt_days      = recordatorio.Get(usuario.ToUpper());
         DataView         dv           = dt_days.DefaultView;
         dv.RowFilter = "id_recordatorio = " + id_recordatorio + "";
         if (dv.ToTable().Rows.Count > 0)
         {
             DataRow row           = dv.ToTable().Rows[0];
             bool    isAppointment = Convert.ToBoolean(row["appointment"]);
             if (isAppointment)
             {
                 String    password     = Session["contraseña"] as string;
                 string    username     = Session["usuario"] as string;
                 string    mail         = Session["mail"] as string;
                 string    mail_user    = username + mail.Replace(mail.Split('@')[0], "");
                 string    id           = row["key"].ToString();
                 EWSHelper appointments = new EWSHelper();
                 vmensaje = comand == "aceptar" ? appointments.AcceptAppointment(mail_user, password, id) : appointments.DeclineAppointment(mail_user, password, id, motivo);
                 if (comand == "rechazar" && vmensaje == "")
                 {
                     vmensaje = recordatorio.Eliminar(entidad);
                 }
             }
         }
         if (vmensaje == "")
         {
             ModalClose("#myModal");
             usuario = Session["usuario"] as string;
             ListaRecordatorios(usuario, Convert.ToDateTime(hdffecha.Value));
             LimpiarControles();
             IniciarCalendario();
             Toast.Success("Recordatorio respondido correctamente.", "Mensaje del sistema", this);
         }
         else
         {
             Toast.Error("Error al responder recordatorio: " + vmensaje, this);
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al responder recordatorio: " + ex.Message, this);
     }
     finally {
         load_items.Style["display"] = "none";
     }
 }
Пример #2
0
        private void Eliminar(int id_recordatorio, string motivo, string usuario)
        {
            try
            {
                datos.Model.recordatorios entidad = new datos.Model.recordatorios();
                entidad.id_recordatorio     = id_recordatorio;
                entidad.comentarios_borrado = motivo;
                entidad.usuario_borrado     = usuario;
                RecordatoriosCOM recordatorio = new RecordatoriosCOM();
                string           vmensaje     = "";
                DataTable        dt_days      = recordatorio.Get(usuario.ToUpper());
                DataView         dv           = dt_days.DefaultView;
                dv.RowFilter = "id_recordatorio = " + id_recordatorio + "";
                if (dv.ToTable().Rows.Count > 0)
                {
                    DataRow row           = dv.ToTable().Rows[0];
                    bool    isAppointment = Convert.ToBoolean(row["appointment"]);
                    if (isAppointment)
                    {
                        String    password     = Session["contraseña"] as string;
                        string    username     = Session["usuario"] as string;
                        string    mail         = Session["mail"] as string;
                        string    mail_user    = username + mail.Replace(mail.Split('@')[0], "");
                        string    id           = row["key"].ToString();
                        EWSHelper appointments = new EWSHelper();
                        vmensaje = appointments.CancelAppointment(mail_user, password, id, motivo);
                    }
                }
                if (vmensaje == "")
                {
                    vmensaje = recordatorio.Eliminar(entidad);
                }

                if (vmensaje == "")
                {
                    ModalClose("#myModal");
                    usuario = Session["usuario"] as string;
                    ListaRecordatorios(usuario, Convert.ToDateTime(hdffecha.Value));
                    LimpiarControles();
                    IniciarCalendario();
                    Toast.Success("Recordatorio eliminado correctamente.", "Mensaje del sistema", this);
                }
                else
                {
                    Toast.Error("Error al eliminar recordatorio: " + vmensaje, this);
                }
            }
            catch (Exception ex)
            {
                Toast.Error("Error al eliminar recordatorio: " + ex.Message, this);
            }
        }
Пример #3
0
 private void Editar(int id_recordatorio, string titulo, string descripcion, DateTime fecha, string usuario,
                     string organ, string organ_mail, DateTime fecha_end)
 {
     try
     {
         datos.Model.recordatorios entidad = new datos.Model.recordatorios();
         entidad.titulo            = titulo;
         entidad.id_recordatorio   = id_recordatorio;
         entidad.descripcion       = descripcion;
         entidad.fecha             = fecha;
         entidad.organizer         = organ;
         entidad.organizer_address = organ_mail;
         entidad.usuario           = usuario;
         entidad.fecha_end         = fecha_end;
         entidad.usuario_creacion  = usuario;
         RecordatoriosCOM recordatorio = new RecordatoriosCOM();
         string           vmensaje     = recordatorio.Editar(entidad, new List <recordatorios_usuarios_adicionales>());
         if (vmensaje == "")
         {
             ModalClose("#myModal");
             usuario = Session["usuario"] as string;
             ListaRecordatorios(usuario, Convert.ToDateTime(hdffecha.Value));
             LimpiarControles();
             IniciarCalendario();
             Toast.Success("Recordatorio editado correctamente.", "Mensaje del sistema", this);
         }
         else
         {
             Toast.Error("Error al editado recordatorio: " + vmensaje, this);
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al editar recordatorio: " + ex.Message, this);
     }
     finally
     {
         lnkguardar.Visible           = true;
         lnkcargando.Style["display"] = "none";
     }
 }
Пример #4
0
        /// <summary>
        /// Inserta los meetings en una tabla sql
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public void GetAllCalendar(string userId, string password)
        {
            try
            {
                List <datos.Model.recordatorios> list = new List <datos.Model.recordatorios>();
                service              = new ExchangeService(ExchangeVersion.Exchange2010);
                credentials          = new WebCredentials(userId, password);
                service.Credentials  = credentials;
                service.TraceEnabled = true;
                service.TraceFlags   = TraceFlags.All;
                service.Url          = new Uri("https://mail.migesa.com.mx/ews/exchange.asmx");
                service.AutodiscoverUrl(userId, RedirectionUrlValidationCallback);
                DateTime startDate = DateTime.Now.AddMonths(-6);
                DateTime endDate   = DateTime.Now.AddMonths(3);
                // Initialize the calendar folder object with only the folder ID.
                CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

                // Set the start and end time and number of appointments to retrieve.
                CalendarView cView = new CalendarView(startDate.AddDays(-1), endDate.AddDays(1));

                // Limit the properties returned to the appointment's subject, start time, and end time.
                cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

                // Retrieve a collection of appointments by using the calendar view.
                FindItemsResults <Microsoft.Exchange.WebServices.Data.Appointment> appointments = calendar.FindAppointments(cView);
                string      username        = (userId.Split('@')[0]);
                PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
                itempropertyset.RequestedBodyType = BodyType.Text;
                RecordatoriosCOM reco = new RecordatoriosCOM();
                int total_actual      = reco.GetRecords(username);
                if (total_actual != appointments.Items.Count)
                {
                }

                foreach (Microsoft.Exchange.WebServices.Data.Appointment a in appointments)
                {
                    a.Load(itempropertyset);
                    DateTime         fecha_inicio  = a.Start;
                    DateTime         fecha_fin     = a.End;
                    string           subject       = a.Subject == null ? "" : a.Subject.ToString();
                    string           organizer     = a.Organizer.Name == null ? "" : a.Organizer.Name.ToString();
                    RecordatoriosCOM recordatorios = new RecordatoriosCOM();
                    string           id            = a.Id.ToString();
                    List <recordatorios_usuarios_adicionales> list_Ad = new List <recordatorios_usuarios_adicionales>();
                    string nbody = a.Body.Text == null ? "" : a.Body.Text.ToString();
                    datos.Model.recordatorios e = new datos.Model.recordatorios();
                    string organizer_address    = a.Organizer.Address == null ? "" : a.Organizer.Address.ToString();
                    string body          = a.Body.Text == null ? "" : a.Body.Text.ToString();
                    string participantes = a.DisplayTo == null ? "" : a.DisplayTo.ToString();
                    string lugar         = a.Location == null ? "" : a.Location.ToString();
                    if (participantes != "")
                    {
                        string[] participantes_array = participantes.Split(';');
                        foreach (string part in participantes_array)
                        {
                            if (part.ToUpper() != organizer.ToUpper())
                            {
                                recordatorios_usuarios_adicionales rec = new recordatorios_usuarios_adicionales
                                {
                                    nombre = part,
                                    activo = true
                                };
                                list_Ad.Add(rec);
                            }
                        }
                    }
                    e.organizer                 = organizer;
                    e.organizer_address         = organizer_address;
                    e.key_appointment_exchanged = id;
                    e.fecha            = fecha_inicio;
                    e.fecha_end        = fecha_fin;
                    e.titulo           = subject;
                    e.usuario          = username;
                    e.descripcion      = body;
                    e.usuario_creacion = username;
                    e.location         = lugar;
                    bool caneled = e.titulo.Contains("Cancelada:") || a.IsCancelled;
                    e.activo = !caneled;
                    if (e.descripcion.Contains("https://connext.webex.com/join/sergio_gaytan"))
                    {
                        e.activo = e.activo;
                    }
                    int id_recordatorio = recordatorios.ExistAppointmentID(username, id, organizer, subject, fecha_inicio, fecha_fin);
                    e.id_recordatorio = id_recordatorio;
                    string vmensaje = id_recordatorio == 0 ?
                                      recordatorios.Agregar(e, list_Ad) :
                                      reco.Editar(e, list_Ad);
                }
            }
            catch (Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException obj)
            {
                exchangeInitialized = false;
            }
            catch (Exception ex)
            {
                exchangeInitialized = false;
            }
        }