app.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using BizCom;
  2. using SQLData;
  3. using StackExchange.Redis;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Web;
  13. using System.Web.SessionState;
  14. using Utils;
  15. using Utils.ImageUtils;
  16. using Utils.Serialization;
  17. namespace SiteCore.Handler
  18. {
  19. public partial class app : BaseHandler, IHttpHandler, IRequiresSessionState
  20. {
  21. public void ProcessRequest(HttpContext context)
  22. {
  23. if (UrlParmsCheck("t"))
  24. {
  25. String tname = GetString("t");
  26. MethodInfo method;
  27. Type type = this.GetType();
  28. method = type.GetMethod(tname);
  29. con = context;
  30. if (method == null)
  31. {
  32. conError("服务器返回错误");
  33. return;
  34. }
  35. successFlag = false;
  36. context.Response.ContentType = "application/json";
  37. context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
  38. try
  39. {
  40. method.Invoke(this, null);
  41. }
  42. catch (Exception ex)
  43. {
  44. XLog.SaveLog(0, ex.Message, ex);
  45. conError("服务器返回错误");
  46. }
  47. finally
  48. {
  49. //AfterInvoke(methodName);
  50. }
  51. //if (!successFlag) returnErrorMsg("服务器返回错误");
  52. }
  53. }
  54. public UserObj GetUserEntity()
  55. {
  56. string session_id = con.Request.Headers["session-id"];
  57. if (string.IsNullOrEmpty(session_id))
  58. {
  59. conLoginError("未授权登录");
  60. return null;
  61. }
  62. try
  63. {
  64. RedisValue re = (RedisValue)RedisHelper.StringGet(session_id);
  65. if (re.IsNull)
  66. {
  67. conLoginError("请重新登录");
  68. return null;
  69. }
  70. UserObj uo = JSON.ToObject<UserObj>(re.ToString());
  71. return uo;
  72. }
  73. catch (Exception ex)
  74. {
  75. XLog.SaveLog(0,"GetUserEntity:" + ex.Message);
  76. conLoginError("请重新登录");
  77. return null;
  78. }
  79. }
  80. public void get_android_update()
  81. {
  82. DataTable dt = WebCache.GetAppVer();
  83. DataView dv = new DataView(dt);
  84. dv.RowFilter = "appname='a_huoyi'";
  85. if (dv.Count > 0)
  86. {
  87. conSuccess(dv[0]["appver"].ToString()+"|"+dv[0]["downfile"]);
  88. return;
  89. }
  90. conSuccess("0.0");
  91. }
  92. public void get_weixinver()
  93. {
  94. string ps = GetPostString("ps");
  95. DataTable dt = WebCache.GeWeixinVer(ps);
  96. conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
  97. }
  98. public void save_formids()
  99. {
  100. int uid = getDecodeInt("uid");
  101. if (uid == 0)
  102. {
  103. conError("找不到会员");
  104. return;
  105. }
  106. if (UrlPostParmsCheck("formids"))
  107. {
  108. DataTable dt = WebCache.FormTable;
  109. if (dt != null && dt.Rows.Count > 0)
  110. {
  111. DataView dv = new DataView(dt);
  112. dv.RowFilter = "userid=" + uid;
  113. if (dv.Count > 0 && Convert.ToInt32(dv[0]["fc"]) >= 20)
  114. {
  115. conSuccess("2");
  116. return;
  117. }
  118. }
  119. string[] fArr = GetPostString("formids").Split(',');
  120. StringBuilder sql = new StringBuilder();
  121. for (int i = 0; i < fArr.Length; i++)
  122. {
  123. if (fArr[i] == "") continue;
  124. //sql.AppendFormat("if (select count(0) from s_wxformid where userid={0}) begin ")
  125. sql.AppendFormat("insert into S_WxFormId(userid,FormIds,addtime)values({0},'{1}',getdate()) ", uid, fArr[i]);
  126. //sql.Append("end");
  127. }
  128. if (sql.Length > 0)
  129. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  130. conSuccess("1");
  131. return;
  132. }
  133. conError("错误的参数");
  134. }
  135. }
  136. }