static void Main(string[] args) { SkimurContext.Initialize(new Infrastructure.Registrar(), new Infrastructure.Membership.Registrar(), new Infrastructure.Email.Registrar(), new Infrastructure.Messaging.Registrar(), new Infrastructure.Messaging.RabbitMQ.Registrar(), new Subs.Registrar(), new Registrar()); using (SkimurContext.Resolve <IBusLifetime>()) { Console.WriteLine("Press enter to end process..."); Console.ReadLine(); } }
static void Main(string[] args) { SkimurContext.ContainerInitialized += Skimur.Cassandra.Migrations.Migrations.Run; SkimurContext.ContainerInitialized += Skimur.Postgres.Migrations.Migrations.Run; SkimurContext.Initialize(new Skimur.Markdown.Registrar(), new Skimur.Scraper.Registrar(), new Subs.Registrar(), new Registrar(), new Membership.Registrar()); using (SkimurContext.Resolve <IBusLifetime>()) { Console.WriteLine("Press enter to end process..."); Console.ReadLine(); } }
static void Main(string[] args) { SkimurContext.ContainerInitialized += Skimur.Cassandra.Migrations.Migrations.Run; SkimurContext.ContainerInitialized += Skimur.Postgres.Migrations.Migrations.Run; SkimurContext.Initialize(new Skimur.Markdown.Registrar(), new Skimur.Scraper.Registrar(), new Subs.Registrar(), new Subs.Worker.Registrar(), new Membership.Registrar()); using (SkimurContext.Resolve <IBusLifetime>()) { var subDao = SkimurContext.Resolve <ISubDao>(); var membershipService = SkimurContext.Resolve <IMembershipService>(); var postDao = SkimurContext.Resolve <IPostDao>(); var commentDao = SkimurContext.Resolve <ICommentDao>(); var defaultUser = membershipService.GetUserByUserName("skimur"); if (defaultUser == null) { Console.WriteLine("You must have a user with the username 'skimur' created to insert test data."); return; } foreach (var subToExamine in new List <string> { "/r/news", "/r/pics" }) { ExamineSubreddit(subToExamine, subreddit => { var sub = subDao.GetSubByName(subreddit.Name); if (sub != null) { return(sub); } var response = SkimurContext.Resolve <ICommandHandlerResponse <CreateSub, CreateSubResponse> >() .Handle(new CreateSub { Name = subreddit.Name, CreatedByUserId = defaultUser.Id, Description = subreddit.Description, SidebarText = subreddit.Description, Type = Subs.SubType.Public }); if (!string.IsNullOrEmpty(response.Error)) { Console.WriteLine("Couldn't create the news sub. " + response.Error); return(null); } return(subDao.GetSubByName(response.SubName)); }, (sub, redditPost) => { var response = SkimurContext.Resolve <ICommandHandlerResponse <CreatePost, CreatePostResponse> >() .Handle(new CreatePost { Url = redditPost.Url.OriginalString, SubName = sub.Name, PostType = redditPost.IsSelfPost ? Subs.PostType.Text : Subs.PostType.Link, Title = redditPost.Title, Content = redditPost.SelfText, CreatedByUserId = defaultUser.Id, IpAddress = "127.0.0.1", NotifyReplies = true }); if (!string.IsNullOrEmpty(response.Error)) { Console.WriteLine("Error creating post. " + response.Error); return(null); } if (!response.PostId.HasValue) { Console.WriteLine("No post id returned."); return(null); } return(postDao.GetPostById(response.PostId.Value)); }, (post, redditComment, parentComment) => { var response = SkimurContext.Resolve <ICommandHandlerResponse <CreateComment, CreateCommentResponse> >() .Handle(new CreateComment { PostId = post.Id, ParentId = parentComment != null ? parentComment.Id : (Guid?)null, DateCreated = redditComment.CreatedUTC, AuthorUserName = defaultUser.UserName, AuthorIpAddress = "127.0.0.1", Body = redditComment.Body, SendReplies = true }); if (!string.IsNullOrEmpty(response.Error)) { Console.WriteLine("Error creating comment. " + response.Error); return(null); } if (!response.CommentId.HasValue) { Console.WriteLine("No comment id returned."); return(null); } return(commentDao.GetCommentById(response.CommentId.Value)); }); } } }