|
|
@ -1,5 +1,6 @@ |
|
|
using ButcherFactory.BO.Utils; |
|
|
using ButcherFactory.BO.Utils; |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.JsonRpc.Client; |
|
|
using Forks.JsonRpc.Client; |
|
|
using Newtonsoft.Json; |
|
|
using Newtonsoft.Json; |
|
|
using System; |
|
|
using System; |
|
|
@ -38,17 +39,38 @@ namespace ButcherFactory.BO.Rpcs |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void SyncGoodsByTag(string tag) |
|
|
|
|
|
|
|
|
public static void SyncGoodsByTag(ApplyClient applyClient) |
|
|
{ |
|
|
{ |
|
|
//var json = RpcFacade.Call<string>(baseInfoRpcPath + "SyncGoods");
|
|
|
|
|
|
//var list = JsonConvert.DeserializeObject<List<Goods>>(json);
|
|
|
|
|
|
//using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// TruncateTable(typeof(Goods), session);
|
|
|
|
|
|
// foreach (var item in list)
|
|
|
|
|
|
// session.Insert(item);
|
|
|
|
|
|
// session.Commit();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
var json = RpcFacade.Call<string>(baseInfoRpcPath + "SyncClientGoodsSetByClient", (short)applyClient); |
|
|
|
|
|
var list = JsonConvert.DeserializeObject<List<ClientGoodsSet>>(json); |
|
|
|
|
|
using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection)) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in list) |
|
|
|
|
|
{ |
|
|
|
|
|
DeleteOld(item.ID, session); |
|
|
|
|
|
if (!item.Stopped) |
|
|
|
|
|
Insert(item, session); |
|
|
|
|
|
} |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void DeleteOld(long id, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var detail = new DQDeleteDom(typeof(ClientGoodsSet_Detail)); |
|
|
|
|
|
detail.Where.Conditions.Add(DQCondition.EQ("ClientGoodsSet_ID", id)); |
|
|
|
|
|
session.ExecuteNonQuery(detail); |
|
|
|
|
|
|
|
|
|
|
|
var main = new DQDeleteDom(typeof(ClientGoodsSet)); |
|
|
|
|
|
main.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
session.ExecuteNonQuery(main); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void Insert(ClientGoodsSet entity, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
session.Insert(entity); |
|
|
|
|
|
foreach (var detail in entity.Details) |
|
|
|
|
|
session.Insert(detail); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |