public static List<FacebookStreamEntry> JSONToStreamEntries(JSONObject obj)
        {
            List<FacebookStreamEntry> entries = new List<FacebookStreamEntry>();

            try
            {
                JSONObject data = obj.Dictionary["data"];
                foreach (JSONObject dataEntry in data.Array)
                {
                    FacebookStreamEntry entry = new FacebookStreamEntry()
                    {
                        ActorID = dataEntry.Dictionary["actor_id"].Integer,
                        CreatedTime = TimeHelpers.UnixToDateTime(dataEntry.Dictionary["created_time"].Integer),
                        Message = dataEntry.Dictionary["message"].String,
                        PostID = dataEntry.Dictionary["post_id"].String
                    };

                    entries.Add(entry);
                }
            }
            catch (Exception ex)
            {
                Logger.Warn("Failed to parse a JSON object to a facebook entry. Exception detail: " + ex);
            }

            return entries;
        }
Пример #2
0
        /// <summary>
        /// Recursively constructs this JSONObject 
        /// </summary>
        private static JSONObject Create(object o)
        {
            JSONObject obj = new JSONObject();
            if (o is object[])
            {
                object[] objArray = o as object[];
                obj._arrayData = new JSONObject[objArray.Length];
                for (int i = 0; i < obj._arrayData.Length; ++i)
                {
                    obj._arrayData[i] = Create(objArray[i]);
                }
            }
            else if (o is Dictionary<string, object>)
            {
                obj._dictData = new Dictionary<string, JSONObject>();
                Dictionary<string, object> dict =
                    o as Dictionary<string, object>;
                foreach (string key in dict.Keys)
                {
                    obj._dictData[key] = Create(dict[key]);
                }
            }
            else if (o != null) // o is a scalar
            {
                obj._stringData = o.ToString();
            }

            return obj;
        }
