| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using BizCom;
- using SQLData;
- using StackExchange.Redis;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web;
- using System.Web.SessionState;
- using Utils;
- using Utils.ImageUtils;
- using Utils.Serialization;
- namespace SiteCore.Handler
- {
- public partial class app : BaseHandler, IHttpHandler, IRequiresSessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- if (UrlParmsCheck("t"))
- {
- String tname = GetString("t");
- MethodInfo method;
- Type type = this.GetType();
- method = type.GetMethod(tname);
- con = context;
- if (method == null)
- {
- conError("服务器返回错误");
- return;
- }
- successFlag = false;
- context.Response.ContentType = "application/json";
- context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
- try
- {
- method.Invoke(this, null);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, ex.Message, ex);
- conError("服务器返回错误");
- }
- finally
- {
- //AfterInvoke(methodName);
- }
- //if (!successFlag) returnErrorMsg("服务器返回错误");
- }
- }
- public UserObj GetUserEntity()
- {
- string session_id = con.Request.Headers["session-id"];
- if (string.IsNullOrEmpty(session_id))
- {
- conLoginError("未授权登录");
- return null;
- }
- try
- {
- RedisValue re = (RedisValue)RedisHelper.StringGet(session_id);
- if (re.IsNull)
- {
- conLoginError("请重新登录");
- return null;
- }
- UserObj uo = JSON.ToObject<UserObj>(re.ToString());
- return uo;
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0,"GetUserEntity:" + ex.Message);
- conLoginError("请重新登录");
- return null;
- }
- }
- public void get_android_update()
- {
- DataTable dt = WebCache.GetAppVer();
- DataView dv = new DataView(dt);
- dv.RowFilter = "appname='a_huoyi'";
- if (dv.Count > 0)
- {
- conSuccess(dv[0]["appver"].ToString()+"|"+dv[0]["downfile"]);
- return;
- }
- conSuccess("0.0");
- }
- public void get_weixinver()
- {
- string ps = GetPostString("ps");
- DataTable dt = WebCache.GeWeixinVer(ps);
- conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt));
- }
- public void save_formids()
- {
- int uid = getDecodeInt("uid");
- if (uid == 0)
- {
- conError("找不到会员");
- return;
- }
- if (UrlPostParmsCheck("formids"))
- {
- DataTable dt = WebCache.FormTable;
- if (dt != null && dt.Rows.Count > 0)
- {
- DataView dv = new DataView(dt);
- dv.RowFilter = "userid=" + uid;
- if (dv.Count > 0 && Convert.ToInt32(dv[0]["fc"]) >= 20)
- {
- conSuccess("2");
- return;
- }
- }
- string[] fArr = GetPostString("formids").Split(',');
- StringBuilder sql = new StringBuilder();
- for (int i = 0; i < fArr.Length; i++)
- {
- if (fArr[i] == "") continue;
- //sql.AppendFormat("if (select count(0) from s_wxformid where userid={0}) begin ")
- sql.AppendFormat("insert into S_WxFormId(userid,FormIds,addtime)values({0},'{1}',getdate()) ", uid, fArr[i]);
- //sql.Append("end");
- }
- if (sql.Length > 0)
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- conSuccess("1");
- return;
- }
- conError("错误的参数");
- }
- }
- }
|