protected void btnNuevo_Click(object sender, ImageClickEventArgs e)
        {
            CAMPO campo = new CAMPO()
            {
                CAM_REQUERIDO = bool.Parse(((RadioButtonList)this.grvCampo.FooterRow.FindControl("rblRequeridoFooter")).SelectedValue),
                MEN_CODIGO=int.Parse(((HiddenField)this.frmMensaje.FindControl("hdnCodigoMensaje")).Value)
            };

            CAMPO_PLANTILLA campoPlantilla=new CAMPO_PLANTILLA()
            {
                CMP_CODIGO = int.Parse(((DropDownList)this.grvCampo.FooterRow.FindControl("drlCampoPlantillaFooter")).SelectedValue)
            };
            campo.CAMPO_PLANTILLA = campoPlantilla;

            MENSAJE mensaje = new MENSAJE()
            {
                MEN_CODIGO=int.Parse(((HiddenField)this.frmMensaje.FindControl("hdnCodigoMensaje")).Value)
            };

            campo.MENSAJE = mensaje;

            EstadoOperacion estado = BusinessLayer.Mensajeria.CampoMensajeBL.insertarCampoPorCampoPlantilla(campo);
            if (estado.Estado)
            {
                this.grvCampo.DataBind();
            }
            else
            {
                this.lblMensaje.Text = estado.Mensaje;
            }
        }
Пример #2
0
        public IHttpActionResult PutMENSAJE(int id, MENSAJE mENSAJE)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mENSAJE.ID)
            {
                return(BadRequest());
            }

            db.Entry(mENSAJE).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MENSAJEExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        /// <summary>
        /// metodo que se conecta a la base de datos para cancelar un registro
        /// </summary>
        /// <param name="_traslado">objeto de tipo "TRASLADO" con valores a insertar</param>
        /// <param name="id_mensaje_tipo">llave numerica del tipo de mensaje para cancelar una calendarizacion de traslado</param>
        /// <param name="fecha_servidor">fecha del servidor</param>
        public void Actualizar(TRASLADO _traslado, int id_mensaje_tipo_cancelado, DateTime fecha_servidor)
        {
            try
            {
                using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    var _id_centro        = _traslado.CENTRO_ORIGEN.Value;
                    var imputados_mensaje = new List <DatosImputado>();
                    var _mensaje_tipo     = Context.MENSAJE_TIPO.FirstOrDefault(w => w.ID_MEN_TIPO == id_mensaje_tipo_cancelado);

                    foreach (var item in _traslado.TRASLADO_DETALLE.Where(w => w.ID_ESTATUS == "CA"))
                    {
                        Context.Entry(item).State = EntityState.Modified;
                        var _imputado = Context.IMPUTADO.First(w => w.ID_ANIO == item.ID_ANIO && w.ID_CENTRO == item.ID_CENTRO && w.ID_IMPUTADO == item.ID_IMPUTADO);
                        imputados_mensaje.Add(new DatosImputado
                        {
                            Anio           = item.ID_ANIO,
                            Folio          = item.ID_IMPUTADO,
                            NombreCompleto = string.Format("{0} {1} {2}", !string.IsNullOrEmpty(_imputado.NOMBRE) ? _imputado.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_imputado.PATERNO) ? _imputado.PATERNO.Trim() : string.Empty, !string.IsNullOrEmpty(_imputado.MATERNO) ? _imputado.MATERNO.Trim() : string.Empty)
                        });
                    }
                    Context.Entry(_traslado).State = EntityState.Modified;
                    Context.SaveChanges();
                    if (imputados_mensaje != null && imputados_mensaje.Count > 0)
                    {
                        var _id_mensaje = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                        var _contenido  = new StringBuilder();
                        _contenido.AppendLine(_mensaje_tipo.CONTENIDO + " SE CANCELA EL TRASLADO DE LOS SIGUIENTES IMPUTADOS");

                        foreach (var item in imputados_mensaje)
                        {
                            _contenido.AppendLine(string.Format("{0}/{1}", item.Anio, item.Folio) + " " + item.NombreCompleto);
                        }
                        var _mensaje = new MENSAJE
                        {
                            CONTENIDO    = _contenido.ToString(),
                            ENCABEZADO   = _mensaje_tipo.ENCABEZADO,
                            ID_MEN_TIPO  = _mensaje_tipo.ID_MEN_TIPO,
                            ID_MENSAJE   = _id_mensaje,
                            REGISTRO_FEC = fecha_servidor,
                            ID_CENTRO    = _id_centro
                        };
                        Context.MENSAJE.Add(_mensaje);
                        Context.SaveChanges();
                    }
                    transaccion.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
            }
        }
        private void GenerarNotificacion(string Tipo)
        {
            try
            {
                var mt = new cTipoMensaje().Obtener((short)enumMensajeTipo.SANCION).FirstOrDefault();
                if (mt != null)
                {
                    string contenido = string.Empty;
                    var    obj       = new MENSAJE();
                    obj.ID_MEN_TIPO = mt.ID_MEN_TIPO;
                    if (Tipo == "A")
                    {
                        obj.ENCABEZADO = mt.ENCABEZADO;
                        contenido      = "SE HA AUTORIZADO LA SANCIÓN";
                    }
                    else
                    if (Tipo == "C")
                    {
                        obj.ENCABEZADO = "SE HA CANCELADO LA SANCIÓN";
                        contenido      = "SE HA CANCELADO LA SANCIÓN";
                    }
                    else
                    if (Tipo == "P")
                    {
                        obj.ENCABEZADO = "SE HA PUESTO EN PENDIENTE LA SANCIÓN";
                        contenido      = "SE HA PUESTO EN PENDIENTE LA SANCIÓN";
                    }

                    if (SelectIncidentes != null)
                    {
                        var i = new cImputado().Obtener(SelectIncidentes.Id_Imputado, SelectIncidentes.Id_Anio, SelectIncidentes.Id_Centro).FirstOrDefault();
                        if (i != null)
                        {
                            contenido += string.Format("DEL INTERNO {0}/{1} {2} {3} {4}",
                                                       SelectIncidentes.Id_Anio,
                                                       SelectIncidentes.Id_Imputado,
                                                       i.NOMBRE.Trim(),
                                                       !string.IsNullOrEmpty(i.PATERNO) ? i.PATERNO.Trim() : string.Empty,
                                                       !string.IsNullOrEmpty(i.MATERNO) ? i.MATERNO.Trim() : string.Empty);
                        }
                    }
                    obj.CONTENIDO    = contenido;
                    obj.REGISTRO_FEC = Fechas.GetFechaDateServer;
                    obj.ID_CENTRO    = GlobalVar.gCentro;
                    new cMensaje().Insertar(obj);
                }
                else
                {
                    new Dialogos().ConfirmacionDialogo("Validación", "No se envio notificación");
                }
            }
            catch (Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al generar notificación.", ex);
            }
        }
        public IHttpActionResult PostMENSAJE_POR_TRABAJO(MENSAJE mensaje, int idTrabajo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            pobj_areaLogic.agregarMensajeATrabajo(mensaje, idTrabajo);

            return(Ok(mensaje));
        }
