From 0fb0f17319ecf71d66b96a6acfd07f754be9443e Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 24 十月 2024 13:44:38 +0800
Subject: [PATCH] WCS添加穿梭车信息表,修改任务信息表
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/Seed/DBContext.cs | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 216 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Seed/DBContext.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Seed/DBContext.cs"
new file mode 100644
index 0000000..3ebd497
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/Seed/DBContext.cs"
@@ -0,0 +1,216 @@
+锘縰sing SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.Const;
+using WIDESEA_Core.DB;
+using WIDESEA_Core.Helper;
+
+namespace WIDESEA_Core.Seed
+{
+ public class DBContext
+ {
+ private static MutiDBOperate connectObject => GetMainConnectionDb();
+ private static string _connectionString = connectObject.Connection;
+ private static DbType _dbType = (DbType)connectObject.DbType;
+ public static string ConnId = connectObject.ConnId;
+ private SqlSugarClient _db;
+
+ /// <summary>
+ /// 杩炴帴瀛楃涓�
+ /// </summary>
+ public static MutiDBOperate GetMainConnectionDb()
+ {
+ MutiDBOperate mainDb = new MutiDBOperate()
+ {
+ Connection = AppSettings.app(MainDb.ConnectionString).DecryptDES(AppSecret.DB),
+ ConnId = MainDb.CurrentDbConnId,
+ DbType = DataBaseType.SqlServer
+ };
+
+ return mainDb;
+ }
+ /// <summary>
+ /// 杩炴帴瀛楃涓�
+ /// </summary>
+ public static string ConnectionString
+ {
+ get { return _connectionString; }
+ set { _connectionString = value; }
+ }
+ /// <summary>
+ /// 鏁版嵁搴撶被鍨�
+ /// </summary>
+ public static DbType DbType
+ {
+ get { return _dbType; }
+ set { _dbType = value; }
+ }
+ /// <summary>
+ /// 鏁版嵁杩炴帴瀵硅薄
+ /// </summary>
+ public SqlSugarClient Db
+ {
+ get { return _db; }
+ private set { _db = value; }
+ }
+
+ //public SqlSugarScope DbClient
+ //{
+ // get { return _dbClient; }
+ // private set { _dbClient = value; }
+ //}
+
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鏋勯�犲嚱鏁�
+ /// </summary>
+ public DBContext(ISqlSugarClient sqlSugarClient)
+ {
+ if (string.IsNullOrEmpty(_connectionString))
+ throw new ArgumentNullException("鏁版嵁搴撹繛鎺ュ瓧绗︿覆涓虹┖");
+
+ _db = sqlSugarClient as SqlSugarClient;
+ //_db.Aop.DataExecuting = SqlSugarAop.DataExecuting;
+ }
+
+ #region 瀹炰緥鏂规硶
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鑾峰彇鏁版嵁搴撳鐞嗗璞�
+ /// </summary>
+ /// <returns>杩斿洖鍊�</returns>
+ public SimpleClient<T> GetEntityDB<T>() where T : class, new()
+ {
+ return new SimpleClient<T>(_db);
+ }
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鑾峰彇鏁版嵁搴撳鐞嗗璞�
+ /// </summary>
+ /// <param name="db">db</param>
+ /// <returns>杩斿洖鍊�</returns>
+ //public SimpleClient<T> GetEntityDB<T>(SqlSugarClient db) where T : class, new()
+ //{
+ // return new SimpleClient<T>(db);
+ //}
+
+
+
+ #endregion
+
+
+ #region 鏍规嵁瀹炰綋绫荤敓鎴愭暟鎹簱琛�
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鏍规嵁瀹炰綋绫荤敓鎴愭暟鎹簱琛�
+ /// </summary>
+ /// <param name="blnBackupTable">鏄惁澶囦唤琛�</param>
+ /// <param name="lstEntitys">鎸囧畾鐨勫疄浣�</param>
+ public void CreateTableByEntity<T>(bool blnBackupTable, params T[] lstEntitys) where T : class, new()
+ {
+ Type[] lstTypes = null;
+ if (lstEntitys != null)
+ {
+ lstTypes = new Type[lstEntitys.Length];
+ for (int i = 0; i < lstEntitys.Length; i++)
+ {
+ T t = lstEntitys[i];
+ lstTypes[i] = typeof(T);
+ }
+ }
+ CreateTableByEntity(blnBackupTable, lstTypes);
+ }
+
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鏍规嵁瀹炰綋绫荤敓鎴愭暟鎹簱琛�
+ /// </summary>
+ /// <param name="blnBackupTable">鏄惁澶囦唤琛�</param>
+ /// <param name="lstEntitys">鎸囧畾鐨勫疄浣�</param>
+ public void CreateTableByEntity(bool blnBackupTable, params Type[] lstEntitys)
+ {
+ if (blnBackupTable)
+ {
+ _db.CodeFirst.BackupTable().InitTables(lstEntitys); //change entity backupTable
+ }
+ else
+ {
+ _db.CodeFirst.InitTables(lstEntitys);
+ }
+ }
+ #endregion
+
+
+ #region 闈欐�佹柟娉�
+
+ ///// <summary>
+ ///// 鍔熻兘鎻忚堪:鑾峰緱涓�涓狣bContext
+ ///// </summary>
+ ///// <returns></returns>
+ //public static MyContext GetDbContext()
+ //{
+ // return new MyContext();
+ //}
+
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:璁剧疆鍒濆鍖栧弬鏁�
+ /// </summary>
+ /// <param name="strConnectionString">杩炴帴瀛楃涓�</param>
+ /// <param name="enmDbType">鏁版嵁搴撶被鍨�</param>
+ public static void Init(string strConnectionString, DbType enmDbType = SqlSugar.DbType.SqlServer)
+ {
+ _connectionString = strConnectionString;
+ _dbType = enmDbType;
+ }
+
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鍒涘缓涓�涓摼鎺ラ厤缃�
+ /// </summary>
+ /// <param name="blnIsAutoCloseConnection">鏄惁鑷姩鍏抽棴杩炴帴</param>
+ /// <param name="blnIsShardSameThread">鏄惁澶哥被浜嬪姟</param>
+ /// <returns>ConnectionConfig</returns>
+ public static ConnectionConfig GetConnectionConfig(bool blnIsAutoCloseConnection = true, bool blnIsShardSameThread = false)
+ {
+ ConnectionConfig config = new ConnectionConfig()
+ {
+ ConnectionString = _connectionString,
+ DbType = _dbType,
+ IsAutoCloseConnection = blnIsAutoCloseConnection,
+ ConfigureExternalServices = new ConfigureExternalServices()
+ {
+ //DataInfoCacheService = new HttpRuntimeCache()
+ },
+ //IsShardSameThread = blnIsShardSameThread
+ };
+ return config;
+ }
+
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鑾峰彇涓�涓嚜瀹氫箟鐨凞B
+ /// </summary>
+ /// <param name="config">config</param>
+ /// <returns>杩斿洖鍊�</returns>
+ public static SqlSugarClient GetCustomDB(ConnectionConfig config)
+ {
+ return new SqlSugarClient(config);
+ }
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鑾峰彇涓�涓嚜瀹氫箟鐨勬暟鎹簱澶勭悊瀵硅薄
+ /// </summary>
+ /// <param name="sugarClient">sugarClient</param>
+ /// <returns>杩斿洖鍊�</returns>
+ public static SimpleClient<T> GetCustomEntityDB<T>(SqlSugarClient sugarClient) where T : class, new()
+ {
+ return new SimpleClient<T>(sugarClient);
+ }
+ /// <summary>
+ /// 鍔熻兘鎻忚堪:鑾峰彇涓�涓嚜瀹氫箟鐨勬暟鎹簱澶勭悊瀵硅薄
+ /// </summary>
+ /// <param name="config">config</param>
+ /// <returns>杩斿洖鍊�</returns>
+ public static SimpleClient<T> GetCustomEntityDB<T>(ConnectionConfig config) where T : class, new()
+ {
+ SqlSugarClient sugarClient = GetCustomDB(config);
+ return GetCustomEntityDB<T>(sugarClient);
+ }
+ #endregion
+ }
+}
--
Gitblit v1.9.3