コード例 #1
0
        /// <summary>
        /// 获取一页祈愿数据
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>
        private List <WishData> GetWishLog(QueryParam param)
        {
            List <WishData> list   = new List <WishData>();
            var             url    = $@"{baseRequestUrl}{authString}&{param}";
            var             str    = HttpClient.GetStringAsync(url).Result;
            var             result = JsonSerializer.Deserialize <ResponseData>(str);

            if (result.Retcode != 0)
            {
                throw new ArgumentException(result.Message);
            }
            if (result.Data.List.Count != 0)
            {
                list.AddRange(result.Data.List);
            }
            return(list);
        }
コード例 #2
0
        /// <summary>
        /// 获取Url所属的Uid
        /// </summary>
        /// <exception cref="Exception">没有祈愿记录</exception>
        /// <returns></returns>
        public async Task <int> GetUidByUrl()
        {
            var list = new List <WishData>();
            await Task.Run(() =>
            {
                QueryParam param = new QueryParam()
                {
                    WishType = WishType.Novice, Page = 1, Size = 6, EndId = 0
                };
                list.AddRange(GetWishLog(param));
                param = new QueryParam()
                {
                    WishType = WishType.Permanent, Page = 1, Size = 6, EndId = 0
                };
                list.AddRange(GetWishLog(param));
                param = new QueryParam()
                {
                    WishType = WishType.CharacterEvent, Page = 1, Size = 6, EndId = 0
                };
                list.AddRange(GetWishLog(param));
                param = new QueryParam()
                {
                    WishType = WishType.WeaponEvent, Page = 1, Size = 6, EndId = 0
                };
                list.AddRange(GetWishLog(param));
            });

            if (list.Any())
            {
                return(list.First().Uid);
            }
            else
            {
                throw new Exception("没有祈愿记录");
            }
        }