コード例 #1
0
        public static void SetLatestVersion(DatabaseContext db)
        {
            DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();

            dbUpdater.DatabaseSchemaVersion = DATA_VERSION;
            dbUpdater.Execute();
        }
コード例 #2
0
 private static void UpdateToVersionOne(DatabaseSchemaUpdater schemaUpdater)
 {
     schemaUpdater.AddTable<RecordingTag>();
     schemaUpdater.AddTable<Tag>();
     schemaUpdater.DatabaseSchemaVersion = 1;
     schemaUpdater.Execute();
 }
コード例 #3
0
ファイル: AppViewModel.cs プロジェクト: pnose/TimecardApp
        public void RestoreDatabase(string tmpPathDatabase)
        {
            dellAppDB.Dispose();
            //check downloaded database for version

            string tmpDBConnectionString = "Data Source=isostore:/" + tmpPathDatabase;

            // Create the database if it does not exist.
            using (DBClass tmpDB = new DBClass(tmpDBConnectionString))
            {
                if (tmpDB.DatabaseExists() == true)
                {
                    DatabaseSchemaUpdater dbNewUpdater = tmpDB.CreateDatabaseSchemaUpdater();

                    if (dbNewUpdater.DatabaseSchemaVersion < App.DB_VERSION)
                    {
                    }

                    // version are equal -> replace database files
                    tmpDB.Dispose();
                    IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                    iso.CopyFile(tmpPathDatabase, AppResources.DatabaseName + ".sdf", true);
                    iso.DeleteFile(tmpPathDatabase);
                }
                else
                {
                    MessageBox.Show("Restore failed because the downloaded file is no database for this app.");
                }
            }

            this.ConnectDB();
        }
コード例 #4
0
 public static void UpdateDataContext(DatabaseSchemaUpdater dataBaseUpdater)
 {
     if (dataBaseUpdater != null)
     {
         dataBaseUpdater.AddTable<BudgetProject>();
     }
 }
コード例 #5
0
        public async Task Initialize()
        {
            StorageFolder localFolder  = ApplicationData.Current.LocalFolder;
            StorageFolder scoresFolder = await localFolder.CreateFolderAsync("HighScoreDatabase", CreationCollisionOption.OpenIfExists);

            db = new HighScoresDataContext(@"isostore:/HighScoreDatabase/highscores.sdf");
            if (!db.DatabaseExists())
            {
                db.CreateDatabase();
                DatabaseSchemaUpdater updater = db.CreateDatabaseSchemaUpdater();
                updater.DatabaseSchemaVersion = 1;
                updater.Execute();
            }
            else
            {
                DatabaseSchemaUpdater updater = db.CreateDatabaseSchemaUpdater();
                int databaseSchemaVersion     = updater.DatabaseSchemaVersion;
                if (databaseSchemaVersion == 0)
                {
                    // add the difficulty column introduced in version one
                    updater.AddColumn <HighScore>("Difficulty");
                    updater.DatabaseSchemaVersion = 1;
                    updater.Execute();
                }
            }
        }
コード例 #6
0
ファイル: ROMDatabase.cs プロジェクト: duchuule/snes8x
        //this function return true the first time data base is created
        public bool Initialize()
        {
            bool dbCreated = false;

            //if(context.DatabaseExists())
            //    context.DeleteDatabase();
            if (!context.DatabaseExists())
            {
                context.CreateDatabase();

                DatabaseSchemaUpdater dbUpdater = context.CreateDatabaseSchemaUpdater();
                dbUpdater.DatabaseSchemaVersion = App.APP_VERSION;
                dbUpdater.Execute();

                context.SubmitChanges();
                dbCreated = true;
            }
            else
            {
                UpdateDatabase();
            }


            context.SubmitChanges();

            return(dbCreated);
        }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: qianhk/FeiWP7
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            SourceData sd = new SourceData(dbPath);

            if (!sd.DatabaseExists())
            {
                sd.CreateDatabase();
                DatabaseSchemaUpdater dbUpdater = sd.CreateDatabaseSchemaUpdater();
                dbUpdater.DatabaseSchemaVersion = DB_NEWEST_VERSION;
                dbUpdater.Execute();
            }
            else
            {
                DatabaseSchemaUpdater dbUpdater = sd.CreateDatabaseSchemaUpdater();
                int oriDbVersion = dbUpdater.DatabaseSchemaVersion;
                if (oriDbVersion < 1)
                {
                    dbUpdater.AddColumn <Card>("Phone");
                }
                if (oriDbVersion < DB_NEWEST_VERSION)
                {
                    dbUpdater.DatabaseSchemaVersion = DB_NEWEST_VERSION;
                    dbUpdater.Execute();
                }
            }
        }
コード例 #8
0
ファイル: Global.asax.cs プロジェクト: Grouts/Grout
        protected void Application_Start()
        {
            DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile")
            {
                ContextCondition = (context => DeviceDetection.IsMobile)
            });

            GlobalFilters.Filters.Add(new NoCacheActionFilter
            {
                Duration    = 1,
                VaryByParam = "none",
                Location    = OutputCacheLocation.Client,
                NoStore     = true
            });
            //GlobalFilters.Filters.Add(new AppicationVersionValidationActionFilter());
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            GlobalAppSettings.IsLatestVersion = DatabaseSchemaUpdater.IsLatestVersion();
        }
