void wcf_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                FBFriendsList fl = JsonStringSerializer.Deserialize<FBFriendsList>(e.Result);
                if (fl == null)
                {
                    MessageBox.Show("Make some friends first!!");
                }
                else if (fl.Friends == null)
                {
                    MessageBox.Show("Make some friends first");
                }
                else
                {

                    int idx = random.Next() % fl.Friends.Count();
                    fbf1 = fl.Friends[idx];
                    idx = random.Next() % fl.Friends.Count();
                    fbf2 = fl.Friends[idx];

                    whichIsCorrect = random.Next() % 2;

                    if (whichIsCorrect == 0)
                    {
                        imgPersonPic2.Source = new BitmapImage(new Uri(fbf1.PicLink));
                    }
                    else
                    {
                        imgPersonPic1.Source = new BitmapImage(new Uri(fbf1.PicLink));
                    }

                    WebClient m_wcLoadFeeds = new WebClient();
                    m_wcLoadFeeds.DownloadStringCompleted += new DownloadStringCompletedEventHandler(m_wcLoadFeeds_DownloadStringCompleted);

                    string at = App.AccessToken;
                    Uri uri = SaysWho.HelperClasses.FBUris.GetWallUri(at, fbf2.ID);
                    m_wcLoadFeeds.DownloadStringAsync(uri);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error getting friend list " + ex);
            }
        }
Exemplo n.º 2
0
        public static void StoreFriends(string strOwnerID, FBFriend[] aFriends)
        {
            EnsureDBConnection();
            if(m_cmdInsertFriend == null) {
                m_cmdInsertFriend = new EfzCommand("INSERT INTO Friends(OwnerID, FriendID, Name) VALUES(@OwnerID, @FriendID, @Name)", m_conDB);
                m_cmdInsertFriend.Parameters.Add(new EfzParameter() { DbType = EfzType.VarChar, ParameterName = "@OwnerID" });
                m_cmdInsertFriend.Parameters.Add(new EfzParameter() { DbType = EfzType.VarChar, ParameterName = "@FriendID" });
                m_cmdInsertFriend.Parameters.Add(new EfzParameter() { DbType = EfzType.VarChar, ParameterName = "@Name" });
            }
            //brute force - don't check for existing / new - simply kill the old ones and enter the current friends
            DeleteFriends(strOwnerID);

            m_cmdInsertFriend.Parameters["@OwnerID"].Value = strOwnerID;
            int nCnt = aFriends.Length;
            for(int nX = 0; nX < nCnt; nX++) {
                m_cmdInsertFriend.Parameters["@FriendID"].Value = aFriends[nX].ID;
                m_cmdInsertFriend.Parameters["@Name"].Value = aFriends[nX].Name;
                m_cmdInsertFriend.ExecuteNonQuery();
            }
        }