|
|
|
@ -26,55 +26,55 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad |
|
|
|
|
|
|
|
foreach (var item in allBill) |
|
|
|
{ |
|
|
|
// var bwpClient = new BWPClient(uri, item.Creator);
|
|
|
|
//using (var context = new TransactionContext())
|
|
|
|
//{
|
|
|
|
// #region 删除
|
|
|
|
// if (item.DeleteState)
|
|
|
|
// {
|
|
|
|
// if (item.B3ID.HasValue)
|
|
|
|
// // bwpClient.Call<int>("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/Delete", item.B3ID.Value);
|
|
|
|
// context.Session.Delete(item);
|
|
|
|
// context.Commit();
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// #endregion
|
|
|
|
var bwpClient = new BWPClient(uri, item.Creator); |
|
|
|
using (var context = new TransactionContext()) |
|
|
|
{ |
|
|
|
#region 删除
|
|
|
|
if (item.DeleteState) |
|
|
|
{ |
|
|
|
if (item.B3ID.HasValue) |
|
|
|
bwpClient.Call<int>("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/Delete", item.B3ID.Value); |
|
|
|
context.Session.Delete(item); |
|
|
|
context.Commit(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
var sync = serializer.Serialize(CreateRpcWeightBill(item)); |
|
|
|
// var back = bwpClient.Call<BackRpcObj>("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/UpdateOrInsert", sync);
|
|
|
|
|
|
|
|
//#region 同步完了要清理掉删除的明细(当前实体和数据库)
|
|
|
|
//ClearDetails(item, context.Session);
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
// #region 反填信息
|
|
|
|
//item.B3ID = back.ID;
|
|
|
|
//SetBillAsSynced(item.ID, item.B3ID.Value, context.Session);
|
|
|
|
|
|
|
|
//foreach (var bItem in back.DetailBack)
|
|
|
|
//{
|
|
|
|
// switch (bItem.Flag)
|
|
|
|
// {
|
|
|
|
// case "Details":
|
|
|
|
// ExecuteSimpleDetail<WeightBill_Detail>(bItem, context.Session);
|
|
|
|
// break;
|
|
|
|
// case "FarmerDetails":
|
|
|
|
// ExecuteSimpleDetail<WeightBill_FarmerDetail>(bItem, context.Session);
|
|
|
|
// break;
|
|
|
|
// case "SanctionDetails":
|
|
|
|
// ExecuteSimpleDetail<WeightBill_SanctionDetail>(bItem, context.Session);
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
var back = bwpClient.Call<BackRpcObj>("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/UpdateOrInsert", sync); |
|
|
|
|
|
|
|
#region 同步完了要清理掉删除的明细(当前实体和数据库)
|
|
|
|
ClearDetails(item, context.Session); |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 反填信息
|
|
|
|
item.B3ID = back.ID; |
|
|
|
SetBillAsSynced(item.ID, item.B3ID.Value, context.Session); |
|
|
|
|
|
|
|
foreach (var bItem in back.DetailBack) |
|
|
|
{ |
|
|
|
switch (bItem.Flag) |
|
|
|
{ |
|
|
|
case "Details": |
|
|
|
ExecuteSimpleDetail<WeightBill_Detail>(bItem, context.Session); |
|
|
|
break; |
|
|
|
case "FarmerDetails": |
|
|
|
ExecuteSimpleDetail<WeightBill_FarmerDetail>(bItem, context.Session); |
|
|
|
break; |
|
|
|
case "SanctionDetails": |
|
|
|
ExecuteSimpleDetail<WeightBill_SanctionDetail>(bItem, context.Session); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//栋舍明细在B3系统不存在,所以无返回信息
|
|
|
|
// ExecuteHouseDetial(item.ID, context.Session);
|
|
|
|
// #endregion
|
|
|
|
ExecuteHouseDetial(item.ID, context.Session); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// context.Commit();
|
|
|
|
// }
|
|
|
|
context.Commit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|