protected void Page_Load(object sender, EventArgs e)
    {
        int userId = Convert.ToInt32(Request.Form["userid"]);
        int type   = Convert.ToInt32(Request.Form["type"]);

        //写日志
        log.Info(string.Format(" UserID:{0} | Type:{1}", userId, type));

        DataTable dt = new DataTable();

        dt = bll.GetItemListWithSync(userId);

        /*using (TransactionScope ts = new TransactionScope())
         * {
         *  if (type == 1)
         *  {
         *      user_bll.UpdateSyncByUserId(userId);
         *  }
         *
         *  dt = bll.GetItemListWithSync(userId);
         *
         *  ts.Complete();
         * }*/

        string result = "{";

        if (dt.Rows.Count > 0)
        {
            result += "\"itemlist\":[";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                result += "{\"itemid\":\"" + dt.Rows[i]["ItemID"].ToString() + "\",";
                result += "\"itemappid\":\"" + dt.Rows[i]["ItemAppID"].ToString() + "\",";
                result += "\"itemname\":\"" + dt.Rows[i]["ItemName"].ToString() + "\",";
                result += "\"catid\":\"" + dt.Rows[i]["CategoryTypeID"].ToString() + "\",";
                result += "\"itemprice\":\"" + dt.Rows[i]["ItemPrice"].ToString() + "\",";
                result += "\"itembuydate\":\"" + Convert.ToDateTime(dt.Rows[i]["ItemBuyDate"]).ToString("yyyy-MM-dd HH:mm:ss") + "\",";
                result += "\"recommend\":\"" + dt.Rows[i]["Recommend"].ToString() + "\",";
                result += "\"regionid\":\"" + dt.Rows[i]["RegionID"].ToString() + "\",";
                result += "\"regiontype\":\"" + dt.Rows[i]["RegionType"].ToString() + "\",";
                result += "\"itemtype\":\"" + dt.Rows[i]["ItemType"].ToString() + "\",";
                result += "\"ztid\":\"" + dt.Rows[i]["ZhuanTiID"].ToString() + "\",";
                result += "\"cardid\":\"" + dt.Rows[i]["CardID"].ToString() + "\",";
                result += "\"remark\":\"" + dt.Rows[i]["Remark"].ToString() + "\"},";
            }
            result  = result.Substring(0, result.Length - 1);
            result += "]";
        }
        else
        {
            result += "\"itemlist\":[]";
        }
        result += "}";

        Response.Write(result);
        Response.End();
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int userId = Convert.ToInt32(Request.Form["userid"]);

        string result = "{";

        DataTable dt = bll.GetItemListWithSync(userId);

        if (dt.Rows.Count == 0)
        {
            dt = del_bll.GetDeleteListByUserId(userId);
        }
        if (dt.Rows.Count == 0)
        {
            dt = cat_bll.GetUserCategoryListWithSync(userId);
        }
        if (dt.Rows.Count == 0)
        {
            dt = zt_bll.GetZhuanTiListWithSync(userId);
        }
        if (dt.Rows.Count == 0)
        {
            dt = zz_bll.GetZhuanZhangListWithSync(userId);
        }
        if (dt.Rows.Count == 0)
        {
            dt = card_bll.GetCardListWithSync(userId);
        }
        if (dt.Rows.Count == 0)
        {
            dt = user_bll.GetUserListWithSync(userId);
        }

        if (dt.Rows.Count > 0)
        {
            result += "\"result\":\"ok\"";
        }
        else
        {
            result += "\"result\":\"error\"";
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName    = Request.Form["username"] ?? "";
        string openId      = Request.Form["openid"].ToString();
        string accessToken = Request.Form["accesstoken"].ToString();
        string oAuthFrom   = "sjqq";
        string nickName    = Request.Form["nickname"].ToString();
        string userImage   = Request.Form["userimage"].ToString();
        string userFrom    = Request.Form["userfrom"].ToString() ?? Request.Form["oauthfrom"].ToString();//5.9.1web
        int    type        = Convert.ToInt32(Request.Form["type"]);
        string isUpdate    = Request.Form["isupdate"] ?? "0";

        if (userFrom.Length > 5)
        {
            userFrom = userFrom.Replace("_", "");
            userFrom = userFrom.Substring(5);
        }

        UserInfo user = user_bll.GetUserByUserName(userName);

        if (userName == "")
        {
            user.UserName = UserHelper.GetUserName(oAuthFrom);
        }
        if (userName == "")
        {
            user.UserPassword = "******";
        }
        user.UserNickName = nickName;
        user.UserImage    = (userImage == "" ? "none.gif" : userImage);
        user.UserFrom     = userFrom;
        user.CreateDate   = DateTime.Now;
        user.ModifyDate   = DateTime.Now;
        user.IsUpdate     = Convert.ToByte(isUpdate);

        //写日志
        log.Info(string.Format(" UserInfo -> {0}", user.ToString()));

        OAuthInfo oauth = new OAuthInfo();

        oauth.OpenID      = openId;
        oauth.AccessToken = accessToken;
        oauth.OAuthFrom   = oAuthFrom;
        oauth.OAuthBound  = 1;
        oauth.ModifyDate  = DateTime.Now;

        //写日志
        log.Info(string.Format(" OAuthInfo -> {0}", oauth.ToString()));

        bool success = oauth_bll.OAuthLoginByOpenId(oauth.OpenID);

        if (!success)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                if (user.UserID > 0)
                {
                    success = user_bll.UpdateUser(user);
                }
                else
                {
                    success = user_bll.InsertUser(user);
                    user    = user_bll.GetUserByUserPassword(user.UserName, user.UserPassword);
                }

                oauth.UserID    = user.UserID;
                oauth.OldUserID = user.UserID;
                success         = oauth_bll.InsertOAuth(oauth);

                ts.Complete();
            }
            if (!success)
            {
                Response.Write("{\"result\":\"userid\":\"0\"}");
                Response.End();
            }
        }

        string result = "{";

        if (success)
        {
            oauth = oauth_bll.GetOAuthByOpenId(openId);
            user  = user_bll.GetUserByUserId(oauth.UserID);

            decimal userMoney = user.UserMoney;
            if (isUpdate == "1")
            {
                userMoney = user.MoneyStart;
            }

            result += "\"userid\":\"" + user.UserID + "\",";
            result += "\"username\":\"" + user.UserName + "\",";
            result += "\"userpass\":\"" + user.UserPassword + "\",";
            result += "\"usernickname\":\"" + user.UserNickName + "\",";
            result += "\"createdate\":\"" + user.CreateDate.ToString("yyyy-MM-dd") + "\",";
            result += "\"useremail\":\"" + user.UserEmail + "\",";
            result += "\"userphone\":\"" + user.UserPhone + "\",";
            result += "\"userimage\":\"" + user.UserImage + "\",";
            result += "\"userworkday\":\"" + user.UserWorkDay + "\",";
            result += "\"usermoney\":\"" + userMoney + "\",";

            if (type == 1)
            {
                user_bll.UpdateSyncByUserId(user.UserID);
            }

            DataTable dt = bll.GetItemListWithSync(user.UserID);
            if (dt.Rows.Count > 0)
            {
                result += "\"hassync\":\"1\",";
            }
            else
            {
                result += "\"hassync\":\"0\",";
            }

            result += "\"userbound\":\"1\"";
        }
        else
        {
            result += "\"userid\":\"0\",";
            result += "\"username\":\"\",";
            result += "\"userpass\":\"\",";
            result += "\"usernickname\":\"\",";
            result += "\"createdate\":\"\",";
            result += "\"useremail\":\"\",";
            result += "\"userphone\":\"\",";
            result += "\"userimage\":\"\",";
            result += "\"userworkday\":\"5\",";
            result += "\"usermoney\":\"0\",";
            result += "\"categoryrate\":\"90\",";
            result += "\"hassync\":\"0\",";
            result += "\"userbound\":\"0\"";
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName     = Request.Form["username"].ToString();
        string userPassword = Request.Form["userpass"].ToString();
        int    type         = Convert.ToInt32(Request.Form["type"]);
        string isUpdate     = Request.Form["isupdate"] ?? "0";

        //写日志
        log.Info(string.Format(" UserName:{0} | Type:{1} | IsUpdate:{2}", userName, type, isUpdate));

        string result = "{";

        bool success = user_bll.UserLogin(userName, userPassword);

        if (success)
        {
            UserInfo user = user_bll.GetUserByUserPassword(userName, userPassword);

            decimal userMoney = user.UserMoney;
            if (isUpdate == "1")
            {
                userMoney = user.MoneyStart;
            }

            result += "\"userid\":\"" + user.UserID + "\",";
            result += "\"username\":\"" + user.UserName + "\",";
            result += "\"userpass\":\"" + user.UserPassword + "\",";
            result += "\"usernickname\":\"" + user.UserNickName + "\",";
            result += "\"createdate\":\"" + user.CreateDate.ToString("yyyy-MM-dd") + "\",";
            result += "\"useremail\":\"" + user.UserEmail + "\",";
            result += "\"userphone\":\"" + user.UserPhone + "\",";
            result += "\"userimage\":\"" + user.UserImage + "\",";
            result += "\"userworkday\":\"" + user.UserWorkDay + "\",";
            result += "\"usermoney\":\"" + userMoney + "\",";
            result += "\"categoryrate\":\"" + user.CategoryRate + "\",";

            if (type == 1)
            {
                user_bll.UpdateSyncByUserId(user.UserID);
            }

            DataTable dt = bll.GetItemListWithSync(user.UserID);
            if (dt.Rows.Count > 0)
            {
                result += "\"hassync\":\"1\",";
            }
            else
            {
                result += "\"hassync\":\"0\",";
            }

            OAuthInfo oauth = oauth_bll.GetOAuthByUserId(user.UserID);
            if (oauth.OAuthBound == 0)
            {
                result += "\"userbound\":\"0\"";
            }
            else
            {
                result += "\"userbound\":\"1\"";
            }
        }
        else
        {
            result += "\"userid\":\"0\",";
            result += "\"username\":\"\",";
            result += "\"userpass\":\"\",";
            result += "\"usernickname\":\"\",";
            result += "\"createdate\":\"\",";
            result += "\"useremail\":\"\",";
            result += "\"userphone\":\"\",";
            result += "\"userimage\":\"\",";
            result += "\"userworkday\":\"5\",";
            result += "\"usermoney\":\"0\",";
            result += "\"categoryrate\":\"90\",";
            result += "\"hassync\":\"0\",";
            result += "\"userbound\":\"0\"";
        }

        result += "}";

        Response.Write(result);
        Response.End();
    }