Guest User

Untitled

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