示例#1
0
    IEnumerator GetLeaderboard()    //make a query to the webapi and loads the json
    {
        UnityWebRequest www = UnityWebRequest.Get("http://unitygame.pythonanywhere.com/GetScores");

        yield return(www.Send());

        if (www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            // Show results as text
            string json = www.downloadHandler.text;
            Debug.Log(json);
            json = "{ \"infos\" : " + json + " }";
            Debug.Log(json);
            UserInfoCollection lInfo = JsonUtility.FromJson <UserInfoCollection>(json);
            Debug.Log(lInfo.infos [0].username);
            for (int i = 0; i < lInfo.infos.Length; i++)
            {
                Debug.Log(lInfo.infos [i].username + "\t" + lInfo.infos [i].score);
                leaderboradText.text += lInfo.infos[i].username + "\t" + lInfo.infos[i].score + "\n";
            }
            //byte[] results = www.downloadHandler.data;
            //Debug.Log (results [0]);
        }
    }
示例#2
0
        public object GetWxUserInfoBatch(Dictionary <string, object> dicParas)
        {
            string errMsg     = string.Empty;
            string nextOpenId = dicParas.ContainsKey("nextOpenId") ? dicParas["nextOpenId"].ToString() : string.Empty;

            UserInfoCollection <UserInfoDetailModel> userInfoCollection = null;

            if (!getWxFans <UserInfoDetailModel>("员工组", nextOpenId, out userInfoCollection, out errMsg))
            {
                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
            }

            if (userInfoCollection != null && userInfoCollection.UserInfoList != null)
            {
                var subscribeusers = userInfoCollection.UserInfoList.Exists(p => p.Subscribe.Equals(1)) ?
                                     userInfoCollection.UserInfoList.Where(w => w.Subscribe.Equals(1)).ToList <UserInfoDetailModel>() : default(List <UserInfoDetailModel>);

                //绑定UserID
                UserInfoCacheModel userInfoCacheModel = null;
                foreach (var su in subscribeusers)
                {
                    if (UserBusiness.IsEffectiveXcUser(su.OpenID, out userInfoCacheModel))
                    {
                        su.UserID = userInfoCacheModel.UserID;
                    }
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, subscribeusers));
            }

            return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
        }
示例#3
0
        private bool getWxUsers <T>(string nextOpenId, out UserInfoCollection <T> userInfoCollection, out string errMsg)
        {
            userInfoCollection = null;
            errMsg             = string.Empty;

            string accsess_token = string.Empty;
            string openId        = string.Empty;

            if (TokenMana.GetAccessToken(out accsess_token))
            {
                string url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
                url = string.Format(url, accsess_token, nextOpenId);
                string list = Utils.WebClientDownloadString(url);
                Dictionary <string, object> dict = new Dictionary <string, object>();
                if (WeiXinJsonHelper.GetResponseJsonResult(list, ref dict))
                {
                    var openidarr = ((Dictionary <string, object>)dict["data"])["openid"] as object[];
                    if (openidarr != null && openidarr.Length > 0)
                    {
                        var userinfoarr = new object[openidarr.Length];
                        for (int i = 0; i < openidarr.Length; i++)
                        {
                            userinfoarr[i] = new { openid = openidarr[i].ToString() };
                        }
                        var    pushData = new { user_list = userinfoarr };
                        string json     = Utils.SerializeObject(pushData).ToString();
                        url = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token={0}";
                        url = string.Format(url, accsess_token);
                        string str = Utils.HttpPost(url, json);
                        if (WeiXinJsonHelper.GetResponseJsonResult(str, ref dict))
                        {
                            userInfoCollection = Utils.DataContractJsonDeserializer <UserInfoCollection <T> >(str);
                        }
                        else
                        {
                            errMsg = "获取用户基本信息出错:" + dict["errcode"].ToString() + " " + dict["errmsg"].ToString();
                            return(false);
                        }
                    }
                }
                else
                {
                    errMsg = "获取用户列表出错:" + dict["errcode"].ToString() + " " + dict["errmsg"].ToString();
                    return(false);
                }

                return(true);
            }
            else
            {
                errMsg = "获取微信令牌出错";
                return(false);
            }
        }
示例#4
0
        public static UserInfoCollection Search(SearchFilter SearchKey)
        {
            UserInfoCollection collection = new UserInfoCollection();

            using (var reader = SqlHelper.ExecuteReader("UserInfo_Search", SearchFilterManager.SqlSearchParam(SearchKey)))
            {
                while (reader.Read())
                {
                    UserInfo obj = new UserInfo();
                    obj = GetItemFromReader(reader);
                    obj.userLogin.Password = "******";
                    collection.Add(obj);
                }
            }
            return(collection);
        }
