Exemplo n.º 1
0
        public HomeModule(IViewProjectionFactory viewFactory, ISpamShieldService spamShield, ICommandInvokerFactory commandInvokerFactory)
            : base(viewFactory)
        {
            _viewFactory = viewFactory;
            _commandInvokerFactory = commandInvokerFactory;

            Get["/"] = p =>
                ReturnHomeAction(new RecentBlogPostsBindingModel() { Page = 1, Take = 10 });

            Get["/page/{page:int}"] = p =>
                ReturnHomeAction(new RecentBlogPostsBindingModel() { Page = p.page, Take = 10 });

            Get["/tag/{Tag}"] = p =>
                ReturnArticlesTaggedBy(new TaggedBlogPostsBindingModel() { Tag = p.tag });

            Get[@"/(?<year>\d{4})/(?<month>0[1-9]|1[0-2])/(?<titleslug>[a-zA-Z0-9_-]+)"] = p =>
                ReturnArticle(new BlogPostDetailsBindingModel { Permalink = p.titleslug }, spamShield);//TODO:需要增加对日期有效性的验证

            Get[@"/(?<year>\d{4})/(?<month>0[1-9]|1[0-2])"] = p =>
                                                {
                                                    var input = new IntervalBlogPostsBindingModel
                                                    {
                                                        FromDate = new DateTime(p.year, p.month, 1)
                                                    };

                                                    input.ToDate = input.FromDate.AddMonths(1);

                                                    return ReturnArticles(input);
                                                };

            Post["/spam/hash/{tick}"] = p => spamShield.GenerateHash(p.tick);

            Post["/comment/(?<titleslug>[a-zA-Z0-9_-]+)"] = p => ReturnAddComment(p);
        }
Exemplo n.º 2
0
 public AdminController(IHostingEnvironment hostingEnvironment, IMemoryCache memoryCache, IViewProjectionFactory viewProjectionFactory, ICommandInvokerFactory commandInvokerFactory)
 {
     this._hostingEnvironment    = hostingEnvironment;
     this._memoryCache           = memoryCache;
     this._viewProjectionFactory = viewProjectionFactory;
     this._commandInvokerFactory = commandInvokerFactory;
 }
Exemplo n.º 3
0
 public AccountController(IHostingEnvironment hostingEnvironment, IOptions <WebAppConfiguration> webAppConfiguration, IViewProjectionFactory viewProjectionFactory, ICommandInvokerFactory commandInvokerFactory)
 {
     this._hostingEnvironment    = hostingEnvironment;
     this._webAppConfiguration   = webAppConfiguration;
     this._viewProjectionFactory = viewProjectionFactory;
     this._commandInvokerFactory = commandInvokerFactory;
 }
Exemplo n.º 4
0
        public SessionModule(ICommandInvokerFactory commandInvoker)
        {
            _commandInvoker = commandInvoker;

            Get["/session/login"]  = _ => ShowLoginPage();
            Get["/session/logout"] = _ => Logout();
            Post["/session/login"] = _ => LoginUser(this.Bind <LoginCommand>());
        }
Exemplo n.º 5
0
 public AdminPostController(IHostingEnvironment hostingEnvironment, IOptions <WebAppConfiguration> webAppConfiguration, IMemoryCache memoryCache, IViewProjectionFactory viewProjectionFactory, ICommandInvokerFactory commandInvokerFactory)
 {
     this._hostingEnvironment    = hostingEnvironment;
     this._webAppConfiguration   = webAppConfiguration;
     this._memoryCache           = memoryCache;
     this._viewProjectionFactory = viewProjectionFactory;
     this._commandInvokerFactory = commandInvokerFactory;
 }
Exemplo n.º 6
0
        public AccountModule(ICommandInvokerFactory commandInvoker)
        {
            _commandInvoker = commandInvoker;

            Get["/mz-login"] = _ => ShowLoginPage();
            Post["/mz-login"] = _ => LoginUser(this.BindAndValidate<LoginCommand>());

            Get["/mz-logout"] = _ => Logout();
        }
