using NongFuWebApi.Models; using SqlSugar; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; using static NongFuWebApi.Controllers.AMSModel; namespace NongFuWebApi.Services { [AttributeUsage(AttributeTargets.Class, Inherited = true)] class STAttribute : SugarTable { public static Dictionary TableModelName = new Dictionary(); public STAttribute(string tableName) : base(tableName) { string value = ""; if (TableModelName.TryGetValue(TableName, out value)) { TableName = value; } } /// /// 初始化表名 /// public static void InitTableName() { LogHelper.Info($"StartUp Init CreateTable..."); var order = new SqlHelper().CreateTable();//车体状态信息表 LogHelper.Info($"StartUp Init CreateTable Complete!"); LogHelper.Info($"StartUp Init TableName..."); string[] table = ConfigurationManager.AppSettings.AllKeys; if (table.Length > 0) { List tableName = new List(); for (int i = 0; i < table.Length; i++) { if (table[i].Contains("表")) tableName.Add(table[i]); } if (tableName.Count > 0) { tableName.ForEach(a => { string tableSqlName = ConfigurationManager.AppSettings[a].ToString(); if (!TableModelName.Keys.Contains(a)) { LogHelper.Info($"StartUp Init TableName Add:tableName:{a},tableSqlName:{tableSqlName}"); TableModelName.Add(a, tableSqlName); } }); } } LogHelper.Info($"StartUp Init TableName Complete!"); } /// /// 创建数据中间表表 /// /// public static void CreateMiddleTable() { //var order = new SqlHelper().CreateTable();//车体状态信息表 } } }