From 652951910b9c97c5ed4833deefc0a23f959e736f Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Tue, 19 Sep 2017 23:15:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Rpcs/BillRpc/OrderDetailRpc.cs | 2 ++ .../Tasks/UpdateLoad/UploadOrderDetail.cs | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs index d590a24..11a5326 100644 --- a/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/OrderDetailRpc.cs @@ -209,6 +209,8 @@ namespace BWP.B3ClientService.Rpcs.BillRpc { var update = new DQUpdateDom(typeof(OrderDetail)); update.Columns.Add(new DQUpdateColumn(property, value)); + update.Columns.Add(new DQUpdateColumn("Sync", false)); + update.Columns.Add(new DQUpdateColumn("ModifyTime", DateTime.Now)); update.Where.Conditions.Add(DQCondition.EQ("ID", id)); session.ExecuteNonQuery(update); } diff --git a/B3ClientService/Tasks/UpdateLoad/UploadOrderDetail.cs b/B3ClientService/Tasks/UpdateLoad/UploadOrderDetail.cs index bc407d4..cad8bd6 100644 --- a/B3ClientService/Tasks/UpdateLoad/UploadOrderDetail.cs +++ b/B3ClientService/Tasks/UpdateLoad/UploadOrderDetail.cs @@ -21,6 +21,10 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad public static void Execute(string uri) { var serializer = new JavaScriptSerializer(); + + #region 删除 + DeleteUnSyncDeleteData(); + #endregion //获取所有未上传的数据 var allBill = GetAllNeedSyncBill(); foreach (var group in allBill.GroupBy(x => new { x.Date, x.AccountingUnit_ID }).OrderBy(x => x.Key.Date)) @@ -30,9 +34,6 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad var bwpClient = new BWPClient(uri, creator); using (var context = new TransactionContext()) { - #region 删除 - DeleteUnSyncDeleteData(context.Session); - #endregion var entity = new RpcOrderBill(); entity.AccountingUnit_ID = group.Key.AccountingUnit_ID; entity.Date = group.Key.Date; @@ -73,11 +74,16 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad } } } - static void DeleteUnSyncDeleteData(IDmoSession session) + + static void DeleteUnSyncDeleteData() { - var delete = new DQDeleteDom(typeof(OrderDetail)); - delete.Where.Conditions.Add(DQCondition.And(DQCondition.IsNull(DQExpression.Field("B3ID")), DQCondition.EQ("DeleteState", true))); - session.ExecuteNonQuery(delete); + using (var session = Dmo.NewSession()) + { + var delete = new DQDeleteDom(typeof(OrderDetail)); + delete.Where.Conditions.Add(DQCondition.And(DQCondition.IsNull(DQExpression.Field("B3ID")), DQCondition.EQ("DeleteState", true))); + session.ExecuteNonQuery(delete); + session.Commit(); + } } private static IEnumerable GetAllNeedSyncBill()