Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Configuration;
- using System.IO;
- namespace MOZO.WS
- {
- /// <summary>
- /// Descripción breve de WsEstadoReferencia
- /// </summary>
- public class WsEstadoReferencia : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cnVer"].ConnectionString);
- try
- {
- if (context.Request["ref"] != null)
- {
- SqlCommand cmd = new SqlCommand("Estado_Referencia01", cn);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlDataReader lector;
- cmd.Parameters.AddWithValue("@referencia", context.Request["ref"]);
- cn.Open();
- lector = cmd.ExecuteReader();
- String[] fechas = new String[8];
- while (lector.Read())
- {
- fechas[0] = lector["creacion"].ToString();
- fechas[1] = lector["revalidacion"].ToString();
- fechas[2] = lector["previo"].ToString();
- fechas[3] = lector["fe.entrada"].ToString();
- fechas[4] = lector["fe.pago"].ToString();
- fechas[5] = lector["despacho"].ToString();
- fechas[6] = lector["cta.gtos"].ToString();
- fechas[7] = lector["liquidacion"].ToString();
- }
- Image bm = new Bitmap(900, 50);
- Image[] a0 = new Bitmap[8];
- Graphics objGraphics = Graphics.FromImage(bm);
- int padding = 82;
- for (int i = 0; i < 8; i++)
- {
- if (fechas[i] == "")
- a0[i] = new Bitmap(context.Server.MapPath("~") + "images\imagenesEdoReferencia\g" + i + ".png");
- else
- a0[i] = new Bitmap(context.Server.MapPath("~") + "images\imagenesEdoReferencia\c" + i + ".png");
- objGraphics.DrawImage(a0[i], new Point(padding * i, 0));
- }
- string ruta = Path.GetTempPath() + context.Request["ref"] + ".png";
- bm.Save(ruta);
- context.Response.Clear();
- context.Response.ContentType = "image/png";
- context.Response.WriteFile(ruta);
- //context.Response.Close();
- }
- }
- catch (Exception ex) { }
- finally
- {
- cn.Close();
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment