diff --git a/B3QingDaoWanFu/B3QingDaoWanFu.csproj b/B3QingDaoWanFu/B3QingDaoWanFu.csproj
index 6582a48..9b3d950 100644
--- a/B3QingDaoWanFu/B3QingDaoWanFu.csproj
+++ b/B3QingDaoWanFu/B3QingDaoWanFu.csproj
@@ -159,6 +159,7 @@
+
diff --git a/B3QingDaoWanFu/BL/ExportBL/GoodsExportBL.cs b/B3QingDaoWanFu/BL/ExportBL/GoodsExportBL.cs
index bfc6c82..792a79f 100644
--- a/B3QingDaoWanFu/BL/ExportBL/GoodsExportBL.cs
+++ b/B3QingDaoWanFu/BL/ExportBL/GoodsExportBL.cs
@@ -11,6 +11,10 @@ using System.Linq;
using System.Text;
using TSingSoft.WebPluginFramework.BIPlugins.BLEvents;
using TSingSoft.WebPluginFramework;
+using BWP.B3Frameworks.Utils;
+using BWP.B3ExportBase.BO;
+using Forks.JsonRpc.Client;
+using Newtonsoft.Json;
namespace BWP.B3QingDaoWanFu.BL
{
@@ -23,6 +27,8 @@ namespace BWP.B3QingDaoWanFu.BL
void Stop(string code);
+ void Start(string code);
+
void Delete(string code);
}
@@ -30,6 +36,7 @@ namespace BWP.B3QingDaoWanFu.BL
[ExportID(B3FrameworksConsts.DmoTypeIDBases.B3QingDaoWanFu, B3QingDaoWanFuConsts.DmoTypeIDOffsets.GoodsExport)]
public class GoodsExportBL : ExportBaseBL, IGoodsExportBL
{
+ const string MethodPath = "/MainSystem/B3ClientService/Rpcs/InterfaceRpc/GoodsRpc/";
protected override void BeforeExport(List dmoIDs)
{
Dmos = new List();
@@ -58,22 +65,71 @@ namespace BWP.B3QingDaoWanFu.BL
return;
}
LoadMinDmo(Dmos, dmoIDs);
+ }
+
+ private string _serverUrl;
- scriptHelper.After();
+ protected string ServerUrl
+ {
+ get { return _serverUrl; }
+ set { _serverUrl = value; }
}
public void Export(List dmoIDs, long extSystemID)
{
+ if (dmoIDs.Count == 0)
+ throw new Exception("没有要导出的内容");
+ ExtSystemID = extSystemID;
+ _serverUrl = InnerBLUtil.GetDmoPropertyByID(Session, typeof(ExtSystem), "Address", extSystemID);
+ if (string.IsNullOrEmpty(_serverUrl))
+ throw new Exception("外部系统地址不能为空");
BeforeExport(dmoIDs);
+ DoExport(dmoIDs);
+ }
+
+ private void DoExport(List dmoIDs)
+ {
+ var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this);
+ var dmos = Dmos.OrderBy(x => x.ID).ToList();
+ scriptHelper.AddLocalVar("dmos", dmos);
+ scriptHelper.Execute();
+ InitRpc();
+ var json = JsonConvert.SerializeObject(dmos);
+ RpcFacade.Call(MethodPath + "BatchImport", json);
+ BIFactory.MsgBuilder.Append("导出成功!");
}
public void UpdateOrInsert(Goods goods)
- { }
+ {
+ RpcFacade.Call(MethodPath + "UpdateOrInsert", JsonConvert.SerializeObject(goods));
+ }
public void Stop(string code)
- { }
+ {
+ RpcFacade.Call(MethodPath + "Stop", code);
+ }
+
+ public void Start(string code)
+ {
+ RpcFacade.Call(MethodPath + "Start", code);
+ }
public void Delete(string code)
- { }
+ {
+ RpcFacade.Call(MethodPath + "Delete", code);
+ }
+
+ void InitRpc()
+ {
+ try
+ {
+ RpcFacade.Init(_serverUrl, "B3QingFu");
+ }
+ catch (Exception ex)
+ {
+ if (ex.Message != "Can only start once")
+ throw;
+ }
+ }
}
}
diff --git a/B3QingDaoWanFu/TypeIOCs/GoodsBLTypeIOC.cs b/B3QingDaoWanFu/TypeIOCs/GoodsBLTypeIOC.cs
new file mode 100644
index 0000000..9a370b8
--- /dev/null
+++ b/B3QingDaoWanFu/TypeIOCs/GoodsBLTypeIOC.cs
@@ -0,0 +1,65 @@
+using BWP.B3Frameworks;
+using BWP.B3ProcurementInterface.Utils;
+using BWP.B3QingDaoWanFu.BL;
+using BWP.B3UnitedInfos.BL;
+using BWP.B3UnitedInfos.BO;
+using Forks.EnterpriseServices.BusinessInterfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BWP.B3QingDaoWanFu.TypeIOCs
+{
+ [TypeIOC(typeof(GoodsBL), typeof(GoodsBL.BaseBLIOCs.AfterSave))]
+ public class GoodsAfterSave : GoodsBL.BaseBLIOCs.AfterSave
+ {
+ public void Invoke(IDmoContext context, Goods dmo)
+ {
+ if (ClientServerFacedRpcFacadeUtil.InitRpcFacade())
+ {
+ var bl = BIFactory.Create(context);
+ bl.UpdateOrInsert(dmo);
+ }
+ }
+ }
+
+ [TypeIOC(typeof(GoodsBL), typeof(GoodsBL.BaseInfoBLIOCs.AfterStart))]
+ public class GoodsAfterStart : GoodsBL.BaseInfoBLIOCs.AfterStart
+ {
+ public void Invoke(IDmoContext context, Goods dmo)
+ {
+ if (ClientServerFacedRpcFacadeUtil.InitRpcFacade())
+ {
+ var bl = BIFactory.Create(context);
+ bl.Start(dmo.Code);
+ }
+ }
+ }
+
+ [TypeIOC(typeof(GoodsBL), typeof(GoodsBL.BaseInfoBLIOCs.AfterStop))]
+ public class GoodsAfterStop : GoodsBL.BaseInfoBLIOCs.AfterStop
+ {
+ public void Invoke(IDmoContext context, Goods dmo)
+ {
+ if (ClientServerFacedRpcFacadeUtil.InitRpcFacade())
+ {
+ var bl = BIFactory.Create(context);
+ bl.Stop(dmo.Code);
+ }
+ }
+ }
+
+ [TypeIOC(typeof(GoodsBL), typeof(GoodsBL.BaseBLIOCs.AfterDelete))]
+ public class GoodsAfterDelete : GoodsBL.BaseBLIOCs.AfterDelete
+ {
+ public void Invoke(IDmoContext context, Goods dmo)
+ {
+ if (ClientServerFacedRpcFacadeUtil.InitRpcFacade())
+ {
+ var bl = BIFactory.Create(context);
+ bl.Delete(dmo.Code);
+ }
+ }
+ }
+}