Guest User

Untitled

a guest
Feb 13th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. public void ProcessRequest(HttpContext context)
  2. {
  3.  
  4. SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cnVer"].ConnectionString);
  5.  
  6. try
  7. {
  8. if (context.Request["ref"] != null)
  9. {
  10. SqlCommand cmd = new SqlCommand("Estado_Referencia01", cn);
  11. cmd.CommandType = CommandType.StoredProcedure;
  12.  
  13. SqlDataReader lector;
  14.  
  15. cmd.Parameters.AddWithValue("@referencia", context.Request["ref"]);
  16.  
  17. cn.Open();
  18. lector = cmd.ExecuteReader();
  19. String[] fechas = new String[8];
  20. while (lector.Read())
  21. {
  22. fechas[0] = lector["creacion"].ToString();
  23. fechas[1] = lector["revalidacion"].ToString();
  24. fechas[2] = lector["previo"].ToString();
  25. fechas[3] = lector["fe.entrada"].ToString();
  26. fechas[4] = lector["fe.pago"].ToString();
  27. fechas[5] = lector["despacho"].ToString();
  28. fechas[6] = lector["cta.gtos"].ToString();
  29. fechas[7] = lector["liquidacion"].ToString();
  30. }
  31.  
  32. Image bm = new Bitmap(900, 50);
  33. Image[] a0 = new Bitmap[8];
  34. Graphics objGraphics = Graphics.FromImage(bm);
  35. int padding = 82;
  36. for (int i = 0; i < 8; i++)
  37. {
  38.  
  39. if (fechas[i] == "")
  40. a0[i] = new Bitmap(context.Server.MapPath("~") + "images\imagenesEdoReferencia\g" + i + ".png");
  41. else
  42. a0[i] = new Bitmap(context.Server.MapPath("~") + "images\imagenesEdoReferencia\c" + i + ".png");
  43.  
  44. objGraphics.DrawImage(a0[i], new Point(padding * i, 0));
  45. }
  46.  
  47.  
  48.  
  49. string ruta = Path.GetTempPath() + context.Request["ref"] + ".png";
  50. bm.Save(ruta);
  51.  
  52. context.Response.Clear();
  53. context.Response.ContentType = "image/png";
  54. context.Response.WriteFile(ruta);
  55. //context.Response.Close();
  56. }
  57. }
  58. catch (Exception ex)
  59. {
  60.  
  61. }
  62. finally
  63. {
  64. cn.Close();
  65. }
  66. }
  67.  
  68. public bool IsReusable
  69. {
  70. get
  71. {
  72. return false;
  73. }
  74. }
  75. }
Add Comment
Please, Sign In to add comment