Пример #6
0
        public IHttpActionResult GetMENSAJE(int id)
        {
            MENSAJE mENSAJE = db.MENSAJE.Find(id);

            if (mENSAJE == null)
            {
                return(NotFound());
            }

            return(Ok(mENSAJE));
        }
        public IHttpActionResult PostMENSAJE_POR_Proyecto(MENSAJE mensaje, int idProyecto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            pobj_areaLogic.agregarMensajeAProyecto(mensaje, idProyecto);

            return(Ok(mensaje));
        }
Пример #8
0
        public IHttpActionResult PostMENSAJE(MENSAJE mENSAJE)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MENSAJE.Add(mENSAJE);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mENSAJE.ID }, mENSAJE));
        }
Пример #9
0
        public IHttpActionResult DeleteMENSAJE(int id)
        {
            MENSAJE mENSAJE = db.MENSAJE.Find(id);

            if (mENSAJE == null)
            {
                return(NotFound());
            }

            db.MENSAJE.Remove(mENSAJE);
            db.SaveChanges();

            return(Ok(mENSAJE));
        }
Пример #10
0
 public bool agregarMensajeAProyecto(MENSAJE mensaje, int idProyecto)
 {
     //guarda el menssaje y el la tabla mensaje por proyecto relaciona el mensaje al proyecto
     db.SP_Insertar_Mensaje_Proyecto(mensaje.Contenido, mensaje.Adjunto, idProyecto, mensaje.NombreEmisor);
     try
     {
         db.SaveChanges();
     }
     catch (DbUpdateException)
     {
         throw;
     }
     return(true);
 }
Пример #11
0
        /// <summary>
        /// Método que actualiza una entidad de ATENCION_CITA con incidencia.
        /// </summary>
        /// <param name="Entidad">Entidad a actualizar.</param>
        /// <param name="_incidencia">Entidad incidencia a agregar</param>
        /// <param name="fecha_servidor">Fecha del servidor</param>
        /// <param name="id_mensaje_tipo">ID del tipo de mensaje que se envia como notificacion</param>
        /// <returns>bool</returns>
        public bool Actualizar(ATENCION_CITA Entidad, DateTime fecha_servidor, ATENCION_CITA_INCIDENCIA _incidencia, short id_mensaje_tipo)
        {
            try
            {
                using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    if (_incidencia != null)
                    {
                        _incidencia.ID_CITA = Entidad.ID_CITA;
                        var consec = GetIDProceso <short>("ATENCION_CITA_INCIDENCIA", "ID_CONSEC", string.Format("ID_CITA = {0} AND ID_ACMOTIVO = {1} AND ID_CENTRO_UBI={2}", _incidencia.ID_CITA, _incidencia.ID_ACMOTIVO, _incidencia.ID_CENTRO_UBI));
                        _incidencia.ID_CONSEC = consec;
                        Context.ATENCION_CITA_INCIDENCIA.Add(_incidencia);
                        var _mensaje_tipo            = Context.MENSAJE_TIPO.First(w => w.ID_MEN_TIPO == id_mensaje_tipo);
                        var _ingreso                 = Context.INGRESO.First(w => w.ID_ANIO == Entidad.ID_ANIO && w.ID_CENTRO == Entidad.ID_CENTRO && w.ID_IMPUTADO == Entidad.ID_IMPUTADO && w.ID_INGRESO == Entidad.ID_INGRESO);
                        var _nombre_completo         = string.Format("{0} {1} {2}", !string.IsNullOrEmpty(_ingreso.IMPUTADO.NOMBRE) ? _ingreso.IMPUTADO.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_ingreso.IMPUTADO.PATERNO) ? _ingreso.IMPUTADO.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_ingreso.IMPUTADO.MATERNO) ? _ingreso.IMPUTADO.MATERNO.Trim() : string.Empty);
                        var _motivo_incidencia       = Context.ATENCION_CITA_IN_MOTIVO.First(w => w.ID_ACMOTIVO == _incidencia.ID_ACMOTIVO);
                        var _usuario                 = Context.USUARIO.First(w => w.ID_USUARIO.Trim() == _incidencia.ID_USUARIO);
                        var _nombre_completo_usuario = string.Format("{0} {1} {2}", !string.IsNullOrEmpty(_usuario.EMPLEADO.PERSONA.NOMBRE) ? _usuario.EMPLEADO.PERSONA.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_usuario.EMPLEADO.PERSONA.PATERNO) ? _usuario.EMPLEADO.PERSONA.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_usuario.EMPLEADO.PERSONA.MATERNO) ? _usuario.EMPLEADO.PERSONA.MATERNO.Trim() : string.Empty);
                        var _id_mensaje              = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");

                        var _mensaje = new MENSAJE
                        {
                            CONTENIDO = _mensaje_tipo.CONTENIDO + _nombre_completo + " CON FOLIO " + string.Format("{0}/{1}", _ingreso.ID_ANIO, _ingreso.ID_IMPUTADO) + ".\n"
                                        + "LA CAUSA DE LA INCIDENCIA ES POR EL MOTIVO " + _motivo_incidencia.DESCR + " CON LA SIGUIENTE OBSERVACION " + _incidencia.OBSERV + " REALIZADA " +
                                        "POR " + _nombre_completo_usuario,
                            ENCABEZADO   = _mensaje_tipo.ENCABEZADO,
                            ID_MEN_TIPO  = _mensaje_tipo.ID_MEN_TIPO,
                            ID_MENSAJE   = _id_mensaje,
                            REGISTRO_FEC = fecha_servidor
                        };
                        Context.MENSAJE.Add(_mensaje);
                    }
                    Context.Entry(Entidad).State = EntityState.Modified;
                    Context.SaveChanges();
                    transaccion.Complete();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
            return(false);
        }
Пример #12
0
        public void Test_AgregarRespuesta()
        {
            MENSAJE mns = new MENSAJE();

            mns.Id           = 1;
            mns.Contenido    = "Unit Test sent as message";
            mns.NombreEmisor = "The Emperor of Mankind";

            RESPUESTA res = new RESPUESTA();

            res.Id           = 1;
            res.MensajeRaiz  = 1;
            res.NombreEmisor = "Malcador The Sigilite";

            mns.RESPUESTA.Add(res);

            Assert.AreEqual(res.Contenido, mns.RESPUESTA.First <RESPUESTA>().Contenido);
        }
Пример #13
0
        public List <MENSAJE> getListaMensajesDeProyecto(int idProyecto)
        {
            //se obtiene la lista de mensajes pro trabajo
            List <MENSAJE_POR_PROYECTO> lobj_mensajesPorProyecto = db.MENSAJE_POR_PROYECTO.Where(men => men.IdProyecto == idProyecto)
                                                                   .OrderByDescending(men => men.IdMensaje)
                                                                   .ToList <MENSAJE_POR_PROYECTO>();
            //lista de resultado
            List <MENSAJE> lobj_result = new List <MENSAJE>();

            //extrae los mensajes
            for (int li_x = 0; li_x < lobj_mensajesPorProyecto.Count; li_x++)
            {
                MENSAJE lobj_temp = lobj_mensajesPorProyecto[li_x].MENSAJE;
                lobj_result.Add(lobj_temp);
            }

            return(lobj_result);
        }
