Example #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = Speedy.Extensions.GetSerializerSettings(true, false);
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
            GlobalConfiguration.Configuration.EnsureInitialized();

            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ScribeSqlDatabase, Configuration>(true));

            var appDataPath = HttpContext.Current.Server.MapPath("~/App_Data");
            var client      = new ScribeDataChannel(new ScribeDatabaseProvider(() => new ScribeSqlDatabase()));
            var provider    = new KeyValueRepositoryProvider <Event>(appDataPath);

            Tracker = Tracker.Start(client, provider);

            using (var datacontext = new ScribeSqlDatabase())
            {
                var siteSettings = SiteSettings.Load(datacontext);

                IsConfigured = datacontext.Users.Any();
                PrintCss     = siteSettings.PrintCss ?? string.Empty;
                ViewCss      = siteSettings.ViewCss ?? string.Empty;
            }
        }
Example #2
0
 public override bool IsUserInRole(string username, string roleName)
 {
     using (var database = new ScribeSqlDatabase())
     {
         var userId = username.Split(';').First().ConvertToInt();
         var user   = database.Users.FirstOrDefault(x => x.Id == userId);
         return(user != null && user.InRole(roleName));
     }
 }
Example #3
0
 public override string[] GetRolesForUser(string username)
 {
     using (var database = new ScribeSqlDatabase())
     {
         var userId = username.Split(';').First().ConvertToInt();
         var user   = database.Users.FirstOrDefault(x => x.Id == userId);
         return(user?.Tags?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray() ?? new string[0]);
     }
 }
Example #4
0
        public static IScribeDatabase GetDatabase(bool clearDatabase = true)
        {
            var database = new ScribeSqlDatabase();

            if (clearDatabase)
            {
                database.Database.ExecuteSqlCommand(Resources.ClearDatabase);
            }

            return(database);
        }
Example #5
0
        public void Reload()
        {
            using (var datacontext = new ScribeSqlDatabase())
            {
                SettingsService.ClearCache();

                var settingsService = SiteSettings.Load(datacontext, true);

                MvcApplication.IsConfigured = datacontext.Users.Any();
                MvcApplication.PrintCss     = settingsService.PrintCss;
                MvcApplication.ViewCss      = settingsService.ViewCss;
            }
        }