mirror of
https://github.com/dotnetcore/AgileConfig.git
synced 2026-10-19 05:22:02 +08:00
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using AgileConfig.Server.Data.Abstraction.DbProvider;
|
|
using AgileConfig.Server.Data.Entity;
|
|
using AgileConfig.Server.Data.Freesql;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AgileConfig.Server.ServiceTests.sqlite;
|
|
|
|
public class BasicTestService
|
|
{
|
|
public BasicTestService()
|
|
{
|
|
Console.WriteLine("BasicTestService ctor.");
|
|
}
|
|
|
|
protected ServiceProvider GlobalServiceProvider { get; set; }
|
|
|
|
public virtual Task<Dictionary<string, string>> GetConfigurationData()
|
|
{
|
|
return
|
|
null;
|
|
}
|
|
|
|
public IFreeSql GetFreeSql()
|
|
{
|
|
var dict = GetConfigurationData().Result;
|
|
|
|
var config = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(dict)
|
|
.Build();
|
|
|
|
var myfreesql = new MyFreeSQL(new DbConfigInfoFactory(config));
|
|
var factory = new EnvFreeSqlFactory(myfreesql);
|
|
var fsq = factory.Create("");
|
|
|
|
return fsq;
|
|
}
|
|
|
|
public virtual void ClearData()
|
|
{
|
|
var fsq = GetFreeSql();
|
|
|
|
fsq.Delete<ServerNode>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<App>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<AppInheritanced>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<Config>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<PublishDetail>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<PublishTimeline>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<ConfigPublished>().Where("1=1").ExecuteAffrows();
|
|
//fsq.Delete<Setting>().Where("1=1").ExecuteAffrows();
|
|
fsq.Delete<SysLog>().Where("1=1").ExecuteAffrows();
|
|
|
|
fsq.Dispose();
|
|
}
|
|
} |