Exemple #1
0
        public static async Task <bool> UpdateProfile()
        {
            string friendRawData = await KakaoRequestClass.GetFriendData();

            string profileRawData = await KakaoRequestClass.GetProfileData();

            UserFriends = JsonConvert.DeserializeObject <FriendData.Friends>(friendRawData);
            UserProfile = JsonConvert.DeserializeObject <UserProfile.ProfileData>(profileRawData);
            return(true);
        }
        private async void BT_BackupFriends_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder      builder            = new StringBuilder();
            List <string[]>    ids                = new List <string[]>();
            var                friends            = JsonConvert.DeserializeObject <FriendData.Friends>(await KakaoRequestClass.GetFriendData());
            ProgressShowWindow progressShowWindow = new ProgressShowWindow();

            progressShowWindow.Show();
            progressShowWindow.Topmost = true;
            progressShowWindow.Title   = "친구 목록 백업중";
            int progressCount = 0;

            foreach (var friend in friends.profiles)
            {
                try
                {
                    KakaoRequestClass.notShowError = true;
                    var profile = await KakaoRequestClass.GetProfileFeed(friend.id, null, true);

                    KakaoRequestClass.notShowError = false;
                    builder.Append(profile.profile.display_name);
                    builder.Append(" : ");
                    builder.Append(profile.profile.permalink);
                    builder.Append("\n");
                    ids.Add(new string[] { profile.profile.permalink, profile.profile.id, profile.profile.display_name });
                }
                catch (Exception) { }
                progressCount++;
                progressShowWindow.PB_Main.Value = ((double)progressCount / friends.profiles.Count) * 100.0;
            }
            Clipboard.SetDataObject(builder.ToString());
            progressShowWindow.isFinish = true;
            progressShowWindow.Close();
            var sfd = new System.Windows.Forms.SaveFileDialog()
            {
                FileName = DateTime.Now.ToShortDateString() + ".kfd2",
                Filter   = "Kakao Friend Data V2|*.kfd2",
                Title    = "친구 목록 저장"
            };

            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var str    = JsonConvert.SerializeObject(ids);
                var writer = new System.IO.StreamWriter(sfd.FileName);
                writer.Write(str);
                writer.Close();
            }
            MessageBox.Show("클립보드에 친구 정보가 복사됐습니다.");
        }