Пример #3
0
        public ActionResult returnfromfb()
        {
            Employee e    = new Employee();
            string   code = Request.QueryString["code"];

            if (code == null)
            {
                return(RedirectToAction("LastWindow", "Login"));
            }
            string AccessToken = "";

            try
            {
                if (code != null)
                {
                    string         str = "https://graph.facebook.com/oauth/access_token?client_id=" + System.Web.Configuration.WebConfigurationManager.AppSettings["facebookappid"] + "&redirect_uri=http://" + Request.Url.Authority + "/Home/returnfromfb&client_secret=" + System.Web.Configuration.WebConfigurationManager.AppSettings["facebookappsecret"] + "&code=" + code;
                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(str);
                    req.Method      = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    byte[] Param      = Request.BinaryRead(System.Web.HttpContext.Current.Request.ContentLength);
                    string strRequest = System.Text.Encoding.ASCII.GetString(Param);

                    req.ContentLength = strRequest.Length;

                    StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                    streamOut.Write(strRequest);
                    streamOut.Close();
                    StreamReader streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
                    string       strResponse = streamIn.ReadToEnd();
                    if (strResponse.Contains("&expires"))
                    {
                        strResponse = strResponse.Substring(0, strResponse.IndexOf("&expires"));
                    }
                    AccessToken = strResponse.Replace("access_token=", "");
                    streamIn.Close();
                }

                Facebook.FacebookAPI api = new Facebook.FacebookAPI(AccessToken);
                string request           = "/me";

                Facebook.JSONObject fbobject = api.Get(request);
                try
                {
                    string   fbId  = fbobject.Dictionary["id"].String;
                    string   email = fbobject.Dictionary["email"].String;
                    Employee e2    = db.EmployeeDB.Where(x => x.Email == email).FirstOrDefault();
                    if (e2 == null)
                    {
                        Employee e1 = db.EmployeeDB.Where(x => x.FacebookId == fbId).FirstOrDefault();
                        if (e1 == null)
                        {
                            e.FirstName = fbobject.Dictionary["first_name"].String;
                            e.LastName  = fbobject.Dictionary["last_name"].String;
                            e.Email     = email;
                            e.Gender    = fbobject.Dictionary["gender"].String;
                            if (fbobject.Dictionary.ContainsKey("birthday"))
                            {
                                e.DateOfBirth = Convert.ToDateTime(fbobject.Dictionary["birthday"].String);
                            }
                            e.FacebookId = fbId;
                            e.Created    = DateTime.Now;
                            e.Updated    = DateTime.Now;
                            db.EmployeeDB.Add(e);
                            db.SaveChanges();
                            Session["userId"]     = e.Id;
                            Session["firstLogin"] = true;

                            string         str         = "http://graph.facebook.com/" + fbobject.Dictionary["id"].String + "?fields=picture.type(large)";
                            HttpWebRequest req         = (HttpWebRequest)WebRequest.Create(str);
                            StreamReader   streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
                            string         strResponse = streamIn.ReadToEnd();
                            JObject        je          = new JObject();
                            je = JObject.Parse(strResponse);

                            string ProfilePicURL = je["picture"]["data"]["url"].ToString().Replace("\"", "");
                            UploadProfilePic(ProfilePicURL, e.Id);
                        }
                        else
                        {
                            return(RedirectToAction("Resume", "Profile"));
                        }
                    }
                    else
                    {
                        e2.FacebookId = fbId;
                        db.SaveChanges();
                        Session["userId"] = e2.Id;
                        return(RedirectToAction("Resume", "Profile"));
                    }
                }
                catch (Exception ex)
                {
                }
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("Resume", "Profile"));
        }
        private void GetKeyValues
        (
            JSONObject ob,
            out string sPageGroupID,
            out string sImageURL,
            out string sTitle,
            out string sDescription,
            out string sLikes,
            out string sTalking
        )
        {
            sPageGroupID = "";
            sImageURL = "";
            sTitle = "";
            sDescription = "";
            sLikes = "";
            sTalking = "";

            if (ob.Dictionary.ContainsKey("id"))
            {
                sPageGroupID = ob.Dictionary["id"].String;
            }
            if (ob.Dictionary.ContainsKey("picture"))
            {
                sImageURL = ob.Dictionary["picture"].Dictionary["data"].Dictionary["url"].String;
            }
            if (ob.Dictionary.ContainsKey("name"))
            {
                sTitle = ob.Dictionary["name"].String;
            }
            if (ob.Dictionary.ContainsKey("category"))
            {
                sDescription = ob.Dictionary["category"].String;
            }
            if (ob.Dictionary.ContainsKey("likes"))
            {
                sLikes = ob.Dictionary["likes"].String;
            }
            if (ob.Dictionary.ContainsKey("talking_about_count"))
            {
                sTalking = ob.Dictionary["talking_about_count"].String;
            }
        }
 private void AddToResultsPanel
 (
     JSONObject oResults
 )
 {
     if (oResults != null && oResults.IsDictionary && oResults.Dictionary.ContainsKey("data"))
     {
         string sPageGroupID;
         string sImageURL;
         string sTitle;
         string sDescription;
         string sLikes;
         string sTalking;
         flpResults.Controls.Clear();
         foreach (JSONObject ob in oResults.Dictionary["data"].Array)
         {
             GetKeyValues(ob, out sPageGroupID, out sImageURL, out sTitle, out sDescription, out sLikes, out sTalking);
             flpResults.Controls.Add(new SearchResultsComboBox(
                 sPageGroupID, sImageURL,
                 sTitle, sDescription,
                 sLikes, sTalking, this));
         }
         pnResults.Visible = true;
         piLoading.SendToBack();
         piLoading.Stop();
     }
 }
Пример #6
0
 public DynamicJSONObject(JSONObject source)
 {
     this.source = source;
 }
