Ejemplo n.º 1
0
        public string Post(ParametrosVOBO Datos)
        {
            try
            {
                SqlCommand comando = new SqlCommand("EnviaVoBo");
                comando.CommandType = CommandType.StoredProcedure;

                //Declaracion de parametros
                comando.Parameters.Add("@usuarioActual", SqlDbType.VarChar);
                comando.Parameters.Add("@usuariovobo", SqlDbType.VarChar);
                comando.Parameters.Add("@idinforme", SqlDbType.VarChar);
                comando.Parameters.Add("@comentariosValidacion", SqlDbType.VarChar);
                comando.Parameters.Add("@ualterno", SqlDbType.VarChar);

                string ususariodesencripta = Seguridad.DesEncriptar(Datos.usuarioActual);

                string UAlterno = GetUsuarioAlterno.UsuarioAlterno(Datos.usuariovobo).Resultado;

                //Asignacion de valores a parametros
                comando.Parameters["@usuarioActual"].Value         = ususariodesencripta;
                comando.Parameters["@usuariovobo"].Value           = Datos.usuariovobo;
                comando.Parameters["@idinforme"].Value             = Datos.idinforme;
                comando.Parameters["@comentariosValidacion"].Value = Datos.comentariosValidacion;
                comando.Parameters["@ualterno"].Value = UAlterno;


                comando.Connection     = new SqlConnection(VariablesGlobales.CadenaConexion);
                comando.CommandTimeout = 0;
                comando.Connection.Open();

                DataTable      DT = new DataTable();
                SqlDataAdapter DA = new SqlDataAdapter(comando);
                comando.Connection.Close();
                DA.Fill(DT);


                if (DT.Rows.Count > 0)
                {
                    foreach (DataRow row in DT.Rows)
                    {
                        string mensaje       = Convert.ToString(row["msn"]);
                        string titulo        = Convert.ToString(row["titulo"]);
                        string usuarioActual = Convert.ToString(row["usuarioActual"]);
                        string usuariovobo   = Convert.ToString(row["usuariovobo"]);
                        string correo        = Convert.ToString(row["correo"]);

                        //Mensaje(usuariovobo);

                        EnvioCorreosELE.Envio(usuarioActual, correo, "", usuariovobo, "", titulo, mensaje, 0);
                    }

                    return("OK");
                }
                else
                {
                    return("Error");
                }
            }
            catch (System.Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public List <ObtieneVOBOResult> Post(ParametrosVOBO datos)
        {
            try
            {
                SqlCommand comando = new SqlCommand("ObtieneVOBO");//ok
                comando.CommandType = CommandType.StoredProcedure;

                //Declaracion de parametros
                comando.Parameters.Add("@c_accion", SqlDbType.VarChar);
                comando.Parameters.Add("@usuarioActual", SqlDbType.VarChar);
                comando.Parameters.Add("@idinforme", SqlDbType.VarChar);

                //Asignacion de valores a parametros
                comando.Parameters["@c_accion"].Value      = datos.c_accion;
                comando.Parameters["@usuarioActual"].Value = datos.usuarioActual;
                comando.Parameters["@idinforme"].Value     = datos.idinforme;

                comando.Connection     = new SqlConnection(VariablesGlobales.CadenaConexion);
                comando.CommandTimeout = 0;
                comando.Connection.Open();

                DataTable      DT = new DataTable();
                SqlDataAdapter DA = new SqlDataAdapter(comando);
                comando.Connection.Close();
                DA.Fill(DT);

                //ObtieneInformeResult items;

                List <ObtieneVOBOResult> lista = new List <ObtieneVOBOResult>();

                if (DT.Rows.Count > 0)
                {
                    foreach (DataRow row in DT.Rows)
                    {
                        if (Convert.ToString(row["Resultado"]) == "Error")
                        {
                            ObtieneVOBOResult ent = new ObtieneVOBOResult
                            {
                                Resultado = Convert.ToString(row["Resultado"])
                            };

                            lista.Add(ent);
                        }
                        else
                        {
                            ObtieneVOBOResult ent = new ObtieneVOBOResult
                            {
                                c_usuario_nombre = Convert.ToString(row["c_usuario_nombre"]),
                                c_correo         = Convert.ToString(row["c_correo"]),
                                c_usuario        = Convert.ToString(row["c_usuario"]),
                                c_valor_default  = Convert.ToInt32(row["c_valor_default"]),
                                c_chk_bloqueado  = Convert.ToInt32(row["c_chk_bloqueado"]),
                                c_duracion_ini   = Convert.ToString(row["c_duracion_ini"]),
                                c_duracion_fin   = Convert.ToString(row["c_duracion_fin"]),
                                Resultado        = Convert.ToString(row["Resultado"]),
                                VerChk           = Convert.ToInt16(row["VerChk"])
                            };

                            lista.Add(ent);
                        }
                    }

                    return(lista);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                List <ObtieneVOBOResult> lista = new List <ObtieneVOBOResult>();
                ObtieneVOBOResult        ent   = new ObtieneVOBOResult
                {
                    Resultado = ex.ToString(),
                };

                lista.Add(ent);

                return(lista);
            }
        }