From 1dd40e5ec2818ed3ab4022371047dc57a133150c Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Sun, 24 Sep 2017 21:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3ClientService/B3ClientService.csproj | 2 + .../BO/BaseInfo/BodyDiscontItem.cs | 16 +++++++ .../BO/BaseInfo/BodyDiscontRelate.cs | 19 ++++++++ .../Rpcs/BillRpc/GradeAndWeightRpc.cs | 40 +++++++++++++++++ B3ClientService/Tasks/SyncInfoFromServer.cs | 45 ++++++++++++++----- 5 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 B3ClientService/BO/BaseInfo/BodyDiscontItem.cs create mode 100644 B3ClientService/BO/BaseInfo/BodyDiscontRelate.cs diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index bf706cf..7a5e458 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -66,6 +66,8 @@ + + diff --git a/B3ClientService/BO/BaseInfo/BodyDiscontItem.cs b/B3ClientService/BO/BaseInfo/BodyDiscontItem.cs new file mode 100644 index 0000000..4d24ced --- /dev/null +++ b/B3ClientService/BO/BaseInfo/BodyDiscontItem.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Forks.EnterpriseServices.DomainObjects2; + +namespace BWP.B3ClientService.BO +{ + [Serializable] + public class BodyDiscontItem : BaseInfo + { + [ReferenceTo(typeof(BodyDiscontRelate), "Discont")] + [Join("ID", "BodyDiscontItem_ID")] + public decimal? Discont { get; set; } + } +} diff --git a/B3ClientService/BO/BaseInfo/BodyDiscontRelate.cs b/B3ClientService/BO/BaseInfo/BodyDiscontRelate.cs new file mode 100644 index 0000000..623e005 --- /dev/null +++ b/B3ClientService/BO/BaseInfo/BodyDiscontRelate.cs @@ -0,0 +1,19 @@ +using Forks.EnterpriseServices.DomainObjects2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using TSingSoft.WebPluginFramework; + +namespace BWP.B3ClientService.BO +{ + [BOClass] + [Serializable] + [KeyField("BodyDiscontItem_ID", KeyGenType.assigned)] + public class BodyDiscontRelate + { + public long BodyDiscontItem_ID { get; set; } + + public decimal? Discont { get; set; } + } +} diff --git a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs index 6afb589..d6044a3 100644 --- a/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs +++ b/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs @@ -205,5 +205,45 @@ namespace BWP.B3ClientService.Rpcs.BillRpc query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("OrderDetail_ID", orderDetailID), DQCondition.EQ("Technics", technics))); return query.EExecuteScalar(); } + + [Rpc] + public static string GetBodyDiscontItemSetting() + { + var query = new DmoQuery(typeof(BodyDiscontItem)); + var list = query.EExecuteList().Cast().ToList(); + return serializer.Serialize(list); + } + + [Rpc] + public static int SaveBodyDiscontItemSetting(string json) + { + var list = serializer.Deserialize>>(json); + using (var session = Dmo.NewSession()) + { + foreach (var item in list) + { + var entity = new BodyDiscontRelate(); + entity.BodyDiscontItem_ID = item.Item1; + entity.Discont = item.Item2; + session.AddUpdateOrInsert(entity); + } + session.Commit(); + } + return 1; + } + + [Rpc] + public static int UpdateWeight(long id, decimal? weight) + { + using (var session = Dmo.NewSession()) + { + var update = new DQUpdateDom(typeof(GradeAndWeight_Detail)); + update.Where.Conditions.Add(DQCondition.EQ("ID", id)); + update.Columns.Add(new DQUpdateColumn("Weight", weight)); + session.ExecuteNonQuery(update); + session.Commit(); + } + return 1; + } } } diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index ff0b361..af94385 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -52,6 +52,7 @@ namespace BWP.B3ClientService.Tasks SyncLiveColonyHouse(); SyncSanction(); SyncLiveVarieties(); + SyncBodyDiscontItem(); } //catch { } @@ -62,8 +63,7 @@ namespace BWP.B3ClientService.Tasks var list = RpcFacade.Call>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetWpfUser"); using (var context = new TransactionContext()) { - var sql1 = @"truncate table [WPF_User];SET IDENTITY_INSERT [WPF_User] ON; -"; + var sql1 = @"truncate table [WPF_User];SET IDENTITY_INSERT [WPF_User] ON;"; context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) { @@ -86,8 +86,7 @@ namespace BWP.B3ClientService.Tasks var list = RpcFacade.Call>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetUserEmployee"); using (var context = new TransactionContext()) { - var sql1 = @"truncate table [B3Frameworks_User_Employee]; -"; + var sql1 = @"truncate table [B3Frameworks_User_Employee];"; context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) { @@ -105,8 +104,7 @@ namespace BWP.B3ClientService.Tasks var list = RpcFacade.Call>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetEmployee"); using (var context = new TransactionContext()) { - var sql1 = @"truncate table [B3Frameworks_Employee];SET IDENTITY_INSERT [B3Frameworks_Employee] ON; -"; + var sql1 = @"truncate table [B3Frameworks_Employee];SET IDENTITY_INSERT [B3Frameworks_Employee] ON;"; context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) { @@ -180,13 +178,41 @@ namespace BWP.B3ClientService.Tasks } } + void SyncBodyDiscontItem() + { + SyncBaseInfoFromString("GetBodyDiscontItem"); + } + + void SyncBaseInfoFromString(string rpcMethodName, string rpcClassName = null) + where T : BWP.B3ClientService.BO.BaseInfo, new() + { + if (rpcClassName == null) + rpcClassName = "TouchScreenRpcs"; + var result = RpcFacade.Call(string.Format("/MainSystem/B3ButcherManage/Rpcs/{0}/{1}", rpcClassName, rpcMethodName)); + var list = serializer.Deserialize>>(result); + var dmoInfo = DmoInfo.Get(typeof(T)); + using (var context = new TransactionContext()) + { + var sql1 = string.Format(@"truncate table [{0}];", dmoInfo.MappedDBObject); + context.Session.ExecuteSqlNonQuery(sql1); + foreach (var item in list) + { + var entity = new T(); + entity.ID = item.Item1; + entity.Name = item.Item2; + entity.Spell = item.Item3; + context.Session.Insert(entity); + } + context.Commit(); + } + } + void SyncPurchaseType() { var list = RpcFacade.Call>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetPurchaseType"); using (var context = new TransactionContext()) { - var sql1 = @"truncate table [B3ClientService_PurchaseType]; -"; + var sql1 = @"truncate table [B3ClientService_PurchaseType];"; context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) { @@ -229,8 +255,7 @@ namespace BWP.B3ClientService.Tasks var list = RpcFacade.Call>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/GetSanctionSetting"); using (var context = new TransactionContext()) { - var sql1 = @"truncate table [B3ClientService_Sanction]; -"; + var sql1 = @"truncate table [B3ClientService_Sanction];"; context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) {