コード例 #1
0
        private void downUserData(JObject ReqJo, JObject Rep)
        {
            XingshenUser xu = XingshenUser.GetModelByUserName(ReqJo["user"].ToString());

            if (xu.id != 0 && xu.isHold)
            {
                Dictionary <string, string> headers = new Dictionary <string, string>();
                string dataStr = svrHelper.Create_first_login(xu.isAndroid, ReqJo["user"].ToString(), ReqJo["pass"].ToString(), ref headers);
                Rep["data"] = dataStr;
                JArray head = new JArray();
                foreach (var item in headers)
                {
                    JObject ar = new JObject();
                    ar["k"] = item.Key;
                    ar["v"] = item.Value;
                    head.Add(ar);
                }
                Rep["head"] = head;
                Rep["hold"] = true;
                xu.isHold   = false;
                xu.Update();
            }
            Rep["ok"] = true;
        }
コード例 #2
0
        public static JObject newUser(string JsonStr, JObject Rep)
        {
            JObject jo = null;

            try
            {
                jo = (JObject)JsonConvert.DeserializeObject(JsonStr);
            }
            catch (Exception exx)
            {
                Rep["msg"] = exx.Message;
                return(Rep);
            }
            XingshenUser user = XingshenUser.GetModelByUserName(jo["user_name"].ToString());

            if (user.id > 0)
            {
                //已存在的用户
                Rep["ok"]  = true;
                Rep["uid"] = user.uuid;
                return(Rep);
            }
            user.user_name = jo["user_name"].ToString();
            if (string.IsNullOrEmpty(user.user_name))
            {
                Rep["msg"] = "参数错误:user_name";
                return(Rep);
            }
            user.pass = jo["password"].ToString();
            if (string.IsNullOrEmpty(user.pass))
            {
                Rep["msg"] = "参数错误:password";
                return(Rep);
            }
            user.isAndroid = jo["platform"].ToString() == "0";
            user.uuid      = jo["uuid"].ToString();
            XingshenUserData ud = null;

            if (string.IsNullOrEmpty(user.uuid))
            {
                //没有UUid只能尝试登陆(登录有1小时只允许登录一次的限制
                string ErrData = svrHelper.first_login(user, ref ud);
                if (!string.IsNullOrEmpty(ErrData))
                {
                    Rep["msg"] = "登录失败!" + ErrData;
                    return(Rep);
                }
                user.Add();
                Rep["ok"]  = true;
                Rep["uid"] = user.uuid;
            }
            else
            {
                //如果有uuid可以通过system_user_info获取存档信息
                string ErrData = svrHelper.system_user_info(user, ref ud);
                if (!string.IsNullOrEmpty(ErrData))
                {
                    Rep["msg"] = "下载数据存档失败!" + ErrData;
                    return(Rep);
                }
                user.Add();
                Rep["ok"]  = true;
                Rep["uid"] = user.uuid;
            }
            if (ud != null)
            {
                if (ud.id > 0)
                {
                    ud.Update();
                }
                else
                {
                    ud.Add();
                }
            }
            return(Rep);
        }
コード例 #3
0
        private void Page_Load_POST()
        {
            JObject Rep = new JObject();

            Rep["ok"]  = false;
            Rep["msg"] = "";
            try
            {
                string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes));
                if (Request["a"] == "login")
                {
                    Rep["msg"] = "用户名或密码错误!";
                    string username = "";
                    string password = "";
                    try
                    {
                        JObject jo = (JObject)JsonConvert.DeserializeObject(Data);
                        username = jo["user_name"].ToString();
                        password = jo["password"].ToString();
                    }
                    catch (Exception)
                    {
                        return;
                    }
                    OptAdmin admin = OptAdmin_BLL.GetModel(username);
                    if (admin.id != 0 && admin.pass == password)
                    {
                        //管理员登陆
                        _optuser          = new pubPagebase.optUser();
                        _optuser.isAdmin  = true;
                        _optuser.username = username;
                        Session["usrifo"] = _optuser;
                        Rep["go"]         = "/xingshen/lst.aspx";
                        Rep["ok"]         = true;
                        return;
                    }
                    //尝试普通登陆
                    XingshenUser user = XingshenUser.GetModelByUserName(username);
                    if (user.id != 0 && user.pass == password)
                    {
                        _optuser = new pubPagebase.optUser();
                        _optuser.xingshenUser = user;
                        _optuser.isAdmin      = false;
                        _optuser.username     = username;
                        Session["usrifo"]     = _optuser;
                        Rep["go"]             = "/xingshen/accinfo.aspx?uid=" + user.uuid;
                        Rep["ok"]             = true;
                    }
                }
            }
            finally
            {
                if ((bool)Rep["ok"] == false && Rep["msg"].ToString() == "")
                {
                    Rep["msg"] = "系统错误";
                }
                Response.CacheControl = "no-cache";
                Response.Write(Rep.ToString(Formatting.None));
                Response.End();
            }
        }