public FlowScheme Get(string id) { var result = new TableData(); FlowScheme data = __unitWork.FindSingle <FlowScheme>(u => u.Id == int.Parse(id)); result.data = data; return(result.data); }
public void SaveFlowSchemeData(string flowContent) { FlowScheme flowScheme = new FlowScheme(); flowScheme.SchemeContent = flowContent; flowScheme.CreatedOn = DateTime.Now; _flowSchemeRepository.Insert(flowScheme); }
public static FlowDirection Reverse(this FlowDirection value, FlowScheme scheme) { return(value switch { FlowDirection.LeftToRight => scheme == FlowScheme.LR_LR ? FlowDirection.LeftToRight : FlowDirection.RightToLeft, FlowDirection.RightToLeft => FlowDirection.LeftToRight, _ => throw new ArgumentOutOfRangeException() });
public TableData Query(FlowScheme entity) { var result = new TableData(); var data = _app.Find(EntityToExpression <FlowScheme> .GetExpressions(entity)); GetData(data, result); result.count = data.Count(); return(result); }
public void SaveFlowScheme(FlowSchemeInsertInput input) { FlowScheme flowScheme = new FlowScheme(); flowScheme.SchemeContent = input.SchemeContent; flowScheme.CreatedOn = DateTime.Now; _flowSchemeRepository.Insert(flowScheme); //send mail job BackgroundJob.Enqueue(() => Console.WriteLine("send mail to inform the related user!")); }
public static Flow Create() { var scheme = new FlowScheme("Flow2. Uses fork-join node", "MicroFlow.Meta.Test.Flow2"); scheme.DefaultFaultHandlerType = typeof(MyFaultHandler); scheme.DefaultCancellationHandlerType = typeof(MyCancellationHandler); scheme .AddProperty <IWriter>("Writer") .AddProperty <int>("A") .AddProperty <int>("B") .AddProperty <int>("C"); var first = new ActivityInfo(typeof(DelayedIncrementActivity)) .WithDescription("First work") .AddPropertyBinding(new PropertyBindingInfo("X", "A")); var second = new ActivityInfo(typeof(DelayedIncrementActivity)) .WithDescription("Second work") .AddPropertyBinding(new PropertyBindingInfo("X", "B")); var third = new ActivityInfo(typeof(DelayedIncrementActivity)) .WithDescription("First work") .AddPropertyBinding(new PropertyBindingInfo("X", "C")); var forkJoin = new ForkJoinInfo() .WithDescription("My fork join node") .AddForks(first, second, third); var sum = new ActivityInfo(typeof(SumActivity)) .WithDescription("Sum action") .AddPropertyBinding(new PropertyBindingInfo("A", PropertyBindingKind.ActivityResult) { Activity = first }) .AddPropertyBinding(new PropertyBindingInfo("B", PropertyBindingKind.ActivityResult) { Activity = second }) .AddPropertyBinding(new PropertyBindingInfo("C", PropertyBindingKind.ActivityResult) { Activity = third }); scheme.AddNodes(forkJoin, sum); scheme.IntialNode = forkJoin; forkJoin.ConnectTo(sum); scheme.AddService(ServiceInfo.Singleton <IWriter>("Writer")); return(scheme.EmitFlow()); }
public string Ins(FlowScheme Table_entity) { try { _app.Ins(Table_entity); } catch (Exception ex) { Result.Status = false; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public string Update(FlowScheme obj) { try { _app.Update(obj); } catch (Exception ex) { Result.Code = 500; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public Response Update(FlowScheme obj) { var result = new Response(); try { _app.Update(obj); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return(result); }
public void Ins(FlowScheme entity) { if (entity.ProductId == null) { entity.ProductId = 0; } if (entity.DeleteMark == null) { entity.DeleteMark = 0; } if (entity.Disabled == null) { entity.Disabled = 0; } _app.Add(entity); }
public void Upd(FlowScheme entity) { if (entity.ProductId == null) { entity.ProductId = 0; } if (entity.DeleteMark == null) { entity.DeleteMark = 0; } if (entity.Disabled == null) { entity.Disabled = 0; } _app.Update(entity); }
public string GetTemplate() { var result = new TableData(); List <FlowScheme> listFlowScheme = new List <FlowScheme>(); FlowScheme entity = _app.FindSingle(u => u.Id > 0); if (entity != null) { listFlowScheme.Add(entity); } else { listFlowScheme.Add(new FlowScheme()); } result.data = listFlowScheme; result.count = listFlowScheme.Count; return(JsonHelper.Instance.Serialize(result)); }
public Response ImportIn(IFormFile excelfile) { Response result = new Infrastructure.Response(); List <FlowScheme> exp = imp.ConvertToModel <FlowScheme>(excelfile); string sErrorMsg = ""; for (int i = 0; i < exp.Count; i++) { try { FlowScheme e = exp[i]; e.Id = null; _app.Add(e); } catch (Exception ex) { sErrorMsg += "第" + (i + 2) + "行:" + ex.Message + "<br>"; result.Message = sErrorMsg; break; } } if (sErrorMsg.Equals(string.Empty)) { if (exp.Count == 0) { sErrorMsg += "没有发现有效数据, 请确定模板是否正确, 或是否有填充数据!"; result.Message = sErrorMsg; } else { result.Message = "导入完成"; } } else { result.Status = false; result.Message = result.Message; } return(result); }
public static Flow Create() { var scheme = new FlowScheme("Flow3. Uses block and variable", "MicroFlow.Meta.Test.Flow3"); scheme.DefaultFaultHandlerType = typeof(MyFaultHandler); scheme.DefaultCancellationHandlerType = typeof(MyCancellationHandler); scheme .AddProperty <IReader>("Reader") .AddProperty <IWriter>("Writer"); var var = new VariableInfo(typeof(int), "var"); var activity = new ActivityInfo(typeof(ReadIntActivity)) .WithDescription("Input number") .AddVariableBinding(new VariableBindingInfo(var, VariableBindingKind.ActivityResult)); var block = new BlockInfo() .WithDescription("MyBlock") .AddNode(activity); var outputActivity = new ActivityInfo(typeof(WriteMessageActivity)) .WithDescription("Output activity") .AddPropertyBinding(new PropertyBindingInfo("Message", "() => $\"Echo: {var.CurrentValue}\"")); scheme.AddNodes(block, outputActivity); scheme.AddVariable(var); scheme.IntialNode = block; block.ConnectTo(outputActivity); scheme .AddService(ServiceInfo.Singleton <IReader>("Reader")) .AddService(ServiceInfo.Singleton <IWriter>("Writer")); return(scheme.EmitFlow()); }
/// <summary> /// 创建一个实例 /// </summary> /// <returns></returns> public bool CreateInstance(AddFlowInstanceReq addFlowInstanceReq) { FlowScheme scheme = null; if (!string.IsNullOrEmpty(addFlowInstanceReq.SchemeId)) { scheme = _flowSchemeApp.Get(addFlowInstanceReq.SchemeId); } if ((scheme == null) && !string.IsNullOrEmpty(addFlowInstanceReq.SchemeCode)) { scheme = _flowSchemeApp.FindByCode(addFlowInstanceReq.SchemeCode); } if (scheme == null) { throw new Exception("该流程模板已不存在,请重新设计流程"); } addFlowInstanceReq.SchemeContent = scheme.SchemeContent; var form = _formApp.FindSingle(scheme.FrmId); if (form == null) { throw new Exception("该流程模板对应的表单已不存在,请重新设计流程"); } addFlowInstanceReq.FrmContentData = form.ContentData; addFlowInstanceReq.FrmContentParse = form.ContentParse; addFlowInstanceReq.FrmType = form.FrmType; addFlowInstanceReq.FrmId = form.Id; var flowInstance = addFlowInstanceReq.MapTo <FlowInstance>(); //创建运行实例 var wfruntime = new FlowRuntime(flowInstance); var user = _auth.GetCurrentUser(); #region 根据运行实例改变当前节点状态 flowInstance.ActivityId = wfruntime.nextNodeId; flowInstance.ActivityType = wfruntime.GetNextNodeType(); flowInstance.ActivityName = wfruntime.nextNode.name; flowInstance.PreviousId = wfruntime.currentNodeId; flowInstance.CreateUserId = user.User.Id; flowInstance.CreateUserName = user.User.Account; flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : ""); flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4 ? 1 : 0); UnitWork.Add(flowInstance); wfruntime.flowInstanceId = flowInstance.Id; if (flowInstance.FrmType == 1) { var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App"); ICustomerForm icf = (ICustomerForm)_serviceProvider.GetService(t); icf.Add(flowInstance.Id, flowInstance.FrmData); } #endregion 根据运行实例改变当前节点状态 #region 流程操作记录 FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory { InstanceId = flowInstance.Id, CreateUserId = user.User.Id, CreateUserName = user.User.Name, CreateDate = DateTime.Now, Content = "【创建】" + user.User.Name + "创建了一个流程进程【" + addFlowInstanceReq.Code + "/" + addFlowInstanceReq.CustomName + "】" }; UnitWork.Add(processOperationHistoryEntity); #endregion 流程操作记录 AddTransHistory(wfruntime); UnitWork.Save(); return(true); }
public TableData Load(PageReq pageRequest, FlowScheme entity) { return(_app.Load(pageRequest, entity)); }
public string Export(FlowScheme entity) { return(JsonHelper.Instance.Serialize(_app.ExportData(entity))); }
public TableData ExportData(FlowScheme entity) { return(_app.ExportData(entity)); }
public static Flow Create() { var scheme = new FlowScheme("Flow1. Uses condition node", "MicroFlow.Meta.Test.Flow1"); scheme.DefaultFaultHandlerType = typeof(MyFaultHandler); scheme.DefaultCancellationHandlerType = typeof(MyCancellationHandler); var inputFirst = new ActivityInfo(typeof(ReadIntActivity)) { Description = "Read first number", Result = new VariableInfo(typeof(int), "first") }; var inputSecond = new ActivityInfo(typeof(ReadIntActivity)) { Description = "Read second number", Result = new VariableInfo(typeof(int), "second") }; var condition = new ConditionInfo("() => first.Get() > second.Get()") { Description = "If first number > second number" }; var outputWhenTrue = new ActivityInfo(typeof(WriteMessageActivity)) { Description = "Output: first > second" }; outputWhenTrue.AddPropertyBinding(new PropertyBindingInfo("Message", PropertyBindingKind.Expression) { BindingExpression = "() => $\"{first.Get()} > {second.Get()}\"" }); var outputWhenFalse = new ActivityInfo(typeof(WriteMessageActivity)) { Description = "Output: first <= second" }; outputWhenFalse.AddPropertyBinding(new PropertyBindingInfo("Message", PropertyBindingKind.Expression) { BindingExpression = "() => $\"{first.Get()} <= {second.Get()}\"" }); scheme.IntialNode = inputFirst; inputFirst.PointsTo = inputSecond; inputSecond.PointsTo = condition; condition.WhenTrue = outputWhenTrue; condition.WhenFalse = outputWhenFalse; scheme.AddNodes(inputFirst, inputSecond, condition, outputWhenTrue, outputWhenFalse); scheme.AddProperty(new FlowPropertyInfo(typeof(IReader), "Reader")); scheme.AddProperty(new FlowPropertyInfo(typeof(IWriter), "Writer")); scheme.AddService( new ServiceInfo(typeof(IReader), lifetimeKind: LifetimeKind.Singleton, instanceExpression: "Reader")); scheme.AddService( new ServiceInfo(typeof(IWriter), lifetimeKind: LifetimeKind.Singleton, instanceExpression: "Writer")); return(scheme.EmitFlow()); }
public string Load(PageReq pageRequest, FlowScheme entity) { return(JsonHelper.Instance.Serialize(_app.Load(pageRequest, entity))); }