From 03edede999dffacd1f3c0ad9b60bbb49e181da75 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Thu, 14 Sep 2017 09:51:32 +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 --- B3ClientService/B3ClientService.csproj | 1 + B3ClientService/BO/BaseInfo/BaseInfo.cs | 4 +- .../BO/Bill/OrderDetail/OrderDetail.cs | 34 ++++++++++ B3ClientService/Rpcs/BaseInfoRpc.cs | 65 +++++++++++++++++++ B3ClientService/Tasks/SyncInfoFromServer.cs | 21 +++--- 5 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 B3ClientService/BO/Bill/OrderDetail/OrderDetail.cs diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj index 9b0a91b..fc33379 100644 --- a/B3ClientService/B3ClientService.csproj +++ b/B3ClientService/B3ClientService.csproj @@ -75,6 +75,7 @@ + diff --git a/B3ClientService/BO/BaseInfo/BaseInfo.cs b/B3ClientService/BO/BaseInfo/BaseInfo.cs index 82818a8..30d0284 100644 --- a/B3ClientService/BO/BaseInfo/BaseInfo.cs +++ b/B3ClientService/BO/BaseInfo/BaseInfo.cs @@ -1,4 +1,5 @@ -using System; +using Forks.EnterpriseServices.DomainObjects2; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,6 +9,7 @@ using TSingSoft.WebPluginFramework; namespace BWP.B3ClientService.BO { [Serializable, BOClass] + [KeyField("ID", KeyGenType.assigned)] public abstract class BaseInfo { public long ID { get; set; } diff --git a/B3ClientService/BO/Bill/OrderDetail/OrderDetail.cs b/B3ClientService/BO/Bill/OrderDetail/OrderDetail.cs new file mode 100644 index 0000000..c55ba3f --- /dev/null +++ b/B3ClientService/BO/Bill/OrderDetail/OrderDetail.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BWP.B3ClientService.BO +{ + [Serializable] + public class OrderDetail : SyncBill + { + public long? AccountingUnit_ID { get; set; } + + public DateTime? Date { get; set; } + + public long? B3MainID { get; set; } + + public long WeighBill_ID { get; set; } + + public int Order { get; set; } + + public int PlanNumber { get; set; } + + public int? HotFadeNumber { get; set; } + + public int? PeelingNumber { get; set; } + + public string LiveColonyHouse_Name { get; set; } + + public bool IsHurryButcher { get; set; } + + public bool SecondarySplit { get; set; } + } +} diff --git a/B3ClientService/Rpcs/BaseInfoRpc.cs b/B3ClientService/Rpcs/BaseInfoRpc.cs index 4422fd8..4e1328c 100644 --- a/B3ClientService/Rpcs/BaseInfoRpc.cs +++ b/B3ClientService/Rpcs/BaseInfoRpc.cs @@ -1,4 +1,5 @@ using BWP.B3ClientService.BO; +using Forks.EnterpriseServices.DataForm; using Forks.EnterpriseServices.DomainObjects2; using Forks.EnterpriseServices.DomainObjects2.DQuery; using Forks.EnterpriseServices.JsonRpc; @@ -138,5 +139,69 @@ namespace BWP.B3ClientService.Rpcs { return GetBaseInfoList(input, args, top); } + + [Rpc(RpcFlags.SkipAuth)] + public static int UpdateOrInsertFarmer(Farmer farmer) + { + UpdateBaseInfo(farmer); + return 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int UpdateOrInsertCar(Car car) + { + UpdateBaseInfo(car); + return 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int UpdateOrInsertSupplier(Supplier supplier) + { + UpdateBaseInfo(supplier); + return 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int DeleteFarmer(long id) + { + DeleteBaseInfo(id); + return 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int DeleteCar(long id) + { + DeleteBaseInfo(id); + return 1; + } + + [Rpc(RpcFlags.SkipAuth)] + public static int DeleteSupplier(long id) + { + DeleteBaseInfo(id); + return 1; + } + + static void UpdateBaseInfo(T entity) + where T : BWP.B3ClientService.BO.BaseInfo, new() + { + using (var session = Dmo.NewSession()) + { + session.AddUpdateOrInsert(entity); + session.Commit(); + } + } + + static void DeleteBaseInfo(long id) + where T : BWP.B3ClientService.BO.BaseInfo, new() + { + using (var session = Dmo.NewSession()) + { + var delete = new DQDeleteDom(typeof(T)); + delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); + session.ExecuteNonQuery(delete); + session.Commit(); + } + } } } diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs index fcf1cb8..6a345d9 100644 --- a/B3ClientService/Tasks/SyncInfoFromServer.cs +++ b/B3ClientService/Tasks/SyncInfoFromServer.cs @@ -153,12 +153,12 @@ namespace BWP.B3ClientService.Tasks void SyncCar() { - SyncBaseInfo("GetCar", "B3ClientService_Car"); + SyncBaseInfo("GetCar"); } void SyncLivestock() { - SyncBaseInfo("GetLivestock", "B3ClientService_Livestock"); + SyncBaseInfo("GetLivestock"); } void SyncPurchaseType() @@ -182,27 +182,27 @@ namespace BWP.B3ClientService.Tasks void SyncSupplier() { - SyncBaseInfo("GetSupplier", "B3ClientService_Supplier"); + SyncBaseInfo("GetSupplier"); } void SyncZone() { - SyncBaseInfo("GetZone", "B3ClientService_Zone"); + SyncBaseInfo("GetZone"); } void SyncFarmer() { - SyncBaseInfo("GetFarmer", "B3ClientService_Farmer"); + SyncBaseInfo("GetFarmer"); } void SyncHogGrade() { - SyncBaseInfo("GetHogGrade", "B3ClientService_HogGrade"); + SyncBaseInfo("GetHogGrade"); } void SyncLiveColonyHouse() { - SyncBaseInfo("GetLiveColonyHouse", "B3ClientService_LiveColonyHouse"); + SyncBaseInfo("GetLiveColonyHouse"); } void SyncSanction() @@ -227,18 +227,19 @@ namespace BWP.B3ClientService.Tasks void SyncLiveVarieties() { - SyncBaseInfo("GetLiveVarieties", "B3ClientService_LiveVarieties"); + SyncBaseInfo("GetLiveVarieties"); } - void SyncBaseInfo(string rpcMethodName, string tableName, string rpcClassName = null) + void SyncBaseInfo(string rpcMethodName, string rpcClassName = null) where T : BWP.B3ClientService.BO.BaseInfo, new() { if (rpcClassName == null) rpcClassName = "TouchScreenRpcs"; var list = RpcFacade.Call>(string.Format("/MainSystem/B3ButcherManage/Rpcs/{0}/{1}", rpcClassName, rpcMethodName)); + var dmoInfo = DmoInfo.Get(typeof(T)); using (var context = new TransactionContext()) { - var sql1 = string.Format(@"truncate table [{0}];", tableName); + var sql1 = string.Format(@"truncate table [{0}];", dmoInfo.MappedDBObject); context.Session.ExecuteSqlNonQuery(sql1); foreach (RpcObject o in list) {