Exemple #1
0
    public DBCLASSFORWEIXIN.Model.LocalWeixinUser CheckUserAndInsert(string openid, string popenid)
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
        DBCLASSFORWEIXIN.Model.LocalWeixinUser SingleUserInf = new WeixinApiClass.WEIxinUserApi().GetSingleUserInf(openid);
        DBCLASSFORWEIXIN.DAL.LocalWeixinUser   ld            = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();
        if (!ld.Exists(openid) && SingleUserInf != null)
        {
            SingleUserInf.regtime = DateTime.Now;
            SingleUserInf.Tel     = "";
            if (popenid.Trim() == "")
            {
                SingleUserInf.pid = 0;
            }
            else
            {
                SingleUserInf.pid = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser().GetModel(popenid).id;
            }
            ld.Add(SingleUserInf);
        }
        else
        {
            SingleUserInf = ld.GetModel(openid);
        }

        return(SingleUserInf);
    }
Exemple #2
0
    protected void btn_Tj_Click(object sender, EventArgs e)
    {
        openid = Session["openid"].ToString();
        DBCLASSFORWEIXIN.DAL.LocalWeixinUser   ld    = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();
        DBCLASSFORWEIXIN.Model.LocalWeixinUser wxmdl = ld.GetModel(openid);

        LVWEIBA.BLL.MemberList   mbll = new LVWEIBA.BLL.MemberList();
        LVWEIBA.Model.MemberList mmm  = new LVWEIBA.Model.MemberList();

        System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection(Request.Form);
        string txt_user = nc.GetValues("txt_user")[0].ToString();
        string txt_tel  = nc.GetValues("txt_tel")[0].ToString();
        string txt_xm   = nc.GetValues("txt_xm")[0].ToString();
        string txt_card = nc.GetValues("txt_card")[0].ToString();
        string txt_mail = nc.GetValues("txt_mail")[0].ToString();
        string txt_pwd  = nc.GetValues("txt_pwd")[0].ToString();
        string txt_pwd2 = nc.GetValues("txt_pwd2")[0].ToString();

        bool isexists = false;

        if (mbll.Exists(openid))
        {
            mmm      = mbll.GetModel(openid);
            isexists = true;
        }
        wxmdl.nickname = txt_user;
        wxmdl.Tel      = txt_tel;
        mmm.MemberName = txt_xm;
        wxmdl.sex      = int.Parse(ddl_sex.SelectedValue);
        mmm.Card       = txt_card;
        mmm.Mail       = txt_mail;
        mmm.UserPwd    = txt_pwd;
        mmm.UserPwd    = txt_pwd2;
        mmm.MemberId   = openid;
        bool isok = false;

        try
        {
            isok = ld.Update(wxmdl);
            if (isexists)
            {
                isok = mbll.Update(mmm);
            }
            else
            {
                isok = mbll.Add(mmm);
            }
            Response.Write(String.Format("<script>alert('个人信息修改成功');window.location='myindex.aspx';</script>"));
        }
        catch (Exception ex)
        {
            log4netHelper.WriteExceptionLog(typeof(aboutme), "aboutme异常", ex);
        }
    }
 /// <summary>
 /// 对微信登陆操作进行验证
 /// </summary>
 /// <param name="request"></param>
 /// <param name="page"></param>
 /// <returns></returns>
 public static bool userAuthorize(HttpRequest request, Page page)
 {
     try
     {
         string code = request.QueryString["code"];
         if (code == null || code == "")
         {
             return(false);
         }
         string openid = new WEIxinUserApi().GetUserOpenid(code);
         DBCLASSFORWEIXIN.DAL.LocalWeixinUser ld = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();
         if (ld.Exists(openid))
         {
             //DBCLASSFORWEIXIN.Model.LocalWeixinUser localUser = new WeixinApiClass.WEIxinUserApi().GetSingleUserInf(openid);
             DBCLASSFORWEIXIN.Model.LocalWeixinUser user = ld.GetModel(openid);
             UserAuthorizationModel userInfo             = new UserAuthorizationModel();
             userInfo.mobile = user.Tel;
             userInfo.name   = user.nickname;
             userInfo.openId = user.openid;
             BaseClass.Common.Common.UserLoginSetCookie(userInfo.name, page, DateTime.Now.AddDays(30), userInfo);
             return(true);
         }
         else
         {
             HttpContext.Current.Session["weixincode"] = code;
             page.Response.Redirect("~/index/bindCode.aspx");
             return(false);
         }
     }
     catch (Exception ex)
     {
         // BaseClass.Common.LoggerUtil.printLog("userAuthorize error:"+ex.Message);
         log4netHelper.WriteExceptionLog(typeof(UserAuthorization), "userAuthorize", ex);
         return(false);
     }
 }