예제 #1
0
 public async Task <int> InsertAsync(int siteId, WxUser user)
 {
     user.SiteId = siteId;
     return(await _repository.InsertAsync(user, Q
                                          .CachingRemove(GetCacheKey(siteId))
                                          ));
 }
예제 #2
0
        public void Subscribe(string toUserName, string fromUserName, DateTime subscribeTime)
        {
            var        wxOfficialSpecification = new Specification <WxOfficial>(p => p.Account == toUserName);
            WxOfficial wxOfficial = wxOfficialRepository.Find(wxOfficialSpecification);

            var    wxUserSpecification = new Specification <WxUser>(p => p.AppId == wxOfficial.AppId && p.OpenId == fromUserName);
            WxUser wxUser = wxUserRepository.Find(wxUserSpecification);

            if (wxUser == null)
            {
                wxUser                 = new WxUser();
                wxUser.Id              = IdWorkerHelper.GenId64();
                wxUser.AppId           = wxOfficial.AppId;
                wxUser.OpenId          = fromUserName;
                wxUser.SubscribeTime   = subscribeTime;
                wxUser.SubscribeStatus = 1;
                wxUserRepository.Add(wxUser);
            }
            else
            {
                wxUser.SubscribeStatus = 1;
                wxUser.SubscribeTime   = subscribeTime;
                wxUserRepository.Update(wxUser);
            }
        }
예제 #3
0
        public void DeleteTest()
        {
            WxUser v = new WxUser();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID = 18;
                context.Set <WxUser>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(WxUserVM));

            WxUserVM vm = rv.Model as WxUserVM;

            v         = new WxUser();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <WxUser>().Count(), 0);
            }
        }
예제 #4
0
        /// <summary>
        /// 获取微信参数
        /// </summary>
        /// <param name="encrypt">微信加密参数字符</param>
        /// <returns></returns>
        public static WxUser GetWxUser(string encrypt)
        {
            string decparam = DESDecrypt(encrypt, AppConfig.WxUrlKey);

            if (string.IsNullOrEmpty(decparam) || decparam.IndexOf(',') <= 0)
            {
                return(null);
            }

            //由原来逗号分割,改为正则匹配
            string          pattern = @"\<.*?\>";
            MatchCollection list    = Regex.Matches(decparam, pattern);

            if (list.Count != 5)
            {
                return(null);
            }
            try
            {
                WxUser wu = new WxUser
                {
                    openid     = list[0].Value.Substring(1, list[0].Value.Length - 2),
                    unionid    = list[1].Value.Substring(1, list[1].Value.Length - 2),
                    nickname   = list[2].Value.Substring(1, list[2].Value.Length - 2),
                    sex        = Convert.ToByte(list[3].Value.Substring(1, list[3].Value.Length - 2)),
                    headimgurl = list[4].Value.Substring(1, list[4].Value.Length - 2)
                };
                return(wu);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #5
0
        public void BatchDeleteTest()
        {
            WxUser v1 = new WxUser();
            WxUser v2 = new WxUser();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ID = 18;
                context.Set <WxUser>().Add(v1);
                context.Set <WxUser>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv.Model, typeof(WxUserBatchVM));

            WxUserBatchVM vm = rv.Model as WxUserBatchVM;

            vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <WxUser>().Count(), 0);
            }
        }
예제 #6
0
        public void EditTest()
        {
            WxUser v = new WxUser();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID = 18;
                context.Set <WxUser>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(WxUserVM));

            WxUserVM vm = rv.Model as WxUserVM;

            v    = new WxUser();
            v.ID = vm.Entity.ID;

            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

            vm.FC.Add("Entity.ID", "");
            _controller.Edit(vm);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <WxUser>().FirstOrDefault();
            }
        }
