From 1cf00bcc4e6869b356dd15310648bb93c9b1bbde Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期三, 23 七月 2025 09:10:15 +0800
Subject: [PATCH] init_内存泄漏测试- 增加全部释放

---
 2025年6月12日/AuxAllWCS/Build/Project/代码/自定义类.cs |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs"
index f7e69bc..9f66096 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs"
@@ -50,6 +50,29 @@
         }
         #endregion [鑷畾涔夌被][20250323144531864][Settings]
     }
+    public static class ExtendClass
+    {
+        public static void Disnull(this TaskRepository repository)
+        {
+            repository.dbcontext.Dispose();
+            repository = null;
+        }
+        public static void Disnull(this LocRepository repository)
+        {
+            repository.dbcontext.Dispose();
+            repository = null;
+        }
+        public static void Disnull(this TaskActRepository repository)
+        {
+            repository.dbcontext.Dispose();
+            repository = null;
+        }
+        public static void Disnull(this SYSRepository repository)
+        {
+            repository.dbcontext.Dispose();
+            repository = null;
+        }
+    }
     public class LogHelper
     {
         #region    [鑷畾涔夌被][20250323145442478][LogHelper]
@@ -554,6 +577,7 @@
                     sId = new SYSEntity { CN_S_TYPE = snType, CN_T_LAST = DateTime.Now, CN_S_PRE = prefix, CN_N_MAX = 0, CN_S_APP_TYPE = "WCS" };
                     sysservice.Insert(sId);
                 }
+                sysservice.Disnull();
             }
             return result;
         }
@@ -567,7 +591,7 @@
 
             LogHelper.Info($"鍒涘缓浠诲姟 from:{from}>to {to}寮�鍒涘缓>");
             var cntrInfo = string.Join(",", cntrs);
-            ILocRepository locc = new LocRepository();
+            LocRepository locc = new LocRepository();
             var fromLoc = locc.FindEntity(x => x.S_LOC_CODE == from);
             var endLoc = locc.FindEntity(x => x.S_LOC_CODE == to);
 
@@ -609,7 +633,7 @@
                     N_CNTR_COUNT = cntrCount,
                     S_INDEX = S_INDEX,
                 };
-                ITaskRepository taskserice = new TaskRepository();
+                TaskRepository taskserice = new TaskRepository();
                 taskserice.Insert(wmsTask);
 
                 if (workMode == "AGV")
@@ -619,6 +643,9 @@
                     locc.Update(fromLoc);
                     locc.Update(endLoc);
                 }
+
+                locc.Disnull();
+                taskserice.Disnull();
 
                 LogHelper.Info($"鍒涘缓浠诲姟 from:{from}>to {to} 鍒涘缓{wmsTask.S_TASK_NO}鎴愬姛");
                 return true;
@@ -649,7 +676,8 @@
                 N_CREATEMETHOD = 0
             };
             TaskActRepository taskserice = new TaskActRepository();
-            taskserice.Insert(action);
+
+            taskserice.Disnull();
         }
 
         public static System.String GenerateTaskNo(string snType = "浠诲姟鍙�, string Snt = "TN")

--
Gitblit v1.9.1