public void ProcessRequest(HttpContext context) { string action = context.Request["action"]; context.Response.ContentType = "text/plain"; // context.Response.Write("Hello World"); string Id = ""; int res = 0;//返回结果行数 HttpReSultMode resultMode = new HttpReSultMode(); switch (action) { case "GetData": context.Response.Write(GetData(context)); context.Response.End(); break; case "ClickCount": //点击量 Id = FilterTools.FilterSpecial(context.Request["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "Clicks"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; case "PraiseCount": //点赞量加1 Id = FilterTools.FilterSpecial(context.Request["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "Praises"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; case "CallCount": //呼叫量加1 Id = FilterTools.FilterSpecial(context.Request["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "CallCount"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; } }
// 请求例子 /httpSever/TS_RepairShopHandler.ashx?json={"jsonEntity":{"Category":"06","CityCode":"4502","Longitude":"108.267898","Latitude":"22.847358"},"pageIndex":"1","pageSize":"20","action":"GetByCategory"} // 请求例子 /httpSever/TS_RepairShopHandler.ashx?json={"jsonEntity":{"Category":"06","KeyWords":"电车","Longitude":"110.22587","Latitude":"25.272585"},"pageIndex":"1","pageSize":"20","action":"SearhByKeyWords"} public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; // context.Response.Write("Hello World"); HttpReSultMode resultMode = new HttpReSultMode(); string Id = ""; int res = 0;//返回结果行数 try { JObject httpObject = JsonHelper.FromJson(context.Request["json"]); switch (httpObject["action"].ToString()) { case "GetByCategory": this.GetByCategory(context, httpObject, resultMode); break; case "GetById": #region Id = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Id"].ToString()); var mqlG = TS_RepairShopSet.SelectAll().Where(TS_RepairShopSet.Id.Equal(Id)); TS_RepairShop modelG = OPBiz.GetEntity(mqlG); if (modelG != null) { resultMode.Code = 11; resultMode.Msg = "获取成功"; resultMode.Data = JsonHelper.ToJson(modelG, true); } else { resultMode.Code = -13; resultMode.Msg = "数据不存在"; resultMode.Data = ""; } #endregion break; case "ClickCount": //点击量 Id = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "Clicks"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; case "PraiseCount": //点赞量加1 Id = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "Praises"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; case "CallCount": //呼叫量加1 Id = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Id"].ToString()); res = OPBiz.SetCout("Id", Id, "CallCount"); if (res > 0) { resultMode.Code = 11; resultMode.Data = res.ToString(); resultMode.Msg = "统计成功"; } else { resultMode.Code = -13; resultMode.Data = "0"; resultMode.Msg = "统计失败!"; } break; } } catch (Exception ex) { resultMode.Code = -11; resultMode.Data = ex.ToString(); } context.Response.Write(JsonHelper.ToJson(resultMode, true)); context.Response.End(); }