From bd53976ed5c79ec07b19689fa4a0b9446b34b493 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Wed, 23 Dec 2020 16:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=8F=91=E8=B4=A7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ButcherFactory.BO/LocalBL/BLUtil.cs | 2 +- ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs | 56 +++++++++++-------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ButcherFactory.BO/LocalBL/BLUtil.cs b/ButcherFactory.BO/LocalBL/BLUtil.cs index 12a492f..1eb47b6 100644 --- a/ButcherFactory.BO/LocalBL/BLUtil.cs +++ b/ButcherFactory.BO/LocalBL/BLUtil.cs @@ -20,7 +20,7 @@ namespace ButcherFactory.BO.LocalBL public static void DeleteSaleOutStoreInfo() { var delete = new DQDeleteDom(typeof(T)); - delete.Where.Conditions.Add(DQCondition.LessThan("Time", DateTime.Today.AddDays(-3))); + delete.Where.Conditions.Add(DQCondition.LessThan("Time", DateTime.Today.AddDays(-30))); delete.EExecute(); } } diff --git a/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs b/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs index 5b2e45f..12b1c38 100644 --- a/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs +++ b/ButcherFactory.BO/LocalBL/CarcassSaleOutBL.cs @@ -229,10 +229,20 @@ namespace ButcherFactory.BO.LocalBL } public static void Delete(long id) - { - var delete = new DQDeleteDom(typeof(CarcassSaleOut_Detail)); + { + using (var session = DmoSession.New()) + { + var item = session.Load(new DmoIdentity(typeof(CarcassSaleOut_Detail),id)) as CarcassSaleOut_Detail; + SaveDeleteInfo(session, item); + Delete(session, id); + session.Commit(); + } + } + + static void Delete(IDmoSession session, long id) + { var delete = new DQDeleteDom(typeof(CarcassSaleOut_Detail)); delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); - delete.EExecute(); + delete.EExecute(); } public static void AddAndUpdate(CarcassSaleOut_Detail detail, int flag,DateTime? productTime) @@ -257,27 +267,27 @@ namespace ButcherFactory.BO.LocalBL public static void DeleteAndUpdate(CarcassSaleOut_Detail tag) { var json = JsonConvert.SerializeObject(new List() { new ExtensionObj { LongExt1 = tag.DetailID, LongExt2 = tag.WeightRecord_ID, LongExt3 = tag.ScanRecord_ID } }); - RpcFacade.Call(RpcPath + "SaleOutStoreRpc/DeleteAndUpdate", json); - SaveDeleteInfo(tag); - Delete(tag.ID); - } - - static void SaveDeleteInfo(CarcassSaleOut_Detail tag) - { - using (var session = DmoSession.New()) - { - var delete = new CarcassSaleOut_Delete(); - var type = typeof(CarcassSaleOut_Delete); - foreach (var p in tag.GetType().GetProperties()) - { - if (p.CanWrite) - type.GetProperty(p.Name).SetValue(delete, p.GetValue(tag)); - } - delete.DeleteTime = DateTime.Now; - delete.Deleter = AppContext.Worker.Name; - session.Insert(delete); - session.Commit(); + RpcFacade.Call(RpcPath + "SaleOutStoreRpc/DeleteAndUpdate", json); + using (var session = DmoSession.New()) + { + SaveDeleteInfo(session, tag); + Delete(session, tag.ID); + session.Commit(); } + } + + static void SaveDeleteInfo(IDmoSession session, CarcassSaleOut_Detail tag) + { + var delete = new CarcassSaleOut_Delete(); + var type = typeof(CarcassSaleOut_Delete); + foreach (var p in tag.GetType().GetProperties()) + { + if (p.CanWrite) + type.GetProperty(p.Name).SetValue(delete, p.GetValue(tag)); + } + delete.DeleteTime = DateTime.Now; + delete.Deleter = AppContext.Worker.Name; + session.Insert(delete); } public static void RollBackDetails(List backList)