From 2d3ee03961d6cfbde70342e8a97bc7b05d0b0dc3 Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期一, 21 七月 2025 17:27:34 +0800 Subject: [PATCH] 优化代码, 封装货位锁和创建任务流程, 数据库事务等 --- util/SqlHelper.cs | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/util/SqlHelper.cs b/util/SqlHelper.cs index f0f6028..e59332d 100644 --- a/util/SqlHelper.cs +++ b/util/SqlHelper.cs @@ -6,20 +6,19 @@ namespace HH.WCS.Mobox3.DSZSH.util { //https://www.donet5.com/Home/Doc public class SqlHelper<T> where T : class, new() { + // NOTE:濡傛灉鐢∣racle鏁版嵁搴�闇�鍖匫racle.ManagedDataAccess/21.15.0,鐜netframework 4.6.2 (澶柊浜�.8鏈夌殑鏈嶅姟鍣ㄥ畨瑁呬笉涓婂幓) - /// <summary> - /// 濡傛灉鐢∣racle鏁版嵁闇�鍖匫racle.ManagedDataAccess/21.15.0锛岀幆澧僴etframework 4.62锛屽お鏂颁簡4.8鏈夌殑鏈嶅姟鍣ㄥ畨瑁呬笉涓婂幓 - /// </summary> - /// <param name="url"></param> - /// <returns></returns> public SqlSugarClient GetInstance(string url = "") { //鍒涘缓鏁版嵁搴撳璞� SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = string.IsNullOrEmpty(url) ? Settings.SqlServer : url, + //ConnectionString = @"Data Source=192.168.1.198\sql2008;Initial Catalog=OIMobox;User ID=sa;Password=sa@2015", DbType = DbType.SqlServer, + //ConnectionString = @"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OIMobox)));User Id=system;Password=Am123123;", //DbType = DbType.Oracle, + IsAutoCloseConnection = true, InitKeyType = InitKeyType.Attribute//浠庣壒鎬ц鍙栦富閿嚜澧炰俊鎭� }); @@ -39,6 +38,12 @@ //鐩稿綋浜嶦F鐨�PrintToMiniProfiler }; + // 閰嶇疆AOP鏃ュ織 + //db.Aop.OnLogExecuting = (sql, pars) => + //{ + // Console.WriteLine(sql); // 杈撳嚭绾疭QL璇彞 + //}; + //姣忔璁剧疆鏁板�鏃堕兘鍘婚櫎鍓嶅鍚庡绌烘牸 db.Aop.DataExecuted = (value, entity) => { entity.EntityColumnInfos.ToList().ForEach(a => { @@ -49,7 +54,7 @@ }); }; - //鎹浆鎹�(ExecuteCommand鎵嶄細鎷︽埅锛屾煡璇笉琛� + //鎹浆鎹�(ExecuteCommand鎵嶄細鎷︽埅,鏌ヨ涓嶈) //db.Aop.DataExecuting = (value, entity) => { // //var val=entity.EntityColumnInfo // Console.WriteLine(entity.EntityName); @@ -57,7 +62,5 @@ return db; } - } - } -- Gitblit v1.9.1