예제 #7
0
        /// <summary>
        /// 获取微信参数
        /// </summary>
        /// <param name="encrypt">微信加密参数字符</param>
        /// <returns></returns>
        public static WxUser GetWxUser(string encrypt)
        {
            string decparam = DESDecrypt(encrypt, AppConfig.WxUrlKey);

            if (string.IsNullOrEmpty(decparam) || decparam.IndexOf(',') <= 0)
            {
                return(null);
            }
            string[] param = decparam.Split(',');
            if (param.Length != 5)
            {
                return(null);
            }
            try
            {
                WxUser wu = new WxUser
                {
                    openid     = param[0].Substring(1, param[0].Length - 2),
                    unionid    = param[1].Substring(1, param[1].Length - 2),
                    nickname   = param[2].Substring(1, param[2].Length - 2),
                    sex        = Convert.ToByte(param[3].Substring(1, param[3].Length - 2)),
                    headimgurl = param[4].Substring(1, param[4].Length - 2)
                };
                return(wu);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #8
0
        public void BindOpenId(int userId, string openId, bool single = false)
        {
            List <WxUser> list;

            if (single)
            {
                list = m_repWxUser.GetByCondition(r => r.UserId == userId);
            }
            else
            {
                list = m_repWxUser.GetByCondition(r => r.UserId == userId && r.OpenId == openId);
            }

            WxUser user = new WxUser()
            {
                UserId = userId, OpenId = openId, NoMsg = false
            };

            if (list.Count == 0)
            {
                m_repWxUser.Insert(user);
            }
            else if (single)
            {
                m_repWxUser.DeleteByCondition(r => r.UserId == userId);
                m_repWxUser.Insert(user);
            }
        }
예제 #9
0
        public ActionResult WxLogin()
        {
            WxUser wu = new WxUser();

            wu.Wxidcode   = Request["Wxidcode"];
            wu.wxName     = Request["wxName"];
            wu.Wxprovince = Request["Wxprovince"];
            wu.Wxcity     = Request["Wxcity"];
            wu.WxImg      = Request["WxImg"];
            wu.Wxgender   = Convert.ToInt16(Request["Wxgender"]);
            wu.AddTime    = MvcApplication.GetT_time();
            wu.Del        = false;
            wu.Wx_id      = Request["Wx_id"];
            int    Cot = WxUserService.LoadEntities(x => x.Wx_id == wu.Wx_id).Count();
            string ret = "n";

            if (Cot <= 0)
            {
                try
                {
                    WxUserService.AddEntity(wu);
                    ret = "y";
                }
                catch {
                }
            }
            return(Json(new { Wxidcode = wu, T = ret }, JsonRequestBehavior.AllowGet));
        }
예제 #10
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.WxChat))
            {
                return(Unauthorized());
            }

            WxUser        user  = null;
            List <WxChat> chats = null;

            var(success, token, errorMessage) = await _wxManager.GetAccessTokenAsync(request.SiteId);

            if (success)
            {
                user = await _wxManager.GetUserAsync(token, request.OpenId);

                chats = await _wxChatRepository.GetChatsAsyncByOpenId(request.SiteId, request.OpenId);
            }

            return(new GetResult
            {
                Success = success,
                ErrorMessage = errorMessage,
                User = user,
                Chats = chats
            });
        }