Exemplo n.º 7
0
        public AccountModule(ICommandInvokerFactory commandInvoker)
        {
            _commandInvoker = commandInvoker;

            Get["/mz-login"]  = _ => ShowLoginPage();
            Post["/mz-login"] = _ => LoginUser(this.BindAndValidate <LoginCommand>());

            Get["/mz-logout"] = _ => Logout();
        }
Exemplo n.º 8
0
        public PerformanceModule(
            IViewProjectionFactory viewProjectionFactory,
            ICommandInvokerFactory commandInvokerFactory) : base("/Performance")
        {
            this.viewProjectionFactory = viewProjectionFactory;
            this.commandInvokerFactory = commandInvokerFactory;

            Get["/"] = _ => View["List"];
            Get["/GetPerformanceList"] = _ => GetPerformanceList();
        }
Exemplo n.º 9
0
        public AdminModule(ICommandInvokerFactory commandInvokerFactory, MongoDatabase database, IViewProjectionFactory viewProjectionFactory, IRootPathProvider rootPath) : base(database, viewProjectionFactory)
        {
            _commandInvokerFactory = commandInvokerFactory;
            _rootPath = rootPath;

            Get["/admin"] = _ => Index();
            Get["/admin/changepassword"]  = _ => ChangePassword();
            Post["/admin/changepassword"] = _ => ChangePassword(this.Bind <ChangePasswordCommand>());
            Post["/admin/uploadFile"]     = _ => UploadFile(Request.Files.First());
        }
Exemplo n.º 10
0
 public AccountController(
     IHostingEnvironment hostingEnvironment,
     IViewProjectionFactory viewProjectionFactory,
     ICommandInvokerFactory commandInvokerFactory,
     IOptions <AppConfig> appConfig)
 {
     this._hostingEnvironment    = hostingEnvironment;
     this._viewProjectionFactory = viewProjectionFactory;
     this._commandInvokerFactory = commandInvokerFactory;
     this._appConfig             = appConfig;
 }
Exemplo n.º 11
0
        public AdminModule(ICommandInvokerFactory commandInvokerFactory, IViewProjectionFactory viewProjectionFactory)
            : base(viewProjectionFactory)
        {
            _commandInvokerFactory = commandInvokerFactory;

            Get["/mz-admin"] = _ => Index();
            Get["/mz-admin/change-password"]  = _ => ChangePassword();
            Post["/mz-admin/change-password"] = _ => ChangePassword(this.Bind <ChangePasswordCommand>());

            Get["/mz-admin/change-profile"]  = _ => ChangeProfile();
            Post["/mz-admin/change-profile"] = _ => ChangeProfile(this.Bind <ChangeProfileCommand>());
        }
Exemplo n.º 12
0
 public HomeController(
     IHostingEnvironment hostingEnvironment,
     IMemoryCache memoryCache,
     IViewProjectionFactory viewProjectionFactory,
     ICommandInvokerFactory commandInvokerFactory,
     IOptions <AppConfig> appConfig)
 {
     this._hostingEnvironment    = hostingEnvironment;
     this._memoryCache           = memoryCache;
     this._viewProjectionFactory = viewProjectionFactory;
     this._commandInvokerFactory = commandInvokerFactory;
     this._appConfig             = appConfig;
 }
Exemplo n.º 13
0
        public AdminModule(ICommandInvokerFactory commandInvokerFactory, IViewProjectionFactory viewProjectionFactory, IRootPathProvider rootPath)
            : base(viewProjectionFactory)
        {
            _commandInvokerFactory = commandInvokerFactory;
            _rootPath = rootPath;

            Get["/mz-admin"] = _ => Index();
            Get["/mz-admin/change-password"] = _ => ChangePassword();
            Post["/mz-admin/change-password"] = _ => ChangePassword(this.Bind<ChangePasswordCommand>());

            Get["/mz-admin/change-profile"] = _ => ChangeProfile();
            Post["/mz-admin/change-profile"] = _ => ChangeProfile(this.Bind<ChangeProfileCommand>());
        }