Пример #7
0
 private object ToResult(JSONObject json)
 {
     if (json.IsInteger)
         return json.Integer;
     else if (json.IsBoolean)
         return json.Boolean;
     else if (json.IsString)
         return json.String;
     else if (json.IsArray)
         return new DynamicJSONObject(json);
     else if (json.IsDictionary)
         return new DynamicJSONObject(json);
     return json;
 }
        private void GetKeyValues
        (
            JSONObject ob,
            out string sPageGroupID,
            out string sImageURL,
            out string sTitle,
            out string sDescription,
            out string sMembers
        )
        {
            sPageGroupID = "";
            sImageURL = "https://www.facebook.com/images/icons/group-types/large/default.png";
            sTitle = "";
            sDescription = "Group";
            sMembers = "";

            if (ob.Dictionary.ContainsKey("id"))
            {
                sPageGroupID = ob.Dictionary["id"].String;
            }            
            if (ob.Dictionary.ContainsKey("name"))
            {
                sTitle = ob.Dictionary["name"].String;
            }            
        }
        AddUserUserCommentsEdges
        (
            ref GraphMLXmlDocument oGraphMLXmlDocument,
            Dictionary<string, Dictionary<string, List<string>>> commentersComments,
            JSONObject streamPosts,
            Dictionary<string, Dictionary<string, JSONObject>> attributeValues
        )
        {
            Dictionary<string, List<string>> postCommenters = new Dictionary<string,List<string>>();
            XmlNode oEdgeXmlNode = null;
            List<string> postsIntersection = new List<string>();
            string posts = "";

            //Create the Post-Commenter relationship from commenterComments
            foreach(JSONObject item in streamPosts.Array)
            {
                foreach (KeyValuePair<string, Dictionary<string, List<string>>> kvp in commentersComments)
                {
                    if (kvp.Value.ContainsKey(item.Dictionary["post_id"].String))
                    {
                        try
                        {
                            postCommenters[item.Dictionary["post_id"].String].Add(kvp.Key);
                            
                        }
                        catch (KeyNotFoundException e)
                        {
                            List<string> tmp = new List<string>();
                            tmp.Add(kvp.Key);
                            postCommenters.Add(item.Dictionary["post_id"].String, tmp);
                        }                        
                    }
                }
            }

            //Add Edges
            foreach (KeyValuePair<string, List<string>> kvp in postCommenters)
            {
                for (int i = 0; i < kvp.Value.Count - 1; i++)
                {
                    for (int j = i + 1; j < kvp.Value.Count; j++)
                    {
                        //Sometimes a commenter or liker can be another fan page and this is not a user
                        if (!usersDisplayName.ContainsKey(kvp.Value[i]) ||
                            !usersDisplayName.ContainsKey(kvp.Value[j])) continue;
                        
                        oEdgeXmlNode = oGraphMLXmlDocument.AppendEdgeXmlNode(usersDisplayName[kvp.Value[i]],
                                                                            usersDisplayName[kvp.Value[j]]);
                       
                        postsIntersection = commentersComments[kvp.Value[i]].Keys.Intersect(commentersComments[kvp.Value[j]].Keys).ToList();
                        oGraphMLXmlDocument.AppendGraphMLAttributeValue(oEdgeXmlNode, "e_weight", postsIntersection.Count);
                        string[] postsToJoin = (from p in postsIntersection
                                                        select new { Post = streamPosts.Array.Single(x => x.Dictionary["post_id"].String.Equals(p)).Dictionary["message"].String }).Select(x => x.Post).ToArray();
                        posts = String.Join("\n\n", postsToJoin);
                        oGraphMLXmlDocument.AppendGraphMLAttributeValue(oEdgeXmlNode, "post", posts);
                        oGraphMLXmlDocument.AppendGraphMLAttributeValue(oEdgeXmlNode, "Relationship", "Co-Commenter");                        
                    }
                }
            }                                                           
        }
 AddEdges
 (
     ref GraphMLXmlDocument oGraphMlXmlDocument,
     List<NetworkType> netTypes,
     Dictionary<string, Dictionary<string, List<string>>> commentersComments,
     Dictionary<string, List<string>> likersPosts,
     JSONObject streamPosts,
     Dictionary<string, Dictionary<string, JSONObject>> attributeValues
 )
 {
     if (netTypes.Contains(NetworkType.UserUserComments))
     {
         AddUserUserCommentsEdges(ref oGraphMlXmlDocument, commentersComments,
                             streamPosts, attributeValues);
     }
     if (netTypes.Contains(NetworkType.UserUserLikes))
     {
         AddUserUserLikesEdges(ref oGraphMlXmlDocument, likersPosts,
                         streamPosts, attributeValues);
     }
     if (netTypes.Contains(NetworkType.PostPostComments))
     {
         AddPostPostCommentsEdges(ref oGraphMlXmlDocument, commentersComments);
     }
     if (netTypes.Contains(NetworkType.PostPostLikes))
     {
         AddPostPostLikesEdges(ref oGraphMlXmlDocument, likersPosts);
     }
     if (netTypes.Contains(NetworkType.UserPostComments))
     {
         AddUserPostCommentsEdges(ref oGraphMlXmlDocument, commentersComments,
                         attributeValues);
     }
     if (netTypes.Contains(NetworkType.UserPostLikes))
     {
         AddUserPostLikesEdges(ref oGraphMlXmlDocument, likersPosts,
                         attributeValues);
     }  
 }
        AddPostVertices
        (
            ref GraphMLXmlDocument oGraphMLXmlDocument,
            JSONObject streamPosts
        )
        {
            XmlNode oVertexXmlNode;

            //Add nodes (posts)
            foreach (JSONObject ob in streamPosts.Array)
            {
                oVertexXmlNode = oGraphMLXmlDocument.AppendVertexXmlNode(ob.Dictionary["post_id"].String);

                //Add tooltip
                AppendVertexTooltipXmlNodes(oGraphMLXmlDocument, oVertexXmlNode,
                    ob.Dictionary["post_id"].String, ob.Dictionary["message"].String);
                //Add attributes
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, "type", "2");
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, LabelColumnName, ob.Dictionary["message"].String);
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, "content", ob.Dictionary["message"].String);
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, MenuTextID,
                    "Open Facebook Page for This Post");
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, MenuActionID,
                    ob.Dictionary["permalink"].String);
                //If the post contains a link to a video, photo, document etc
                //and it has a picture, use it as the post image
                if(ob.Dictionary["attachment"].Dictionary.ContainsKey("media") &&
                    ob.Dictionary["attachment"].Dictionary["media"].Array.Length>0)
                {
                    oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode, "Image",
                        ob.Dictionary["attachment"].Dictionary["media"].Array[0].Dictionary["src"].String);
                }
                
            }
        }
        AddVertices
        (
            ref GraphMLXmlDocument oGraphMLXmlDocument,
            ref Dictionary<string, Dictionary<string, JSONObject>> attributeValues,            
            Dictionary<Attribute, bool> attributes,            
            List<NetworkType> netTypes,
            Dictionary<string, Dictionary<string, List<string>>> commentersComments,
            Dictionary<string, List<string>> likersPosts,
            JSONObject streamPosts
        )
        {            
            Dictionary<string, List<Dictionary<string, object>>> statusUpdates = new Dictionary<string, List<Dictionary<string, object>>>();
            Dictionary<string, List<Dictionary<string, object>>> wallPosts = new Dictionary<string, List<Dictionary<string, object>>>();
            List<string> uniqueVertices;            

            
            //In case commenters and likers vertices need to be added
            //we have to produce unique vertices since a liker can be
            //also a commenter and this will result in having duplicate
            //vertices
            if ((netTypes.Contains(NetworkType.UserUserComments) ||                
                netTypes.Contains(NetworkType.UserPostComments)) &&
                netTypes.Contains(NetworkType.UserUserLikes) ||                
                netTypes.Contains(NetworkType.UserPostLikes))
            {
                uniqueVertices = commentersComments.Keys.ToList().Union(likersPosts.Keys.ToList()).Distinct().ToList();
                attributeValues = getAttributes(attributes, uniqueVertices);
                ManageDisplayNames(ref attributeValues);
                if (bGetStatusUpdates)
                {
                    statusUpdates = GetStatusUpdates(uniqueVertices);
                }

                if (bGetWallPosts)
                {
                    wallPosts = GetWallPosts(uniqueVertices);
                }

                //Add all commenters vertices
                AddCommenterVertices(ref oGraphMLXmlDocument,
                                     commentersComments, attributeValues,                                       
                                     statusUpdates, wallPosts);                

                //Add likers vertices by excluding those who are also commenters
                AddLikerVertices(ref oGraphMLXmlDocument, likersPosts.Where(x=>!commentersComments.ContainsKey(x.Key)).ToDictionary(y=>y.Key, y=>y.Value),
                    attributeValues, statusUpdates,wallPosts);
                
                
            }               
            //Only commenters vertices will be added
            else if (netTypes.Contains(NetworkType.UserUserComments) ||
                    netTypes.Contains(NetworkType.UserPostComments))
            {
                attributeValues = getAttributes(attributes, commentersComments.Keys.ToList());
                ManageDisplayNames(ref attributeValues);
                if (bGetStatusUpdates)
                {
                    statusUpdates = GetStatusUpdates(commentersComments.Keys.ToList());
                }

                if (bGetWallPosts)
                {
                    wallPosts = GetWallPosts(commentersComments.Keys.ToList());
                }
                AddCommenterVertices(ref oGraphMLXmlDocument,
                                     commentersComments, attributeValues,                                      
                                     statusUpdates, wallPosts);                
            }
            //Only likers vertices will be added
            else if (netTypes.Contains(NetworkType.UserUserLikes) ||
                    netTypes.Contains(NetworkType.UserPostLikes))
            {
                attributeValues = getAttributes(attributes, likersPosts.Keys.ToList());
                ManageDisplayNames(ref attributeValues);
                if (bGetStatusUpdates)
                {
                    statusUpdates = GetStatusUpdates(likersPosts.Keys.ToList());
                }

                if (bGetWallPosts)
                {
                    wallPosts = GetWallPosts(likersPosts.Keys.ToList());
                }
                AddLikerVertices( ref oGraphMLXmlDocument,
                                likersPosts, attributeValues,                                 
                                statusUpdates, wallPosts);
            }

            //Add post vertices if any related network is selected
            if (netTypes.Contains(NetworkType.UserPostComments) ||
                netTypes.Contains(NetworkType.UserPostLikes) ||
                netTypes.Contains(NetworkType.PostPostComments) ||
                netTypes.Contains(NetworkType.PostPostLikes))
            {
                AddPostVertices(ref oGraphMLXmlDocument, streamPosts);
            }
        }
        DownloadComments
        (
            JSONObject streamPosts,
            int iLimit
        )
        {
            Debug.Assert(fbAPI != null);
            Debug.Assert(streamPosts.IsArray);
            AssertValid();

            JSONObject result = null;
            List<JSONObject> comments = new List<JSONObject>();

            CurrentStep++;
            ReportProgress(String.Format("Step {0}/{1}: Downloading commenters network", CurrentStep, NrOfSteps));
            if (streamPosts.IsArray)
            {
                for (int i = 0; i < streamPosts.Array.Length; i++)
                {
                    //Get the total number of likes for the actual post
                    int totalNrOfComments = iLimit<1?(int)streamPosts.Array[i].Dictionary["comment_info"].Dictionary["comment_count"].Integer:iLimit;
                    //We can get a maximum of 10000 results for multiqueries, so we have to make multiple multiqueries
                    //We have to get information from two different tables and we are limited to 5000 results each
                    //for a total of 10000 results for the whole multiquery
                    int nrOfMultiqueries = (int)Math.Ceiling(totalNrOfComments / 5000.0);
                    int nrOfQueries = 10;

                    for (int j = 0; j < nrOfMultiqueries; j++)
                    {
                        Dictionary<string, string> queries = new Dictionary<string, string>();
                        if ((j == nrOfMultiqueries - 1) && (nrOfMultiqueries % 10000 > 0))
                        {
                            nrOfQueries = (int)Math.Ceiling((nrOfMultiqueries % 10000) / 1000.0);
                        }
                        //Divide the 10000 results in 10 different queries with 1000 results each
                        //For each comment we get the commenter's information in another query.
                        for (int k = 0; k < nrOfQueries; k++)
                        {
                            int nrRes;
                            if (iLimit < 1)
                            {
                                nrRes = 1000;
                            }
                            else if (iLimit < 1000)
                            {
                                nrRes = iLimit;
                            }
                            else
                            {
                                nrRes = (k + 1) * 1000 > iLimit ? iLimit % (k * 1000) : 1000;
                            }
                            queries.Add("query" + (k + 1).ToString(), "SELECT fromid, text, post_id FROM comment WHERE post_id='" + streamPosts.Array[i].Dictionary["post_id"].String + "' ORDER BY time ASC LIMIT " + (k * 1000).ToString() + ", "+nrRes);
                        }

                        result = ExecuteFQLMultiqueryWithRetryRelogin(queries, String.Format("Step {0}/{1}: Downloading comments - Post {2}/{3}(Batch {4}/{5})",
                                                        CurrentStep, NrOfSteps, i + 1, streamPosts.Array.Length, j + 1, nrOfMultiqueries),false);
                                               

                        //After successfull run of the multiquery extract the data
                        if (result != null && result.IsArray)
                        {
                            for (int k = 0; k < result.Array.Length; k++)
                            {
                                comments.AddRange(result.Array[k].Dictionary["fql_result_set"].Array);
                            }

                        }
                    }
                }                
            }

            Dictionary<string, Dictionary<string, List<string>>> commentersComments = (from c in comments
                                                                                       group c by new { FromID = c.Dictionary["fromid"].String } into g
                                                                                       select new
                                                                                       {
                                                                                           Key = g.Key.FromID,
                                                                                           PostID = (from x in g
                                                                                                     group x by x.Dictionary["post_id"].String into g2
                                                                                                     select new
                                                                                                     {
                                                                                                         PostKey = g2.Key,
                                                                                                         List = g2.Select(c => c.Dictionary["text"].String).ToList()
                                                                                                     }
                                                                                              ).ToDictionary(y => y.PostKey, y => y.List)

                                                                                       }).ToDictionary(x => x.Key, x => x.PostID);

            return commentersComments;
        }
        AddPostDateRangeToNetworkDescription
        (
            JSONObject streamPosts,
            NetworkDescriber oNetworkDescriber
        )
        {
            DateTime minPostDate = DateTime.MaxValue;
            DateTime maxPostsDate = DateTime.MinValue;

            if (streamPosts.IsArray)
            {
                for (int i = 0; i < streamPosts.Array.Length; i++)
                {
                    DateTime tmp = DateUtil.ConvertToDateTime(double.Parse(streamPosts.Array[i].Dictionary["created_time"].String));                    

                    if (tmp <= minPostDate)
                    {
                        minPostDate = tmp;
                    }
                    
                    if(tmp >= maxPostsDate)
                    {
                        maxPostsDate = tmp;
                    }
                }
            }

            oNetworkDescriber.AddEventTime(
                "The earliest post in the network was posted ",
                minPostDate
                );

            oNetworkDescriber.AddEventTime(
                "The latest post in the network was posted ",
                maxPostsDate
                );
        }
        GetNetworkDescription
        (
            JSONObject streamPosts,
            String fanPageUsernameID,
            List<NetworkType> netTypes,
            int iFromPost,
            int iToPost,
            DateTime fromDate,          
            DateTime endDate,
            GraphMLXmlDocument oGraphMLXmlDocument
        )
        {
            Debug.Assert(oGraphMLXmlDocument != null);
            AssertValid();

            NetworkDescriber oNetworkDescriber = new NetworkDescriber();

            oNetworkDescriber.AddSentence(
                "The graph represents the {0} network of the \"{1}\" Facebook fan page.",
                ConcatenateNetworkTypes(netTypes),fanPageUsernameID
                );

            oNetworkDescriber.AddNetworkTime();

            if (iFromPost > 0 && iToPost >0)
            {
                oNetworkDescriber.AddSentence(
                    "Wall post from {0} to {1} of the fan page are analyzed.",
                    iFromPost, iToPost
                    );
            }
            else
            {
                oNetworkDescriber.AddSentence(
                    "Wall posts between {0} and {1} of the fan page are analyzed.",
                    fromDate, endDate
                    );
            }

            if (netTypes.Contains(NetworkType.UserUserComments))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between users that have co-commented on the same post."
                    );
            }

            if (netTypes.Contains(NetworkType.UserUserLikes))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between users that have co-liked on the same post."                    
                    );
            }

            if (netTypes.Contains(NetworkType.UserPostComments))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between the user that has commented "
                    +"and the post in which he has commented."                    
                    );
            }

            if (netTypes.Contains(NetworkType.UserPostLikes))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between the user that has liked "
                    + "and the post which he has liked."                    
                    );
            }

            if (netTypes.Contains(NetworkType.PostPostComments))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between posts that share the same commenters."
                    );
            }

            if (netTypes.Contains(NetworkType.PostPostLikes))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge between posts that share the same likers."
                    );
            }

            if (bGetWallPosts)
            {
                oNetworkDescriber.AddSentence(
                    "For each user, 8000 characters of his wall posts are downloaded."
                    );
            }

            if (bGetStatusUpdates)
            {
                oNetworkDescriber.AddSentence(
                    "For each user, 8000 characters of his status updates are downloaded."
                    );
            }

            if (bGetWallPosts || bGetStatusUpdates)
            {
                oNetworkDescriber.AddSentence(
                    "URLs, Hashtags and user tags are extracted from the downloaded"
                    + " wall posts/status updates."
                    );
            }

            AddPostDateRangeToNetworkDescription(streamPosts, oNetworkDescriber);

            return (oNetworkDescriber.ConcatenateSentences());
        }
