using NFine.Data.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
namespace NFine.Web
{
///
/// ChulingHandler 的摘要说明
///
public class ChulingHandler : IHttpHandler
{
///
/// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
///
protected string strPrintData;
///
/// 标识是否安装了控件
///
protected bool bIsInstallPrintControl = true;
///
/// 打印控件的Cookie值
///
protected string strPrintControlCookie = "";
public void ProcessRequest(HttpContext context)
{
string action = context.Request.Params["action"];
switch (action)
{
case "GetUrlPath":
GetUrlPath(context);
break;
}
}
public bool IsReusable
{
get
{
return false;
}
}
private string GetUrlPath(HttpContext context)
{
string strUrl = context.Request.Url.ToString();
int iEnd = strUrl.LastIndexOf("/");
strUrl = strUrl.Substring(0, iEnd + 1);
return strUrl;
}
///
/// 设置控件调用的Cookie值,判断是否安装了打印控件
///
///
private void SetCookieAndURL(HttpContext context, PrintJson pJson)
{
//bIsInstallPrintControl = false;
//strPrintControlCookie = "";
//HttpCookie pCookieInstall = context.Request.Cookies["InstallPrintControl"];
//if (pCookieInstall != null)
//{ //Cookie存在
// strPrintControlCookie = pCookieInstall.Value.ToString();
// //以Cookie值查找在数据表中是否存在
// string strSql = @"Select * From CheckInstall Where Cookie = @Cookie";
// SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
// using (SqlDataReader drCookie = SqlHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
// {
// if (drCookie.Read())
// { //标识为已经安装
// bIsInstallPrintControl = true;
// }
// drCookie.Close();
// }
// //更新Cookie的保存时间
// pCookieInstall.Expires = DateTime.Now.AddYears(10);
// context.Response.SetCookie(pCookieInstall);
//}
//else
//{//Cookie不存在,则新建Cookie
// strPrintControlCookie = System.Guid.NewGuid().ToString();
// pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
// pCookieInstall.Expires = DateTime.Now.AddYears(10);
// context.Response.Cookies.Add(pCookieInstall);
//}
//string strUrl = GetUrlPath(context) + "PrintCookie.aspx";
//pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
}
}
}