Example #1
0
        public JsonResult GetInfo(string ID)
        {
            var           mql2   = TS_ClientUserSet.SelectAll().Where(TS_ClientUserSet.Id.Equal(ID));
            TS_ClientUser Rmodel = OPBiz.GetEntity(mql2);

            //  groupsBiz.Add(rol);
            return(MyJson(Rmodel, JsonRequestBehavior.AllowGet));
        }
        private void update(HttpContext context, JObject httpObject)
        {
            #region
            HttpReSultMode resultMode = new HttpReSultMode();
            TS_ClientUser  Rmodel2    = JsonHelper.FromJson <TS_ClientUser>(httpObject["jsonEntity"].ToString());

            var           Loginmql   = TS_ClientUserSet.SelectAll().Where(TS_ClientUserSet.Id.Equal(Rmodel2.Id));
            TS_ClientUser Loginmodel = OPBiz.GetEntity(Loginmql);

            Rmodel2.WhereExpression    = TS_ClientUserSet.Id.Equal(Rmodel2.Id);
            Rmodel2.UpdateTime         = DateTime.Now;
            Rmodel2.LocationUpdateTime = DateTime.Now;
            Rmodel2.isDeleted          = Loginmodel.isDeleted;;
            Rmodel2.isValid            = Loginmodel.isValid;
            Rmodel2.States             = Loginmodel.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);
            }

            if (OPBiz.Update(Rmodel2) > 0)
            {
                resultMode.Code = 11;
                resultMode.Msg  = "更新成功";
                resultMode.Data = "";
            }
            else
            {
                resultMode.Code = -13;
                resultMode.Msg  = "更新失败";
                resultMode.Data = "";
            }
            #endregion
            context.Response.Write(JsonHelper.ToJson(resultMode, true));
            context.Response.End();
        }