コード例 #9
0
ファイル: ROMDatabase.cs プロジェクト: duchuule/snes8x
        private void UpdateDatabase()
        {
            // Check whether a database update is needed.
            DatabaseSchemaUpdater dbUpdater = context.CreateDatabaseSchemaUpdater();

            if (dbUpdater.DatabaseSchemaVersion < App.APP_VERSION)
            {
                try
                {
                    if (dbUpdater.DatabaseSchemaVersion < 2)
                    {
                        dbUpdater.AddColumn <ROMDBEntry>("AutoSaveIndex");
                    }

                    // Update the new database version.
                    dbUpdater.DatabaseSchemaVersion = App.APP_VERSION;

                    // Perform the database update in a single transaction.
                    dbUpdater.Execute();
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #10
0
ファイル: PlaylistDBContext.cs プロジェクト: qeef/Podcatcher
        public PlaylistDBContext()
            : base(m_connection)
        {
            DatabaseSchemaUpdater updater = null;

            if (!DatabaseExists())
            {
                CreateDatabase();
                updater = Microsoft.Phone.Data.Linq.Extensions.CreateDatabaseSchemaUpdater(this);
                updater.DatabaseSchemaVersion = PLAYLIST_DB_VERSION;
                updater.Execute();
            }

            if (updater == null)
            {
                updater = Microsoft.Phone.Data.Linq.Extensions.CreateDatabaseSchemaUpdater(this);

                if (updater.DatabaseSchemaVersion < 2)
                {
                    updater.AddColumn <PlaylistItem>("SavedPlayPosTick");
                    updater.AddColumn <PlaylistItem>("TotalPlayTicks");
                }

                updater.DatabaseSchemaVersion = PLAYLIST_DB_VERSION;
                updater.Execute();
            }

            Playlist = GetTable <PlaylistItem>();
            // TODO: Handle scheme changes.
        }
コード例 #11
0
        public static void Execute(DatabaseSchemaUpdater updater, int initialVersion, int targetVersion)
        {
            while (true)
            {
                var migrates = new Migrates();
                var method   = migrates.GetType().GetMethods().FirstOrDefault(m => Migrate.MigrationEnabled(m, initialVersion));
                if (method != null)
                {
                    method.Invoke(migrates, new object[] { updater });
                    initialVersion = Migrate.Get(method).TargetVersion;
                    if (initialVersion == targetVersion)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            if (updater.DatabaseSchemaVersion != targetVersion)
            {
                throw new NotSupportedException("Valid dynamic db version update migration failed.");
            }
        }
コード例 #12
0
 private void Update(DatabaseSchemaUpdater dbUpdater)
 {
     dbUpdater.AddColumn <Memo>("AudioFormat");
     dbUpdater.AddColumn <Memo>("SampleRate");
     dbUpdater.AddColumn <Memo>("BitRate");
     dbUpdater.AddColumn <Memo>("Channels");
 }
コード例 #13
0
ファイル: Changeset6.cs プロジェクト: bdvsoft/reader_wp8_OPDS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     updater.AddColumn <BookDownloadModel>("Author");
     updater.AddColumn <BookDownloadModel>("Description");
     updater.AddColumn <BookDownloadModel>("AcquisitionUrl");
     updater.AddColumn <BookDownloadModel>("AcquisitionType");
     updater.AddColumn <BookDownloadModel>("AcquisitionPrices");
 }
コード例 #14
0
ファイル: Changeset6.cs プロジェクト: karbazol/FBReaderCS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     updater.AddColumn<BookDownloadModel>("Author");
     updater.AddColumn<BookDownloadModel>("Description");
     updater.AddColumn<BookDownloadModel>("AcquisitionUrl");
     updater.AddColumn<BookDownloadModel>("AcquisitionType");
     updater.AddColumn<BookDownloadModel>("AcquisitionPrices");
 }
コード例 #15
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            //string startPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);// System.IO.Directory.GetCurrentDirectory();
            //var filepath = startPath + "\\" + "Database.sdf";

            // Specify the local database connection string.
            string DBConnectionString = "Data Source=isostore:/Places.sdf";

            // Create the data context.
            //string DBConnectionString = "Data Source = 'appdata:/mydb.sdf'; File Mode = read only;";
            //https://msdn.microsoft.com/en-us/library/windows/apps/hh286411(v=vs.105).aspx

            // Create the database if it does not exist.
            using (PlaceDataContext db = new PlaceDataContext(DBConnectionString))
            {
                if (db.DatabaseExists() == false)
                {
                    // Create the local database.
                    db.CreateDatabase();

                    // Prepopulate the places.
                    db.Places.InsertOnSubmit(new PlaceDetails {
                        PlaceName = "Miejsce nr 1"
                    });                                                                        // Jakiś tam opis tego miejsca | Miejscowość, ulica | /PictureOfPlaces/p1.jpg

                    // Save categories to the database.
                    db.SubmitChanges();

                    // Set the new database version.
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();
                    dbUpdater.DatabaseSchemaVersion = APP_VERSION;
                    dbUpdater.Execute();
                }
                else
                {
                    // Check whether a database update is needed.
                    DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();

                    /*if (dbUpdater.DatabaseSchemaVersion < APP_VERSION)
                     * {
                     *  // Add the Priority column (added in version 2).
                     *  dbUpdater.AddColumn<ToDoItem>("Priority");
                     *
                     *  // Add the new database version.
                     *  dbUpdater.DatabaseSchemaVersion = 2;
                     *
                     *  // Perform the database update in a single transaction.
                     *  dbUpdater.Execute();
                     * }*/
                }
            }

            // Create the ViewModel object.
            viewModel = new PlaceViewModel(DBConnectionString);

            // Query the local database and load observable collections.
            viewModel.LoadCollectionsFromDatabase();
        }
コード例 #16
0
 private void UpdateToVersionOne(DatabaseSchemaUpdater updater)
 {
     updater.AddTable<AwfulThreadBookmark>();
     updater.AddAssociation<AwfulProfile>("ThreadBookmarks");
     updater.AddColumn<AwfulProfile>("LastBookmarkRefresh");
     updater.AddAssociation<AwfulThread>("ThreadBookmarks");
     updater.DatabaseSchemaVersion = 1;
     updater.Execute();
 }
コード例 #17
0
        public void CheckAndUpdate()
        {
            TabDataContext        dataContext = new TabDataContext(_dbConnectionString);
            DatabaseSchemaUpdater dbUpdater   = dataContext.CreateDatabaseSchemaUpdater();

            if (dbUpdater.DatabaseSchemaVersion < _dbVersion)
            {
                UpdateDataBase(dbUpdater);
            }
        }
コード例 #18
0
ファイル: Changeset7.cs プロジェクト: karbazol/FBReaderCS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     db.Catalogs.InsertOnSubmit(new CatalogModel
                                {
                                    Title = string.Empty,
                                    Description = string.Empty,
                                    IconLocalPath = "",
                                    Type = CatalogType.StorageFolder,
                                    AccessDenied = true
                                });
     db.SubmitChanges();
 }
コード例 #19
0
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     db.Catalogs.InsertOnSubmit(new CatalogModel
     {
         Title         = string.Empty,
         Description   = string.Empty,
         IconLocalPath = "",
         Type          = CatalogType.StorageFolder,
         AccessDenied  = true
     });
     db.SubmitChanges();
 }
