src/ZKEACMS.Updater/Service/DbUpdaterService.cs

(开头部分) 14KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Easy.Extend;
using Easy.Mvc.Plugin;
using Easy.Net;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.Json;
using ZKEACMS.Options;
using ZKEACMS.Updater.Models;

namespace ZKEACMS.Updater.Service
{
    public class DbUpdaterService : IDbUpdaterService
    {
        private readonly IOptions<DBVersionOption> _dbVersionOption;
        private readonly IWebClient _webClient;
        private readonly ILogger<DbUpdaterService> _logger;
        private readonly IDBContextProvider _dbContextProvider;
        private const int DBVersionRecord = 1;
        private readonly string _scriptFileName;
        private string availableSource;
        public DbUpdaterService(DatabaseOption databaseOption,
            IOptions<DBVersionOption> dbVersionOption,
            IWebClient webClient,
            IDBContextProvider dbContextProvider,
            ILogger<DbUpdaterService> logger)
        {
            _dbVersionOption = dbVersionOption;
            _webClient = webClient;
            _scriptFileName = $"{databaseOption.DbType}.sql";//MsSql.sql, MySql.sql, Sqlite.sql
            _logger = logger;
            _dbContextProvider = dbContextProvider;
        }

        public void UpdateDatabase()
        {
            ExcuteLocalScripts();

            UpgradeDbToLatest();
        }

        private void UpgradeDbToLatest()
        {
            var appVersion = Easy.Version.Parse(Version.VersionInfo);
            bool allSuccess = true;
            foreach (var dbContext in _dbContextProvider.GetAvailableDbContexts())
后面还有 347 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。