Esempio n. 1
0
        protected void Application_Start()
        {
            RouteTable.Routes.MapHubs();
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            if (_configured)
            {
                return;
            }

            var connectionString = ConfigureDatabase();

            Cohort.Initialize(DatabaseType.Sqlite, connectionString, cs => UnitOfWork.Current);
            CohortApi.Register(GlobalConfiguration.Configuration);
            CohortMvc.Register();

            Linger.Backend = () => new DatabaseJobRepository(DatabaseDialect.Sqlite, () => UnitOfWork.Current);
            Schema.Install(UnitOfWork.Current, DatabaseDialect.Sqlite);
            Func <bool> hello = () =>
            {
                Logger.Info("Hello, world!");
                return(true);
            };

            hello.PerformAsync();
            Linger.StartWorker();

            _configured = true;
        }
Esempio n. 2
0
        public bool Initialize()
        {
            var principal = GetPrincipalIdentity();

            if (principal == null)
            {
                return(false);
            }

            /* -> Belongs in a separate execution context (using scope for ACL executions)
             * var admin = principal.IsInRole(WindowsBuiltInRole.Administrator);
             * if (!admin)
             * {
             *  Console.WriteLine("API startup requires administrator privileges.");
             *  return false;
             * }
             * _username = principal.Identity.Name;
             */


            Port                    = ConfigurationManager.AppSettings["ServicePort"] ?? "8181";
            Machine                 = Environment.MachineName;
            BaseAddress             = String.Concat("http://", Machine, ":", Port, "/");
            Thread.CurrentPrincipal = principal;

            var host = ConfigureSelfHost();

            Configuration = host;

            _server = new HttpSelfHostServer(host);
            CohortApi.Register(Configuration);

            return(true);
        }