コード例 #20
0
        static void Main(string[] args)
        {
            string strDatabasePath = Environment.ExpandEnvironmentVariables(@"%APPDATA%\EsentSchemaUpgradeDemo");

            EsentDatabase.Settings settings = new EsentDatabase.Settings(strDatabasePath);
            using (var serializer = new EseSerializer(settings, 1, null))
                using (var sess = serializer.OpenDatabase(false))
                {
                    if (serializer.isNewDatabase)
                    {
                        sess.AddType(typeof(Person));

                        PopulateDemoDatabase(sess);

                        DatabaseSchemaUpdater dbUpdater = new DatabaseSchemaUpdater(sess);
                        dbUpdater.DatabaseSchemaVersion = DB_SCHEMA_VERSION;
                        dbUpdater.Execute();
                    }
                    else
                    {
                        DatabaseSchemaUpdater dbUpdater = new DatabaseSchemaUpdater(sess);

                        switch (dbUpdater.DatabaseSchemaVersion)
                        {
                        case 0:
                            dbUpdater.DatabaseSchemaVersion = DB_SCHEMA_VERSION;
                            goto case 1;

                        case 1:
                            dbUpdater.AddColumn <Person>("note");
                            dbUpdater.DatabaseSchemaVersion = 2;
                            goto case 2;

                        case 2:
                            dbUpdater.CreateIndex <Person>("name");
                            dbUpdater.DatabaseSchemaVersion = 3;
                            goto case 3;

                        case DB_SCHEMA_VERSION:
                            break;

                        default:
                            throw new ApplicationException("Unknown DB schema version #" + dbUpdater.DatabaseSchemaVersion.ToString());
                        }

                        dbUpdater.Execute();

                        sess.AddType(typeof(Person));
                    }

                    Console.WriteLine("Initialized OK");
                }
        }
コード例 #21
0
 private void CheckAndUpdateToVersion2_0(DatabaseSchemaUpdater dbUpdater)
 {
     // Release 2.0
     if (!_dbService.TabTypes.Any(type => type.Name == TabTypeNames.GuitarPro))
     {
         _dbService.TabTypes.InsertOnSubmit(new TabType
         {
             Name     = TabTypeNames.GuitarPro,
             ImageUrl = "/Images/instrument/Guitarpro"
         });
     }
 }