Example #3
0
        public JsonResult EditInfo(TS_ClientUser TS_ClientUserModle)
        {
            HttpReSultMode ReSultMode = new HttpReSultMode();

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

            bool IsAdd = false;

            if (TS_ClientUserModle.Details != null)
            {
                TS_ClientUserModle.Details = TS_ClientUserModle.Details.Replace("&lt", "<").Replace("&gt", ">");
            }
            else
            {
                TS_ClientUserModle.Details = "";
            }
            TS_ClientUserModle.UpdateTime = DateTime.Now;
            if (!(TS_ClientUserModle.Id != null && !TS_ClientUserModle.Id.ToString().Equals("00000000-0000-0000-0000-000000000000")))//id为空,是添加
            {
                IsAdd = true;
            }
            if (IsAdd)
            {
                TS_ClientUserModle.Category           = "";
                TS_ClientUserModle.isDeleted          = false;
                TS_ClientUserModle.isValid            = 1;
                TS_ClientUserModle.Id                 = Guid.NewGuid();
                TS_ClientUserModle.AddTime            = DateTime.Now;
                TS_ClientUserModle.LocationUpdateTime = DateTime.Now;
                try
                {
                    OPBiz.Add(TS_ClientUserModle);

                    ReSultMode.Code = 11;
                    ReSultMode.Data = TS_ClientUserModle.Id.ToString();
                    ReSultMode.Msg  = "添加成功";
                }
                catch (Exception e) {
                    ReSultMode.Code = -11;
                    ReSultMode.Data = e.ToString();
                    ReSultMode.Msg  = "添加失败";
                }
            }
            else
            {
                TS_ClientUserModle.WhereExpression = TS_ClientUserSet.Id.Equal(TS_ClientUserModle.Id);
                //TS_ClientUserModle.ChangedMap.Remove("doctorid");//移除主键值
                if (OPBiz.Update(TS_ClientUserModle) > 0)
                {
                    ReSultMode.Code = 11;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改成功";
                }
                else
                {
                    ReSultMode.Code = -13;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改失败";
                }
            }

            return(Json(ReSultMode, JsonRequestBehavior.AllowGet));
        }
        // 请求例子 /httpSever/TS_ClientUserHandler.ashx?json={"jsonEntity":{"UserName":"******","Pwd":"123456"},"action":"Login"}
        // 请求例子  /httpSever/TS_ClientUserHandler.ashx?json={"jsonEntity":{"UserName":"******","Pwd":"123456"},"action":"Register"}
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            // context.Response.Write("Hello World");
            HttpReSultMode resultMode = new HttpReSultMode();

            try
            {
                JObject httpObject = JsonHelper.FromJson(context.Request["json"]);
                // JObject ObjectParameter = (JObject)JsonConvert.DeserializeObject(httpObject["jsonEntity"].ObjToStr());
                string jsonData = httpObject["jsonEntity"].ToString();
                string UserName = "";
                string Pwd      = "";
                switch (httpObject["action"].ToString())
                {
                case "Register":

                    UserName = FilterTools.FilterSpecial(httpObject["jsonEntity"]["UserName"].ToString());
                    var           registermql   = TS_ClientUserSet.SelectAll().Where(TS_ClientUserSet.UserName.Equal(UserName));
                    TS_ClientUser registermodel = OPBiz.GetEntity(registermql);
                    if (registermodel != null)
                    {
                        resultMode.Code = -13;
                        resultMode.Msg  = "用户已经存在";
                        resultMode.Data = "";
                    }
                    else
                    {
                        TS_ClientUser Rmodel = JsonHelper.FromJson <TS_ClientUser>(jsonData);
                        Rmodel.Id                 = Guid.NewGuid();
                        Rmodel.AddTime            = DateTime.Now;
                        Rmodel.UpdateTime         = DateTime.Now;
                        Rmodel.LocationUpdateTime = DateTime.Now;
                        Rmodel.isDeleted          = false;
                        Rmodel.States             = 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();
                    }

                    break;

                case "Login":
                    UserName = FilterTools.FilterSpecial(httpObject["jsonEntity"]["UserName"].ToString());
                    Pwd      = httpObject["jsonEntity"]["Pwd"].ToString();
                    var           Loginmql   = TS_ClientUserSet.SelectAll().Where(TS_ClientUserSet.UserName.Equal(UserName).And(TS_ClientUserSet.Pwd.Equal(Pwd)));
                    TS_ClientUser Loginmodel = OPBiz.GetEntity(Loginmql);
                    if (Loginmodel != null)
                    {
                        resultMode.Code = 11;
                        resultMode.Msg  = "登录成功";
                        resultMode.Data = JsonHelper.ToJson(Loginmodel, true);
                    }
                    else
                    {
                        resultMode.Code = -13;
                        resultMode.Msg  = "用户或密码错误";
                        resultMode.Data = "";
                    }
                    break;

                case "ChangePassword":
                    UserName = FilterTools.FilterSpecial(httpObject["jsonEntity"]["UserName"].ToString());
                    Pwd      = httpObject["jsonEntity"]["Pwd"].ToString();
                    var           mqlG   = TS_ClientUserSet.SelectAll().Where(TS_ClientUserSet.UserName.Equal(UserName));
                    TS_ClientUser modelG = OPBiz.GetEntity(mqlG);
                    if (modelG != null)
                    {
                        modelG.Pwd             = Pwd;
                        modelG.UpdateTime      = DateTime.Now;
                        modelG.WhereExpression = TS_ClientUserSet.Id.Equal(modelG.Id);
                        if (OPBiz.Update(modelG) > 0)
                        {
                            resultMode.Code = 11;
                            resultMode.Msg  = "修改密码成功";
                            resultMode.Data = "";
                        }
                        else
                        {
                            resultMode.Code = -13;
                            resultMode.Msg  = "修改失败";
                            resultMode.Data = "";
                        }
                    }
                    else
                    {
                        resultMode.Code = -13;
                        resultMode.Msg  = "用户不存在";
                        resultMode.Data = "";
                    }


                    break;

                case "update":
                    this.update(context, httpObject);
                    break;
                }
            }
            catch (Exception ex)
            {
                resultMode.Code = -1;
                resultMode.Data = ex.ToString();
            }
            context.Response.Write(JsonHelper.ToJson(resultMode, true));
            context.Response.End();
        }