Exemplo n.º 14
0
 public AdminPostsModule(MongoDatabase database, IViewProjectionFactory factory, ICommandInvokerFactory commandInvokerFactory) : base(database, factory)
 {
     _commandInvokerFactory       = commandInvokerFactory;
     Get["/admin/posts/{page?1}"] = _ => ShowPosts(_.page);
     Get["/admin/posts/new"]      = _ => ShowNewPost();
     Post["/admin/posts/new"]     = _ =>
     {
         var command = this.Bind <NewPostCommand>();
         command.Author = CurrentUser;
         return(CreateNewPost(command));
     };
     Get["/admin/posts/edit/{postId}"]  = _ => ShowPostDetails(_.postId);
     Post["/admin/posts/edit/{postid}"] = _ => EditPost(this.Bind <EditPostCommand>());
 }
Exemplo n.º 15
0
        public HomeModule(IViewProjectionFactory viewProjectionFactory,
                          ICommandInvokerFactory commandInvokerFactory)
            : base()
        {
            this.viewProjectionFactory = viewProjectionFactory;
            this.commandInvokerFactory = commandInvokerFactory;

            Get["/"] = _ =>
            {
                ViewBag.NewJobCount         = GetNewJobCount();
                ViewBag.NewPerformanceCount = GetNewPerformanceCount();
                return(View["Index"]);
            };

            Get["/Home/GetJobPerformanceTrend"] = _ => GetJobPerformanceTrend();
        }
Exemplo n.º 16
0
        public HomeModule(IViewProjectionFactory viewFactory, ISpamShieldService spamShield, ICommandInvokerFactory commandInvokerFactory)
            : base(viewFactory)
        {
            _viewFactory           = viewFactory;
            _commandInvokerFactory = commandInvokerFactory;

            Get["/"] = p =>
                       ReturnHomeAction(new RecentBlogPostsBindingModel()
            {
                Page = 1, Take = 10
            });

            Get["/page/{page:int}"] = p =>
                                      ReturnHomeAction(new RecentBlogPostsBindingModel()
            {
                Page = p.page, Take = 10
            });

            Get["/tag/{Tag}"] = p =>
                                ReturnArticlesTaggedBy(new TaggedBlogPostsBindingModel()
            {
                Tag = p.tag
            });

            Get[@"/(?<year>\d{4})/(?<month>0[1-9]|1[0-2])/(?<titleslug>[a-zA-Z0-9_-]+)"] = p =>
                                                                                           ReturnArticle(new BlogPostDetailsBindingModel {
                Permalink = p.titleslug
            }, spamShield);                                                                            //TODO:需要增加对日期有效性的验证

            Get[@"/(?<year>\d{4})/(?<month>0[1-9]|1[0-2])"] = p =>
            {
                var input = new IntervalBlogPostsBindingModel
                {
                    FromDate = new DateTime(p.year, p.month, 1)
                };

                input.ToDate = input.FromDate.AddMonths(1);

                return(ReturnArticles(input));
            };

            Post["/spam/hash/{tick}"] = p => spamShield.GenerateHash(p.tick);

            Post["/comment/(?<titleslug>[a-zA-Z0-9_-]+)"] = p => ReturnAddComment(p);
        }
Exemplo n.º 17
0
        public JobModule(IViewProjectionFactory viewProjectionFactory,
                         ICommandInvokerFactory commandInvokerFactory) : base("/Job")
        {
            this.viewProjectionFactory = viewProjectionFactory;
            this.commandInvokerFactory = commandInvokerFactory;

            Get["/"]                   = _ => View["List", new { Url = IDPJobManagerConfiguration.Config.Provider.Uri.Trim('/', ' ') }];
            Get["/GetJobList"]         = _ => GetJobList();
            Get["/Get"]                = _ => GetJob();
            Get["/GetJobDependency"]   = _ => GetJobDependency();
            Post["/Add"]               = _ => AddJob(this.Bind <AddJobCommand>());
            Post["/Edit"]              = _ => EditJob(this.Bind <EditJobCommand>());
            Post["/Delete"]            = _ => DeleteJob(this.Bind <DeleteJobCommand>());
            Post["/Start"]             = _ => StartJob(this.Bind <StartJobCommand>());
            Post["/Stop"]              = _ => StopJob(this.Bind <StopJobCommand>());
            Post["/SaveJobDependency"] = _ => SaveJobDependency(this.Bind <EditJobDependencyCommand>());
            Post["/BatchOperate"]      = _ => BatchOperate(this.Bind <BatchOperateJobCommand>());
            Post["/Upload"]            = _ => Upload();
        }