コード例 #22
0
        public RelatorioDataBaseContext(string connectionString)
            : base(connectionString)
        {
            if (!this.DatabaseExists())
            {
                try
                {
                    this.CreateDatabase();

                    DatabaseSchemaUpdater dbUpdater = this.CreateDatabaseSchemaUpdater();
                    dbUpdater.DatabaseSchemaVersion = DB_VERSION;
                    dbUpdater.Execute();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                    Debug.WriteLine(e.Message);
                    MessageBox.Show("PROBLEMA AO CRIAR BANCO DE DADOS");
                }
            }
            else
            {
                try
                {
                    DatabaseSchemaUpdater dbUpdater = this.CreateDatabaseSchemaUpdater();

                    if (dbUpdater.DatabaseSchemaVersion < DB_VERSION)
                    {
                        if (dbUpdater.DatabaseSchemaVersion == 0)
                        {
                            dbUpdater.AddTable <Estudo>();
                            dbUpdater.DatabaseSchemaVersion = DB_VERSION;
                            dbUpdater.Execute();
                        }
                        if (dbUpdater.DatabaseSchemaVersion < 2)
                        {
                            dbUpdater.AddColumn <Relatorio>("Folhetos");
                            dbUpdater.DatabaseSchemaVersion = DB_VERSION;
                            dbUpdater.Execute();
                        }
                    }
                }
                catch (Exception e)
                {
                    //this.DeleteDatabase();
                    Debug.WriteLine(e.StackTrace);
                    Debug.WriteLine(e.Message);
                    MessageBox.Show("PROBLEMA AO ATUALIZAR BANCO DE DADOS");
                }
            }
        }
コード例 #23
0
ファイル: App.xaml.cs プロジェクト: ITSF/WP8Book
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            DB = new MoviesDataContext();
            if (!DB.DatabaseExists())
            {
                DB.CreateDatabase();
                var dbUpdater = DB.CreateDatabaseSchemaUpdater();
                dbUpdater.DatabaseSchemaVersion = 2;
                dbUpdater.Execute();
            }

            DatabaseSchemaUpdater updater = DB.CreateDatabaseSchemaUpdater();

            if (updater.DatabaseSchemaVersion < 2)
            {
                // PublishedDate-Spalte fehlt => hinzufügen und Version erhöhen
                updater.AddColumn <Movie>("PublishedDate");
                updater.DatabaseSchemaVersion = 2;
                updater.Execute();
            }
        }
コード例 #24
0
ファイル: UpdateHelper.cs プロジェクト: NPadrutt/Places
        public void UpdateDatabase(MainDataContext db)
        {
            schemaUpdate = db.CreateDatabaseSchemaUpdater();
            if (schemaUpdate.DatabaseSchemaVersion < db.SCHEMAVERSION)
            {
                if (schemaUpdate.DatabaseSchemaVersion == 1)
                {
                    schemaUpdate.AddColumn<Location>("Distance");
                }

                schemaUpdate.DatabaseSchemaVersion = db.SCHEMAVERSION;
                schemaUpdate.Execute();
            }
        }
コード例 #25
0
        public void AddPositionColumn(DatabaseSchemaUpdater updater)
        {
            //DML update
            updater.AddColumn <FavoriteEntry>("Position");
            updater.DatabaseSchemaVersion = 1;
            updater.Execute();
            //DDL update
            var ctx = (DyanamicDBContext)updater.Context;

            foreach (var fav in ctx.FavoriteEntries)
            {
                fav.Position = fav.EntryID;
            }
            ctx.SubmitChanges();
        }
コード例 #26
0
        private void CheckAndUpdateToVersion3_0(DatabaseSchemaUpdater dbUpdater)
        {
            // Release 3.0
            // NOTE can't relay on DatabaseSchemaVersion cause it's always zero for clean installed versions
            // NOTE can't check for column existing - no such API, so use ImageUrl as a marker of version 3.0
            if (_dbService.TabTypes.Any(type => type.ImageUrl == "/Images/instrument/Electric-Guitar"))
            {
                return;
            }

            dbUpdater.AddColumn <Tab>("CloudName");
            dbUpdater.AddColumn <Tab>("AlbumCoverImageUrl");

            dbUpdater.AddColumn <Group>("LargeImageUrl");
            dbUpdater.AddColumn <Group>("ExtraLargeImageUrl");
        }
コード例 #27
0
        private void CheckAndUpdateToVersion1_1(DatabaseSchemaUpdater dbUpdater)
        {
            if (!_dbService.TabTypes.Any(type => type.Name == "chords"))
            {
                _dbService.TabTypes.InsertOnSubmit(new TabType {
                    Name = "chords", ImageUrl = "/Images/instrument/Chords"
                });
            }

            if (!_dbService.TabTypes.Any(type => type.Name == "drums"))
            {
                _dbService.TabTypes.InsertOnSubmit(new TabType {
                    Name = "drums", ImageUrl = "/Images/instrument/Drums"
                });
            }
        }
コード例 #28
0
        public void CreateTable <T>() where T : class
        {
            bool TableExists = this.Table <T>() != null;

            if (TableExists)
            {
                try { var x = this.Table <T>().Count(); }
                catch { TableExists = false; }
            }

            if (!TableExists)
            {
                DatabaseSchemaUpdater su = Microsoft.Phone.Data.Linq.Extensions.CreateDatabaseSchemaUpdater(this);
                su.AddTable <T>();
                su.Execute();
            }
        }
コード例 #29
0
        /// <summary>
        /// This Method adds the TimeStamp Column for MMOs, if it doesn't exist
        /// Change made in Commit 22a87e3bfd878951116798ae68ff81b5dd6fa26d
        /// Version 0.9.8
        /// </summary>
        /// <param name="schema"></param>
        private static void AddMultimediaTimeStamp(DatabaseSchemaUpdater schema)
        {
            try
            {
                var q = from mmo in schema.Context.GetTable<MultimediaObject>()
                        select mmo.TimeStamp;

                if (q.Any(ts => ts.HasValue))
                {
                    return;
                }
            }
            catch (Exception)
            {
                schema.AddColumn<MultimediaObject>("TimeStamp");
            }
        }
