1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| protected void IbLinkToDoc_Click(object sender, ImageClickEventArgs e)
{
iddocument = Session["ag"].ToString();
Session["rf"] = getMd5Hash(Session["ci"].ToString());
Session["dl"] = String.Format("http://www.monsite.com/lcsubscription/consultation.aspx?d={0}&s={1}&r={2}&m={3}", Session["dt"].ToString(), Session["s"].ToString(), Session["rf"].ToString(), Session["ml"].ToString());
string docurl = null;
string proxdir = @"D:\xxxxx\";
string ecgsdir = @"D:\yyyyyy\";
string girdir = @"D:\zzzzzz\";
string docdir = "";
string doc = "";
switch (Session["tp"].ToString())
{
case "gir":
doc = "ECG" + iddocument + ".PDF";
docdir = girdir;
break;
case "ecgs":
doc = "ECG" + iddocument + ".PDF";
docdir = ecgsdir;
break;
default:
doc = "ASF" + iddocument + ".PDF";
docdir = proxdir;
break;
}
docurl = docdir + doc;
FileStream MyFileStream = new FileStream(docurl, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= " + doc);
Response.BinaryWrite(Buffer);
if (!Tablesendmail.Visible && !TableForward.Visible)
{
Tablesendmail.Visible = true;
TableForward.Visible = true;
Response.Redirect(Session["dl"].ToString());
}
} |
Partager