|
@@ -1,13 +1,18 @@
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.AspNetCore.StaticFiles;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Drawing;
|
|
|
+using System.Drawing.Imaging;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using wispro.sp.entity;
|
|
|
using wispro.sp.entity.workflowInstance;
|
|
|
using wispro.sp.share;
|
|
|
+using wispro.sp.share.Utility;
|
|
|
|
|
|
namespace wispro.sp.api.Controllers
|
|
|
{
|
|
@@ -47,15 +52,33 @@ namespace wispro.sp.api.Controllers
|
|
|
{
|
|
|
if (workflowObject.InitAction != null)
|
|
|
{
|
|
|
- Context.Actions.Add(workflowObject.InitAction);
|
|
|
+ Context.Actions.Add(workflowObject.InitAction.Action);
|
|
|
Context.SaveChanges();
|
|
|
+
|
|
|
+ foreach(var iv in workflowObject.InitAction.InputValueSettingObjects)
|
|
|
+ {
|
|
|
+ iv.InputValueSetting.actionId = workflowObject.InitAction.Action.Id;
|
|
|
+ Context.InputValueSettings.Add(iv.InputValueSetting);
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if(iv.Children != null)
|
|
|
+ {
|
|
|
+ foreach(var childIV in iv.Children)
|
|
|
+ {
|
|
|
+ childIV.actionId = workflowObject.InitAction.Action.Id;
|
|
|
+ childIV.ParentSettingId = iv.InputValueSetting.Id;
|
|
|
+ Context.InputValueSettings.Add(childIV);
|
|
|
+ }
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new ApplicationException("没有设定初始化Action!");
|
|
|
}
|
|
|
|
|
|
- workflowObject.Workflow.InitActionId = workflowObject.InitAction.Id;
|
|
|
+ workflowObject.Workflow.InitActionId = workflowObject.InitAction.Action.Id;
|
|
|
workflowObject.Workflow.CreateTime = DateTime.Now;
|
|
|
workflowObject.Workflow.CreateUserId = Context.Staffs.FirstOrDefault<Staff>(s => s.Name == User.Identity.Name).Id;
|
|
|
Context.Workflows.Add(workflowObject.Workflow);
|
|
@@ -189,61 +212,47 @@ namespace wispro.sp.api.Controllers
|
|
|
Context.Steps.Add(step);
|
|
|
Context.SaveChanges();
|
|
|
|
|
|
- if (stepObj.actions != null)
|
|
|
+ if(stepObj.NewActions != null)
|
|
|
{
|
|
|
- foreach (var ac in stepObj.actions)
|
|
|
+ foreach(var ac in stepObj.NewActions)
|
|
|
{
|
|
|
- var temAc = Context.Actions.FirstOrDefault(a => a.Id == ac.Id);
|
|
|
-
|
|
|
- if (temAc == null)
|
|
|
- {
|
|
|
- ac.StepId = step.Id;
|
|
|
- Context.Actions.Add(ac);
|
|
|
- Context.SaveChanges();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temAc.Name = ac.Name;
|
|
|
- temAc.InputForm = ac.InputForm;
|
|
|
- temAc.OnActionObjectType = ac.OnActionObjectType;
|
|
|
- temAc.StepId = ac.StepId;
|
|
|
- Context.SaveChanges();
|
|
|
- }
|
|
|
+ ac.Action.StepId = step.Id;
|
|
|
+ Context.Actions.Add(ac.Action);
|
|
|
+ Context.SaveChanges();
|
|
|
|
|
|
- if (ac.inputValuesSettings != null)
|
|
|
+ if(ac.NewInputValueSettingObjects!= null)
|
|
|
{
|
|
|
- foreach (var iv in ac.inputValuesSettings)
|
|
|
+ foreach(var iv in ac.NewInputValueSettingObjects)
|
|
|
{
|
|
|
- var temIV = Context.InputValueSettings.FirstOrDefault(p => p.Id == iv.Id);
|
|
|
- if (temIV == null)
|
|
|
- {
|
|
|
- iv.actionId = temAc.Id;
|
|
|
- Context.InputValueSettings.Add(iv);
|
|
|
- Context.SaveChanges();
|
|
|
- }
|
|
|
- else
|
|
|
+ iv.InputValueSetting.actionId = ac.Action.Id;
|
|
|
+ Context.InputValueSettings.Add(iv.InputValueSetting);
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if(iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
|
|
|
{
|
|
|
- temIV.actionId = temAc.Id;
|
|
|
- temIV.bindField = iv.bindField;
|
|
|
- temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
|
|
|
- temIV.DisplayName = iv.DisplayName;
|
|
|
- temIV.Options = iv.Options;
|
|
|
- temIV.ParentSettingId = iv.ParentSettingId;
|
|
|
- temIV.valueType = iv.valueType;
|
|
|
- Context.SaveChanges();
|
|
|
+ if(iv.Children != null)
|
|
|
+ {
|
|
|
+ foreach(var cIV in iv.Children)
|
|
|
+ {
|
|
|
+ cIV.ParentSettingId = iv.InputValueSetting.Id;
|
|
|
+ Context.InputValueSettings.Add(cIV);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var temStep = Context.Steps.FirstOrDefault(a => a.Id == step.Id);
|
|
|
if (temStep != null)
|
|
|
{
|
|
|
- if(temStep.workflowId != step.workflowId)
|
|
|
+ if (temStep.workflowId != step.workflowId)
|
|
|
{
|
|
|
throw new ApplicationException("修改步骤时,不能修改步骤所属流程!");
|
|
|
}
|
|
@@ -251,53 +260,112 @@ namespace wispro.sp.api.Controllers
|
|
|
temStep.Name = step.Name;
|
|
|
temStep.stepType = step.stepType;
|
|
|
temStep.defaultResponseSetting = step.defaultResponseSetting;
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
|
|
|
- foreach (var ac in stepObj.actions)
|
|
|
+ if (stepObj.NewActions != null)
|
|
|
{
|
|
|
- var temAc = Context.Actions.FirstOrDefault(a => a.Id == ac.Id);
|
|
|
-
|
|
|
- if (temAc == null)
|
|
|
+ foreach (var ac in stepObj.NewActions)
|
|
|
{
|
|
|
- ac.StepId = step.Id;
|
|
|
- Context.Actions.Add(ac);
|
|
|
+ ac.Action.StepId = temStep.Id;
|
|
|
+ Context.Actions.Add(ac.Action);
|
|
|
Context.SaveChanges();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- temAc.Name = ac.Name;
|
|
|
- temAc.InputForm = ac.InputForm;
|
|
|
- temAc.OnActionObjectType = ac.OnActionObjectType;
|
|
|
- temAc.StepId = ac.StepId;
|
|
|
+
|
|
|
+ if (ac.NewInputValueSettingObjects != null)
|
|
|
+ {
|
|
|
+ foreach (var iv in ac.NewInputValueSettingObjects)
|
|
|
+ {
|
|
|
+ iv.InputValueSetting.actionId = ac.Action.Id;
|
|
|
+ Context.InputValueSettings.Add(iv.InputValueSetting);
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if (iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
|
|
|
+ {
|
|
|
+ if (iv.Children != null)
|
|
|
+ {
|
|
|
+ foreach (var cIV in iv.Children)
|
|
|
+ {
|
|
|
+ cIV.ParentSettingId = iv.InputValueSetting.Id;
|
|
|
+ Context.InputValueSettings.Add(cIV);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Context.SaveChanges();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (ac.inputValuesSettings != null)
|
|
|
+ if(stepObj.ModifyActions != null)
|
|
|
+ {
|
|
|
+ foreach(var ac in stepObj.ModifyActions)
|
|
|
{
|
|
|
- foreach (var iv in ac.inputValuesSettings)
|
|
|
+
|
|
|
+ var temAction = Context.Actions.FirstOrDefault(a=>a.Id == ac.Action.Id);
|
|
|
+
|
|
|
+ if(temAction != null)
|
|
|
{
|
|
|
- var temIV = Context.InputValueSettings.FirstOrDefault(p => p.Id == iv.Id);
|
|
|
- if (temIV == null)
|
|
|
+ temAction.Name = ac.Action.Name;
|
|
|
+ temAction.InputForm = ac.Action.InputForm;
|
|
|
+ //temAction.inputValuesSettings = ac.Action.inputValuesSettings;
|
|
|
+ temAction.OnActionObjectType = ac.Action.OnActionObjectType;
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if(ac.NewInputValueSettingObjects != null)
|
|
|
{
|
|
|
- iv.actionId = temAc.Id;
|
|
|
- Context.InputValueSettings.Add(iv);
|
|
|
+ foreach (var iv in ac.NewInputValueSettingObjects)
|
|
|
+ {
|
|
|
+ iv.InputValueSetting.actionId = ac.Action.Id;
|
|
|
+ Context.InputValueSettings.Add(iv.InputValueSetting);
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if (iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
|
|
|
+ {
|
|
|
+ if (iv.Children != null)
|
|
|
+ {
|
|
|
+ foreach (var cIV in iv.Children)
|
|
|
+ {
|
|
|
+ cIV.ParentSettingId = iv.InputValueSetting.Id;
|
|
|
+ Context.InputValueSettings.Add(cIV);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Context.SaveChanges();
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ if(ac.UpdateInputValueSettingObjects != null)
|
|
|
{
|
|
|
- temIV.actionId = temAc.Id;
|
|
|
- temIV.bindField = iv.bindField;
|
|
|
- temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
|
|
|
- temIV.DisplayName = iv.DisplayName;
|
|
|
- temIV.Options = iv.Options;
|
|
|
- temIV.ParentSettingId = iv.ParentSettingId;
|
|
|
- temIV.valueType = iv.valueType;
|
|
|
+ foreach (var iv in ac.UpdateInputValueSettingObjects)
|
|
|
+ {
|
|
|
+ var temIvObj = Context.InputValueSettings.FirstOrDefault(s=>s.Id == iv.InputValueSetting.Id);
|
|
|
+
|
|
|
+ if(temIvObj != null)
|
|
|
+ {
|
|
|
+ temIvObj.actionId = iv.InputValueSetting.actionId;
|
|
|
+ temIvObj.bindField = iv.InputValueSetting.bindField;
|
|
|
+ temIvObj.bindFieldSavetoObjectCondition = iv.InputValueSetting.bindFieldSavetoObjectCondition;
|
|
|
+ temIvObj.DisplayName = iv.InputValueSetting.DisplayName;
|
|
|
+ temIvObj.Options = iv.InputValueSetting.Options;
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
Context.SaveChanges();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -355,6 +423,7 @@ namespace wispro.sp.api.Controllers
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public ApiSaveResponse DeleteTransfer(int Id)
|
|
|
{
|
|
|
ApiSaveResponse ret = new ApiSaveResponse();
|
|
@@ -379,6 +448,30 @@ namespace wispro.sp.api.Controllers
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ public ApiSaveResponse DeleteInputValueSetting(int Id)
|
|
|
+ {
|
|
|
+ ApiSaveResponse ret = new ApiSaveResponse();
|
|
|
+ ret.Success = true;
|
|
|
+
|
|
|
+ using (var t = Context.Database.BeginTransaction())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Context.InputValueSettings.Remove(new entity.workflowDefine.InputValueSetting() { Id = Id });
|
|
|
+ Context.SaveChanges();
|
|
|
+ t.Commit();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ t.Rollback();
|
|
|
+ ret.Success = false;
|
|
|
+ ret.ErrorMessage = ex.Message;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
public ApiSaveResponse DeleteStep(int Id)
|
|
|
{
|
|
|
ApiSaveResponse ret = new ApiSaveResponse();
|
|
@@ -450,10 +543,25 @@ namespace wispro.sp.api.Controllers
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ var temInputValueSettings = action.inputValuesSettings;
|
|
|
+ action.inputValuesSettings = null;
|
|
|
|
|
|
if (action.Id == 0)
|
|
|
{
|
|
|
Context.Actions.Add(action);
|
|
|
+ Context.SaveChanges();
|
|
|
+
|
|
|
+ if (temInputValueSettings != null)
|
|
|
+ {
|
|
|
+ foreach (var iv in temInputValueSettings)
|
|
|
+ {
|
|
|
+ iv.actionId = action.Id;
|
|
|
+
|
|
|
+ Context.InputValueSettings.Add(iv);
|
|
|
+ }
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -465,6 +573,34 @@ namespace wispro.sp.api.Controllers
|
|
|
temAtion.StepId = action.StepId;
|
|
|
temAtion.inputValuesSettings = action.inputValuesSettings;
|
|
|
temAtion.OnActionObjectType = action.OnActionObjectType;
|
|
|
+
|
|
|
+ if(temInputValueSettings != null)
|
|
|
+ {
|
|
|
+ foreach (var iv in temInputValueSettings)
|
|
|
+ {
|
|
|
+ var temIV = Context.InputValueSettings.FirstOrDefault(p=>p.Id == iv.Id);
|
|
|
+
|
|
|
+ if(temIV != null)
|
|
|
+ {
|
|
|
+ temIV.actionId = iv.actionId;
|
|
|
+ temIV.bindField = iv.bindField;
|
|
|
+ temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
|
|
|
+ temIV.DisplayName = iv.DisplayName;
|
|
|
+ temIV.Options = iv.Options;
|
|
|
+ temIV.ParentSettingId = iv.ParentSettingId;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ iv.actionId = action.Id;
|
|
|
+ Context.InputValueSettings.Add(iv);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Context.SaveChanges();
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -564,5 +700,51 @@ namespace wispro.sp.api.Controllers
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
|
+ [HttpGet, DisableRequestSizeLimit]
|
|
|
+ public async Task<IActionResult> ExportToImage(int workflowId)
|
|
|
+ {
|
|
|
+ var workflow = GetWorkflow(workflowId);
|
|
|
+ var Steps = GetSteps(workflowId);
|
|
|
+ var Actions = GetActions(workflowId);
|
|
|
+ var Transfers = GetTrasfers(workflowId);
|
|
|
+
|
|
|
+ FlowChartUtility flowChart = new FlowChartUtility();
|
|
|
+ flowChart.workflow = workflow;
|
|
|
+ flowChart.Steps = Steps;
|
|
|
+ flowChart.Transfers = Transfers;
|
|
|
+
|
|
|
+ string strSvg = flowChart.GetSvgString();
|
|
|
+
|
|
|
+ System.Xml.XmlDocument xmdoc = new System.Xml.XmlDocument();
|
|
|
+ xmdoc.LoadXml(strSvg);
|
|
|
+ Svg.SvgDocument svg = Svg.SvgDocument.Open(xmdoc);
|
|
|
+ Bitmap bitmap = svg.Draw();
|
|
|
+ MemoryStream mStream = new MemoryStream();
|
|
|
+ bitmap.Save(mStream, ImageFormat.Jpeg);
|
|
|
+
|
|
|
+ var filename = $"{workflow.Name}.jpg";
|
|
|
+ mStream.Position = 0;
|
|
|
+ return File(mStream, GetContentType(filename), filename);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private string GetContentType(string path)
|
|
|
+ {
|
|
|
+ var provider = new FileExtensionContentTypeProvider();
|
|
|
+ string contentType;
|
|
|
+
|
|
|
+ if (!provider.TryGetContentType(path, out contentType))
|
|
|
+ {
|
|
|
+ contentType = "application/octet-stream";
|
|
|
+ }
|
|
|
+
|
|
|
+ return contentType;
|
|
|
+ }
|
|
|
+
|
|
|
+ public entity.workflowDefine.InputValueSetting getInputValueSteeingById(int Id)
|
|
|
+ {
|
|
|
+ return Context.InputValueSettings.FirstOrDefault(s=>s.Id == Id);
|
|
|
+ }
|
|
|
}
|
|
|
}
|