コード例 #30
0
        public static void UpdateDatabase(DatabaseContext db)
        {
            DatabaseSchemaUpdater dbUpdater = db.CreateDatabaseSchemaUpdater();

            if (dbUpdater.DatabaseSchemaVersion < DATA_VERSION)
            {
                // Update date from 1.1.48.0 version
                if (dbUpdater.DatabaseSchemaVersion < 1)
                {
                    dbUpdater.AddColumn <Exercise>("WithoutWeight");
                    dbUpdater.AddColumn <Exercise>("Order");
                }

                dbUpdater.DatabaseSchemaVersion = DATA_VERSION;
                dbUpdater.Execute();
            }
        }
コード例 #31
0
        public void SetSystemSettings(string globalAdminDetails, string systemSettingsData)
        {
            LogExtension.LogInfo("Initializes system settings at first time", MethodBase.GetCurrentMethod());
            var systemSettingsProperties = JsonConvert.DeserializeObject <SystemSettings>(systemSettingsData);
            var globalAdminDetail        = JsonConvert.DeserializeObject <User>(globalAdminDetails);

            systemSettingsProperties.SqlConfiguration.AuthenticationType = 0;

            GlobalAppSettings.DbSupport = systemSettingsProperties.SqlConfiguration.ServerType;

            var systemSettingsModel = new SystemStartUpPageModel();

            SystemStartUpPageModel.SetSystemProperties(systemSettingsProperties);
            Connection.ConnectionString = _tokenCryptography.Decrypt(systemSettingsProperties.SqlConfiguration.ConnectionString);

            var systemSettings = new SystemSettings
            {
                OrganizationName         = "Grout",
                WelcomeNoteText          = "Welcome to Grout",
                ActivationExpirationDays = 3,
                DateFormat     = "MM/dd/yyyy",
                FavIcon        = "Grout_Favicon.png",
                LoginLogo      = "Grout_Login_Logo.png",
                MainScreenLogo = "Grout_Main_Logo.png",
                ReportCount    = 20,
                TimeZone       = TimeZoneInfo.Local.Id,
                Language       = "en-US",
                BaseUrl        = new UriBuilder(HttpContext.Request.Url.Scheme, HttpContext.Request.Url.Host, HttpContext.Request.Url.Port).ToString().TrimEnd('/')
            };

            //Insert System Settings
            systemSettingsModel.InsertSystemSettings(systemSettings, _tokenCryptography.Decrypt(systemSettingsProperties.SqlConfiguration.ConnectionString));

            //Initialize System Settings
            GlobalAppSettings.InitializeSystemSettings(GlobalAppSettings.GetConfigFilepath() + ServerSetup.Configuration);

            //Add System Administrator
            SystemStartUpPageModel.AddSystemAdmin(globalAdminDetail.UserName.ToLower(), CultureInfo.CurrentCulture.TextInfo.ToTitleCase(globalAdminDetail.FirstName), CultureInfo.CurrentCulture.TextInfo.ToTitleCase(globalAdminDetail.LastName),
                                                  globalAdminDetail.Email.ToLower(), globalAdminDetail.Password);

            DatabaseSchemaUpdater.UpdateLaterversionToServerVersion(DatabaseSchemaUpdater.GetLatestVersion());
            GlobalAppSettings.IsLatestVersion = false;

            //Add Sample Reports
            SystemStartUpPageModel.InsertSampleReports();
        }
コード例 #32
0
        internal void Open()
        {
            using (var transaction = this.BeginInternalTransaction())
            {
                if (!transaction.DatabaseExists())
                {
                    transaction.CreateDatabase();

                    DatabaseSchemaUpdater schemaUpdater = transaction.CreateDatabaseSchemaUpdater();
                    foreach (var model in models.Values)
                    {
                        MethodInfo method  = schemaUpdater.GetType().GetMethod("AddTable");
                        MethodInfo generic = method.MakeGenericMethod(model.Type);
                        generic.Invoke(schemaUpdater, null);
                    }
                    schemaUpdater.Execute();
                }
            }
        }
コード例 #33
0
        public void AddTablesHistoryTables(DatabaseSchemaUpdater updater)
        {
            //DML update
            updater.AddTable <StopHistoryEntry>();
            updater.AddTable <PlanningHistoryEntry>();
            updater.AddTable <RecentEntry>();
            updater.DatabaseSchemaVersion = 2;
            updater.Execute();

            //DDL update
            var ctx = (DyanamicDBContext)updater.Context;

            foreach (var entry in ctx.HistoryEntries)
            {
                if (entry.TypeLegacy == HistoryEntry.HistoryEntryTypeLegacy.Stop)
                {
                    entry.TypeIDLegacy = 0;
                    var stopEntry = new StopHistoryEntry {
                        StopID = entry.StopID, Count = entry.Count
                    };
                    ctx.StopHistoryEntries.InsertOnSubmit(stopEntry);
                    ctx.HistoryEntries.DeleteOnSubmit(entry);
                }
                else if (entry.TypeLegacy == HistoryEntry.HistoryEntryTypeLegacy.SourceTarget)
                {
                    entry.TypeIDLegacy = 0;
                    var planningEntry = new PlanningHistoryEntry {
                        StopID = entry.StopID, Count = entry.Count, IsSource = false
                    };
                    var planningEntry2 = new PlanningHistoryEntry {
                        StopID = entry.StopID, Count = entry.Count, IsSource = true
                    };
                    ctx.PlanningHistoryEntries.InsertOnSubmit(planningEntry);
                    ctx.PlanningHistoryEntries.InsertOnSubmit(planningEntry2);
                    ctx.HistoryEntries.DeleteOnSubmit(entry);
                }
                else
                {
                    entry.TypeIDLegacy = 0;
                }
            }
            ctx.SubmitChanges();
        }
