GetAjaxData.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Web;
  5. using TP.BizCom;
  6. namespace TP.WebCore.Handler
  7. {
  8. public class GetAjaxData : BaseHandler, IHttpHandler
  9. {
  10. public void ProcessRequest(HttpContext context)
  11. {
  12. context.Response.ContentType = "application/jason";
  13. string msg = "";
  14. if (CurrentUser == null)
  15. {
  16. ReturnLoginMsg("请先登录!");
  17. return;
  18. }
  19. if (UrlParmsCheck("pType"))
  20. {
  21. string pType = GetString("pType").ToLower();
  22. try
  23. {
  24. switch (pType)
  25. {
  26. case "hotarea":
  27. {
  28. if (UrlParmsCheck("code"))
  29. {
  30. string code=GetString("code");
  31. IList<DicItem> list = WebCache.GetHotArea(code);
  32. if (list.Count > 0)
  33. {
  34. StringBuilder str = new StringBuilder();
  35. foreach (DicItem item in list)
  36. {
  37. str.Append("{");
  38. str.AppendFormat("\"ID\":\"{0}\",\"Code\":\"{1}\",\"Name\":\"{2}\"", item.ID, item.Code, item.Name);
  39. str.Append("},");
  40. }
  41. returnSuccess("[" + str.ToString().TrimEnd(',') + "]");
  42. return;
  43. }
  44. returnSuccess("[]");
  45. }
  46. break;
  47. }
  48. }
  49. if (successFlag) return;
  50. }
  51. catch (Exception ex)
  52. {
  53. SyLog.WriteLog(ex);
  54. }
  55. }
  56. returnErrorMsg(msg);
  57. }
  58. }
  59. }