Пример #16
0
 private static void RecursiveDictionaryToString(JSONObject obj, 
     StringBuilder sb, int level)
 {
     foreach (KeyValuePair<string, JSONObject> kvp in obj.Dictionary)
     {
         sb.Append(' ', level * 2);
         sb.Append(kvp.Key);
         sb.Append(" => ");
         RecursiveObjectToString(kvp.Value, sb, level);
         sb.AppendLine();
     }
 }
Пример #17
0
 private static void RecursiveObjectToString(JSONObject obj, 
     StringBuilder sb, int level)
 {
     if (obj.IsDictionary)
     {
         sb.AppendLine();
         RecursiveDictionaryToString(obj, sb, level + 1);
     }
     else if (obj.IsArray)
     {
         foreach (JSONObject o in obj.Array)
         {
             RecursiveObjectToString(o, sb, level);
             sb.AppendLine();
         }
     }
     else // some sort of scalar value
     {
         sb.Append(obj.String);
     }
 }
        private void AddToResultsPanel
        (
            JSONObject[] oResults
        )
        {
            if (oResults != null && oResults.Length>0)
            {
                string sPageGroupID;
                string sImageURL;
                string sTitle;
                string sDescription;
                string sMembers;

                flpResults.Controls.Clear();
                foreach (JSONObject ob in oResults)
                {
                    GetKeyValues(ob, out sPageGroupID, out sImageURL, out sTitle, out sDescription, out sMembers);
                    flpResults.Controls.Add(new SearchResultsComboBox(
                        sPageGroupID, sImageURL,
                        sTitle,sDescription,
                        sMembers,this));
                }
                pnResults.Visible = true;
                piLoading.SendToBack();
                piLoading.Stop();
            }
        }