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;
![](/Images/OutliningIndicators/None.gif)
public partial class DisplayVenueImage : System.Web.UI.Page
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
//joey
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"Page_Load"#region "Page_Load"
protected void Page_Load(object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (Session["UserSession"] != null)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
UserSession us = (UserSession)Session["UserSession"];
if (!us.SecurityCheck(us, (int)PermissionIdentity.UserPermission.Add_Venue))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("UserDetails.aspx", true);
}
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("BobsleighLogin.aspx", true);
}
try
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
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
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
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
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.End();
}
}
#endregion
//end
}
![](/Images/OutliningIndicators/None.gif)
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;
![](/Images/OutliningIndicators/None.gif)
public partial class FileDownload : System.Web.UI.Page
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
//joey
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"Page_Load"#region "Page_Load"
protected void Page_Load(object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (Session["UserSession"] != null)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
UserSession us = (UserSession)Session["UserSession"];
if (!us.SecurityCheck(us, (int)PermissionIdentity.UserPermission.Add_Results))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("UserDetails.aspx", true);
}
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("BobsleighLogin.aspx", true);
}
try
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
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
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
finally
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.End();
}
}
#endregion
//end
}
![](/Images/OutliningIndicators/None.gif)
posted @
2008-03-27 22:23
N/A2011
阅读(
320)
评论()
编辑
收藏
举报