56 lines
No EOL
1.9 KiB
C#
56 lines
No EOL
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace safety
|
|
{
|
|
/// <summary>
|
|
/// Summary description for photo
|
|
/// </summary>
|
|
public class BerichtImg : IHttpHandler
|
|
{
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
int MessageID = 0;
|
|
if (context.Request.Params["MessageID"] != null && int.TryParse(context.Request.Params["MessageID"].ToString(), out MessageID) && MessageID > 0)
|
|
{
|
|
System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["BerichtConnectionString"].ConnectionString);
|
|
System.Data.SqlClient.SqlCommand cm = new System.Data.SqlClient.SqlCommand("GetImage", cn);
|
|
cm.CommandType = System.Data.CommandType.StoredProcedure;
|
|
cm.Parameters.AddWithValue("@id", MessageID);
|
|
cm.Parameters.AddWithValue("@lang", "nl");
|
|
|
|
cn.Open();
|
|
try
|
|
{
|
|
System.Data.SqlClient.SqlDataReader r = cm.ExecuteReader(System.Data.CommandBehavior.CloseConnection | System.Data.CommandBehavior.SingleResult | System.Data.CommandBehavior.SingleRow);
|
|
if (r != null && r.Read())
|
|
{
|
|
Byte[] bytChunk = (byte[])r["Message"];
|
|
context.Response.ContentType = "image/jpeg";
|
|
context.Response.BinaryWrite(bytChunk);
|
|
}
|
|
else
|
|
context.Response.Redirect("images/no-photo.gif");
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
cn.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |