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<string, string> TableModelName = new Dictionary<string, string>();
|
|
public STAttribute(string tableName) : base(tableName)
|
{
|
string value = "";
|
if (TableModelName.TryGetValue(TableName, out value))
|
{
|
TableName = value;
|
}
|
}
|
|
/// <summary>
|
/// 初始化表名
|
/// </summary>
|
public static void InitTableName()
|
{
|
LogHelper.Info($"StartUp Init CreateTable...");
|
var order = new SqlHelper<ChunAnCacheData>().CreateTable();//车体状态信息表
|
LogHelper.Info($"StartUp Init CreateTable Complete!");
|
|
LogHelper.Info($"StartUp Init TableName...");
|
string[] table = ConfigurationManager.AppSettings.AllKeys;
|
if (table.Length > 0)
|
{
|
List<string> tableName = new List<string>();
|
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!");
|
}
|
/// <summary>
|
/// 创建数据中间表表
|
/// </summary>
|
/// <returns></returns>
|
public static void CreateMiddleTable()
|
{
|
//var order = new SqlHelper<HangChaAGV>().CreateTable();//车体状态信息表
|
}
|
}
|
}
|