示例#5
0
        public static UserInfoCollection GetbyUser(string CreatedUser, int CompanyID)
        {
            UserInfoCollection collection = new UserInfoCollection();
            UserInfo           obj;
            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CreatedUser", CreatedUser),
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("tblUserInfo_GetAll_byUser", sqlParams))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
示例#6
0
        public static UserInfoCollection GetItembyEmpCD(int CompanyID, string EmpCD)
        {
            UserInfoCollection collection = new UserInfoCollection();

            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CompanyID", CompanyID),
                new SqlParameter("@EmpCD", EmpCD),
            };

            using (var reader = SqlHelper.ExecuteReader("tblUserInfo_GetbyEmpCD", sqlParams))
            {
                while (reader.Read())
                {
                    UserInfo obj = new UserInfo();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
示例#7
0
        public object GetWxUserList(Dictionary <string, object> dicParas)
        {
            string errMsg     = string.Empty;
            string nextOpenId = dicParas.ContainsKey("nextOpenId") ? dicParas["nextOpenId"].ToString() : string.Empty;

            UserInfoCollection <UserInfoModel> userInfoCollection = null;

            if (!getWxUsers <UserInfoModel>(nextOpenId, out userInfoCollection, out errMsg))
            {
                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
            }

            if (userInfoCollection != null && userInfoCollection.UserInfoList != null)
            {
                var subscribeusers = userInfoCollection.UserInfoList.Exists(p => p.Subscribe.Equals(1)) ?
                                     userInfoCollection.UserInfoList.Where(w => w.Subscribe.Equals(1)).ToList <UserInfoModel>() : default(List <UserInfoModel>);
                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, subscribeusers));
            }

            return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
        }
示例#8
0
        private bool getWxFans <T>(string tagName, string nextOpenId, out UserInfoCollection <T> userInfoCollection, out string errMsg)
        {
            userInfoCollection = null;
            errMsg             = string.Empty;

            string accsess_token = string.Empty;
            string openId        = string.Empty;

            if (TokenMana.GetAccessToken(out accsess_token))
            {
                string url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token={0}";
                url = string.Format(url, accsess_token);
                Dictionary <string, object> dict = new Dictionary <string, object>();
                string list = Utils.WebClientDownloadString(url);
                if (WeiXinJsonHelper.GetResponseJsonResult(list, ref dict))
                {
                    var tagId = 0;
                    var tags  = (object[])dict["tags"];
                    if (tags != null && tags.Length > 0)
                    {
                        foreach (IDictionary <string, object> el in tags)
                        {
                            if (el != null)
                            {
                                var    dicPara = new Dictionary <string, object>(el, StringComparer.OrdinalIgnoreCase);
                                string name    = dicPara.ContainsKey("name") ? dicPara["name"].ToString() : string.Empty;
                                if (name.Equals(tagName, StringComparison.OrdinalIgnoreCase))
                                {
                                    int.TryParse(dicPara["id"].ToString(), out tagId);
                                    break;
                                }
                            }
                        }
                    }

                    if (tagId == 0)
                    {
                        errMsg = "该标签不存在";
                        return(false);
                    }

                    var    pushData = new { tagid = tagId, next_openid = nextOpenId };
                    string json     = Utils.SerializeObject(pushData).ToString();
                    url = "https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token={0}";
                    url = string.Format(url, accsess_token);
                    string str = Utils.HttpPost(url, json);
                    if (WeiXinJsonHelper.GetResponseJsonResult(str, ref dict))
                    {
                        var openidarr = ((Dictionary <string, object>)dict["data"])["openid"] as object[];
                        if (openidarr != null && openidarr.Length > 0)
                        {
                            var userinfoarr = new object[openidarr.Length];
                            for (int i = 0; i < openidarr.Length; i++)
                            {
                                userinfoarr[i] = new { openid = openidarr[i].ToString() };
                            }
                            var pushData2 = new { user_list = userinfoarr };
                            json = Utils.SerializeObject(pushData2).ToString();
                            url  = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token={0}";
                            url  = string.Format(url, accsess_token);
                            str  = Utils.HttpPost(url, json);
                            if (WeiXinJsonHelper.GetResponseJsonResult(str, ref dict))
                            {
                                userInfoCollection = Utils.DataContractJsonDeserializer <UserInfoCollection <T> >(str);
                            }
                            else
                            {
                                errMsg = "获取用户基本信息出错:" + dict["errcode"].ToString() + " " + dict["errmsg"].ToString();
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        errMsg = "获取标签粉丝信息出错:" + dict["errcode"].ToString() + " " + dict["errmsg"].ToString();
                        return(false);
                    }
                }
                else
                {
                    errMsg = "获取标签列表出错:" + dict["errcode"].ToString() + " " + dict["errmsg"].ToString();
                    return(false);
                }

                return(true);
            }
            else
            {
                errMsg = "获取微信令牌出错";
                return(false);
            }
        }
示例#9
0
        public List <model1> LogIn([FromBody] User dataUser)
        {
            var data = UserInfoCollection.Find(it => it.USERID == dataUser.USERID && it.PASSWORD == dataUser.PASSWORD).ToList();

            return(data);
        }
示例#10
0
        public List <model1> GetAllUserInfo(string TID, string CWT)
        {
            var data = UserInfoCollection.Find(it => true).ToList();

            return(data);
        }