pubeditorSrv.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using SiteCore.ueditor;
  2. using System.Web;
  3. using System.Web.SessionState;
  4. namespace SiteCore.Handler
  5. {
  6. public class pubEditorSrv : BaseHandler, IHttpHandler, IRequiresSessionState
  7. {
  8. public void ProcessRequest(HttpContext context)
  9. {
  10. con = context;
  11. ueditor.Handler action = null;
  12. //if (con.Session["pubUserID"] == null || con.Session["pubUserID"].ToString() == "")
  13. //{
  14. // returnErrorMsg("请重新登录!");
  15. // return;
  16. //}
  17. switch (context.Request["action"])
  18. {
  19. case "config":
  20. action = new ConfigHandler(context);
  21. break;
  22. case "uploadimage":
  23. action = new UploadHandler(context, new UploadConfig()
  24. {
  25. AllowExtensions = Config.GetStringList("imageAllowFiles"),
  26. PathFormat = Config.GetString("imagePathFormat"),
  27. SizeLimit = Config.GetInt("imageMaxSize"),
  28. UploadFieldName = Config.GetString("imageFieldName")
  29. });
  30. //string err = "{\"originalName\":\"\",\"name\":\"\",\"url\":\"\",\"size\":\"0\",\"state\":\"没有上传文件\",\"type\":\"jpg\"}";
  31. //if (context.Request.Files.Count < 1)
  32. //{
  33. // context.Response.Write(err);
  34. // return;
  35. //}
  36. //string fn = CurrentUser.UserID + "_" + DateTime.Now.ToString("yyMMddHHmmss");
  37. //try
  38. //{
  39. // HttpPostedFile postFile = context.Request.Files[0];
  40. // if (postFile != null)
  41. // {
  42. // string errMsg = "";
  43. // if (!ImageHandler.CheckImage(postFile, out errMsg)) return;
  44. // string saveFile = Path.Combine(webConfig.umPicPath, fn + ".jpg");
  45. // string result = "";
  46. // using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream))
  47. // {
  48. // result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 800, "", 9, 3);
  49. // }
  50. // context.Response.Write("{\"originalName\":\"" + postFile.FileName + "\",\"name\":\"" + fn + ".jpg\",\"url\":\"" + fn + ".jpg\",\"size\":\"0\",\"state\":\"SUCCESS\",\"type\":\"jpg\"}");
  51. // return;
  52. // }
  53. //}
  54. //catch
  55. //{
  56. // context.Response.Write("{\"originalName\":\"\",\"name\":\"\",\"url\":\"上传成功!\",\"size\":\"0\",\"state\":\"图片上专失败\",\"type\":\"jpg\"}");
  57. // return;
  58. //}
  59. break;
  60. case "uploadscrawl":
  61. action = new UploadHandler(context, new UploadConfig()
  62. {
  63. AllowExtensions = new string[] { ".png" },
  64. PathFormat = Config.GetString("scrawlPathFormat"),
  65. SizeLimit = Config.GetInt("scrawlMaxSize"),
  66. UploadFieldName = Config.GetString("scrawlFieldName"),
  67. Base64 = true,
  68. Base64Filename = "scrawl.png"
  69. });
  70. break;
  71. case "uploadvideo":
  72. action = new UploadHandler(context, new UploadConfig()
  73. {
  74. AllowExtensions = Config.GetStringList("videoAllowFiles"),
  75. PathFormat = Config.GetString("videoPathFormat"),
  76. SizeLimit = Config.GetInt("videoMaxSize"),
  77. UploadFieldName = Config.GetString("videoFieldName")
  78. });
  79. break;
  80. case "uploadfile":
  81. action = new UploadHandler(context, new UploadConfig()
  82. {
  83. AllowExtensions = Config.GetStringList("fileAllowFiles"),
  84. PathFormat = Config.GetString("filePathFormat"),
  85. SizeLimit = Config.GetInt("fileMaxSize"),
  86. UploadFieldName = Config.GetString("fileFieldName")
  87. });
  88. break;
  89. case "listimage":
  90. action = new ListFileManager(context, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
  91. break;
  92. case "listfile":
  93. action = new ListFileManager(context, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
  94. break;
  95. case "catchimage":
  96. action = new CrawlerHandler(context);
  97. break;
  98. default:
  99. action = new NotSupportedHandler(context);
  100. break;
  101. }
  102. action.Process();
  103. }
  104. }
  105. }