Guest User

Untitled

a guest
Dec 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. using System;
  2. using System.Threading.Tasks;
  3. using Microsoft.Owin;
  4. using Owin;
  5.  
  6. [assembly: OwinStartup(typeof(MvcMasterPrueba.Startup))]
  7.  
  8. namespace MvcMasterPrueba
  9. {
  10. public class Startup
  11. {
  12. public void Configuration(IAppBuilder app)
  13. {
  14. //ConfigureAuth(app);
  15. app.MapSignalR();
  16. }
  17. }
  18. }
  19.  
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Linq;
  23. using System.Web;
  24. using Microsoft.AspNet.SignalR;
  25.  
  26. namespace MvcMasterPrueba
  27. {
  28. public class MyHub : Hub
  29. {
  30. public void Send(string name, string message)
  31. {
  32. Clients.All.broadcastMessage(name, message);
  33. }
  34.  
  35. public void BroadcastMessageToAll(string nombreImpresora, String divHTML)
  36. {
  37. //Clients.All.newMessageReceived(message);
  38. Clients.All.imprimeDiv(nombreImpresora, divHTML);
  39.  
  40. }
  41. public void BroadcastMessageToPrinter(string nombreImpresora, String divHTML)
  42. {
  43. Clients.All.imprimeDiv(nombreImpresora, divHTML);
  44. }
  45.  
  46. public void JoinAGroup(string group)
  47. {
  48. Groups.Add(Context.ConnectionId, group);
  49. }
  50.  
  51. public void RemoveFromAGroup(string group)
  52. {
  53. Groups.Remove(Context.ConnectionId, group);
  54. }
  55.  
  56. }
  57. }
  58.  
  59. public ActionResult Acceder(string User, string Pass)
  60. {
  61. string estado = "0";
  62. string ip = "";
  63. string db = "";
  64. string user = "";
  65. string pass = "";
  66. string password = "";
  67. string sql = "SELECT ip,db,user,CONVERT(AES_DECRYPT(`pass`,'1234444444') USING UTF8) AS pass,password " +
  68. "FROM usuarios " +
  69. "WHERE email='" + User + "' and password='" + Pass + "' limit 1";
  70. conexion.conectar();
  71. MySqlDataAdapter datos = new MySqlDataAdapter(sql, conexion.conlogin);
  72. conexion.cerrar();
  73. DataTable dt = new DataTable();
  74. datos.Fill(dt);
  75. foreach (DataRow row in dt.Rows)
  76. {
  77. ip = row[0].ToString();
  78. db = row[1].ToString();
  79. user = row[2].ToString();
  80. pass = row[3].ToString();
  81. password = row[4].ToString();
  82. }
  83. if (Pass == password)
  84. {
  85. Session["Session_User"] = User;
  86. Session["ip"] = ip;
  87. Session["db"] = db;
  88. Session["user"] = user;
  89. Session["pass"] = pass;
  90. estado = "1";
  91. Session["ss_nro_caja"] = obtieneNroCaja();
  92. }
  93. switch (estado)
  94. {
  95. case "0":
  96. ViewData["Mensaje"] = "Usuario o Password invalido..!!";
  97. return View("Login");
  98. case "1":
  99. FormsAuthentication.SetAuthCookie(User, false);
  100. return RedirectToAction("Home", "Acceso");
  101. default:
  102. return View("Login");
  103. }
  104. }
  105.  
  106. case "1":
  107. FormsAuthentication.SetAuthCookie(User, false);
  108. return RedirectToAction("Principal", "Acceso");
Add Comment
Please, Sign In to add comment