예제 #11
0
        /// <summary>
        /// 获取用户基本信息
        /// </summary>
        /// <returns></returns>
        private WxUser UserInfo()
        {
            WxUser wxuser = null;

            try
            {
                var model = GetOpenidByCode();
                if (model != null && !string.IsNullOrEmpty(model.openid))
                {
                    wxuser = BlogHelper.GetModelByWhere_WxUser(new Dictionary <string, object>()
                    {
                        { nameof(WxUser.Openid), model.openid },
                        { nameof(WxUser.States), 0 },
                        { nameof(WxUser.IsDeleted), 0 }
                    });
                    if (wxuser != null && wxuser.KID > 0)
                    {
                        System.Web.HttpContext.Current.Cache.Insert(wxuser.Openid, JsonConvert.SerializeObject(wxuser), null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                    else
                    {
                        #region 第二步OPENID换取用户信息

                        WxUserBaseInfoModel model2 = GetBaseByOpenid(model.openid, model.access_token);
                        //异步写入数据库

                        WxUser user = new WxUser();
                        user.Openid         = model2.openid;
                        user.NickName       = model2.nickname;
                        user.Privilege      = string.Join(",", model2.privilege);
                        user.Province       = model2.province;
                        user.Sex            = model2.sex;
                        user.City           = model2.city;
                        user.Country        = model2.country;
                        user.HeadImgUrl     = model2.headimgurl;
                        user.CreateUserId   = "1";
                        user.CreateUserName = "******";
                        user.CreateTime     = DateTime.Now;
                        user.UpdateTime     = DateTime.Now;
                        var res = BlogHelper.AddByEntity_WxUser(user, null);
                        LogHelper.WriteLog("addentity");
                        if (res.IsSucceed)
                        {
                            user.KID = Convert.ToInt32(res.Message);
                            System.Web.HttpContext.Current.Cache.Insert(user.Openid, JsonConvert.SerializeObject(user), null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration);
                            wxuser = user;
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex, "GetUserBaseInfo");
            }
            return(wxuser);
        }
예제 #12
0
        public void SaveWechatUser(WxUser user)
        {
            if (string.IsNullOrEmpty(user.openid))
            {
                throw new ArgumentException("必须提供用的openid");
            }

            Connection.Execute(SQL_SAVE_USER, user);
        }
예제 #13
0
파일: UserInfoBLL.cs 프로젝트: soon14/vzan
 public void updateWeiXinOAuthUser(UserInfo model, WxUser weixinUser)
 {
     model.nickname   = weixinUser.nickname;
     model.headimgurl = weixinUser.headimgurl;
     model.sex        = weixinUser.sex.ToString();
     model.country    = weixinUser.country;
     model.city       = weixinUser.city;
     model.province   = weixinUser.province;
     model.unionid    = weixinUser.unionid;
     Update(model);
 }
        public UserAuthTokenResponse FindGetAuthUserToken(LoginGetAuthUserTokenReceive parame)
        {
            var wxOpen = WxUser.FindGetUserOpenId(new UserOpenIdReceive
            {
                WxCode   = "0330e6MM15Asz61xuFNM1lk4MM10e6MQ",
                WxConfig = _wxConfig
            });

            return(new UserAuthTokenResponse {
                _TokenKey = Guid.NewGuid().ToString(), ExpiredTime = DateTime.Now.AddDays(1)
            });
        }
예제 #15
0
        /// <summary>
        /// 生成Jwt的Token
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        private string CreateJwtToken(WxUser user)
        {
            Claim[] claims =
            {
                new Claim(ClaimTypes.NameIdentifier, user.ID.ToString()),
                new Claim(ClaimTypes.Name,           user.NickName)
            };

            var token = JwtHelper.CreateToken(claims, _jwtSettings);

            return(token);
        }
예제 #16
0
        private Int32 AddUser()
        {
            WxUser v = new WxUser();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID = 28;
                context.Set <WxUser>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
예제 #17
0
 public UserInfo(WxUser _wxUser)
 {
     openid     = _wxUser.openid;
     unionid    = _wxUser.unionid;
     headimgurl = _wxUser.headimgurl;
     nickname   = _wxUser.nickname;
     sex        = _wxUser.sex.ToString();
     country    = _wxUser.country;
     city       = _wxUser.city;
     province   = _wxUser.province;
     addtime    = DateTime.Now;
 }
예제 #18
0
        public void BatchGetUserInfo()
        {
            string            appId             = WxOperatorProvider.Provider.GetCurrent().AppId;
            string            appSecret         = WxOperatorProvider.Provider.GetCurrent().AppSecret;
            AccessTokenResult accessTokenResult = AccessTokenContainer.GetAccessTokenResult(appId);
            var specification = new Specification <WxUser>(p => p.AppId == appId && p.SubscribeStatus == 1 && p.SynchronisedTime == null);
            List <BatchGetUserInfoData> batchGetUserInfoDataList = new List <BatchGetUserInfoData>();
            List <WxUser> wxUserList = wxUserRepository.FindAll(specification).ToList();

            if (wxUserList.Count > 0)
            {
                foreach (WxUser wxuser in wxUserList)
                {
                    int index = wxUserList.IndexOf(wxuser);
                    if (index > 100)
                    {
                        break;
                    }
                    BatchGetUserInfoData batchGetUserInfoData = new BatchGetUserInfoData();
                    batchGetUserInfoData.openid   = wxuser.OpenId;
                    batchGetUserInfoData.lang     = "zh_CN";
                    batchGetUserInfoData.LangEnum = 0;
                    batchGetUserInfoDataList.Add(batchGetUserInfoData);
                }
                BatchGetUserInfoJsonResult batchGetUserInfoJsonResult = UserApi.BatchGetUserInfo(accessTokenResult.access_token, batchGetUserInfoDataList);
                if (batchGetUserInfoJsonResult.ErrorCodeValue == 0)
                {
                    if (batchGetUserInfoJsonResult.user_info_list.Count > 0)
                    {
                        foreach (UserInfoJson userInfoJson in batchGetUserInfoJsonResult.user_info_list)
                        {
                            var    specification2 = new Specification <WxUser>(p => p.AppId == appId && p.OpenId == userInfoJson.openid);
                            WxUser wxUser         = wxUserRepository.Find(specification2);
                            wxUser.Nickname         = userInfoJson.nickname;
                            wxUser.Sex              = userInfoJson.sex;
                            wxUser.HeadImgUrl       = userInfoJson.headimgurl;
                            wxUser.Country          = userInfoJson.country;
                            wxUser.Province         = userInfoJson.province;
                            wxUser.City             = userInfoJson.city;
                            wxUser.Language         = userInfoJson.language;
                            wxUser.UnionId          = userInfoJson.unionid;
                            wxUser.Remark           = userInfoJson.remark;
                            wxUser.GroupId          = userInfoJson.groupid;
                            wxUser.SynchronisedTime = System.DateTime.Now;
                            wxUserRepository.Update(wxUser);
                        }
                    }
                }
            }
        }
예제 #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (AppConfig.Mode != AppConfig.CodeMode.Dev)
         {
             //演示和通用平台
             if (string.IsNullOrEmpty(wxparam))
             {
                 string domain = "http://" + (string.IsNullOrEmpty(AppConfig.FrontSiteDomain)
                                     ? GameRequest.GetCurrentFullHost()
                                     : AppConfig.FrontSiteDomain);
                 Response.Redirect(domain + AppConfig.AuthorizeURL + "?url=http://" +
                                   GameRequest.GetCurrentFullHost() + "/Card/Index.aspx?code=1001");
             }
             else
             {
                 WxUser wu = Fetch.GetWxUser(wxparam);
                 if (wu == null)
                 {
                     Response.Write(
                         "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">参数异常,请稍后尝试。</div>");
                     return;
                 }
                 Message msg = FacadeManage.aideAccountsFacade.WXLogin(wu.unionid, GameRequest.GetUserIP());
                 if (msg.Success)
                 {
                     UserInfo ui = msg.EntityList[0] as UserInfo;
                     if (ui != null)
                     {
                         Fetch.SetUserCookie(ui.ToUserTicketInfo());
                         Response.Redirect("/Card/AgentInfo.aspx");
                     }
                     else
                     {
                         Response.Write(
                             "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">登录失败,请稍后尝试</div>");
                     }
                 }
                 else
                 {
                     Response.Write(
                         "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">" +
                         wu.nickname + "," +
                         msg.Content + "</div>");
                 }
             }
         }
     }
 }
예제 #20
0
        private void UserCt_Click(object sender, EventArgs e)
        {
            resetBack();

            var userCt = sender as UserPanel.UserPanel;

            if (wxUser == null)
            {
                wxUser = new WxUser();
            }
            wxUser.openid    = userCt.openId;
            wxUser.nickname  = userCt.nickName;
            userCt.BackColor = Color.LightBlue;
        }
예제 #21
0
        // GET: Me
        public ActionResult Index(string openid)
        {
            if (!string.IsNullOrEmpty(openid))
            {
                WxUserDao userDao = new WxUserDao();


                //1 查询是否已经存在ticket和nickname信息
                WxUser user = userDao.Find(openid);

                bool isExist = user != null;

                //2 如果没有nickname需获取用户信息
                if (user == null || string.IsNullOrEmpty(user.headimgurl) || string.IsNullOrEmpty(user.nickname))
                {
                    var userinfo = Common.HttpUtility.HttpGet($"https://api.weixin.qq.com/cgi-bin/user/info?access_token={AccessTokenHelper.GetAccessToken()}&openid={openid}&lang=zh_CN", "", "utf-8");

                    JObject jobect = (JObject)JsonConvert.DeserializeObject(userinfo);
                    if ((string)jobect["subscribe"] == "0")
                    {
                        return(View("Error", new { message = "未关注" }));
                    }

                    user            = new WxUser();
                    user.openid     = openid;
                    user.headimgurl = (string)jobect["headimgurl"];
                    user.nickname   = (string)jobect["nickname"];

                    user.ticket = WeixinHelper.CreateTempQRCode(openid);
                    user.ticketcreatedatetime = DateTime.Now;

                    if (!isExist)
                    {
                        userDao.Add(user);
                    }
                    else
                    {
                        userDao.Update(user);
                    }
                }


                return(View(user));
            }
            else
            {
                return(View("Error"));
            }
        }
예제 #22
0
        //public void Unsubscribe(string appId, string openId, DateTime subscribeTime)
        //{
        //    var specification = new Specification<WxUser>(p => p.AppId == appId && p.OpenId == openId);
        //    WxUser wxUser = wxUserRepository.Find(specification);
        //    if (wxUser != null)
        //    {
        //        wxUser.SubscribeStatus = 0;
        //        wxUser.SubscribeTime = subscribeTime;
        //        wxUserRepository.Update(wxUser);
        //    }
        //}
        public void Unsubscribe(string toUserName, string fromUserName, DateTime createTime)
        {
            var        wxOfficialSpecification = new Specification <WxOfficial>(p => p.Account == toUserName);
            WxOfficial wxOfficial = wxOfficialRepository.Find(wxOfficialSpecification);

            var    wxUserSpecification = new Specification <WxUser>(p => p.AppId == wxOfficial.AppId && p.OpenId == fromUserName);
            WxUser wxUser = wxUserRepository.Find(wxUserSpecification);

            if (wxUser != null)
            {
                wxUser.SubscribeStatus = 0;
                wxUser.SubscribeTime   = createTime;
                wxUserRepository.Update(wxUser);
            }
        }
예제 #23
0
        public void DetailsTest()
        {
            WxUser v = new WxUser();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID = 18;
                context.Set <WxUser>().Add(v);
                context.SaveChanges();
            }
            PartialViewResult rv = (PartialViewResult)_controller.Details(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(IBaseCRUDVM <TopBasePoco>));
            Assert.AreEqual(v.ID, (rv.Model as IBaseCRUDVM <TopBasePoco>).Entity.GetID());
        }
예제 #24
0
        public object userInfoCallback(string code, string state, string returnUrl)
        {
            var res = new { code = code, state = state, returnUrl = returnUrl };

            Console.WriteLine("=================:" + code);
            if (code != null && code != String.Empty)
            {
                OAuthAccessTokenResult result = null;
                result = OAuthApi.GetAccessToken(WechatConfig.AppId, WechatConfig.secret, code);

                OAuthUserInfo userInfo = OAuthApi.GetUserInfo(result.access_token, result.openid);

                var wxUser = (from u in this.db.wxUsers where u.openid == userInfo.openid select u).FirstOrDefault();
                if (wxUser == null)
                {
                    var newUser = new User {
                        nickname = userInfo.nickname, headimg = userInfo.headimgurl
                    };
                    // 新用户注册
                    var newWxUser = new WxUser
                    {
                        openid   = userInfo.openid,
                        nickname = userInfo.nickname,
                        headimg  = userInfo.headimgurl
                    };
                    this.db.wxUsers.Add(newWxUser);
                    newUser.wxUserId = newWxUser.id;
                    this.db.users.Add(newUser);
                    Console.WriteLine("returnUrl" + returnUrl);
                    return(Redirect(returnUrl + "?userId=" + newUser.id));
                    // return userInfo;
                    // return this.Redirect(returnUrl);
                }
                else
                {
                    var user = (from u in this.db.users
                                where
                                u.id == wxUser.id
                                select u).FirstOrDefault();
                    return(Redirect(returnUrl + "?userId=" + user.id));
                }
            }
            else
            {
                return(Content("您拒绝了授权"));
            }
        }
예제 #25
0
파일: UserInfoBLL.cs 프로젝트: soon14/vzan
        /// <summary>
        /// 拿微信的信息进行添加到基础用户表
        /// </summary>
        /// <param name="weixinUser"></param>
        /// <returns></returns>
        public UserInfo addWeiXinOAuthUser(WxUser weixinUser)
        {
            UserInfo model = new UserInfo();

            model.openid     = weixinUser.openid;
            model.nickname   = weixinUser.nickname;
            model.headimgurl = weixinUser.headimgurl;
            model.sex        = weixinUser.sex.ToString();
            model.country    = weixinUser.country;
            model.city       = weixinUser.city;
            model.province   = weixinUser.province;
            model.unionid    = weixinUser.unionid;
            model.addtime    = DateTime.Now;
            model.Id         = Convert.ToInt32(Add(model));

            return(model);
        }
예제 #26
0
        public ActionResult Wallet(string openid)
        {
            if (!string.IsNullOrEmpty(openid))
            {
                WxUserDao userDao = new WxUserDao();

                WxUser user = userDao.Find(openid);
                if (user == null)
                {
                    return(View("Error"));
                }
                return(View(user));
            }
            else
            {
                return(View("Error"));
            }
        }
예제 #27
0
        public void Update(WxUser user)
        {
            string sqlStr = "update tb_weixin_info set nickname=@nickname,tj_openid=@tj_openid,isSubscribe=@isSubscribe,createdatetime=@createdatetime,headimgurl=@headimgurl,ticket=@ticket,ticketcreatedatetime=@ticketcreatedatetime where openid=@openid ";

            MySqlParameter[] mySqlParameters =
            {
                new MySqlParameter("openid",               user.openid),
                new MySqlParameter("nickname",             user.nickname),
                new MySqlParameter("tj_openid",            user.tj_openid),
                new MySqlParameter("isSubscribe",          user.isSubscribe),
                new MySqlParameter("createdatetime",       user.createdatetime),
                new MySqlParameter("headimgurl",           user.headimgurl),
                new MySqlParameter("ticket",               user.ticket),
                new MySqlParameter("ticketcreatedatetime", user.ticketcreatedatetime)
            };

            mySqlHelper.ExecuteSql(sqlStr, mySqlParameters);
        }
예제 #28
0
        public void Add(WxUser user)
        {
            string sqlStr = "insert into tb_weixin_info(openid,nickname,isSubscribe,createdatetime,headimgurl,ticket,ticketcreatedatetime,tj_openid) values(@openid,@nickname,@isSubscribe,@createdatetime,@headimgurl,@ticket,@ticketcreatedatetime,@tj_openid)";

            MySqlParameter[] mySqlParameters =
            {
                new MySqlParameter("openid",               user.openid),
                new MySqlParameter("nickname",             user.nickname),
                new MySqlParameter("isSubscribe",          user.isSubscribe),
                new MySqlParameter("createdatetime",       user.createdatetime),
                new MySqlParameter("headimgurl",           user.headimgurl),
                new MySqlParameter("ticket",               user.ticket),
                new MySqlParameter("ticketcreatedatetime", user.ticketcreatedatetime),
                new MySqlParameter("tj_openid",            user.tj_openid)
            };

            mySqlHelper.ExecuteSql(sqlStr, mySqlParameters);
        }
예제 #29
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="decodedUser"></param>
        /// <returns></returns>
        public WxUser DoAdd(DecodedUserInfo decodedUser)
        {
            var user = new WxUser()
            {
                OpenId     = decodedUser.openId,
                NickName   = decodedUser.nickName,
                AvatarUrl  = decodedUser.avatarUrl,
                Gender     = (WxSexEnum)decodedUser.gender,
                Country    = decodedUser.country,
                Province   = decodedUser.province,
                City       = decodedUser.city,
                Language   = decodedUser.language,
                CreateTime = DateTime.Now
            };

            DC.Set <WxUser>().Add(user);
            DC.SaveChanges();
            return(user);
        }
예제 #30
0
        /// <summary>
        /// 订阅请求
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ResponseRootMsg OnEvent_SubscribeRequest(RequestSubscribeEventMsg request)
        {
            var dbrule = databaseFixture.Db.WxRule.Find(m => m.RuleType == (int)WxRuleType.Subscribe);

            if (dbrule == null)
            {
                return(null);
            }
            #region 添加用户 TODO 可优化
            WxUser user = new WxUser
            {
                OpenId    = request.FromUserName,
                Subscribe = 1,
                IsSync    = 0
            };
            databaseFixture.Db.WxUser.Insert(user);
            #endregion
            switch ((ResponseMsgType)dbrule.ResponseMsgType)
            {
            case ResponseMsgType.Text:
                return(GetResponseTextMsgByRuleId(dbrule.Id, request));

            case ResponseMsgType.Image:
                break;

            case ResponseMsgType.Voice:
                break;

            case ResponseMsgType.Video:
                break;

            case ResponseMsgType.Music:
                break;

            case ResponseMsgType.News:
                break;

            case ResponseMsgType.Transfer_Customer_Service:
                break;
            }
            return(null);
        }
예제 #31
0
        private void UserCt_Click(object sender, EventArgs e)
        {
            resetBack();

            var userCt = sender as UserPanel.UserPanel;

            if (wxUser == null)
                wxUser = new WxUser();
            wxUser.openid = userCt.openId;
            wxUser.nickname = userCt.nickName;
            userCt.BackColor = Color.LightBlue;
        }