예제 #1
0
        public async Task <object> GetFullStory(int storyid)
        {
            FullStory fs           = FullStoryFactory.GetFullStory(storyid);
            string    json         = fs.GetCommentTreeString();
            string    tagCloudJson = fs.GetTagCloudTreeString();
            Dictionary <int, string> commentDictionary = GetCommentDictionary(fs);
            List <CommentObj>        comments          = new List <CommentObj>();
            List <SentenceObj>       topSentenceObjs   = fs.GetTopSentences(5);

            foreach (var item in commentDictionary)
            {
                comments.Add(new CommentObj()
                {
                    Id = item.Key, Text = item.Value
                });
            }
            List <UserCommentObj> userComments = new List <UserCommentObj>();
            var userCommentsForStory           = fs.GetUserComments();

            foreach (var kvp in userCommentsForStory)
            {
                userComments.Add(new UserCommentObj()
                {
                    User = kvp.Key, Comments = kvp.Value
                });
            }
            List <KeywordCommentObj> keywordComments = new List <KeywordCommentObj>();
            var namedObjectsForStory = fs.GetNamedObjects(20);

            foreach (var kvp in namedObjectsForStory)
            {
                keywordComments.Add(new KeywordCommentObj()
                {
                    Keyword = kvp.Key, Comments = kvp.Value
                });
            }
            Directory.CreateDirectory("data");
            string fileName = Path.Combine("data", "following.txt");

            if (!File.Exists(fileName))
            {
                File.Create(fileName);
            }
            string[] following        = File.ReadAllLines(fileName);
            string   csv              = string.Join(",", following);
            string   fileNameWatching = Path.Combine("data", "watching.txt");

            if (!File.Exists(fileNameWatching))
            {
                File.Create(fileNameWatching);
            }
            string[]     watching     = File.ReadAllLines(fileNameWatching);
            string       csvWatching  = string.Join(",", watching);
            FullStoryObj fullStoryObj = new FullStoryObj()
            {
                Json = json, TagCloudJson = tagCloudJson, TotalComments = commentDictionary.Count, Comments = comments, Sentences = topSentenceObjs, UserComments = userComments, KeywordComments = keywordComments, AllFollowing = csv, AllWatching = csvWatching, TotalWords = fs.TotalWords
            };

            return(fullStoryObj);
        }
예제 #2
0
 public async Task<object> GetFullStory(int storyid)
 {
     FullStory fs = FullStoryFactory.GetFullStory(storyid);
     string json = fs.GetCommentTreeString();
     string tagCloudJson = fs.GetTagCloudTreeString();
     Dictionary<int, string> commentDictionary = GetCommentDictionary(fs);
     List<CommentObj> comments = new List<CommentObj>();
     List<SentenceObj> topSentenceObjs = fs.GetTopSentences(5);
     foreach (var item in commentDictionary)
     {
         comments.Add(new CommentObj() { Id = item.Key, Text = item.Value });
     }
     List<UserCommentObj> userComments = new List<UserCommentObj>();
     var userCommentsForStory = fs.GetUserComments();
     foreach (var kvp in userCommentsForStory)
     {
         userComments.Add(new UserCommentObj(){User = kvp.Key,Comments = kvp.Value});
     }
     List<KeywordCommentObj> keywordComments = new List<KeywordCommentObj>();
     var namedObjectsForStory = fs.GetNamedObjects(20);
     foreach (var kvp in namedObjectsForStory)
     {
         keywordComments.Add(new KeywordCommentObj(){Keyword = kvp.Key,Comments = kvp.Value});
     }
     Directory.CreateDirectory("data");
     string fileName = Path.Combine("data", "following.txt");
     if (!File.Exists(fileName))
     {
         File.Create(fileName);
     }
     string[] following = File.ReadAllLines(fileName);
     string csv = string.Join(",", following);
     string fileNameWatching = Path.Combine("data", "watching.txt");
     if (!File.Exists(fileNameWatching))
     {
         File.Create(fileNameWatching);
     }
     string[] watching = File.ReadAllLines(fileNameWatching);
     string csvWatching = string.Join(",", watching);
     FullStoryObj fullStoryObj = new FullStoryObj() { Json = json, TagCloudJson = tagCloudJson,TotalComments = commentDictionary.Count,Comments = comments,Sentences = topSentenceObjs,UserComments = userComments,KeywordComments = keywordComments,AllFollowing = csv, AllWatching = csvWatching,TotalWords = fs.TotalWords};
     return fullStoryObj;
 }