Exemplo n.º 18
0
        public AdminPostsModule(IViewProjectionFactory factory, ICommandInvokerFactory commandInvokerFactory)
            : base(factory)
        {
            _commandInvokerFactory = commandInvokerFactory;
            Get["/mz-admin/posts/{page?1}"] = _ => ShowPosts(_.page);
            Get["/mz-admin/posts/new"] = _ => ShowNewPost();
            Post["/mz-admin/posts/new"] = _ =>
                                           {
                                               var command = this.Bind<NewPostCommand>();
                                               command.Author = CurrentUser;
                                               return CreateNewPost(command);
                                           };
            Get["/mz-admin/posts/edit/{postId}"] = _ => ShowPostEdit(_.postId);
            Post["/mz-admin/posts/edit/{postid}"] = _ => EditPost(this.Bind<EditPostCommand>());
            Get["/mz-admin/posts/delete/{postid}"] = _ => DeletePost(this.Bind<DeletePostCommand>());

            Get["/mz-admin/comment/{page?1}"] = _ => ShowComments(_.page);
            Get["/mz-admin/comment/delete/{commentid}"] = _ => DeleteComment(this.Bind<DeleteCommentCommand>());
            Get["/mz-admin/tags"] = _ => ShowTags();
            Post["/mz-admin/slug"] = _ => GetSlug();
        }
Exemplo n.º 19
0
        public AdminPostsModule(IViewProjectionFactory factory, ICommandInvokerFactory commandInvokerFactory)
            : base(factory)
        {
            _commandInvokerFactory          = commandInvokerFactory;
            Get["/mz-admin/posts/{page?1}"] = _ => ShowPosts(_.page);
            Get["/mz-admin/posts/new"]      = _ => ShowNewPost();
            Post["/mz-admin/posts/new"]     = _ =>
            {
                var command = this.Bind <NewPostCommand>();
                command.Author = CurrentUser;
                return(CreateNewPost(command));
            };
            Get["/mz-admin/posts/edit/{postId}"]   = _ => ShowPostEdit(_.postId);
            Post["/mz-admin/posts/edit/{postid}"]  = _ => EditPost(this.Bind <EditPostCommand>());
            Get["/mz-admin/posts/delete/{postid}"] = _ => DeletePost(this.Bind <DeletePostCommand>());

            Get["/mz-admin/comments/{page?1}"]           = _ => ShowComments(_.page);
            Get["/mz-admin/comments/delete/{commentid}"] = _ => DeleteComment(this.Bind <DeleteCommentCommand>());
            Get["/mz-admin/tags"]  = _ => ShowTags();
            Post["/mz-admin/slug"] = _ => GetSlug();
        }
Exemplo n.º 20
0
        /// <summary>
        /// 检查是否已存在后台管理账号
        /// </summary>
        /// <returns>存在返回true,不存在返回false</returns>
        private bool CheckAccount(ICommandInvokerFactory commandInvokerFactory)
        {
            var commandResult = commandInvokerFactory.Handle <UserRegisterCheckCommand, CommandResult>(new UserRegisterCheckCommand());

            return(commandResult.IsSuccess);
        }
Exemplo n.º 21
0
 public UserController(ICommandInvokerFactory commandInvokerFactory)
 {
     this._commandInvokerFactory = commandInvokerFactory;
 }