public JsonResult GetInfo(string ID)
        {
            var            mql2   = TS_TransactionSet.SelectAll().Where(TS_TransactionSet.Id.Equal(ID));
            TS_Transaction Rmodel = OPBiz.GetEntity(mql2);

            //  groupsBiz.Add(rol);
            return(MyJson(Rmodel, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        // 请求例子  /httpSever/TS_TransactionHandler.ashx?json={"jsonEntity":{"Category":"09","Longitude":"110.22587","Latitude":"25.272585"},"pageIndex":"1","pageSize":"20","action":"GetByCategory"}
        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 "GetById":
                    #region
                    Id = FilterTools.FilterSpecial(httpObject["jsonEntity"]["Id"].ToString());
                    var            mqlG   = TS_TransactionSet.SelectAll().Where(TS_TransactionSet.Id.Equal(Id));
                    TS_Transaction 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 "GetByCategory":
                    this.GetByCategory(context, httpObject, resultMode);
                    break;

                case "add":
                    #region
                    TS_Transaction Rmodel = JsonHelper.FromJson <TS_Transaction>(httpObject["jsonEntity"].ToString());
                    Rmodel.Id         = Guid.NewGuid();
                    Rmodel.CreateTime = DateTime.Now;
                    Rmodel.CreateTime = DateTime.Now;
                    Rmodel.isDeleted  = false;
                    Rmodel.isValid    = 1;
                    Rmodel.Clicks     = 0;
                    Rmodel.Praises    = 0;
                    Rmodel.CallCount  = 0;
                    Rmodel.States     = 0;
                    Rmodel.isTop      = 0;

                    if (Rmodel.Longitude != null && Rmodel.Latitude != null)    //geohash编码
                    {
                        double Latitude  = double.Parse(Rmodel.Latitude.ToString());
                        double Longitude = double.Parse(Rmodel.Longitude.ToString());
                        Rmodel.geohash = Geohash.Encode(Latitude, Longitude);
                    }


                    OPBiz.Add(Rmodel);
                    resultMode.Code = 11;
                    resultMode.Msg  = "添加成功";
                    resultMode.Data = Rmodel.Id.ToString();

                    #endregion
                    break;

                case "update":
                    #region
                    TS_Transaction Rmodel2 = JsonHelper.FromJson <TS_Transaction>(httpObject["jsonEntity"].ToString());
                    var            mqlu    = TS_TransactionSet.SelectAll().Where(TS_TransactionSet.Id.Equal(Rmodel2.Id));
                    TS_Transaction modelu  = OPBiz.GetEntity(mqlu);
                    Rmodel2.CreateTime = modelu.CreateTime;
                    Rmodel2.CreateTime = DateTime.Now;
                    Rmodel2.isDeleted  = modelu.isDeleted;
                    Rmodel2.isValid    = modelu.isValid;
                    Rmodel2.Clicks     = modelu.Clicks;
                    Rmodel2.Praises    = modelu.Praises;
                    Rmodel2.CallCount  = modelu.CallCount;
                    Rmodel2.States     = modelu.States;

                    if (Rmodel2.Longitude != null && Rmodel2.Latitude != null)    //geohash编码
                    {
                        double Latitude  = double.Parse(Rmodel2.Latitude.ToString());
                        double Longitude = double.Parse(Rmodel2.Longitude.ToString());
                        Rmodel2.geohash = Geohash.Encode(Latitude, Longitude);
                    }


                    Rmodel2.WhereExpression = TS_TransactionSet.Id.Equal(Rmodel2.Id);
                    Rmodel2.UpdateTime      = DateTime.Now;
                    if (OPBiz.Update(Rmodel2) > 0)
                    {
                        resultMode.Code = 11;
                        resultMode.Msg  = "更新成功";
                        resultMode.Data = "";
                    }
                    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();
        }