Commit da5c105e by 陶然

优化插件功能

parent e0b8f06c
...@@ -15,6 +15,8 @@ namespace Kivii.Seeyon ...@@ -15,6 +15,8 @@ namespace Kivii.Seeyon
/// <returns></returns> /// <returns></returns>
object OnSubmitApplyForm<T>(Guid Kvid); object OnSubmitApplyForm<T>(Guid Kvid);
object OnSubmitApplyForm<T>(T form);
/// <summary> /// <summary>
/// OA申请结果调用 /// OA申请结果调用
/// </summary> /// </summary>
......
using Kivii.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Collections.Generic.Dictionary<string, object>;
namespace Kivii.Seeyon
{
internal static class Extension
{
public static T ConvertTo<T>(this Dictionary<string, object> dic)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
using (Enumerator enumerator = dic.GetEnumerator())
{
while (enumerator.MoveNext())
{
KeyValuePair<string, object> current = enumerator.Current;
dictionary[current.Key] = current.Value;
}
}
return (T)dictionary.FromObjectDictionary(typeof(T));
}
}
}
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<Compile Include="Entities\SeeyonInterface.cs" /> <Compile Include="Entities\SeeyonInterface.cs" />
<Compile Include="Entities\Request.Response.cs" /> <Compile Include="Entities\Request.Response.cs" />
<Compile Include="Entities\SeeyonApply.cs" /> <Compile Include="Entities\SeeyonApply.cs" />
<Compile Include="Extension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Transforms\RestfulApply.cs" /> <Compile Include="Transforms\RestfulApply.cs" />
</ItemGroup> </ItemGroup>
......
...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; ...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2023.9200")] [assembly: AssemblyVersion("5.4.2023.9260")]
[assembly: AssemblyFileVersion("5.4.2023.9200")] [assembly: AssemblyFileVersion("5.4.2023.9260")]
using Kivii.Seeyon.Entities; using Kivii.Seeyon.Entities;
using Kivii.Text;
using Kivii.Web; using Kivii.Web;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -8,24 +9,41 @@ using System.Threading.Tasks; ...@@ -8,24 +9,41 @@ using System.Threading.Tasks;
namespace Kivii.Seeyon.Transforms namespace Kivii.Seeyon.Transforms
{ {
//[RequiresAnyRole(SystemRoles.Everyone)] [RequiresAnyRole(SystemRoles.Everyone)]
//[Api(Description = "提交OA申请表单")] [Api(Description = "提交OA申请表单")]
//public class ApplyRequest2 : RestfulExecution<Apply> public class ApplyRequest2 : RestfulExecutionGeneric<Apply>
//{ {
// public string EntityType { get; set; } public string FormType { get; set; }
// public object Form { get; set; } public JsonObject Form { get; set; }
// public override object OnExecution(IRequest req, IResponse res)
// {
// EntityType.ThrowIfNull("请传入业务实体EntityType");
// var type = Kivii.Text.AssemblyUtils.FindType(EntityType);
// var instance = Activator.CreateInstance(type) as IEntityIsSeeyonApply; public override object OnExecutionGeneric<G>(IRequest req, IResponse res)
// if (instance == null) return null; {
// var results = instance.OnSubmitApplyForm(Form); FormType.ThrowIfNull("请传入业务实体FormType");
// return results; var type = Kivii.Text.AssemblyUtils.FindType(FormType);
// } Dictionary<string,object> form = new Dictionary<string, object>();
//} foreach (var item in Form)
{
if (item.Key == "Metadata")
{
var metadata = JsonObject.Parse(item.Value);
JsonObject metadata2 = new JsonObject();
foreach (var meta in metadata)
{
var val = metadata[meta.Key];
metadata2[meta.Key] = val;
}
form[item.Key] = metadata2;
continue;
}
form[item.Key] = Form[item.Key];
}
var formFormat = form.ConvertTo<G>();
var instance = Activator.CreateInstance(type) as IEntityIsSeeyonApply;
if (instance == null) return null;
var results = instance.OnSubmitApplyForm<G>(formFormat);
return results;
}
}
[RequiresAnyRole(SystemRoles.Everyone)] [RequiresAnyRole(SystemRoles.Everyone)]
[Api(Description = "提交OA申请表单")] [Api(Description = "提交OA申请表单")]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment