예제 #1
0
        /// <summary>
        /// 获取用户所在的团队
        /// </summary>
        /// <returns>ObservableCollection<Team></returns>
        public static async Task<ObservableCollection<Team>> GetTeamList()
        {
            string url = apiUrl + "teams";
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("access_token", AccessToken);

            string json = await Helper.HttpHelper.DoGet(url, parameters);
            if (string.IsNullOrEmpty(json))
            {
                return null;
            }
            else
            {
                //开始解析返回数据
                try
                {
                    Debug.WriteLine("开始解析返回json---\n" + json);
                    JArray result = JArray.Parse(json);
                    Debug.WriteLine("解析返回json成功---\n");

                    ObservableCollection<Team> TeamList = new ObservableCollection<Team>();
                    foreach (JObject obj in result)
                    {
                        Team team = new Team();
                        team.TeamId = obj["team_id"].ToString();
                        team.URL = obj["url"].ToString();
                        team.Name = obj["name"].ToString();
                        team.Description = obj["desc"].ToString();
                        team.CreateTime = (DateTime)obj["created_at"];
                        team.Visibility = (Team.TeamVisibility)int.Parse(obj["visibility"].ToString());
                        TeamList.Add(team);
                    }
                    return TeamList;
                }
                catch (Exception)
                {
                    Debug.WriteLine("解析返回json失败---\n" + json);
                    return null;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 获取团队信息
        /// </summary>
        /// <param name="TeamId">团队id</param>
        /// <returns></returns>
        public static async Task<Team> GetTeamInfo(string TeamId)
        {
            string url = apiUrl + "teams/" + TeamId;
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("access_token", AccessToken);
            parameters.Add("team_id", TeamId);

            string json = await Helper.HttpHelper.DoGet(url, parameters);
            if (string.IsNullOrEmpty(json))
            {
                return null;
            }
            else
            {
                //开始解析返回数据
                try
                {
                    Debug.WriteLine("开始解析返回json---\n" + json);
                    JArray result = JArray.Parse(json);
                    Debug.WriteLine("解析返回json成功---\n");

                    Team team = new Team();
                    team.TeamId = result["team_id"].ToString();
                    team.URL = result["url"].ToString();
                    team.Name = result["name"].ToString();
                    team.Logo = result["pic"].ToString();
                    team.Description = result["desc"].ToString();
                    team.CreateTime = (DateTime)result["created_at"];
                    team.Visibility = (Team.TeamVisibility)int.Parse(result["visibility"].ToString());

                    JObject createdBy = result["created_by"] as JObject;
                    team.CreatedBy.Uid = createdBy["uid"].ToString();
                    team.CreatedBy.Name = createdBy["name"].ToString();
                    team.CreatedBy.NickName = createdBy["display_name"].ToString();
                    team.CreatedBy.HeadImage = createdBy[" avatar"].ToString();
                    team.CreatedBy.Description = createdBy["desc"].ToString();
                    team.CreatedBy.Status = (UserProfile.UserStatus)int.Parse(createdBy["status"].ToString());
                    team.CreatedBy.Online = (UserProfile.UserOnline)int.Parse(createdBy["online"].ToString());

                    return team;
                }
                catch (Exception)
                {
                    Debug.WriteLine("解析返回json失败---\n" + json);
                    return null;
                }
            }
        }
예제 #3
0
 private void GotoTeamPage(Team team)
 {
     frame.Navigate(typeof(View.TeamPage), team);
 }