コード例 #1
0
        public async Task SyncDatabaseAsync()
        {
            var repositories = GetAllRepositories();

            foreach (var repository in repositories)
            {
                if (string.IsNullOrEmpty(repository.TableName) || repository.TableColumns == null || repository.TableColumns.Count <= 0)
                {
                    continue;
                }

                if (!await _settingsManager.Database.IsTableExistsAsync(repository.TableName))
                {
                    await CreateTableAsync(repository.TableName, repository.TableColumns, string.Empty, false);
                }
                else
                {
                    await AlterTableAsync(repository.TableName, repository.TableColumns, string.Empty);
                }
            }

            var config = await ConfigRepository.GetAsync();

            if (config.Id == 0)
            {
                await ConfigRepository.InsertAsync(config);
            }

            await SyncContentTablesAsync();

            await UpdateConfigVersionAsync();
        }
コード例 #2
0
        private async Task UpdateConfigVersionAsync()
        {
            var configInfo = await ConfigRepository.GetAsync();

            if (configInfo.Id > 0)
            {
                configInfo.DatabaseVersion = _settingsManager.Version;
                configInfo.UpdateDate      = DateTime.UtcNow;
                await ConfigRepository.UpdateAsync(configInfo);
            }
        }