public void Dispose()
 {
     CurrentNode = null;
     doc = null;
 }
 public FacebookDataReader(Facebook.JsonArray json)
 {
     doc = json;
 }
 public void Close()
 {
     CurrentNode = null;
     doc = null;
 }
Exemple #4
0
        private void btnAreFriends_Click(object sender, EventArgs e)
        {
            // calculate total calls to Facebook for this
            int totalCalls = 0;

            // ((n) + (n-1) + (n-2) + ... 1) - n = number of combinations
            for (int i = Friends.Keys.Count; i > 0; i--)
            {
                totalCalls += i;
            }
            totalCalls -= Friends.Keys.Count;

            if (MessageBox.Show(
                    string.Format("Warning: checking for friend relationships can take a long time! \n(Generates {0} calls to Facebook to check friend combinations).  \n\nDo you want to continue?", totalCalls),
                    "Warning: Long operation", MessageBoxButtons.YesNo)
                == System.Windows.Forms.DialogResult.Yes)
            {
                // init array of friend IDs
                FriendIds = new string[Friends.Keys.Count];
                Friends.Keys.CopyTo(FriendIds, 0);

                for (int i = 0; i < FriendIds.Length; i++)
                {
                    for (int j = i + 1; j < FriendIds.Length; j++)
                    {
                        try
                        {
                            tsStatusMessage.Text = string.Format("Checking {0} and {1}", Friends[FriendIds[i]].Name, Friends[FriendIds[j]].Name);
                            Application.DoEvents();

                            Dictionary <string, object> parms = new Dictionary <string, object>();
                            parms.Add("method", "friends.areFriends");
                            parms.Add("uids1", FriendIds[i]);
                            parms.Add("uids2", FriendIds[j]);
                            parms.Add("format", "json");
                            object             obj  = app.Api(parms);
                            Facebook.JsonArray resp = (Facebook.JsonArray)obj;
                            if ((bool)((Facebook.JsonObject)resp[0])["are_friends"] == true)
                            {
                                string friendId1   = ((Facebook.JsonObject)resp[0])["uid1"].ToString();
                                string friendId2   = ((Facebook.JsonObject)resp[0])["uid2"].ToString();
                                string friendName1 = Friends.ContainsKey(friendId1) ?
                                                     Friends[friendId1].Name : "";
                                string friendName2 = Friends.ContainsKey(friendId2) ?
                                                     Friends[friendId2].Name : "";

                                FriendPairs.Add(string.Format("{0},{1},{2},{3}",
                                                              friendId1, friendId2, friendName1, friendName2));
                                FriendPairs.Add(string.Format("{0},{1},{2},{3}",
                                                              friendId2, friendId1, friendName2, friendName1));
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                lblStep5.Visible     = true;
                tsStatusMessage.Text = "Check for who is friends with who: complete!";
            }
        }
 public void Dispose()
 {
     CurrentNode = null;
     doc         = null;
 }
 public void Close()
 {
     CurrentNode = null;
     doc         = null;
 }
 public FacebookDataReader(Facebook.JsonArray json)
 {
     doc = json;
 }