コード例 #34
0
        public static void UpdateToVersionOne()
        {
            using (HikeMqttPersistenceDb context = new HikeMqttPersistenceDb(App.MqttDBConnectionstring))
            {
                DatabaseSchemaUpdater schemaUpdater = context.CreateDatabaseSchemaUpdater();
                // get current database schema version
                // if not changed the version is 0 by default
                int version = schemaUpdater.DatabaseSchemaVersion;

                // if current version of database schema is old
                if (version == 0)
                {
                    // add Address column to the table corresponding to the Person class
                    // IMPORTANT: update database schema version before calling Execute
                    schemaUpdater.DatabaseSchemaVersion = Latest_Version;
                    // execute changes to database schema
                    schemaUpdater.Execute();
                }
            }
        }
コード例 #35
0
        private void UpdateDataBase(DatabaseSchemaUpdater dbUpdater)
        {
            CheckAndUpdateToVersion1_1(dbUpdater);

            CheckAndUpdateToVersion2_0(dbUpdater);

            CheckAndUpdateToVersion3_0(dbUpdater);

            _dbService.SubmitChanges();

            // Change database version.
            dbUpdater.DatabaseSchemaVersion = _dbVersion;

            // Perform the database update in a single transaction.
            dbUpdater.Execute();

            //Update table data - for updated db.
            UpdateRowsForVersion3_0();
            _dbService.SubmitChanges();
        }
コード例 #36
0
        public bool hasToMigrate()
        {
            if (database.DatabaseExists() == true)
            {
                // Check whether a database update is needed.
                dbUpdater = database.CreateDatabaseSchemaUpdater();

                if (dbUpdater.DatabaseSchemaVersion < latestVersion)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new Exception("Connectionstring doesn't work for a database!");
            }
        }
コード例 #37
0
 private static void ApplyMigrations(DatabaseSchemaUpdater schema, Version targetVersion)
 {
     // Schema 0 is the default
     // This could be any Version from 0 up to 0.9.9 inclusive
     if (schema.DatabaseSchemaVersion == 0)
     {
         if (targetVersion >= new Version(0, 9, 8))
         {
             AddMultimediaTimeStamp(schema);
         }
         schema.DatabaseSchemaVersion = 1;
     }
     if (schema.DatabaseSchemaVersion == 1)
     {
         if (targetVersion >= new Version(0, 9, 9, 1))
         {
             AddLocalization(schema);
         }
         schema.DatabaseSchemaVersion = 2;
     }
 }
コード例 #38
0
 private void InitializeData()
 {
     DatabaseSourceDefinitor.CreateDatabaseIfNotExist();
     DatabaseSchemaUpdater.Update();
     using (var repository = new LeagueRepository(DatabaseSourceDefinitor.ConnectionString))
     {
         Leagues = repository.GetLeagues();
     }
     if (Leagues.Length > 0)
     {
         int lastSeason = Leagues.Max(t => t.Season);
         League = Leagues.First(t => t.Season == lastSeason);
         Tour   = League.Tours[0];
         using (var repository = new GameRepository(DatabaseSourceDefinitor.ConnectionString))
         {
             GamesInTour = repository.GetGamesInTour(Tour.Id);
         }
         League.Calculate();
         TeamsStat = League.TeamStats;
     }
 }
コード例 #39
0
 /// <summary>
 /// Updates the structure at_1_9_1.
 /// </summary>
 /// <param name="dataBaseUpdater">The data base updater.</param>
 public static void UpdateStructureAt_1_9_1(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<TallySchedule>("Notes");
     dataBaseUpdater.AddColumn<TallySchedule>("IsActive");
 }
コード例 #40
0
 /// <summary>
 /// Updates the table structure at V1_9_9.
 /// </summary>
 /// <param name="databaseSchemaUpdater">The database schema updater.</param>
 public static void UpdateTableStructureAtV1_9_9(DatabaseSchemaUpdater databaseSchemaUpdater)
 {
     databaseSchemaUpdater.AddColumn<TallySchedule>("RecurrenceInterval");
 }
コード例 #41
0
 private void ApplyMigrations(DatabaseSchemaUpdater schema)
 {
     // In the future
 }
