Пример #1
0
        public override async Task Execute(IJobTaskContext context)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "nm_admin.sql");

            if (!File.Exists(path))
            {
                await Logger.Error("Sql文件不存在~");

                return;
            }

            using (var sr = new StreamReader(path))
            {
                var sql = await sr.ReadToEndAsync();

                using (var con = _dbContext.NewConnection())
                {
                    await con.ExecuteAsync(sql);

                    await Logger.Info("数据库已还原");
                }
            }
        }