Esempio n. 1
0
        public string help(string user_openid, string code, string nickname, string sex, string country, string province, string city, string avatarUrl)
        {
            string Message = "";

            try
            {
                UserLogin UserProof = new UserHelper().GetOpenId(code);
                //为了数据安全,不对外提供这个密钥
                UserProof.session_key = null;

                //添加用户信息到数据库

                sex = sex == "1" ? "男" : "女";
                Model.applet_user applet_User = new Model.applet_user();
                applet_User.user_name         = nickname;
                applet_User.user_openid       = UserProof.openid;
                applet_User.user_avatarUrl    = avatarUrl;
                applet_User.user_city         = city;
                applet_User.user_country      = country;
                applet_User.user_province     = province;
                applet_User.user_sex          = sex;
                applet_User.user_kindling_num = 0;

                BLL.applet_user user = new BLL.applet_user();

                //查询当前openid  是否存在
                if (!user.Exists_openid(UserProof.openid))
                {
                    //添加
                    int row = user.Add(applet_User);
                }

                //为好友助力



                return(UserProof.openid);
            }
            catch (Exception e)
            {
                return(e.Message);
            }


            return(Message);
        }
Esempio n. 2
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Model.applet_user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "applet_user(");
            strSql.Append("user_name,user_sex,user_country,user_province,user_city,user_avatarUrl,add_time,user_openid,user_kindling_num)");
            strSql.Append(" values (");
            strSql.Append("@user_name,@user_sex,@user_country,@user_province,@user_city,@user_avatarUrl,@add_time,@user_openid,@user_kindling_num)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_name",         SqlDbType.NVarChar,   50),
                new SqlParameter("@user_sex",          SqlDbType.NVarChar,   50),
                new SqlParameter("@user_country",      SqlDbType.NVarChar,   50),
                new SqlParameter("@user_province",     SqlDbType.NVarChar,   50),
                new SqlParameter("@user_city",         SqlDbType.NVarChar,   50),
                new SqlParameter("@user_avatarUrl",    SqlDbType.NVarChar,  250),
                new SqlParameter("@add_time",          SqlDbType.DateTime),
                new SqlParameter("@user_openid",       SqlDbType.NVarChar,   50),
                new SqlParameter("@user_kindling_num", SqlDbType.Float, 4)
            };
            parameters[0].Value = model.user_name;
            parameters[1].Value = model.user_sex;
            parameters[2].Value = model.user_country;
            parameters[3].Value = model.user_province;
            parameters[4].Value = model.user_city;
            parameters[5].Value = model.user_avatarUrl;
            parameters[6].Value = DateTime.Now.ToString();
            parameters[7].Value = model.user_openid;
            parameters[8].Value = model.user_kindling_num;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(Model.applet_user model)
 {
     return(dal.Add(model));
 }
Esempio n. 4
0
        public string GetUserProof(string code, string nickname, string sex, string country, string province, string city, string avatarUrl)
        {
            try
            {
                UserLogin UserProof = new UserHelper().GetOpenId(code);
                //为了数据安全,不对外提供这个密钥
                UserProof.session_key = null;

                if (UserProof.openid == "" || UserProof.openid == null)
                {
                    return("openid为空!");
                }

                //添加用户信息到数据库
                sex = sex == "1" ? "男" : "女";
                Model.applet_user applet_User = new Model.applet_user();
                applet_User.user_name         = nickname;
                applet_User.user_openid       = UserProof.openid;
                applet_User.user_avatarUrl    = avatarUrl;
                applet_User.user_city         = city;
                applet_User.user_country      = country;
                applet_User.user_province     = province;
                applet_User.user_sex          = sex;
                applet_User.user_kindling_num = 1;

                string          message = "";
                BLL.applet_user user    = new BLL.applet_user();
                //查询当前openid  是否存在
                if (!user.Exists_openid(UserProof.openid))
                {
                    //添加
                    int row = user.Add(applet_User);
                    message = "点燃成功";
                }
                else
                {
                    //查询用户火苗数是否为1
                    if (user.GetList_user_kindling_num("user_openid='" + UserProof.openid + "'", "id asc") == 1)
                    {
                        //已经自己点燃过火种
                        message = "已点燃";
                    }
                    else
                    {
                        //为点燃火种,点燃火种
                        if (user.Update("user_kindling_num=1", "user_openid=" + UserProof.openid + ""))
                        {
                            message = "点燃成功";
                        }
                        else
                        {
                            message = "点燃失败";
                        }
                    }
                }

                object dataobj = new
                {
                    UserProof.openid,
                    message
                };
                string json = JsonConvert.SerializeObject(dataobj);
                return(json);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }