/// <summary> /// 快递发货 /// </summary> /// <param name="entity"></param> public WfAppResult Delivery(ProductOrderEntity entity) { var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //流程运行 var actionParameterInternal = new ActionParameterInternal(); actionParameterInternal.MethodParameters = new object[] { "alexsenda" }; WfAppRunner.ActionMethodParameters = new Dictionary <string, ActionParameterInternal>(); WfAppRunner.ActionMethodParameters.Add("CallHello", actionParameterInternal); var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (result.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "发货", entity.ID.ToString(), entity.OrderCode, "完成发货"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(result.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return(appResult); }
/// <summary> /// 打样 /// </summary> /// <param name="entity"></param> public WfAppResult Sample(ProductOrderEntity entity) { var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //流程运行 var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (result.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "打样", entity.ID.ToString(), entity.OrderCode, "完成打样"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(result.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return(appResult); }
/// <summary> /// 打样 /// </summary> /// <param name="entity"></param> public WfAppResult Sample(ProductOrderEntity entity) { var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //流程运行 var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (result.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "打样", entity.ID.ToString(), entity.OrderCode, "完成打样"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); try { //调用工厂作业流程节点: //流程节点:OrderFactoryMessageCaught //流程ProcessGUID:0f5829c7-17df-43eb-bfe5-1f2870fb2a0e Version:1 var invokeAppRunner = new WfAppRunner(); invokeAppRunner.UserID = WfAppRunner.UserID; invokeAppRunner.UserName = WfAppRunner.UserName; invokeAppRunner.ProcessGUID = "0f5829c7-17df-43eb-bfe5-1f2870fb2a0e"; invokeAppRunner.Version = "1"; invokeAppRunner.AppName = WfAppRunner.AppName; invokeAppRunner.AppInstanceID = WfAppRunner.AppInstanceID; invokeAppRunner.AppInstanceCode = WfAppRunner.AppInstanceCode; invokeAppRunner.DynamicVariables["ActivityCode"] = "OrderFactoryMessageCaught"; var httpClient = HttpClientHelper.CreateHelper("http://localhost/sfsweb2/api/wfservice/invokejob"); var invokeResult = httpClient.Post(invokeAppRunner); } catch (System.Exception ex) { //记录异常日志 ; } } else { session.Rollback(); appResult = WfAppResult.Error(result.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return(appResult); }
/// <summary> /// 派单 /// </summary> /// <param name="entity"></param> public WfAppResult Dispatch(ProductOrderEntity entity) { //启动流程 var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); try { //判断流程有没有已经启动 var isRunning = wfas.CheckProcessInstanceRunning(WfAppRunner); if (isRunning == false) { var startedResult = wfas.StartProcess(WfAppRunner); if (startedResult.Status != WfExecutedStatus.Success) { appResult = WfAppResult.Error(startedResult.Message); return(appResult); } } } catch (System.Exception ex) { appResult = WfAppResult.Error(ex.Message); return(appResult); } //运行流程部分 //继续下一步运行 var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //运行流程 var runResult = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (runResult.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "派单", entity.ID.ToString(), entity.OrderCode, "完成派单"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt <string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(runResult.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return(appResult); }
/// <summary> /// 快递发货 /// </summary> /// <param name="entity"></param> public WfAppResult Delivery(ProductOrderEntity entity) { var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //流程运行 var actionParameterInternal = new ActionParameterInternal(); actionParameterInternal.MethodParameters = new object[] {"alexsenda"}; WfAppRunner.ActionMethodParameters = new Dictionary<string, ActionParameterInternal>(); WfAppRunner.ActionMethodParameters.Add("CallHello", actionParameterInternal); var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (result.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "发货", entity.ID.ToString(), entity.OrderCode, "完成发货"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt<string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(result.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return appResult; }
/// <summary> /// 称重 /// </summary> /// <param name="entity"></param> public WfAppResult Weight(ProductOrderEntity entity) { var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //流程运行 var result = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (result.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "称重", entity.ID.ToString(), entity.OrderCode, "完成称重"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt<string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(result.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return appResult; }
/// <summary> /// 派单 /// </summary> /// <param name="entity"></param> public WfAppResult Dispatch(ProductOrderEntity entity) { //启动流程 var appResult = WfAppResult.Default(); var wfas = new WfAppInteropService(); try { //判断流程有没有已经启动 var isRunning = wfas.CheckProcessInstanceRunning(WfAppRunner); if (isRunning == false) { var startedResult = wfas.StartProcess(WfAppRunner); if (startedResult.Status != WfExecutedStatus.Success) { appResult = WfAppResult.Error(startedResult.Message); return appResult; } } } catch (System.Exception ex) { appResult = WfAppResult.Error(ex.Message); return appResult; } //运行流程部分 //继续下一步运行 var session = SessionFactory.CreateSession(); try { session.BeginTrans(); //运行流程 var runResult = wfas.RunProcess(session, WfAppRunner, WfAppRunner.Conditions); if (runResult.Status == WfExecutedStatus.Success) { //写步骤记录表 Write(session, WfAppRunner, "派单", entity.ID.ToString(), entity.OrderCode, "完成派单"); //业务数据处理部分,此处是简单示例... short status = GetProductOrderStatusByActivityCode(WfAppRunner.ProcessGUID, WfAppRunner.Version, WfAppRunner.NextActivityPerformers.Keys.ElementAt<string>(0)); UpdateStatus(entity.ID, status, session); session.Commit(); appResult = WfAppResult.Success(); } else { session.Rollback(); appResult = WfAppResult.Error(runResult.Message); } } catch (System.Exception ex) { session.Rollback(); appResult = WfAppResult.Error(ex.Message); } finally { session.Dispose(); } return appResult; }