Exemplo n.º 1
0
        public static Result guardar(int id, int opcionMaestroAnexoId, int?registroTablaId, HttpPostedFile anexo, int usuarioId)
        {
            Result r = ValidateSession.validarSession(usuarioId, HttpContext.Current.Session["usuarioId"]);

            if (r.error != "")
            {
                return(r);
            }
            Anexos a = new Anexos();

            a.id = id;
            a.opcionMaestroAnexoId = opcionMaestroAnexoId;
            a.registroTablaId      = registroTablaId;
            // a.anexo = anexo;
            a.usuarioId = usuarioId;

            try
            {
                AnexoController ac = new AnexoController();
                return(ac.guardarAnexos(a));
            }
            catch (Exception ex)
            {
                return(new Result()
                {
                    error = ex.Message, id = 0, tipoAlerta = "warning"
                });
            }
        }
Exemplo n.º 2
0
        private void AddListaAnexo()
        {
            var listanexos = new AnexoController().FindbyChamado(Chamado.Codigo_chamado);

            for (int i = 0; i < listanexos.Count; i++)
            {
                listaAnexo.Add(listanexos[i]);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AnexoController ac      = new AnexoController();
            int             anexoId = 0;

            int.TryParse(Request.QueryString["id"], out anexoId);
            AnexosViewModel avm = ac.getAnexos(anexoId);

            System.IO.MemoryStream stream = new System.IO.MemoryStream(avm.anexo);
            WriteToResponse(avm.nombreAnexo, true, "", stream);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
            {
                string fn             = System.IO.Path.GetFileName(File1.PostedFile.FileName);
                string valueTipoAnexo = cmbTipoAnexo.SelectedValue;
                string val            = hRegistro.Value;
                try
                {
                    byte[] fileData = null;
                    using (var binaryReader = new BinaryReader(File1.PostedFile.InputStream))
                    {
                        fileData = binaryReader.ReadBytes(File1.PostedFile.ContentLength);
                    }

                    AnexoController ac = new AnexoController();
                    Anexos          a  = new Anexos();
                    a.anexo = fileData;
                    a.consecutivoTemporal = hConsecutivo.Value;
                    a.id = 0;
                    a.opcionMaestroAnexoId = int.Parse(valueTipoAnexo);
                    a.nombreAnexo          = fn;
                    try
                    {
                        a.registroTablaId = int.Parse(hRegistro.Value.ToString());
                    }
                    catch (Exception)
                    {}
                    a.usuarioId = int.Parse(Session["usuarioId"].ToString());

                    Result r = ac.guardarAnexos(a);

                    if (r.error != "")
                    {
                        Response.Write("<h1> Error: " + r.error + "</h1>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    //Note: Exception.Message returns detailed message that describes the current exception.
                    //For security reasons, we do not recommend you return Exception.Message to end users in
                    //production environments. It would be better just to put a generic error message.
                }
            }
            else
            {
                Response.Write("Please select a file to upload.");
            }
        }