Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Console.WriteLine(File.Exists("config/log4net.xml"));
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            //注册Log4Net
            LogUtility.Register(Path.Combine(baseDirectory, "config/log4net.xml"));

            //注册NHibernate
            NSessionFactoryManager.GetInstance(NSessionFactoryManager.SessionFactory.SweetFly)
            .Register("config/hibernate/sweetFly.cfg.xml", typeof(Product).Assembly);
            NSessionFactoryManager.GetInstance(NSessionFactoryManager.SessionFactory.Cmrcn)
            .Register("config/hibernate/cmrcn.cfg.xml", typeof(ExamItem).Assembly);

            //注册Castle
            WindsorUtility.Instance.Register();


            //启动计划任务
            QuartzUtility.GetInstance().Start(Path.Combine(baseDirectory, "config", "Cmr.Crawler.xml"));

            Console.WriteLine("开始执行");

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        protected void Application_Start()
        {
            //注册区域
            AreaRegistration.RegisterAllAreas();

            //注册路由
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //注册Filters
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            //设置视图格式
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            //设置API返回格式
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            //注册Log4Net
            LogUtility.Register(Server.MapPath("~/config/log4net.xml"));

            //注册NHibernate
            NSessionFactoryManager.GetInstance(NSessionFactoryManager.SessionFactory.SweetFly)
            .Register(Server.MapPath("~/config/hibernate/sweetFly.cfg.xml"), typeof(Product).Assembly);
            NSessionFactoryManager.GetInstance(NSessionFactoryManager.SessionFactory.Cmrcn)
            .Register(Server.MapPath("~/config/hibernate/cmrcn.cfg.xml"), typeof(ExamItem).Assembly);

            //注册Castle
            WindsorUtility.Instance.Register();

            //注册ControllerFactory
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory());
            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new WindsorApiControllerActivator());

            //注册处理程序
            GlobalConfiguration.Configuration.MessageHandlers.Add(new TraceHandler());
            //config.EnableSystemDiagnosticsTracing();

#if !DEBUG
            //启动计划任务
            QuartzUtility.GetInstance().Start(Server.MapPath("~/config/Cmr.Crawler.xml"));
#endif
        }