/// <summary>
        /// 创建新的 WeixinUserInfo 对象。
        /// </summary>
        /// <param name="openId">OpenId 属性的初始值。</param>
        /// <param name="nickName">NickName 属性的初始值。</param>
        /// <param name="headImgUrl">HeadImgUrl 属性的初始值。</param>
        /// <param name="language">Language 属性的初始值。</param>
        /// <param name="sex">Sex 属性的初始值。</param>
        /// <param name="city">City 属性的初始值。</param>
        /// <param name="province">Province 属性的初始值。</param>
        /// <param name="country">Country 属性的初始值。</param>
        /// <param name="subscribe_time">Subscribe_time 属性的初始值。</param>
        /// <param name="id">ID 属性的初始值。</param>
        public static WeixinUserInfo CreateWeixinUserInfo(global::System.String openId, global::System.String nickName, global::System.String headImgUrl, global::System.String language, global::System.Int16 sex, global::System.String city, global::System.String province, global::System.String country, global::System.Int64 subscribe_time, global::System.Int32 id)
        {
            WeixinUserInfo weixinUserInfo = new WeixinUserInfo();

            weixinUserInfo.OpenId         = openId;
            weixinUserInfo.NickName       = nickName;
            weixinUserInfo.HeadImgUrl     = headImgUrl;
            weixinUserInfo.Language       = language;
            weixinUserInfo.Sex            = sex;
            weixinUserInfo.City           = city;
            weixinUserInfo.Province       = province;
            weixinUserInfo.Country        = country;
            weixinUserInfo.Subscribe_time = subscribe_time;
            weixinUserInfo.ID             = id;
            return(weixinUserInfo);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 创建新的 WeixinUserInfo 对象。
 /// </summary>
 /// <param name="openId">OpenId 属性的初始值。</param>
 /// <param name="nickName">NickName 属性的初始值。</param>
 /// <param name="headImgUrl">HeadImgUrl 属性的初始值。</param>
 /// <param name="language">Language 属性的初始值。</param>
 /// <param name="sex">Sex 属性的初始值。</param>
 /// <param name="city">City 属性的初始值。</param>
 /// <param name="province">Province 属性的初始值。</param>
 /// <param name="country">Country 属性的初始值。</param>
 /// <param name="subscribe_time">Subscribe_time 属性的初始值。</param>
 /// <param name="id">ID 属性的初始值。</param>
 public static WeixinUserInfo CreateWeixinUserInfo(global::System.String openId, global::System.String nickName, global::System.String headImgUrl, global::System.String language, global::System.Int16 sex, global::System.String city, global::System.String province, global::System.String country, global::System.Int64 subscribe_time, global::System.Int32 id)
 {
     WeixinUserInfo weixinUserInfo = new WeixinUserInfo();
     weixinUserInfo.OpenId = openId;
     weixinUserInfo.NickName = nickName;
     weixinUserInfo.HeadImgUrl = headImgUrl;
     weixinUserInfo.Language = language;
     weixinUserInfo.Sex = sex;
     weixinUserInfo.City = city;
     weixinUserInfo.Province = province;
     weixinUserInfo.Country = country;
     weixinUserInfo.Subscribe_time = subscribe_time;
     weixinUserInfo.ID = id;
     return weixinUserInfo;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 用于向 WeixinUserInfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToWeixinUserInfo(WeixinUserInfo weixinUserInfo)
 {
     base.AddObject("WeixinUserInfo", weixinUserInfo);
 }
 /// <summary>
 /// 用于向 WeixinUserInfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToWeixinUserInfo(WeixinUserInfo weixinUserInfo)
 {
     base.AddObject("WeixinUserInfo", weixinUserInfo);
 }
        /// <summary>
        /// 获取openId对应的用户信息并存入数据库
        /// </summary>
        /// <param name="openId">微信用户openId</param>
        /// <param name="execute">修改、删除或插入操作</param>
        /// <param name="failList">未成功获取到用户信息的openId列表</param>
        private static void ExecuteWeixinUser(string openId, GetExecute execute, List<string> failList)
        {
            string accessToken = AccessTokenContainer.TryGetToken(ConfigurationManager.AppSettings["appID"], ConfigurationManager.AppSettings["appsecret"]);
            var userInfo = User.Info(accessToken, openId);
            if (userInfo.errcode != ReturnCode.请求成功)
            {
                failList.Add(openId);
            }
            else
            {
                WeixinUserInfo entity = new WeixinUserInfo()
                {
                    City = userInfo.city,
                    Province = userInfo.province,
                    Country = userInfo.country,
                    HeadImgUrl = userInfo.headimgurl,
                    Language = userInfo.language,
                    Subscribe_time = userInfo.subscribe_time,
                    Sex = (Int16)userInfo.sex,
                    NickName = userInfo.nickname,
                    OpenId = userInfo.openid

                };
                execute(entity);
            }
        }