示例#1
0
文件: Bot.cs 项目: Termininja/BGNews
        private static async Task ProcessPost(Post post)
        {
            Console.WriteLine("\nPost: " + post.Title);
            await Task.Delay(5000);
            var postTags = await GetTags(post.Link);
            if (postTags.Count > 0)
            {
                postTags = postTags.OrderBy(x => x).ToList();
                postTags.ForEach(async t =>
                {
                    if (!tags.ContainsKey(t))
                    {
                        Task.Run(() => AddTag(t)).Wait();
                        await Task.Delay(1000);
                        Console.WriteLine("A new tag was created: " + t);
                    }
                });

                Console.WriteLine(postTags.Count + " tags was found in the post.");
                postTags.ForEach(x => post.Tags.Add(tags[x]));
            }
            else Console.WriteLine("No tags was found in the post!");

            posts.Add(post.Title, new ParseObject("Post"));
            Task.Run(() => AddPost(post)).Wait();
        }
示例#2
0
文件: Bot.cs 项目: Termininja/BGNews
 private static async Task AddPost(Post post)
 {
     var parsePost = new ParseObject("Post");
     parsePost["title"] = post.Title;
     parsePost["category"] = post.Category;
     parsePost["image"] = post.Image;
     parsePost["content"] = post.Content;
     parsePost["tags"] = post.Tags;
     parsePost["user"] = currentUser;
     await parsePost.SaveAsync();
     await Task.Delay(1000);
     Console.WriteLine("A new post was created in category " + post.Category.Get<string>("name"));
 }