using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DomainObjects;
using System.Drawing;
using Entities;
using System.IO;
public partial class DisplayVenueImage : System.Web.UI.Page
{
// joey
"Page_Load" #region "Page_Load"
protected void Page_Load( object sender, EventArgs e)
{
if (Session[ " UserSession " ] != null )
{
UserSession us = (UserSession)Session[ " UserSession " ];
if ( ! us.SecurityCheck(us, ( int )PermissionIdentity.UserPermission.Add_Venue))
{
Response.Redirect( " UserDetails.aspx " , true );
}
}
else
{
Response.Redirect( " BobsleighLogin.aspx " , true );
}
try
{
System.Web.HttpContext.Current.Response.ContentType = " image/jpeg " ;
int venueID = Convert.ToInt32( this .Request.QueryString[ " VenueID " ]);
byte [] bytes = ((VenueImage)( new VenueImageDO()).retrieveVenueImage(venueID)[ 0 ]).Image;
System.Drawing.Image image = System.Drawing.Image.FromStream( new System.IO.MemoryStream(bytes));
image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch
{
FileStream fs = new FileStream(Server.MapPath( " Images/noImage.gif " ), FileMode.Open, FileAccess.Read);
byte [] errorImage = new byte [fs.Length];
fs.Read(errorImage, 0 , Convert.ToInt32(fs.Length));
Response.Clear();
Response.OutputStream.Write(errorImage, 0 , errorImage.Length);
fs.Close();
}
finally
{
Response.End();
}
}
#endregion
// end
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using Entities;
using DAO;
using DomainObjects;
public partial class FileDownload : System.Web.UI.Page
{
// joey
"Page_Load" #region "Page_Load"
protected void Page_Load( object sender, EventArgs e)
{
if (Session[ " UserSession " ] != null )
{
UserSession us = (UserSession)Session[ " UserSession " ];
if ( ! us.SecurityCheck(us, ( int )PermissionIdentity.UserPermission.Add_Results))
{
Response.Redirect( " UserDetails.aspx " , true );
}
}
else
{
Response.Redirect( " BobsleighLogin.aspx " , true );
}
try
{
int VideoID = Convert.ToInt32( this .Request.QueryString[ " VideoID " ]);
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings[ " ConnectionInfo " ].ConnectionString;
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = " select * from resultvideo where videoid=@VideoID " ;
comm.Parameters.AddWithValue( " @VideoID " , VideoID);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
DataTable dt = new DataTable();
da.Fill(dt);
string path = Server.MapPath( " ~ " ) + " \\ " + ConfigurationManager.AppSettings[ " VideoFolder " ] + dt.Rows[ 0 ][ " VideoName " ].ToString() + dt.Rows[ 0 ][ " VideoID " ].ToString() + dt.Rows[ 0 ][ " Extension " ].ToString();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
byte [] file = new byte [fs.Length];
fs.Read(file, 0 , Convert.ToInt32(fs.Length));
Response.ClearHeaders();
Response.Clear();
Response.OutputStream.Write(file, 0 , file.Length);
fs.Close();
string disheader = " attachment; filename=\ "" + dt.Rows[0][ " VideoName " ].ToString() + dt.Rows[0][ " VideoID " ].ToString() + dt.Rows[0][ " Extension " ].ToString() + " \ "" ;
System.Web.HttpContext.Current.Response.AppendHeader( " Content-Disposition " , disheader);
conn.Close();
}
catch
{
}
finally
{
Response.End();
}
}
#endregion
// end
}
posted @
2008-03-27 22:23
N/A2011
阅读(
320 )
评论()
编辑
收藏
举报