You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.3 KiB

  1. using NFine.Data.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Web;
  8. namespace NFine.Web
  9. {
  10. /// <summary>
  11. /// ChulingHandler 的摘要说明
  12. /// </summary>
  13. public class ChulingHandler : IHttpHandler
  14. {
  15. /// <summary>
  16. /// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
  17. /// </summary>
  18. protected string strPrintData;
  19. /// <summary>
  20. /// 标识是否安装了控件
  21. /// </summary>
  22. protected bool bIsInstallPrintControl = true;
  23. /// <summary>
  24. /// 打印控件的Cookie值
  25. /// </summary>
  26. protected string strPrintControlCookie = "";
  27. public void ProcessRequest(HttpContext context)
  28. {
  29. string action = context.Request.Params["action"];
  30. switch (action)
  31. {
  32. case "GetUrlPath":
  33. GetUrlPath(context);
  34. break;
  35. }
  36. }
  37. public bool IsReusable
  38. {
  39. get
  40. {
  41. return false;
  42. }
  43. }
  44. private string GetUrlPath(HttpContext context)
  45. {
  46. string strUrl = context.Request.Url.ToString();
  47. int iEnd = strUrl.LastIndexOf("/");
  48. strUrl = strUrl.Substring(0, iEnd + 1);
  49. return strUrl;
  50. }
  51. /// <summary>
  52. /// 设置控件调用的Cookie值,判断是否安装了打印控件
  53. /// </summary>
  54. /// <param name="pJson"></param>
  55. private void SetCookieAndURL(HttpContext context, PrintJson pJson)
  56. {
  57. //bIsInstallPrintControl = false;
  58. //strPrintControlCookie = "";
  59. //HttpCookie pCookieInstall = context.Request.Cookies["InstallPrintControl"];
  60. //if (pCookieInstall != null)
  61. //{ //Cookie存在
  62. // strPrintControlCookie = pCookieInstall.Value.ToString();
  63. // //以Cookie值查找在数据表中是否存在
  64. // string strSql = @"Select * From CheckInstall Where Cookie = @Cookie";
  65. // SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
  66. // using (SqlDataReader drCookie = SqlHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
  67. // {
  68. // if (drCookie.Read())
  69. // { //标识为已经安装
  70. // bIsInstallPrintControl = true;
  71. // }
  72. // drCookie.Close();
  73. // }
  74. // //更新Cookie的保存时间
  75. // pCookieInstall.Expires = DateTime.Now.AddYears(10);
  76. // context.Response.SetCookie(pCookieInstall);
  77. //}
  78. //else
  79. //{//Cookie不存在,则新建Cookie
  80. // strPrintControlCookie = System.Guid.NewGuid().ToString();
  81. // pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
  82. // pCookieInstall.Expires = DateTime.Now.AddYears(10);
  83. // context.Response.Cookies.Add(pCookieInstall);
  84. //}
  85. //string strUrl = GetUrlPath(context) + "PrintCookie.aspx";
  86. //pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
  87. }
  88. }
  89. }