Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     InitDatabaseProvider.CreateStdType();
     InitDatabaseProvider.CreateStandard();
     InitDatabaseProvider.CreatEquGroup();
     InitDatabaseProvider.CreateStatus();
     InitDatabaseProvider.CreatCompany();
 }
Esempio n. 2
0
            public override void InitializeDatabase(CFContext context)
            {
                if (!context.Database.Exists())
                {
                    // if database did not exist before - create it
                    context.Database.Create();
                    InitDatabaseProvider.SetupRolesGroups(context);
                    InitDatabaseProvider.GrantDefaultRolesForGroups(context);
                    InitDatabaseProvider.CreateSuperUser(context);
                    InitDatabaseProvider.CreateStdType();
                    InitDatabaseProvider.CreateStandard();
                    InitDatabaseProvider.CreatEquGroup();
                    InitDatabaseProvider.CreateStatus();


                    InitDatabaseProvider.CreateSlide(context);
                    InitDatabaseProvider.CreatePage(context);
                    InitDatabaseProvider.CreateContactDetail(context);
                    InitDatabaseProvider.CreateConfigTitle();
                }
                else
                {
                    // query to check if MigrationHistory table is present in the database
                    var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery <int>(
                        string.Format(
                            "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
                            "dbo"));

                    // if MigrationHistory table is not there (which is the case first time we run) - create it

                    if (migrationHistoryTableExists.FirstOrDefault() == 0)
                    {
                        context.Database.Delete();
                        context.Database.Create();
                        InitDatabaseProvider.SetupRolesGroups(context);
                        InitDatabaseProvider.GrantDefaultRolesForGroups(context);
                        InitDatabaseProvider.CreateSuperUser(context);
                        InitDatabaseProvider.CreateStdType();
                        InitDatabaseProvider.CreateStandard();
                        InitDatabaseProvider.CreatEquGroup();
                        InitDatabaseProvider.CreateStatus();


                        InitDatabaseProvider.CreateSlide(context);
                        InitDatabaseProvider.CreatePage(context);
                        InitDatabaseProvider.CreateContactDetail(context);
                        InitDatabaseProvider.CreateConfigTitle();
                    }
                }
            }