Пример #14
0
        public static EstadoOperacion eliminarMensaje(MENSAJE Mensaje)
        {
            DbFactory Factoria = DataAccessFactory.ObtenerProveedor();
            try
            {
                using (Switch contexto = new Switch())
                {
                    using (contexto.CreateConeccionScope())
                    {
                        string query =
                            "DELETE FROM MENSAJE" +
                            " WHERE MEN_CODIGO = @codigo";

                        DbCommand Comando = contexto.CreateCommand(query, CommandType.Text);
                        Comando.Parameters.Add(Factoria.CrearParametro("@codigo", Mensaje.MEN_CODIGO));

                        if (Comando.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }

                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (DbException e)
            {
                DbExceptionProduct exception = Factoria.CrearException(e);
                if (exception.ForeignKeyError())
                {
                    return new EstadoOperacion(false, "El Mensaje esta siendo utilizado por la aplicación y no se puede eliminar", e, true);
                }
                else
                {
                    return new EstadoOperacion(false, e.Message, e);
                }
            }
            catch (Exception e)
            {

                return new EstadoOperacion(false, e.Message, e);
            }
        }
Пример #15
0
        public static EstadoOperacion insertarMensaje(MENSAJE Mensaje)
        {
            try
            {
                using (Switch contexto = new Switch())
                {

                    using (contexto.CreateConeccionScope())
                    {
                        Mensaje.MEN_CODIGO = (from c in contexto.MENSAJE
                                                         orderby c.MEN_CODIGO descending
                                                         select c.MEN_CODIGO).FirstOrDefault() + 1;

                        string query =
                            "INSERT INTO MENSAJE" +
                            "(MEN_CODIGO" +
                            ",MEN_DESCRIPCION" +
                            ",MEN_NOMBRE" +
                            ",GMJ_CODIGO)" +
                            "VALUES" +
                            "(@codigo" +
                            ",@descripcion" +
                            ",@nombre" +
                            ",@grupomensaje_codigo)";

                        DbCommand Comando = MensajeDA.crearComando(contexto, Mensaje, query);

                        if (Comando.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }
                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (Exception e)
            {

                return new EstadoOperacion(false, e.Message, e);
            }
        }
Пример #16
0
        public static EstadoOperacion modificarMensaje(MENSAJE Mensaje)
        {
            try
            {
                using (Switch contexto = new Switch())
                {
                    using (contexto.CreateConeccionScope())
                    {
                        string query =
                            "UPDATE MENSAJE" +
                            " SET " +
                            "MEN_DESCRIPCION = @descripcion" +
                            ",MEN_NOMBRE = @nombre " +
                            "WHERE MEN_CODIGO = @codigo";

                        DbCommand Comando = MensajeDA.crearComando(contexto, Mensaje, query);

                        if (Comando.ExecuteNonQuery() != 1)
                        {
                            return new EstadoOperacion(false, null, null);
                        }

                        return new EstadoOperacion(true, null, null);
                    }
                }
            }
            catch (Exception e)
            {

                return new EstadoOperacion(false, e.Message, e);
            }
        }
Пример #17
0
        /// <summary>
        /// metodo que se conecta a la base de datos para insertar un registro nuevo
        /// </summary>
        /// <param name="Entity">objeto de tipo "FUERO" con valores a insertar</param>
        public short Insertar(LIBERACION Entity)
        {
            try
            {
                using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    Entity.ID_LIBERACION = GetIDProceso <short>("LIBERACION", "ID_LIBERACION", string.Format("ID_CENTRO = {0} AND ID_ANIO = {1} AND ID_IMPUTADO = {2} AND ID_INGRESO = {3}", Entity.ID_CENTRO, Entity.ID_ANIO, Entity.ID_IMPUTADO, Entity.ID_INGRESO));
                    Context.LIBERACION.Add(Entity);

                    #region Cambiamos el Esatus de la Causa Penal
                    if (Entity.ID_CAUSA_PENAL != null)
                    {
                        var x = Context.CAUSA_PENAL.Where(w => w.ID_CENTRO == Entity.ID_CENTRO && w.ID_ANIO == Entity.ID_ANIO && w.ID_IMPUTADO == Entity.ID_IMPUTADO && w.ID_INGRESO == Entity.ID_INGRESO && w.ID_CAUSA_PENAL == Entity.ID_CAUSA_PENAL).FirstOrDefault();
                        if (x != null)
                        {
                            x.ID_ESTATUS_CP        = 4;
                            Context.Entry(x).State = EntityState.Modified;
                        }
                    }
                    Context.SaveChanges();
                    #endregion

                    #region Busca Causas Penales Activas
                    int[] activas = { 0, 1, 6 };
                    var   cp      = Context.CAUSA_PENAL.Where(w => w.ID_CENTRO == Entity.ID_CENTRO && w.ID_ANIO == Entity.ID_ANIO && w.ID_IMPUTADO == Entity.ID_IMPUTADO && w.ID_INGRESO == Entity.ID_INGRESO && activas.Contains(w.ID_ESTATUS_CP.Value)).FirstOrDefault();
                    if (cp == null)
                    {
                        //si ya no hay causas penales enviamos el mensaje de notifivacion
                        var mt = Context.MENSAJE_TIPO.Where(w => w.ID_MEN_TIPO == 104).FirstOrDefault();
                        if (mt != null)
                        {
                            var obj = new MENSAJE();
                            obj.ID_MENSAJE  = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                            obj.ID_MEN_TIPO = mt.ID_MEN_TIPO;
                            obj.ENCABEZADO  = mt.ENCABEZADO;
                            var imputado = Context.IMPUTADO.Where(w => w.ID_CENTRO == Entity.ID_CENTRO && w.ID_ANIO == Entity.ID_ANIO && w.ID_IMPUTADO == Entity.ID_IMPUTADO).FirstOrDefault();
                            if (imputado != null)
                            {
                                obj.CONTENIDO = string.Format("EL INTERNO: {0}/{1} {2} {3} {4}, YA NO TIENE CAUSAS PENALES ACTIVAS.",
                                                              Entity.ID_ANIO,
                                                              Entity.ID_IMPUTADO,
                                                              !string.IsNullOrEmpty(imputado.NOMBRE) ? imputado.NOMBRE.Trim() : string.Empty,
                                                              !string.IsNullOrEmpty(imputado.PATERNO) ? imputado.PATERNO.Trim() : string.Empty,
                                                              !string.IsNullOrEmpty(imputado.MATERNO) ? imputado.MATERNO.Trim() : string.Empty);
                            }
                            else
                            {
                                obj.CONTENIDO = string.Format("EL INTERNO: {0}/{1}, YA NO TIENE CAUSAS PENALES ACTIVAS.",
                                                              Entity.ID_ANIO,
                                                              Entity.ID_IMPUTADO);
                            }
                            obj.REGISTRO_FEC = GetFechaServerDate();
                            obj.ID_CENTRO    = GlobalVariables.gCentro;
                            Context.MENSAJE.Add(obj);
                        }
                    }
                    #endregion
                    Context.SaveChanges();
                    transaccion.Complete();
                    return(Entity.ID_LIBERACION);
                    //if (Insert(Entity))
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
        protected void imgAgregar_Click(object sender, ImageClickEventArgs e)
        {
            DINAMICA_CRIPTOGRAFIA dinamicaCriptografia = new DINAMICA_CRIPTOGRAFIA()
            {
                DNC_NOMBRE = ((TextBox)this.grvDinamicaCriptografia.FooterRow.FindControl("txtNombreFooter")).Text,
                DNC_TIPO = int.Parse(((DropDownList)this.grvDinamicaCriptografia.FooterRow.FindControl("drlTipoFooter")).SelectedValue)
            };

            MENSAJE mensaje = new MENSAJE()
            {
                MEN_CODIGO = int.Parse(this.drlMensaje.SelectedValue)
            };

            dinamicaCriptografia.MENSAJE = mensaje;

            EstadoOperacion Estado = BusinessLayer.Seguridad.DinamicaCriptografiaBL.insertarDinamicaCriptografia(dinamicaCriptografia);

            if (Estado.Estado)
            {
                this.grvDinamicaCriptografia.DataBind();
            }
            else
            {
                this.lblMensaje.Text = Estado.Mensaje;
            }
        }
Пример #19
0
        public bool CancelaEstudio(INCIDENTE Incidente, short TipoMensaje, short IdEstudio)
        {
            try
            {
                if (Incidente == null)
                {
                    return(false);
                }

                using (System.Transactions.TransactionScope transaccion = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew, new System.Transactions.TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    string NombreImputado        = string.Empty;
                    var    _consecutivoIncidente = GetIDProceso <short>("INCIDENTE", "ID_INCIDENTE", string.Format("ID_CENTRO = {0} AND ID_ANIO = {1} AND ID_IMPUTADO = {2} AND ID_INGRESO = {3}", Incidente.ID_CENTRO, Incidente.ID_ANIO, Incidente.ID_IMPUTADO, Incidente.ID_INGRESO));

                    var Imputado = Context.IMPUTADO.FirstOrDefault(x => x.ID_IMPUTADO == Incidente.ID_IMPUTADO && x.ID_ANIO == Incidente.ID_ANIO && x.ID_CENTRO == Incidente.ID_CENTRO);
                    var Incident = new INCIDENTE()
                    {
                        AUTORIZACION_FEC  = Incidente.AUTORIZACION_FEC,
                        ESTATUS           = Incidente.ESTATUS,
                        ID_ANIO           = Incidente.ID_ANIO,
                        ID_IMPUTADO       = Incidente.ID_IMPUTADO,
                        REGISTRO_FEC      = Incidente.REGISTRO_FEC,
                        ID_CENTRO         = Incidente.ID_CENTRO,
                        ID_INGRESO        = Incidente.ID_INGRESO,
                        MOTIVO            = Incidente.MOTIVO,
                        ID_INCIDENTE_TIPO = Incidente.ID_INCIDENTE_TIPO,
                        ID_INCIDENTE      = _consecutivoIncidente
                    };

                    var _EstudiosPersonalidadProgramados = Context.PERSONALIDAD.FirstOrDefault(x => x.ID_ESTUDIO == IdEstudio && x.ID_INGRESO == Incidente.ID_INGRESO && x.ID_IMPUTADO == Incidente.ID_IMPUTADO && Incidente.ID_ANIO == Incidente.ID_ANIO && x.ID_CENTRO == Incidente.ID_CENTRO);

                    if (_EstudiosPersonalidadProgramados != null)
                    {
                        _EstudiosPersonalidadProgramados.ID_SITUACION = (short)eEstatudDetallePersonalidad.CANCELADO;
                        if (_EstudiosPersonalidadProgramados.PERSONALIDAD_DETALLE != null)
                        {
                            if (_EstudiosPersonalidadProgramados.PERSONALIDAD_DETALLE.Any())
                            {
                                foreach (var item in _EstudiosPersonalidadProgramados.PERSONALIDAD_DETALLE)
                                {
                                    item.ID_ESTATUS = (short)eEstatudDetallePersonalidad.CANCELADO;
                                }
                            }
                        }

                        Context.Entry(_EstudiosPersonalidadProgramados).State = System.Data.EntityState.Modified;

                        NombreImputado = string.Format("{0} / {1} {2} {3} {4}",
                                                       Imputado != null ? Imputado.ID_ANIO.ToString() : string.Empty,
                                                       Imputado != null ? Imputado.ID_IMPUTADO.ToString() : string.Empty,
                                                       Imputado != null ? !string.IsNullOrEmpty(Imputado.NOMBRE) ? Imputado.NOMBRE.Trim() : string.Empty : string.Empty,
                                                       Imputado != null ? !string.IsNullOrEmpty(Imputado.PATERNO) ? Imputado.PATERNO.Trim() : string.Empty : string.Empty,
                                                       Imputado != null ? !string.IsNullOrEmpty(Imputado.MATERNO) ? Imputado.MATERNO.Trim() : string.Empty : string.Empty);

                        System.DateTime _fecha = GetFechaServerDate();
                        var             _MensajeConsiderado = Context.MENSAJE_TIPO.FirstOrDefault(x => x.ID_MEN_TIPO == TipoMensaje);
                        string          _Nombre             = string.Empty;
                        var             _id_mensaje         = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                        if (_MensajeConsiderado != null)
                        {
                            if (_id_mensaje != decimal.Zero)
                            {
                                var NvoMensaje = new MENSAJE()
                                {
                                    CONTENIDO    = string.Format("{0} {1} {2} \n BAJO EL SIGUIENTE MOTIVO: {3}", _MensajeConsiderado.CONTENIDO, " PARA EL IMPUTADO \n ", NombreImputado, Incident.MOTIVO),
                                    ENCABEZADO   = _MensajeConsiderado.ENCABEZADO,
                                    ID_MEN_TIPO  = _MensajeConsiderado.ID_MEN_TIPO,
                                    ID_MENSAJE   = _id_mensaje,
                                    REGISTRO_FEC = _fecha,
                                    ID_CENTRO    = GlobalVariables.gCentro
                                };

                                Context.MENSAJE.Add(NvoMensaje);
                            }
                        }
                        ;
                    }
                    ;

                    Context.SaveChanges();
                    transaccion.Complete();
                    return(true);
                }
            }
            catch (System.Exception exc)
            {
                throw new System.ApplicationException(exc.Message);
            }
        }
Пример #20
0
        public bool GuardaListaCandidatos(System.Collections.ObjectModel.ObservableCollection <PERSONALIDAD> lista, short?IdMotivoB, string OficioNumero, string NombrePrograma, short?Dias, bool FueroSeleccionadoLista, short TipoMensaje)
        {
            try
            {
                if (lista != null && lista.Any())
                {
                    using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                    {
                        IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                    }))
                    {
                        foreach (var item in lista)
                        {
                            var _EstudiosAnteriores = Context.PERSONALIDAD.Where(c => c.ID_INGRESO == item.ID_INGRESO && c.ID_IMPUTADO == item.ID_IMPUTADO && c.ID_ANIO == item.ID_ANIO && c.ID_CENTRO == item.ID_CENTRO);
                            if (_EstudiosAnteriores.Any())
                            {
                                foreach (var item2 in _EstudiosAnteriores)
                                {
                                    item2.ID_SITUACION = item2.ID_SITUACION == (short)eEstatudDetallePersonalidad.CANCELADO ? (short)eEstatudDetallePersonalidad.CANCELADO : (short)eEstatudDetallePersonalidad.TERMINADO;
                                    Context.Entry(item2).Property(x => x.ID_SITUACION).IsModified = true;
                                }
                            }
                            ;

                            var   _ValidacionIngreso       = Context.INGRESO.FirstOrDefault(x => x.ID_CENTRO == item.ID_CENTRO && x.ID_IMPUTADO == item.ID_IMPUTADO && x.ID_INGRESO == item.ID_INGRESO && x.ID_ANIO == item.ID_ANIO);
                            short _ConsecutivoPersonalidad = GetIDProceso <short>("PERSONALIDAD", "ID_ESTUDIO", "1=1");
                            var   NvoPersonalidad          = new PERSONALIDAD()
                            {
                                ID_ANIO       = item.ID_ANIO,
                                ID_CENTRO     = item.ID_CENTRO,
                                ID_IMPUTADO   = item.ID_IMPUTADO,
                                ID_INGRESO    = item.ID_INGRESO,
                                ID_MOTIVO     = IdMotivoB,
                                ID_SITUACION  = (short)eEstatudDetallePersonalidad.PENDIENTE,
                                INICIO_FEC    = item.INICIO_FEC,
                                SOLICITADO    = item.SOLICITADO,
                                SOLICITUD_FEC = GetFechaServerDate(),
                                TERMINO_FEC   = item.TERMINO_FEC,
                                PROG_NOMBRE   = NombrePrograma,
                                NUM_OFICIO    = OficioNumero,
                                PLAZO_DIAS    = _ValidacionIngreso != null?_ValidacionIngreso.CAUSA_PENAL.FirstOrDefault(c => c.CP_FUERO == "F" && c.ID_ESTATUS_CP == 1) != null ? Dias : new short?() : new short?(),
                                ID_ESTUDIO    = _ConsecutivoPersonalidad
                            };

                            Context.PERSONALIDAD.Add(NvoPersonalidad);

                            #region se inicializa el control de las pruebas que se le van a realizar al interno
                            if (!FueroSeleccionadoLista) // fuero comun
                            {
                                short   _ConsecutivoPersonalidadDetalle = GetIDProceso <short>("PERSONALIDAD_DETALLE", "ID_DETALLE", "1=1");
                                short[] _comunes = new[] { (short)eTiposEstudio.CRIMINOLOGICO, (short)eTiposEstudio.LABORAL, (short)eTiposEstudio.MEDICO, (short)eTiposEstudio.PEDAGOGIA, (short)eTiposEstudio.PSICOLOGIA, (short)eTiposEstudio.PSIQUIATRIA, (short)eTiposEstudio.SEGURIDAD, (short)eTiposEstudio.TRABAJO_SOCIAL };
                                foreach (short _com in _comunes)
                                {
                                    var _detallePersonalidad = new PERSONALIDAD_DETALLE()
                                    {
                                        DIAS_BONIFICADOS = null,
                                        ID_ANIO          = item.ID_ANIO,
                                        ID_CENTRO        = item.ID_CENTRO,
                                        ID_DETALLE       = _ConsecutivoPersonalidadDetalle,
                                        ID_ESTATUS       = (short)eEstatudDetallePersonalidad.PENDIENTE,
                                        ID_ESTUDIO       = NvoPersonalidad.ID_ESTUDIO,
                                        ID_IMPUTADO      = item.ID_IMPUTADO,
                                        ID_INGRESO       = item.ID_INGRESO,
                                        ID_TIPO          = _com,
                                        INICIO_FEC       = null,
                                        RESULTADO        = string.Empty,
                                        SOLICITUD_FEC    = item.SOLICITUD_FEC,
                                        TERMINO_FEC      = null,
                                        TIPO_MEDIA       = string.Empty
                                    };

                                    Context.PERSONALIDAD_DETALLE.Add(_detallePersonalidad);
                                    _ConsecutivoPersonalidadDetalle++;
                                }
                                ;
                            }

                            #region detalle federal
                            else
                            {
                                short   _ConsecutivoPersonalidadDetalle = GetIDProceso <short>("PERSONALIDAD_DETALLE", "ID_DETALLE", "1=1");
                                short[] _federales = new[] { (short)eTiposEstudio.CRIMIN_FEDERAL, (short)eTiposEstudio.LABORAL_FEDERAL, (short)eTiposEstudio.MEDICA_FEDERAL, (short)eTiposEstudio.PEDAGOGICA_FEDERAL, (short)eTiposEstudio.PSICOLOGICA_FEDERAL, (short)eTiposEstudio.SEGURIDAD_FEDERAL, (short)eTiposEstudio.TRABAJO_SOCIAL_FEDERAL };
                                foreach (var _fed in _federales)
                                {
                                    var _detallePersonalidad = new PERSONALIDAD_DETALLE()
                                    {
                                        DIAS_BONIFICADOS = null,
                                        ID_ANIO          = item.ID_ANIO,
                                        ID_CENTRO        = item.ID_CENTRO,
                                        ID_DETALLE       = _ConsecutivoPersonalidadDetalle,
                                        ID_ESTATUS       = (short)eEstatudDetallePersonalidad.PENDIENTE,
                                        ID_ESTUDIO       = NvoPersonalidad.ID_ESTUDIO,
                                        ID_IMPUTADO      = item.ID_IMPUTADO,
                                        ID_INGRESO       = item.ID_INGRESO,
                                        ID_TIPO          = _fed,
                                        INICIO_FEC       = null,
                                        RESULTADO        = string.Empty,
                                        SOLICITUD_FEC    = item.SOLICITUD_FEC,
                                        TERMINO_FEC      = null,
                                        TIPO_MEDIA       = string.Empty
                                    };

                                    Context.PERSONALIDAD_DETALLE.Add(_detallePersonalidad);
                                    _ConsecutivoPersonalidadDetalle++;
                                }
                                ;
                            }

                            #endregion

                            #endregion
                        }
                        ;

                        System.DateTime _fecha = GetFechaServerDate();
                        var             _MensajeConsiderado = Context.MENSAJE_TIPO.FirstOrDefault(x => x.ID_MEN_TIPO == TipoMensaje);
                        string          _Nombre             = string.Empty;
                        var             _id_mensaje         = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                        string          DetalleProgramados  = string.Empty;
                        if (lista.Any() && lista != null)
                        {
                            foreach (var item in lista)
                            {
                                DetalleProgramados += string.Format("- {0} {1} {2}  ({3} / {4}) \n",
                                                                    item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.NOMBRE) ? item.INGRESO.IMPUTADO.NOMBRE.Trim() : string.Empty : string.Empty : string.Empty,
                                                                    item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.PATERNO) ? item.INGRESO.IMPUTADO.PATERNO.Trim() : string.Empty : string.Empty : string.Empty,
                                                                    item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.MATERNO) ? item.INGRESO.IMPUTADO.MATERNO.Trim() : string.Empty : string.Empty : string.Empty,
                                                                    item.ID_ANIO.ToString(), item.ID_IMPUTADO.ToString());
                            }
                        }

                        if (_MensajeConsiderado != null)
                        {
                            if (_id_mensaje != decimal.Zero)
                            {
                                var NvoMensaje = new MENSAJE()
                                {
                                    CONTENIDO    = string.Format("SE HAN PROGRAMADO ESTUDIOS DE PERSONALIDAD A LOS SIGUIENTES IMPUTADOS: \n {0}", DetalleProgramados),
                                    ENCABEZADO   = _MensajeConsiderado.ENCABEZADO,
                                    ID_MEN_TIPO  = _MensajeConsiderado.ID_MEN_TIPO,
                                    ID_MENSAJE   = _id_mensaje,
                                    REGISTRO_FEC = _fecha,
                                    ID_CENTRO    = GlobalVariables.gCentro
                                };

                                Context.MENSAJE.Add(NvoMensaje);
                            }
                            ;
                        }
                        ;

                        Context.SaveChanges();
                        transaccion.Complete();
                        return(true);
                    }
                }
            }
            catch (System.Exception exc)
            {
                return(false);
            }

            return(false);
        }
Пример #21
0
        public bool Actualizar(PERSONALIDAD Entity, short TipoMensaje)
        {
            try
            {
                using (System.Transactions.TransactionScope transaccion = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew, new System.Transactions.TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    var _EstudioActual = Context.PERSONALIDAD.FirstOrDefault(x => x.ID_ESTUDIO == Entity.ID_ESTUDIO && x.ID_CENTRO == Entity.ID_CENTRO && x.ID_IMPUTADO == Entity.ID_IMPUTADO && x.ID_INGRESO == Entity.ID_INGRESO && x.ID_ANIO == Entity.ID_ANIO);
                    if (_EstudioActual != null)
                    {
                        //SE GENERA LA NOTIFICACION
                        if (_EstudioActual.INICIO_FEC != Entity.INICIO_FEC)//LA FECHA CAMBIO, SE DEBE GENERAR UNA NOTIFICACION
                        {
                            System.DateTime _fecha = GetFechaServerDate();
                            var             _MensajeConsiderado = Context.MENSAJE_TIPO.FirstOrDefault(x => x.ID_MEN_TIPO == TipoMensaje);
                            string          _Nombre             = string.Empty;
                            var             _id_mensaje         = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                            var             NombreImputado      = Context.IMPUTADO.First(w => w.ID_ANIO == _EstudioActual.ID_ANIO && w.ID_CENTRO == _EstudioActual.ID_CENTRO && w.ID_IMPUTADO == _EstudioActual.ID_IMPUTADO);
                            if (NombreImputado != null)
                            {
                                _Nombre = string.Format("{0} {1} {2}", !string.IsNullOrEmpty(NombreImputado.NOMBRE) ? NombreImputado.NOMBRE.Trim() : string.Empty,
                                                        !string.IsNullOrEmpty(NombreImputado.PATERNO) ? NombreImputado.PATERNO.Trim() : string.Empty,
                                                        !string.IsNullOrEmpty(NombreImputado.MATERNO) ? NombreImputado.MATERNO.Trim() : string.Empty);
                            }

                            if (_MensajeConsiderado != null)
                            {
                                if (_id_mensaje != decimal.Zero)
                                {
                                    var NvoMensaje = new MENSAJE()
                                    {
                                        CONTENIDO    = _MensajeConsiderado.CONTENIDO + " PARA EL IMPUTADO \n " + " - " + _Nombre + " CON FECHA: " + (Entity.INICIO_FEC.HasValue ? Entity.INICIO_FEC.Value.ToString("dd/MM/yyyy") : string.Empty),
                                        ENCABEZADO   = _MensajeConsiderado.ENCABEZADO,
                                        ID_MEN_TIPO  = _MensajeConsiderado.ID_MEN_TIPO,
                                        ID_MENSAJE   = _id_mensaje,
                                        REGISTRO_FEC = _fecha,
                                        ID_CENTRO    = GlobalVariables.gCentro
                                    };

                                    Context.MENSAJE.Add(NvoMensaje);
                                }
                                ;
                            }
                            ;
                        }
                        ;


                        _EstudioActual.ID_ANIO       = Entity.ID_ANIO;
                        _EstudioActual.ID_CENTRO     = Entity.ID_CENTRO;
                        _EstudioActual.ID_ESTUDIO    = Entity.ID_ESTUDIO;
                        _EstudioActual.ID_IMPUTADO   = Entity.ID_IMPUTADO;
                        _EstudioActual.ID_INGRESO    = Entity.ID_INGRESO;
                        _EstudioActual.ID_MOTIVO     = Entity.ID_MOTIVO;
                        _EstudioActual.ID_SITUACION  = Entity.ID_SITUACION;
                        _EstudioActual.INICIO_FEC    = Entity.INICIO_FEC;
                        _EstudioActual.SOLICITADO    = Entity.SOLICITADO;
                        _EstudioActual.SOLICITUD_FEC = Entity.SOLICITUD_FEC;
                        _EstudioActual.TERMINO_FEC   = Entity.TERMINO_FEC;
                        _EstudioActual.PROG_NOMBRE   = Entity.PROG_NOMBRE;
                        _EstudioActual.NUM_OFICIO    = Entity.NUM_OFICIO;
                    }
                    ;

                    Context.SaveChanges();
                    transaccion.Complete();
                    return(true);
                }

                return(false);
            }
            catch (System.Exception ex)
            {
                return(false);
                //throw new System.ApplicationException(ex.Message);
            }
        }
Пример #22
0
        public bool ProgramaEstudiosPersonalidad(System.Collections.Generic.List <PERSONALIDAD> lstPersonalidad, short TipoMensaje)
        {
            try
            {
                if (lstPersonalidad != null && !lstPersonalidad.Any())
                {
                    return(false);
                }

                using (System.Transactions.TransactionScope transaccion = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.RequiresNew, new System.Transactions.TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    string CuerpoMensaje = string.Empty;
                    foreach (var item in lstPersonalidad)
                    {
                        var _EstudioActual = Context.PERSONALIDAD.FirstOrDefault(x => x.ID_ANIO == item.ID_ANIO && x.ID_CENTRO == item.ID_CENTRO && x.ID_INGRESO == item.ID_INGRESO && x.ID_IMPUTADO == item.ID_IMPUTADO && x.ID_ESTUDIO == item.ID_ESTUDIO);

                        if (_EstudioActual != null)
                        {
                            string _temp = string.Format(" - {0}/{1} {2} {3} {4} CON FECHA: {5} \n", item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? item.INGRESO.IMPUTADO.ID_ANIO.ToString() : string.Empty : string.Empty,                       //0
                                                         item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? item.INGRESO.IMPUTADO.ID_IMPUTADO.ToString() : string.Empty : string.Empty,                                                               //1
                                                         item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.NOMBRE) ? item.INGRESO.IMPUTADO.NOMBRE.Trim() : string.Empty : string.Empty : string.Empty,   //2
                                                         item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.PATERNO) ? item.INGRESO.IMPUTADO.PATERNO.Trim() : string.Empty : string.Empty : string.Empty, //3
                                                         item.INGRESO != null ? item.INGRESO.IMPUTADO != null ? !string.IsNullOrEmpty(item.INGRESO.IMPUTADO.MATERNO) ? item.INGRESO.IMPUTADO.MATERNO.Trim() : string.Empty : string.Empty : string.Empty, //4
                                                         item.INICIO_FEC.HasValue ? item.INICIO_FEC.Value.ToString("dd/MM/yyyy hh:mm:ss") : string.Empty);                                                                                                //5

                            if ((CuerpoMensaje.Length + _temp.Length) < 1700)
                            {
                                CuerpoMensaje += _temp;
                            }

                            _EstudioActual.ID_ANIO              = item.ID_ANIO;
                            _EstudioActual.ID_CENTRO            = item.ID_CENTRO;
                            _EstudioActual.ID_ESTUDIO           = item.ID_ESTUDIO;
                            _EstudioActual.ID_IMPUTADO          = item.ID_IMPUTADO;
                            _EstudioActual.ID_INGRESO           = item.ID_INGRESO;
                            _EstudioActual.ID_MOTIVO            = item.ID_MOTIVO;
                            _EstudioActual.ID_SITUACION         = item.RESULT_ESTUDIO == "True" ? short.Parse((3).ToString()) : short.Parse((5).ToString());//estatus de asignado a estudio de personalidad
                            _EstudioActual.INICIO_FEC           = item.INICIO_FEC;
                            _EstudioActual.SOLICITADO           = item.SOLICITADO;
                            _EstudioActual.SOLICITUD_FEC        = item.SOLICITUD_FEC;
                            _EstudioActual.TERMINO_FEC          = item.TERMINO_FEC;
                            _EstudioActual.PROG_NOMBRE          = item.PROG_NOMBRE;
                            _EstudioActual.NUM_OFICIO           = item.NUM_OFICIO;
                            _EstudioActual.ID_AREA              = item.ID_AREA;
                            Context.Entry(_EstudioActual).State = System.Data.EntityState.Modified;
                        }
                        ;
                    }

                    var _MensajeConsiderado = Context.MENSAJE_TIPO.FirstOrDefault(x => x.ID_MEN_TIPO == TipoMensaje);
                    var _id_mensaje         = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                    if (_MensajeConsiderado != null)
                    {
                        if (_id_mensaje != decimal.Zero)
                        {
                            System.DateTime _fecha     = GetFechaServerDate();
                            var             NvoMensaje = new MENSAJE()
                            {
                                CONTENIDO    = _MensajeConsiderado.CONTENIDO + " PARA LOS IMPUTADOS \n " + CuerpoMensaje,
                                ENCABEZADO   = _MensajeConsiderado.ENCABEZADO,
                                ID_MEN_TIPO  = _MensajeConsiderado.ID_MEN_TIPO,
                                ID_MENSAJE   = _id_mensaje,
                                REGISTRO_FEC = _fecha,
                                ID_CENTRO    = GlobalVariables.gCentro
                            };

                            Context.MENSAJE.Add(NvoMensaje);
                        }
                    }
                    ;

                    Context.SaveChanges();
                    transaccion.Complete();
                    return(true);
                }

                return(false);
            }

            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        System.Diagnostics.Trace.TraceInformation("Nombre del causante de excepción: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }

                return(false);
            }

            catch (System.Exception exc)
            {
                return(false);
            }
        }
Пример #23
0
        /// <summary>
        /// metodo para actualizar estatus de destinos de excarcelacion
        /// </summary>
        /// <param name="excarcelacion_destino">entidad excarcelacion destino a actualizar</param>
        /// <param name="mensaje_tipo_autorizacion">llave del mensaje para enviar durante autorizacion/cancelacion de excarcelacion</param>
        /// <param name="mensaje_tipo_autorizacion_area_medica">llave del mensaje para enviar durante autorizacion/cancelacion de excarcelacion al area medica</param>
        /// <param name="id_otro_hospital">llave numerica de referencia de otro hospital en catalogo de hospitales</param>
        /// <param name="fecha_servidor">fecha del servidor</param>
        public void Actualizar(EXCARCELACION_DESTINO excarcelacion_destino, int mensaje_tipo_autorizacion, int mensaje_tipo_autorizacion_area_medica, short id_otro_hospital, DateTime fecha_servidor)
        {
            try
            {
                using (TransactionScope transaccion = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                }))
                {
                    var _mandar_mensaje      = false;
                    var _destinos_cancelados = new List <string>();
                    var _destinos            = new List <string>();
                    Context.Entry(excarcelacion_destino).State = EntityState.Modified;
                    Context.SaveChanges();
                    var _excarcelacion = Context.EXCARCELACION.FirstOrDefault(w => w.ID_ANIO == excarcelacion_destino.ID_ANIO && w.ID_CENTRO == excarcelacion_destino.ID_CENTRO && w.ID_CONSEC == excarcelacion_destino.ID_CONSEC &&
                                                                              w.ID_IMPUTADO == excarcelacion_destino.ID_IMPUTADO && w.ID_INGRESO == excarcelacion_destino.ID_INGRESO);
                    if (_excarcelacion != null)
                    {
                        if (!_excarcelacion.EXCARCELACION_DESTINO.Any(a => a.ID_ESTATUS != "CA" && a.ID_ESTATUS != "AU"))
                        {
                            if (_excarcelacion.EXCARCELACION_DESTINO.Any(a => a.ID_ESTATUS != "CA"))
                            {
                                _excarcelacion.ID_ESTATUS = "AU";
                            }
                            else
                            {
                                _excarcelacion.ID_ESTATUS = "CA";
                            }
                            Context.Entry(_excarcelacion).State = EntityState.Modified;
                            Context.SaveChanges();

                            _mandar_mensaje = true;
                            foreach (var item in _excarcelacion.EXCARCELACION_DESTINO)
                            {
                                if (item.ID_ESTATUS == "CA")
                                {
                                    if (_excarcelacion.ID_TIPO_EX == 1)
                                    {
                                        _destinos_cancelados.Add(Context.JUZGADO.FirstOrDefault(w => w.ID_JUZGADO == item.ID_JUZGADO) == null ? string.Empty : Context.JUZGADO.FirstOrDefault(w => w.ID_JUZGADO == item.ID_JUZGADO).DESCR);
                                    }
                                    else if (_excarcelacion.ID_TIPO_EX == 2)
                                    {
                                        var _solicitud_interconsulta = Context.INTERCONSULTA_SOLICITUD.FirstOrDefault(w => w.ID_INTERSOL == item.ID_INTERSOL);
                                        if (_solicitud_interconsulta != null)
                                        {
                                            _destinos_cancelados.Add(_solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().ID_HOSPITAL == id_otro_hospital ? _solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().HOSPITAL_OTRO
                                                : _solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().HOSPITAL.DESCR);
                                        }
                                        //_destinos_cancelados.Add(Context.HOSPITAL.FirstOrDefault(w => w.ID_HOSPITAL == item.ID_HOSPITAL) == null ? string.Empty : item.ID_HOSPITAL == id_otro_hospital ? item.HOSPITAL_OTRO : Context.HOSPITAL.FirstOrDefault(w => w.ID_HOSPITAL == item.ID_HOSPITAL).DESCR);
                                    }
                                }
                                else
                                {
                                    if (_excarcelacion.ID_TIPO_EX == 1)
                                    {
                                        _destinos.Add(Context.JUZGADO.FirstOrDefault(w => w.ID_JUZGADO == item.ID_JUZGADO) == null ? string.Empty : Context.JUZGADO.FirstOrDefault(w => w.ID_JUZGADO == item.ID_JUZGADO).DESCR);
                                    }
                                    else if (_excarcelacion.ID_TIPO_EX == 2)
                                    {
                                        var _solicitud_interconsulta = Context.INTERCONSULTA_SOLICITUD.FirstOrDefault(w => w.ID_INTERSOL == item.ID_INTERSOL);
                                        if (_solicitud_interconsulta != null)
                                        {
                                            _destinos.Add(_solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().ID_HOSPITAL == id_otro_hospital ? _solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().HOSPITAL_OTRO
                                                : _solicitud_interconsulta.HOJA_REFERENCIA_MEDICA.First().HOSPITAL.DESCR);
                                        }
                                        //_destinos.Add(Context.HOSPITAL.FirstOrDefault(w => w.ID_HOSPITAL == item.ID_HOSPITAL) == null ? string.Empty : item.ID_HOSPITAL == id_otro_hospital ? item.HOSPITAL_OTRO : Context.HOSPITAL.FirstOrDefault(w => w.ID_HOSPITAL == item.ID_HOSPITAL).DESCR);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("La excarcelación padre de este registro fue eliminada fue eliminada durante el proceso");
                    }
                    if (_mandar_mensaje)
                    {
                        var _mensaje_tipo    = Context.MENSAJE_TIPO.FirstOrDefault(w => w.ID_MEN_TIPO == mensaje_tipo_autorizacion);
                        var _imputado        = Context.IMPUTADO.First(w => w.ID_ANIO == _excarcelacion.ID_ANIO && w.ID_CENTRO == _excarcelacion.ID_CENTRO && w.ID_IMPUTADO == _excarcelacion.ID_IMPUTADO);
                        var _nombre_completo = string.Format("{0} {1} {2}", !string.IsNullOrEmpty(_imputado.NOMBRE) ? _imputado.NOMBRE.Trim() : string.Empty, !string.IsNullOrEmpty(_imputado.PATERNO) ? _imputado.PATERNO.Trim() : string.Empty, !string.IsNullOrEmpty(_imputado.MATERNO) ? _imputado.MATERNO.Trim() : string.Empty);
                        var _id_mensaje      = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                        var _contenido       = _mensaje_tipo.CONTENIDO + " PARA EL IMPUTADO " + _nombre_completo + " CON FOLIO " + string.Format("{0}/{1} PARA EL DIA {2} A LAS {3}", _excarcelacion.ID_ANIO, _excarcelacion.ID_IMPUTADO,
                                                                                                                                                 string.Format("{0:dd/MM/yyyy}", _excarcelacion.PROGRAMADO_FEC.Value.Date), String.Format("{0:t}", _excarcelacion.PROGRAMADO_FEC.Value.TimeOfDay));
                        if (_destinos.Count > 0)
                        {
                            _contenido += "\nDESTINOS:\n";
                        }
                        foreach (var item in _destinos)
                        {
                            _contenido += (item + "\n");
                        }
                        if (_destinos_cancelados.Count > 0)
                        {
                            _contenido += "\nDESTINOS CANCELADOS:\n";
                        }
                        foreach (var item in _destinos_cancelados)
                        {
                            _contenido += (item + "\n");
                        }
                        var _mensaje = new MENSAJE
                        {
                            CONTENIDO    = _contenido,
                            ENCABEZADO   = _mensaje_tipo.ENCABEZADO,
                            ID_MEN_TIPO  = _mensaje_tipo.ID_MEN_TIPO,
                            ID_MENSAJE   = _id_mensaje,
                            REGISTRO_FEC = fecha_servidor
                        };
                        Context.MENSAJE.Add(_mensaje);
                        Context.SaveChanges();
                        if (_excarcelacion.CERTIFICADO_MEDICO.HasValue && _excarcelacion.CERTIFICADO_MEDICO.Value == 1)
                        {
                            _mensaje_tipo = Context.MENSAJE_TIPO.FirstOrDefault(w => w.ID_MEN_TIPO == mensaje_tipo_autorizacion_area_medica);
                            _id_mensaje   = GetIDProceso <int>("MENSAJE", "ID_MENSAJE", "1=1");
                            _contenido    = _mensaje_tipo.CONTENIDO + " PARA EL IMPUTADO " + _nombre_completo + " CON FOLIO " + string.Format("{0}/{1} PARA EL DIA {2} A LAS {3}", _excarcelacion.ID_ANIO, _excarcelacion.ID_IMPUTADO, string.Format("{0:dd/MM/yyyy}", _excarcelacion.PROGRAMADO_FEC.Value.Date), String.Format("{0:t}", _excarcelacion.PROGRAMADO_FEC.Value.TimeOfDay));
                            _mensaje      = new MENSAJE
                            {
                                CONTENIDO    = _contenido,
                                ENCABEZADO   = _mensaje_tipo.ENCABEZADO,
                                ID_MEN_TIPO  = _mensaje_tipo.ID_MEN_TIPO,
                                ID_MENSAJE   = _id_mensaje,
                                REGISTRO_FEC = fecha_servidor
                            };
                            Context.MENSAJE.Add(_mensaje);
                            Context.SaveChanges();
                        }
                    }
                    transaccion.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
            }
        }