private void DescargaArchivoAsuntoDoWork(object sender, DoWorkEventArgs e) { foreach (VMAsuntos elemento in viewModelPadre.ListadoAsuntos.Where(x => x.IsSelected)) { dtoAsuntos Asunto = new dtoAsuntos { Asunto = elemento.Asunto, Drive = elemento.Drive, DriveCompartido = elemento.DriveCompartido, FechaAprobacion = elemento.FechaAprobacion, FechaCreacion = elemento.FechaCreacion, FechaArchivo = elemento.FechaArchivo, Email = elemento.Email, Archivo = elemento.Archivo, IdAsunto = elemento.IdAsunto, IdUsuario = elemento.IdUsuario, GuidArchivo = elemento.GuidArchivo, NombreArchivo = elemento.NombreArchivo }; e.Result = new BALAsuntos().DownloadArchivoAsunto(Asunto); Tuple <bool, byte[]> _resultado = e.Result as Tuple <bool, byte[]>; if (!_resultado.Item1) { throw new Exception(DTOWDXDespachoVilla.Constantes.ConstantesComunes.ERROR_GENERICO); } elemento.Archivo = _resultado.Item2; } }
public JsonResult GuardarAsunto(dtoAsuntos Asunto) { if (!Request.IsAuthenticated) { return(Json(new { ErrorInterno = "No se ha podido autenticar al usuario" })); } CultureInfo Cultura = CultureInfo.CreateSpecificCulture("es-MX"); Thread.CurrentThread.CurrentCulture = Cultura; Asunto.Asunto = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Asunto.Asunto); ApplicationUser Usuario = UserManager.FindById(User.Identity.GetUserId()); string RawData = String.Format("{0}_{1}", Usuario.UserName, Asunto.Asunto.Trim()); string Hash = EmailService.ComputarSha256(RawData); Asunto.HashAsunto = Hash; Asunto.Email = Usuario.UserName; Tuple <bool, string> _result = new BALAsuntos().UpdateAsuntos(Asunto); if (!_result.Item1) { return(Json(new { Exito = false, Mensaje = ConstantesComunes.ERROR_GENERICO })); } else { var Servicio = new EmailService(); Servicio.sendMailAsunto(Asunto.Asunto.Trim(), new dtoPersonas { Email = Usuario.UserName }); return(Json(new { Exito = true, Mensaje = ConstantesComunes.EXITOWEB_GENERIO + ConstantesAsuntos.VERIFICAR_ASUNTO })); } }
public Tuple <bool, string> UpdateAsuntos(dtoAsuntos Asunto, bool Actualizar = false) { Tuple <bool, string> _result = new Tuple <bool, string>(false, ConstantesComunes.ERROR_GENERICO); try { string conexion = ConfigurationManager.ConnectionStrings["WDXAdminConnection"].ToString(); using (SqlConnection Conn = new SqlConnection(conexion)) { Conn.Open(); SqlCommand Cmd = Conn.CreateCommand(); Cmd.CommandText = ConstantesAsuntos.PROCEDURE_SP_UPDATEASUNTOS; Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue("@Usuario", Asunto.Email); Cmd.Parameters.AddWithValue("@Asunto", Asunto.Asunto.Trim()); Cmd.Parameters.AddWithValue("@HashAsunto", Asunto.HashAsunto); Cmd.Parameters.AddWithValue("@Accion", Actualizar ? 1 : 0); SqlParameter ParamResult = new SqlParameter("@Result", SqlDbType.VarChar, -1); ParamResult.Direction = ParameterDirection.Output; Cmd.Parameters.Add(ParamResult); Cmd.ExecuteNonQuery(); if (Cmd.Parameters[4].Value.ToString() != String.Empty) { _result = new Tuple <bool, string>(false, Cmd.Parameters[4].Value.ToString()); } _result = new Tuple <bool, string>(true, ConstantesComunes.EXITO_GENERICO); } } catch (Exception ex) { } return(_result); }
public Tuple <bool, byte[]> DownloadArchivoAsunto(dtoAsuntos Asunto, bool Todos = true) { Tuple <bool, byte[]> _result = new Tuple <bool, byte[]>(false, new byte[0]); try { string conexion = ConfigurationManager.ConnectionStrings["WDXAdminConnection"].ToString(); using (SqlConnection Conn = new SqlConnection(conexion)) { Conn.Open(); SqlCommand Cmd = Conn.CreateCommand(); Cmd.CommandText = ConstantesAsuntos.PROCEDURE_SP_DESCARGARARCHIVO; Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue("@GuidArchivo", Asunto.GuidArchivo); Cmd.Parameters.AddWithValue("@Todos", Todos ? DBNull.Value : (object)false); var myReader = Cmd.ExecuteReader(); byte[] Archivo = null; while (myReader.Read()) { Archivo = (byte[])myReader["Archivo"]; } _result = new Tuple <bool, byte[]>(true, Archivo); } } catch (Exception ex) { } return(_result); }
private void GuardaAsuntoDoWork(object sender, DoWorkEventArgs e) { foreach (VMBuzon elemento in viewModelPadre.ListaMensajes.Where(x => x.Selected)) { string Asunto = elemento.Mensaje.Substring(elemento.Mensaje.IndexOf("jurídico:") + 10, (elemento.Mensaje.IndexOf(".") - (elemento.Mensaje.IndexOf("jurídico:") + 10))); Regex Expresion = new Regex(@"[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*"); string Usuario = Expresion.Match(elemento.Mensaje).Value; Usuario = Usuario.Substring(0, Usuario.Length); dtoAsuntos asunto = new dtoAsuntos { Asunto = Asunto, HashAsunto = elemento.Codigo, Email = Usuario }; if (ComputarSha256(String.Format("{0}_{1}", asunto.Email, asunto.Asunto)) != elemento.Codigo.Replace("Código:", "").Trim()) { throw new Exception(DTOWDXDespachoVilla.Constantes.ConstantesComunes.VALIDACION_CODIGO_HASH_FALLIDA); } e.Result = new BALAsuntos().UpdateAsuntos(asunto, true); Tuple <bool, string> _resultado = (Tuple <bool, string>)e.Result; if (!_resultado.Item1) { throw new Exception(_resultado.Item2); } } }
public List <dtoAsuntos> GetAsuntosArchivos(dtoAsuntos Asunto, bool Todos = false, string GuidArchivo = "") { List <dtoAsuntos> _result = new DALAsuntos().GetAsuntosArchivos(Asunto, Todos); return(_result.Count > 0 ? GuidArchivo != String.Empty ? new List <dtoAsuntos> { _result.FirstOrDefault(k => k.GuidArchivo == GuidArchivo) } : _result : null); }
public FileResult DownloadArchivoAsunto(string Guid) { List <dtoAsuntos> _result = new BALAsuntos().GetAsuntosArchivos(new dtoAsuntos { Email = User.Identity.GetUserName() }, false, Guid); if (_result != null) { dtoAsuntos _resultado = _result.FirstOrDefault(); string extension = _resultado.NombreArchivo.Substring(_resultado.NombreArchivo.LastIndexOf("."), _resultado.NombreArchivo.Length - _resultado.NombreArchivo.LastIndexOf(".")); return(File(_result.FirstOrDefault().Archivo, extension.ToLower() == ".pdf" ? System.Net.Mime.MediaTypeNames.Application.Pdf : System.Net.Mime.MediaTypeNames.Application.Pdf, _resultado.NombreArchivo)); } return(null); }
public JsonResult VerificaAsunto(dtoAsuntos Asunto) { List <dtoAsuntos> _result = new BALAsuntos().GetAsuntosArchivos(new dtoAsuntos { Email = User.Identity.GetUserName() }, true); if (_result != null) { CultureInfo Cultura = CultureInfo.CreateSpecificCulture("es-MX"); Thread.CurrentThread.CurrentCulture = Cultura; Asunto.Asunto = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Asunto.Asunto); dtoAsuntos _resultado = _result.FirstOrDefault(k => k.Asunto == Asunto.Asunto); return(Json(new { Exito = _resultado == null }, JsonRequestBehavior.AllowGet)); } return(Json(new { Exito = false }, JsonRequestBehavior.AllowGet)); }
public List <dtoAsuntos> GetAsuntosArchivos(dtoAsuntos Asunto, bool Todos = false) { List <dtoAsuntos> _result = new List <dtoAsuntos>(); try { string conexion = ConfigurationManager.ConnectionStrings["WDXAdminConnection"].ToString(); using (SqlConnection Conn = new SqlConnection(conexion)) { Conn.Open(); SqlCommand Cmd = Conn.CreateCommand(); Cmd.CommandText = ConstantesAsuntos.PROCEDURE_SP_CONSULTAASUNTOS; Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue("@Usuario", Asunto.Email); Cmd.Parameters.AddWithValue("@Todos", Todos ? 0 : 1); IDataReader Reader = Cmd.ExecuteReader(); while (Reader.Read()) { _result.Add(new dtoAsuntos { Email = Reader["UserName"].ToString(), NombreArchivo = Reader["NombreArchivo"].ToString(), Archivo = Reader["Archivo"] != DBNull.Value ? (byte[])Reader["Archivo"] : null, GuidArchivo = Reader["GuidArchivo"].ToString(), IdAsunto = Convert.ToInt32(Reader["Id_Asunto"]), Asunto = Reader["Asunto"].ToString(), Tema = Reader["Tema"].ToString(), FechaCreacion = Convert.ToDateTime(Reader["FechaCreacion"]), FechaAprobacion = Reader["FechaAprobacion"] != DBNull.Value ? (DateTime?)Convert.ToDateTime(Reader["FechaAprobacion"]) : null, FechaArchivo = Reader["FechaArchivo"] != DBNull.Value ? (DateTime?)Convert.ToDateTime(Reader["FechaArchivo"]) : null, }); } } } catch (Exception ex) { } return(_result); }
public ActionResult UploadLocal(dtoAsuntos Asuntos, HttpFileCollection archivos_locales) { string IdUsuario = User.Identity.GetUserId(); HttpFileCollectionBase Archivos = Request.Files; if (Archivos != null) { List <dtoAsuntos> Listado = new List <dtoAsuntos>(); for (int i = 0; i < Archivos.Count; i++) { HttpPostedFileBase file = Request.Files[i]; dtoAsuntos Asunto = new dtoAsuntos { IdUsuario = IdUsuario, Archivo = new byte[file.ContentLength], IdAsunto = Asuntos.IdAsunto, NombreArchivo = file.FileName, Drive = false, }; file.InputStream.Read(Asunto.Archivo, 0, file.ContentLength); string destPath = Path.Combine(Server.MapPath("~/App_Data"), file.FileName); System.IO.File.Create(destPath); Listado.Add(Asunto); } Tuple <bool, string> Upload = new BALAsuntos().UpdateArchivosAsuntos(Listado); if (Upload.Item1) { Session["ArchivosDownloadDrive"] = true; } else { Session["ArchivosDownloadDrive"] = false; } } return(RedirectToAction("MisAsuntos")); }
public Tuple <bool, byte[]> DownloadArchivoAsunto(dtoAsuntos Asunto, bool Todos = true) { return(new DALAsuntos().DownloadArchivoAsunto(Asunto, Todos)); }
public Tuple <bool, string> UpdateAsuntos(dtoAsuntos Asunto, bool Actualizar = false) { return(new DALAsuntos().UpdateAsuntos(Asunto, Actualizar)); }