protected void lblClick(object sender, EventArgs e) { THE_SesionUsuario ObjSession = new THE_SesionUsuario(); ObjSession.EmplLlavPr = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(Session["numeroUsuario"].ToString()) }; ObjSession.IdSesion = int.Parse(Session["IdSesion"].ToString()); bool actualizo = MngNegocioUsuarioSesion.EliminaSesionUsuario(ObjSession); Session["UserName"] = null; Session["nombreUsuario"] = null; Session["numeroUsuario"] = null; Session["UserName"] = null; Session["UserDomain"] = null; Session["UserIP"] = null; Session["UserPuesto"] = null; Session["NomPuesto"] = null; Session.Abandon(); Session.Clear(); Response.Clear(); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); Response.Redirect("~/Default.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { return; } try { if (!IsPostBack) { TDI_LogPaginas logPaginas = new TDI_LogPaginas(); logPaginas.LogFecha = DateTime.Now; logPaginas.LogIp = Session["UserIP"].ToString(); logPaginas.LogUrlPagina = Request.RawUrl; logPaginas.EmpleadoLlavePrimaria = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(Session["numeroUsuario"].ToString()) }; MngNegocioLogPaginas.GuardarLogPaginas(logPaginas); } string IdUsuario = Request.QueryString["data"]; string IdDispositivo = Request.QueryString["guid"]; if (IdDispositivo != "NO") { List <TDI_UsuarioDispositivo> usuaDis = MngNegocioUsuarioDispositivo.ObtieneDispoUsuarioPorIdDispo(int.Parse(IdDispositivo)); if (usuaDis.Count > 0) { lblNombreUsua.Text = usuaDis[0].UsuarioLlavePrimaria.UsuarioNombre; lblDispoNum.Text = usuaDis[0].IdDispositivo.NumerodelTelefono; lblEstado.Text = usuaDis[0].UsuarioLlavePrimaria.EstadoInfo.EstadoNombre; } } else { List <TDI_UsuarioDispositivo> usuDispo = MngNegocioUsuarioDispositivo.ObtieneDispositivoPorUsuario(int.Parse(IdUsuario)); if (usuDispo.Count > 0) { lblNombreUsua.Text = usuDispo[0].UsuarioLlavePrimaria.UsuarioNombre; lblDispoNum.Text = usuDispo[0].IdDispositivo.NumerodelTelefono; lblEstado.Text = usuDispo[0].UsuarioLlavePrimaria.EstadoInfo.EstadoNombre; } else { } } } catch (Exception ex) { EncuestasMoviles.Clases.Error.ManejadorErrores(ex, Session["numeroUsuario"].ToString(), Session["UserDomain"].ToString(), Session["userMachineName"].ToString(), Session["UserIP"].ToString(), "DispositivoInfo", int.Parse(Session["numeroUsuario"].ToString())); } finally { } }
protected void Page_Load(object sender, EventArgs e) { Response.AddHeader("Cache-Control", "no-store"); Response.AddHeader("Pragma", "no-cache"); Response.AddHeader("Cache-Control", "no-cache, must-revalidate"); Response.Expires = -1; if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { Session["nombreUsuario"] = null; Session["numeroUsuario"] = null; Session["UserName"] = null; Session["UserDomain"] = null; Session["UserIP"] = null; Session["UserPuesto"] = null; Session["NomPuesto"] = null; ctrlMessageBox.AddMessage("Su sesion ha expirado", MessageBox.enmMessageType.Info, true, false, "Sesion", "Sesion Expirada"); } if (!Page.IsPostBack) { LlenaMenu(); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } else { List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), (Session["UserIP"].ToString())); if (existeSesion.Count == 0) { Session["nombreUsuario"] = null; Session["numeroUsuario"] = null; Session["UserName"] = null; Session["UserDomain"] = null; Session["UserIP"] = null; Session["UserPuesto"] = null; Session["NomPuesto"] = null; Response.Redirect("~/Default.aspx"); } } } catch { } finally { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { return; } try { if (!IsPostBack) { List <TDI_BaseRespuestas> empl2 = MngNegocioBaseRespuestas.ObtenerRespFrecuentes(); TDI_LogPaginas logPaginas = new TDI_LogPaginas(); logPaginas.LogFecha = DateTime.Now; logPaginas.LogIp = Session["UserIP"].ToString(); logPaginas.LogUrlPagina = Request.RawUrl; logPaginas.EmpleadoLlavePrimaria = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(Session["numeroUsuario"].ToString()) }; MngNegocioLogPaginas.GuardarLogPaginas(logPaginas); List <THE_Encuesta> encuGra = MngNegocioEncuesta.ObtieneEncuestasActivas(); if (encuGra.Count > 0) { RadComboBox1.DataSource = encuGra; RadComboBox1.DataTextField = "Nombreencuesta"; RadComboBox1.DataValueField = "IdEncuesta"; RadComboBox1.DataBind(); //List<THE_Usuario> Usuario = MngNegocioUsuario.ObtieneTodosUsuarios(); //foreach (var us in Usuario) //{ // us.UsuarioNombre = us.UsuarioNombre + " " + us.UsuarioApellPaterno + " " + us.UsuarioApellMaterno; //} //if (Usuario.Count > 0) //{ // RadComboBox2.DataSource = Usuario; // RadComboBox2.DataTextField = "UsuarioNombre"; // RadComboBox2.DataValueField = "UsuarioLlavePrimaria"; // RadComboBox2.DataBind(); //} } } } catch (Exception msException) { } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { return; } if (!IsPostBack) { TDI_LogPaginas logPaginas = new TDI_LogPaginas(); logPaginas.LogFecha = DateTime.Now; logPaginas.LogIp = Session["UserIP"].ToString(); logPaginas.LogUrlPagina = Request.RawUrl; logPaginas.EmpleadoLlavePrimaria = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(Session["numeroUsuario"].ToString()) }; MngNegocioLogPaginas.GuardarLogPaginas(logPaginas); } try { CargaDatos(); ctrlMessageBox.MsgBoxAnswered += new MessageBox.MsgBoxEventHandler(ctrlMessageBox_MsgBoxAnswered); } catch (Exception ex) { EncuestasMoviles.Clases.Error.ManejadorErrores(ex, Session["UserName"].ToString(), Session["UserDomain"].ToString(), Session["userMachineName"].ToString(), Session["UserIP"].ToString(), "frmCatalogos", int.Parse(Session["numeroUsuario"].ToString())); } } catch (Exception ms) { } finally { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { return; } try { if (!IsPostBack) { TDI_LogPaginas logPaginas = new TDI_LogPaginas(); logPaginas.LogFecha = DateTime.Now; logPaginas.LogIp = Session["UserIP"].ToString(); logPaginas.LogUrlPagina = Request.RawUrl; logPaginas.EmpleadoLlavePrimaria = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(Session["numeroUsuario"].ToString()) }; MngNegocioLogPaginas.GuardarLogPaginas(logPaginas); //List<THE_Encuesta> encuGra = MngNegocioEncuesta.ObtieneEncuestasActivas(); //if (encuGra.Count > 0) //{ // cbEncuestas.DataSource = encuGra; // cbEncuestas.DataTextField = "Nombreencuesta"; // cbEncuestas.DataValueField = "IdEncuesta"; // cbEncuestas.DataBind(); //} } } catch (Exception ms) { } }
protected void Acepta_Evento(object sender, EventArgs e) { try { string Opcion = ViewState["Opcion"].ToString(); if (Opcion == "ContinuaSesion") { THE_SesionUsuario ObjSession = new THE_SesionUsuario(); ObjSession.DirIP = ViewState["IPUsr"].ToString(); ObjSession.FechaCreacion = DateTime.Now; ObjSession.EmplLlavPr = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(ViewState["vsIdUser"].ToString()) }; ObjSession.IdSesion = int.Parse(ViewState["vsIdSesion"].ToString()); bool actualizo = MngNegocioUsuarioSesion.ActualizaSesionUsuario(ObjSession); if (actualizo) { XmlDocument xmls = new XmlDocument(); xmls.LoadXml((string)ViewState["vsUserdata"]); string numeroUsuario = xmls.FirstChild.ChildNodes[2].InnerText; XmlDocument UserData = null; if (isNumeric(ViewState["TipoUsuario"].ToString())) { isUserName = false; UsuarioTVA = ViewState["userDesencriptado"].ToString().ToUpper(); usuario = ViewState["userDesencriptado"].ToString().ToUpper(); UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(ViewState["TipoUsuario"].ToString(), ""); string NumUsua = (UserData.GetElementsByTagName("NUMUSUA").Count > 0) ? UserData.GetElementsByTagName("NUMUSUA")[0].InnerText : ""; EmId = (UserData.GetElementsByTagName("NUMEMPL").Count > 0) ? UserData.GetElementsByTagName("NUMEMPL")[0].InnerText : ""; if (ViewState["userDesencriptado"].ToString().ToUpper().Contains("TVA")) { UsuarioTVA = "TVA" + TipoUsuario; } else if (ViewState["userDesencriptado"].ToString().ToUpper().Contains("PTV")) { UsuarioTVA = "PTV" + TipoUsuario; } else { UsuarioTVA = "TVA" + TipoUsuario; } } else { isUserName = true; usuario = ViewState["userDesencriptado"].ToString().ToUpper(); UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado("", usuario); string NumUsua = (UserData.GetElementsByTagName("NUMUSUA").Count > 0) ? UserData.GetElementsByTagName("NUMUSUA")[0].InnerText : ""; EmId = (UserData.GetElementsByTagName("NUMEMPL").Count > 0) ? UserData.GetElementsByTagName("NUMEMPL")[0].InnerText : ""; if (ViewState["userDesencriptado"].ToString().ToUpper().Contains("TVA")) { UsuarioTVA = "TVA" + NumUsua; } else if (ViewState["userDesencriptado"].ToString().ToUpper().Contains("PTV")) { UsuarioTVA = "PTV" + NumUsua; } else { UsuarioTVA = "TVA" + NumUsua; } } isUserName = true; ObtieneDatosUsuario(UserData); ViewState["Opcion"] = ""; } } else { return; txtContraseña.Text = ""; txtUsuario.Text = ""; } } catch (Exception ex) { EncuestasMoviles.Clases.Error.ManejadorErrores(ex, Session["UserName"].ToString(), Session["UserDomain"].ToString(), Session["userMachineName"].ToString(), Session["UserIP"].ToString(), "frmEncuestas", int.Parse(Session["numeroUsuario"].ToString())); } }
protected void btnLogin_Click(object sender, ImageClickEventArgs e) { xml = new XmlDocument(); DataSet ds = new DataSet(); string Pass_Desencriptado = ""; IPUsr = ObtenerIPCliente(); ViewState["IPUsr"] = IPUsr; Azteca.Utility.Security.Rijndael _ChyperRijndael = new Azteca.Utility.Security.Rijndael(); try { try { string ruta = _ChyperRijndael.Transmute(ConfigurationManager.AppSettings["LlavePrivada"], Azteca.Utility.Security.enmTransformType.intDecrypt); string Passphrase = ""; try { Passphrase = (string)Registry.LocalMachine.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt)).GetValue("passphrase"); } catch { //Esto es para Win 7 64 bits RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); localKey = localKey.OpenSubKey(_ChyperRijndael.Transmute(ConfigurationSettings.AppSettings["Registro"], Azteca.Utility.Security.enmTransformType.intDecrypt)); Passphrase = localKey.GetValue("passphrase").ToString(); localKey.Dispose(); } StreamReader stream = new StreamReader(PGPUtil.DesencriptarTexto(txtContraseña.Text, File.OpenRead(ruta), null, Passphrase.ToCharArray()).Datos); StreamReader streamUser = new StreamReader(PGPUtil.DesencriptarTexto(txtUsuario.Text, File.OpenRead(ruta), null, Passphrase.ToCharArray()).Datos); Pass_Desencriptado = stream.ReadToEnd(); userDesencriptado = streamUser.ReadToEnd(); ViewState["userDesencriptado"] = userDesencriptado; TipoUsuario = userDesencriptado.ToUpper().Replace("TVA", "").Replace("PTV", ""); ViewState["TipoUsuario"] = TipoUsuario; if (isNumeric(TipoUsuario)) { isUserName = false; UsuarioTVA = userDesencriptado.ToUpper(); usuario = userDesencriptado.ToUpper(); XmlDocument DatosUsua = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(TipoUsuario, ""); string NumUsua = (DatosUsua.GetElementsByTagName("NUMUSUA").Count > 0) ? DatosUsua.GetElementsByTagName("NUMUSUA")[0].InnerText : ""; EmId = (DatosUsua.GetElementsByTagName("NUMEMPL").Count > 0) ? DatosUsua.GetElementsByTagName("NUMEMPL")[0].InnerText : ""; if (userDesencriptado.ToUpper().Contains("TVA")) { UsuarioTVA = "TVA" + TipoUsuario; } else if (userDesencriptado.ToUpper().Contains("PTV")) { UsuarioTVA = "PTV" + TipoUsuario; } else { UsuarioTVA = "TVA" + TipoUsuario; } } else { isUserName = true; usuario = userDesencriptado.ToUpper(); XmlDocument DatosUsua = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado("", usuario); string NumUsua = (DatosUsua.GetElementsByTagName("NUMUSUA").Count > 0) ? DatosUsua.GetElementsByTagName("NUMUSUA")[0].InnerText : ""; EmId = (DatosUsua.GetElementsByTagName("NUMEMPL").Count > 0) ? DatosUsua.GetElementsByTagName("NUMEMPL")[0].InnerText : ""; if (userDesencriptado.ToUpper().Contains("TVA")) { UsuarioTVA = "TVA" + NumUsua; } else if (userDesencriptado.ToUpper().Contains("PTV")) { UsuarioTVA = "PTV" + NumUsua; } else { UsuarioTVA = "TVA" + NumUsua; } } //Primeras Validacion Tipo de Usuario (Red o TVA) IntentosXIP = MngNegocioBloqueoIP.ConsultaUltimoAccesos(); if (ValidaIP(IPUsr, IntentosXIP) >= 10) { string strMessage = string.Empty; strMessage += strMessage == string.Empty ? "" : "<br>"; strMessage += " * Su IP ha sido bloqueada"; strMessage += "<br>"; tdError.InnerHtml = strMessage; tdError.Visible = true; txtUsuario.Text = usuario; GuardaLogAcceso(8); return; } //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos UserBlock = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "1"); if (UserBlock.Count > 0) { //El Usuario ya ha sido bloqueado string strMessage = string.Empty; strMessage += " * El Usuario ha sido " + UserBlock[0].TipoBloqueo.DescTipoBloqueo; strMessage += "; Su cuenta se Desbloqueara Automaticamente en 10 Minutos"; txtUsuario.Text = usuario; txtError.InnerText = strMessage; GuardaLogAcceso(9); return; } string respuesta = string.Empty; #region Login LlaveMaestra.Service objServicio = new LlaveMaestra.Service(); //LDAPUser ldapUser = new LDAPUser(); string resp = ""; try { resp = objServicio.gsc_llave(userDesencriptado.ToUpper(), Pass_Desencriptado); } catch { } if (resp.Contains("[OK]")) { if (AutenticaUsuario.Validar("", userDesencriptado, Pass_Desencriptado)) { XmlDocument UserData = new XmlDocument(); if (isUserName) { UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado("", userDesencriptado); } else { string temp = resp; temp = temp.Substring(temp.IndexOf("NumEmp=")).Replace("NumEmp=", "").Substring(1); temp = temp.Substring(0, temp.IndexOf("\"")); UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(temp, ""); isUserName = true; } string NumEmpl = (UserData.GetElementsByTagName("NUMEMPL").Count > 0) ? UserData.GetElementsByTagName("NUMEMPL")[0].InnerText : ""; List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.ExisteSesionUsuario(Int32.Parse(NumEmpl)); if (existeSesion.Count > 0) { var listusr = (from Atributos in existeSesion orderby Atributos.IdSesion select Atributos).Take(1); foreach (var itemList in listusr) { ViewState["vsIdSesion"] = itemList.IdSesion; Session["IdSesion"] = itemList.IdSesion; } ViewState["vsIdUser"] = ""; ViewState["Opcion"] = "ContinuaSesion"; var sw = new StringWriter(); var xw = new XmlTextWriter(sw); UserData.WriteTo(xw); ViewState["vsUserdata"] = sw.ToString(); ViewState["vsIdUser"] = NumEmpl; ctrlMessageBox.AddMessage("Usted tiene una sesion abierta ¿Desea iniciar otra sesion en este equipo?", MessageBox.enmMessageType.Attention, true, true, "Sesion", "Valida Sesion Existente"); } else { THE_SesionUsuario ObjSession = new THE_SesionUsuario(); ObjSession.DirIP = IPUsr; ObjSession.FechaCreacion = DateTime.Now; ObjSession.EmplLlavPr = new THE_Empleado { EmpleadoLlavePrimaria = int.Parse(NumEmpl) }; MngNegocioUsuarioSesion.GuardaSesionUsuario(ObjSession); List <THE_SesionUsuario> SesionExist = MngNegocioUsuarioSesion.ExisteSesionUsuario(Int32.Parse(NumEmpl)); if (SesionExist.Count > 0) { var listu = (from Atributos in SesionExist orderby Atributos.IdSesion select Atributos).Take(1); foreach (var itemList in listu) { Session["IdSesion"] = itemList.IdSesion; } } ObtieneDatosUsuario(UserData); } } else { ValidaBloqueosErrorPass(); } } else { try { if (isNumeric(TipoUsuario)) { respuesta = Llave.validaEmpleado(userDesencriptado, Pass_Desencriptado); } else { respuesta = Llave.validaEmpleado(UsuarioTVA, Pass_Desencriptado); } xml.LoadXml(respuesta); } catch (Exception ex) { THE_LogError oLogErrores = new THE_LogError(); oLogErrores.EmplUsua = UsuarioTVA.Replace("TVA", "").Replace("PTV", ""); oLogErrores.DirIP = IPUsr; oLogErrores.Error = ex.Message + "\n" + ex.StackTrace.ToString(); oLogErrores.Pantalla = "Default.aspx"; oLogErrores.MachineName = ""; oLogErrores.FechaCreacion = DateTime.Now; oLogErrores.Dominio = Request.Url.Host.ToLower(); MngNegocioLogErrores.GuardarLogErrores(oLogErrores); } if ((respuesta.IndexOf("Respuesta=\"[OK]\"") != -1) || respuesta.IndexOf("0 - [") != -1) { //Aqui se debe de mandar a validar si el usuario esta bloqueado por Intentos fallidos IList <THE_BloqueoUsuario> UserBlockInactivo = MngNegocioBloqueoUsuario.ConsultaUsuarioBloqueadoXIdUsuario(usuario.ToUpper().ToString(), "2"); if (UserBlockInactivo.Count > 0) { //El Usuario ya ha sido bloqueado string strMessage = string.Empty; strMessage += strMessage == string.Empty ? "" : "<br>"; strMessage += " * El Usuario ha sido bloqueado por : " + UserBlockInactivo[0].TipoBloqueo.DescTipoBloqueo; strMessage += "<br>"; strMessage += "El bloqueo se quitará automáticamente después los 10 minutos"; ClientScript.RegisterStartupScript(Page.GetType(), "AlertBloqueoInactivo" + 3, "<script>alert('El Usuario ha sido bloqueado por " + UserBlock[0].TipoBloqueo.DescTipoBloqueo + ". Para desbloquearlo deberá realizar la solicitud en DATASEC');</script>"); tdError.InnerHtml = strMessage; tdError.Visible = true; txtUsuario.Text = usuario; GuardaLogAcceso(9); return; } tdError.Visible = false; tdError.InnerHtml = ""; string numeroUsuario = xml.FirstChild.ChildNodes[0].Attributes["NumEmp"].Value; XmlDocument UserData = MngNegocioEmpleadoRol.GetUserDataByNumEmpleado(numeroUsuario, ""); ObtieneDatosUsuario(UserData); } else { ValidaBloqueosErrorPass(); } } } catch (Exception ex) { THE_LogError oLogErrores = new THE_LogError(); oLogErrores.EmplUsua = UsuarioTVA.Replace("TVA", "").Replace("PTV", ""); oLogErrores.DirIP = IPUsr; oLogErrores.Error = ex.Message + "\n" + ex.StackTrace.ToString(); oLogErrores.Pantalla = "Default.aspx"; oLogErrores.MachineName = ""; oLogErrores.FechaCreacion = DateTime.Now; oLogErrores.Dominio = Request.Url.Host.ToLower(); MngNegocioLogErrores.GuardarLogErrores(oLogErrores); txtUsuario.Text = ""; GuardaLogAcceso(2); } } catch (Exception ex) { THE_LogError oLogErrores = new THE_LogError(); oLogErrores.EmplUsua = UsuarioTVA.Replace("TVA", "").Replace("PTV", ""); oLogErrores.DirIP = IPUsr; oLogErrores.Error = ex.Message + "\n" + ex.StackTrace.ToString(); oLogErrores.Pantalla = "Default.aspx"; oLogErrores.MachineName = ""; oLogErrores.FechaCreacion = DateTime.Now; oLogErrores.Dominio = Request.Url.Host.ToLower(); MngNegocioLogErrores.GuardarLogErrores(oLogErrores); } #endregion }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["UserName"] == null || Session["UserName"].ToString() == "") { Response.Redirect("~/Default.aspx"); } List <THE_SesionUsuario> existeSesion = MngNegocioUsuarioSesion.VerExisteSesionUsuario(Int32.Parse(Session["numeroUsuario"].ToString()), Session["UserIP"].ToString()); if (existeSesion.Count == 0) { return; } if (!IsPostBack) { using (MemoryStream myMemoryStream = new MemoryStream()) { Document document = new Document(iTextSharp.text.PageSize.LEGAL.Rotate()); PdfWriter PDFWriter = PdfWriter.GetInstance(document, myMemoryStream); string map = Server.MapPath("~/Images/Header.png"); iTextSharp.text.Image encabezado = iTextSharp.text.Image.GetInstance(map); encabezado.ScaleAbsoluteWidth(document.PageSize.Width - 70); encabezado.ScaleAbsoluteHeight(80); var mySize = document.PageSize; document.AddHeader("Content-Disposition", "attachment; filename=wissalReport.pdf"); document.Open(); int recorre = Convert.ToInt32(HttpContext.Current.Application.Get("contador").ToString()); for (int i = 0; i < recorre; i++) { Chunk chunk = new Chunk(DateTime.Now.ToString(), FontFactory.GetFont("ARIAL", 12, iTextSharp.text.Font.NORMAL)); document.Add(new Paragraph(chunk)); document.Add(encabezado); Byte[] imagebyte = Convert.FromBase64String(HttpContext.Current.Application.Get(i.ToString()).ToString()); iTextSharp.text.Image myImage = iTextSharp.text.Image.GetInstance(imagebyte); float wid = 700; float heg = 420; myImage.ScaleAbsolute(wid, heg); myImage.Alignment = Element.ALIGN_CENTER; document.Add(myImage); } document.Close(); byte[] content = myMemoryStream.ToArray(); HttpContext.Current.Response.Buffer = false; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=" + "my_report.pdf"); HttpContext.Current.Response.ContentType = "Application/pdf"; HttpContext.Current.Response.BinaryWrite(content); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } } }catch (Exception ms) { }finally{} }