| | |
| | | { |
| | | public class DBSeed |
| | | { |
| | | private static string SeedDataFolder = "WIDESEAWCS_DB.DBSeed.Json/{0}.tsv"; |
| | | private static string SeedDataFolder = "WIDESEA_DB.DBSeed.Json/{0}.tsv"; |
| | | |
| | | /// <summary> |
| | | /// 寮傛娣诲姞绉嶅瓙鏁版嵁 |
| | |
| | | /// <param name="myContext"></param> |
| | | /// <param name="WebRootPath"></param> |
| | | /// <returns></returns> |
| | | public static async Task SeedAsync(DBContext dbContext, string WebRootPath) |
| | | public static void SeedAsync(DBContext dbContext, string WebRootPath) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | Console.WriteLine("************ WIDESEA DataBase Set *****************"); |
| | | |
| | | //Console.WriteLine($"Master DB ConId: {DBContext.ConnId}"); |
| | | Console.WriteLine($"Master DB Type: {DBContext.DbType}"); |
| | | //Console.WriteLine($"Master DB ConnectString: {DBContext.ConnectionString}"); |
| | | |
| | | Console.WriteLine(); |
| | | |
| | |
| | | Console.WriteLine("Create Tables..."); |
| | | |
| | | var path = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory; |
| | | var referencedAssemblies = System.IO.Directory.GetFiles(path, MainDb.AssemblyName).Select(Assembly.LoadFrom).ToArray(); |
| | | var referencedAssemblies = Directory.GetFiles(path, MainDb.AssemblyName).Select(Assembly.LoadFrom).ToArray(); |
| | | |
| | | var modelTypes = referencedAssemblies |
| | | .SelectMany(a => a.DefinedTypes) |
| | |
| | | #region AddSeedData |
| | | if (seedData != "涓嶅瓨鍦ㄧ浉搴旂殑鐩綍") |
| | | { |
| | | List<Dictionary<string, object>> dicFile = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(seedData); |
| | | List<Dictionary<string, object>>? dicFile = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(seedData); |
| | | |
| | | if (dicFile.Count > 0) |
| | | if (dicFile != null && dicFile.Count > 0) |
| | | { |
| | | List<Dictionary<string, object>> dic = new List<Dictionary<string, object>>(); |
| | | |
| | |
| | | for (int i = 0; i < propertyInfos.Count; i++) |
| | | { |
| | | PropertyInfo propertyInfo = propertyInfos[i]; |
| | | SugarColumn sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | SugarColumn? sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | if (sugarColumn != null) |
| | | { |
| | | if (!sugarColumn.IsIgnore) |
| | |
| | | for (int i = 0; i < propertyInfos.Count; i++) |
| | | { |
| | | PropertyInfo propertyInfo = propertyInfos[i]; |
| | | SugarColumn sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | SugarColumn? sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | if (sugarColumn != null) |
| | | { |
| | | if (!sugarColumn.IsIgnore) |