コード例 #42
0
        public static void UpdateStructure(DatabaseSchemaUpdater dataBaseUpdater)
        {
            if (dataBaseUpdater.DatabaseSchemaVersion == 2)
            {
                dataBaseUpdater.AddColumn<Category>("Favourite");
                dataBaseUpdater.DatabaseSchemaVersion = 3;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 3)
            {
                BudgetItem.UpdateDataContext(dataBaseUpdater);
                BudgetProject.UpdateDataContext(dataBaseUpdater);
                BudgetMonthlyReport.UpdateUpdateDataContext(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 4;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 4)
            {
                BudgetProject.UpdateDataContext_At_v190(dataBaseUpdater);
                Category.UpdateDataContext_At_v190(dataBaseUpdater);
                BudgetItem.UpdateDataContextAt_190(dataBaseUpdater);
                dataBaseUpdater.AddTable<TallySchedule>();
                dataBaseUpdater.AddTable<PeopleProfile>();
                Repayment.UpdateTableStructureAtV1_9_1(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 5;
                dataBaseUpdater.Execute();
                dataBaseUpdater.Context.GetTable<BudgetProject>().ToList<BudgetProject>().ForEach(delegate(BudgetProject p)
                {
                    p.Amount = p.GetMoney();
                });
                dataBaseUpdater.Context.SubmitChanges();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 5)
            {
                AccountItem.UpdateStructureAt1_9_1(dataBaseUpdater);
                SchedulePlanningTable.UpdateStructureAt_1_9_1(dataBaseUpdater);
                TallySchedule.UpdateStructureAt_1_9_1(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 6;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 6)
            {
                PeopleGroup.HandleUpdatingAt_1_9_3(dataBaseUpdater);
                PeopleProfile.UpdateStructureAt_1_9_3(dataBaseUpdater);
                Repayment.UpdateTableStructureAtV1_9_3(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 7;
                dataBaseUpdater.Execute();
                TinyMoneyDataContext db = dataBaseUpdater.Context as TinyMoneyDataContext;
                LoadDefaultPeopleGroups(db);
                Repayment.UpdateOldData(db);
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 7)
            {
                PictureInfo.UpdateStructureAt_196(dataBaseUpdater);
                PeopleAssociationData.UpdateStructureAt_196(dataBaseUpdater);
                AccountItem.UpdateStructureAt1_9_6(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 8;
                dataBaseUpdater.Execute();
            }

            if (dataBaseUpdater.DatabaseSchemaVersion == 8)
            {
                Account.UpdateDataContext_At_v1972(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.LatestVersion;
                dataBaseUpdater.Execute();

                Repayment.UpdateTableStructureAtV1_9_8(dataBaseUpdater, ViewModels.BorrowLeanManager.BorrowLeanViewModel.EnsureStatus);
            }

        }
コード例 #43
0
        public static void UpdateStructure(DatabaseSchemaUpdater dataBaseUpdater)
        {
            if (dataBaseUpdater.DatabaseSchemaVersion == 2)
            {
                dataBaseUpdater.AddColumn<Category>("Favourite");
                dataBaseUpdater.DatabaseSchemaVersion = 3;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 3)
            {
                BudgetItem.UpdateDataContext(dataBaseUpdater);
                BudgetProject.UpdateDataContext(dataBaseUpdater);
                BudgetMonthlyReport.UpdateUpdateDataContext(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 4;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 4)
            {
                BudgetProject.UpdateDataContext_At_v190(dataBaseUpdater);
                Category.UpdateDataContext_At_v190(dataBaseUpdater);
                BudgetItem.UpdateDataContextAt_190(dataBaseUpdater);
                dataBaseUpdater.AddTable<TallySchedule>();
                dataBaseUpdater.AddTable<PeopleProfile>();
                Repayment.UpdateTableStructureAtV1_9_1(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 5;
                dataBaseUpdater.Execute();
                dataBaseUpdater.Context.GetTable<BudgetProject>().ToList<BudgetProject>().ForEach(delegate(BudgetProject p)
                {
                    p.Amount = p.GetMoney();
                });
                dataBaseUpdater.Context.SubmitChanges();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 5)
            {
                AccountItem.UpdateStructureAt1_9_1(dataBaseUpdater);
                SchedulePlanningTable.UpdateStructureAt_1_9_1(dataBaseUpdater);
                TallySchedule.UpdateStructureAt_1_9_1(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 6;
                dataBaseUpdater.Execute();
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 6)
            {
                PeopleGroup.HandleUpdatingAt_1_9_3(dataBaseUpdater);
                PeopleProfile.UpdateStructureAt_1_9_3(dataBaseUpdater);
                Repayment.UpdateTableStructureAtV1_9_3(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 7;
                dataBaseUpdater.Execute();
                TinyMoneyDataContext db = dataBaseUpdater.Context as TinyMoneyDataContext;
                LoadDefaultPeopleGroups(db);
                Repayment.UpdateOldData(db);
            }
            if (dataBaseUpdater.DatabaseSchemaVersion == 7)
            {
                PictureInfo.UpdateStructureAt_196(dataBaseUpdater);
                PeopleAssociationData.UpdateStructureAt_196(dataBaseUpdater);
                AccountItem.UpdateStructureAt1_9_6(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = 8;
                dataBaseUpdater.Execute();
            }

            if (dataBaseUpdater.DatabaseSchemaVersion == 8)
            {
                Account.UpdateDataContext_At_v1972(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.v1_9_7;
                dataBaseUpdater.Execute();
            }

            if (dataBaseUpdater.DatabaseSchemaVersion == DatabaseVersion.v1_9_7)
            {
                TransferingItem.UpdateStructureAt_1_9_8(dataBaseUpdater);
                TallySchedule.UpdateStructureAt_1_9_8(dataBaseUpdater);

                // TODO: update to 1.98
                dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.v1_9_8;
                dataBaseUpdater.Execute();
            }

            if (dataBaseUpdater.DatabaseSchemaVersion == DatabaseVersion.v1_9_8)
            {
                AccountItem.UpdateAt199(dataBaseUpdater);

                dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.v1_9_9;
                dataBaseUpdater.Execute();

                try
                {
                    BudgetManager.BugFixingFor1_9_9(dataBaseUpdater.Context as TinyMoneyDataContext);
                }
                catch { }
            }

            if (dataBaseUpdater.DatabaseSchemaVersion == DatabaseVersion.v1_9_9)
            {
                TallySchedule.UpdateTableStructureAtV1_9_9(dataBaseUpdater);

                Account.UpdateDataContext_At_v199(dataBaseUpdater);
                dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.v1_9_9_2;
                dataBaseUpdater.Execute();

                try
                {
                    // update accounts order  
                    TinyMoneyDataContext db = dataBaseUpdater.Context as TinyMoneyDataContext;

                    Account.ResetOrders(db);
                    Category.UpdateDataContext_At_v199(db);

                    AppSetting.Instance.AutoBackupWhenAppUp = true;
                    db = null;
                }
                catch (Exception ex)
                {

                }
            }
        }
コード例 #44
0
 public static void UpdateStructureAt_1_9_3(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<PeopleProfile>("HasCurrency");
 }
コード例 #45
0
 public static void UpdateDataContext_At_v190(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<BudgetProject>("Amount");
 }
コード例 #46
0
 public static void UpdateDataContextAt_190(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<BudgetItem>("SettleType");
 }
コード例 #47
0
ファイル: Changeset5.cs プロジェクト: karbazol/FBReaderCS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     updater.AddColumn<BookModel>("CatalogItemId");
     updater.AddColumn<BookDownloadModel>("CatalogItemId");
 }
コード例 #48
0
 public static void UpdateDataContext(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddTable<BudgetItem>();
 }
コード例 #49
0
 public static void UpdateStructureAt1_9_6(DatabaseSchemaUpdater dataBaseUpdater)
 {
 }
コード例 #50
0
 public static void UpdateStructureAt_196(DatabaseSchemaUpdater updater)
 {
     updater.AddTable<PictureInfo>();
 }
コード例 #51
0
 /// <summary>
 /// Updates the structure at_1_9_1.
 /// </summary>
 /// <param name="dataBaseUpdater">The data base updater.</param>
 public static void UpdateStructureAt_1_9_8(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<TallySchedule>("DataProvider");
     dataBaseUpdater.AddColumn<TallySchedule>("TransferingPoundageAmount");
     dataBaseUpdater.AddColumn<TallySchedule>("PeopleIds");
     dataBaseUpdater.AddColumn<TallySchedule>("PictureIds");
 }
コード例 #52
0
ファイル: Changeset1.cs プロジェクト: bdvsoft/reader_wp8_OPDS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     updater.AddColumn<BookModel>("Language");
     updater.AddColumn<BookModel>("Description");
 }
コード例 #53
0
 public static void UpdateDataContext_At_v190(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddColumn<Category>("Order");
     dataBaseUpdater.AddIndex<Category>("Category_Index_Order");
 }
コード例 #54
0
 public static void UpdateStructureAt1_9_1(DatabaseSchemaUpdater updater)
 {
     updater.AddColumn<AccountItem>("IsClaim");
 }
コード例 #55
0
ファイル: Changeset4.cs プロジェクト: karbazol/FBReaderCS
 public override void Update(BookDataContext db, DatabaseSchemaUpdater updater)
 {
     updater.AddColumn<BookModel>("Trial");
     updater.AddColumn<BookDownloadModel>("IsTrial");
 }
コード例 #56
0
 private static void AfterRebuild(DatabaseSchemaUpdater dataBaseUpdater)
 {
     UpdateStructure(dataBaseUpdater);
 }
コード例 #57
0
ファイル: BaseChangeset.cs プロジェクト: karbazol/FBReaderCS
 public abstract void Update(BookDataContext db, DatabaseSchemaUpdater updater);
コード例 #58
0
 public static void UpdateUpdateDataContext(DatabaseSchemaUpdater dataBaseUpdater)
 {
     dataBaseUpdater.AddTable<BudgetMonthlyReport>();
 }
コード例 #59
0
        /// <summary>
        /// This Method adds the Localization Table, if it doesn't exist
        /// Version 0.9.10.0/1.0
        /// </summary>
        /// <param name="schema"></param>
        private static void AddLocalization(DatabaseSchemaUpdater schema)
        {
            var ctx = schema.Context;

            try
            {
                var locTable = ctx.GetTable<Localization>();
                if (locTable.Any())
                {
                    LogManager.GetLogger(typeof(VersionMigration)).Info("Localization Table already exists");
                }
            }
            catch (Exception ex)
            {
                schema.AddTable<Localization>();
            }
        }
コード例 #60
0
 public static void UpdateStructureAt_1_9_1(DatabaseSchemaUpdater databaseUpdater)
 {
     databaseUpdater.AddTable<SchedulePlanningTable>();
 }