improve task processing and allow multiple instances in monikerlist
This commit is contained in:
parent
63e72ab97f
commit
a0fa60a9e8
@ -30,9 +30,7 @@ public class ElementCommand : InstanceCommand
|
|||||||
|
|
||||||
protected override void ProcessInternal(WebServerProcessRequestEventArgs e, Core.Oms oms, Core.OmsContext ctx, StreamWriter sw)
|
protected override void ProcessInternal(WebServerProcessRequestEventArgs e, Core.Oms oms, Core.OmsContext ctx, StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (e.Context.Request.Method == "POST")
|
if (e.Context.Request.Method == "POST" && oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Element)))
|
||||||
{
|
|
||||||
if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Element)))
|
|
||||||
{
|
{
|
||||||
ctx.SetWorkData(oms.GetInstance(KnownInstanceGuids.Classes.Instance), ProcessingInstance);
|
ctx.SetWorkData(oms.GetInstance(KnownInstanceGuids.Classes.Instance), ProcessingInstance);
|
||||||
|
|
||||||
@ -64,7 +62,6 @@ public class ElementCommand : InstanceCommand
|
|||||||
obj.Add("message", "not implemented");
|
obj.Add("message", "not implemented");
|
||||||
RespondWithJson(oms, sw, e.Context, 500, "Internal Server Error", obj);
|
RespondWithJson(oms, sw, e.Context, 500, "Internal Server Error", obj);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Renderer renderer = new Renderer(oms);
|
Renderer renderer = new Renderer(oms);
|
||||||
@ -100,6 +97,27 @@ public class ElementCommand : InstanceCommand
|
|||||||
}
|
}
|
||||||
else if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Task)))
|
else if (oms.IsInstanceOf(ProcessingInstance, oms.GetInstance(KnownInstanceGuids.Classes.Task)))
|
||||||
{
|
{
|
||||||
|
foreach (KeyValuePair<string, string> kvp in e.Context.Request.Form)
|
||||||
|
{
|
||||||
|
if (kvp.Key == "relatedInstance")
|
||||||
|
{
|
||||||
|
object? v = oms.ParseValue(kvp.Value);
|
||||||
|
|
||||||
|
InstanceHandle relatedWorkSet = oms.GetRelatedInstance(ProcessingInstance, oms.GetInstance(KnownRelationshipGuids.Task__has_related__Work_Set));
|
||||||
|
if (relatedWorkSet != InstanceHandle.Empty)
|
||||||
|
{
|
||||||
|
ctx.SetWorkData(relatedWorkSet, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (oms.TryParseInstanceRef(kvp.Key, out InstanceHandle h))
|
||||||
|
{
|
||||||
|
ctx.SetWorkData(h, oms.ParseValue(kvp.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RespndWithTask(oms, sw, e.Context, ctx, ProcessingInstance);
|
RespndWithTask(oms, sw, e.Context, ctx, ProcessingInstance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -49,6 +49,7 @@ namespace Mocha.Core
|
|||||||
}
|
}
|
||||||
public static class Boolean
|
public static class Boolean
|
||||||
{
|
{
|
||||||
|
public static Guid EvaluateWorkSet { get; } = new Guid("{62c28f9e-5ce8-4ce5-8a56-1e80f1af7f6a}");
|
||||||
public static Guid MethodIsOfTypeSpecified { get; } = new Guid("{6e9df667-0f95-4320-a4be-5cdb00f1d4ee}");
|
public static Guid MethodIsOfTypeSpecified { get; } = new Guid("{6e9df667-0f95-4320-a4be-5cdb00f1d4ee}");
|
||||||
public static Guid DisplayVersionInBadge { get; } = new Guid("{BE5966A4-C4CA-49A6-B504-B6E8759F392D}");
|
public static Guid DisplayVersionInBadge { get; } = new Guid("{BE5966A4-C4CA-49A6-B504-B6E8759F392D}");
|
||||||
public static Guid Editable { get; } = new Guid("{957fd8b3-fdc4-4f35-87d6-db1c0682f53c}");
|
public static Guid Editable { get; } = new Guid("{957fd8b3-fdc4-4f35-87d6-db1c0682f53c}");
|
||||||
|
|||||||
@ -292,6 +292,7 @@ namespace Mocha.Core
|
|||||||
public static Guid GetInstanceText { get; } = new Guid("{b024abd6-1f2b-495a-9da3-c9ce29fb0c2f}");
|
public static Guid GetInstanceText { get; } = new Guid("{b024abd6-1f2b-495a-9da3-c9ce29fb0c2f}");
|
||||||
public static Guid GetRandomNumber { get; } = new Guid("{8f7945da-4cad-49cb-9838-85f3524a5adb}");
|
public static Guid GetRandomNumber { get; } = new Guid("{8f7945da-4cad-49cb-9838-85f3524a5adb}");
|
||||||
public static Guid GetIPAddress { get; } = new Guid("{45411e57-ef6e-44f5-8801-603e567d73d4}");
|
public static Guid GetIPAddress { get; } = new Guid("{45411e57-ef6e-44f5-8801-603e567d73d4}");
|
||||||
|
public static Guid GetGlobalIdentifier { get; } = new Guid("{1a7ebec3-dc02-4c9b-a5df-0c72646453c9}");
|
||||||
}
|
}
|
||||||
public static class SystemInstanceSetRoutines
|
public static class SystemInstanceSetRoutines
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,6 +101,7 @@ namespace Mocha.Core
|
|||||||
public static Guid Task__has__Task_Category { get; } = new Guid("{84048159-430d-4f6c-9361-115c8629c517}");
|
public static Guid Task__has__Task_Category { get; } = new Guid("{84048159-430d-4f6c-9361-115c8629c517}");
|
||||||
public static Guid Task__executes__Method_Call { get; } = new Guid("{D8C0D4D4-F8C6-4B92-A2C1-8BF16B16203D}");
|
public static Guid Task__executes__Method_Call { get; } = new Guid("{D8C0D4D4-F8C6-4B92-A2C1-8BF16B16203D}");
|
||||||
public static Guid Task__has_preview_action_title__Translation { get; } = new Guid("{3f65ce02-11dd-4829-a46b-b9ea1b43e56a}");
|
public static Guid Task__has_preview_action_title__Translation { get; } = new Guid("{3f65ce02-11dd-4829-a46b-b9ea1b43e56a}");
|
||||||
|
public static Guid Task__has_related__Work_Set { get; } = new Guid("{2eb391b4-7da2-4eca-8460-dcda7757c47a}");
|
||||||
|
|
||||||
public static Guid Prompt__has__Report_Field { get; } = new Guid("{922CCB05-61EA-441D-96E0-63D58231D202}"); // 3de784b9-4561-42f0-946f-b1e90d80029e
|
public static Guid Prompt__has__Report_Field { get; } = new Guid("{922CCB05-61EA-441D-96E0-63D58231D202}"); // 3de784b9-4561-42f0-946f-b1e90d80029e
|
||||||
public static Guid Report_Field__for__Prompt { get; } = new Guid("{5DED3DB4-6864-45A9-A5FF-8E5A35AD6E6F}"); // b5f59216-a1f1-4979-8642-a4845e59daa8
|
public static Guid Report_Field__for__Prompt { get; } = new Guid("{5DED3DB4-6864-45A9-A5FF-8E5A35AD6E6F}"); // b5f59216-a1f1-4979-8642-a4845e59daa8
|
||||||
|
|||||||
@ -62,6 +62,27 @@ public abstract class Oms
|
|||||||
|
|
||||||
UpdateSyntacticSugar();
|
UpdateSyntacticSugar();
|
||||||
|
|
||||||
|
RegisterSystemAttributeRoutine<string?>(KnownInstanceGuids.SystemAttributeRoutines.GetGlobalIdentifier, delegate (Oms oms, OmsContext context)
|
||||||
|
{
|
||||||
|
object? wd = context.GetWorkData(oms.GetInstance(KnownInstanceGuids.Classes.Instance));
|
||||||
|
if (wd is InstanceHandle wdi)
|
||||||
|
{
|
||||||
|
if (oms.IsInstanceOf(wdi, oms.GetInstance(KnownInstanceGuids.Classes.WorkSet)))
|
||||||
|
{
|
||||||
|
bool evaluateWorkSet = oms.GetAttributeValue<bool>(wdi, oms.GetInstance(KnownAttributeGuids.Boolean.EvaluateWorkSet));
|
||||||
|
if (evaluateWorkSet)
|
||||||
|
{
|
||||||
|
wd = context.GetWorkData<InstanceHandle>(wdi);
|
||||||
|
if (wd is InstanceHandle wdi2)
|
||||||
|
{
|
||||||
|
wdi = wdi2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return oms.GetGlobalIdentifier(wdi).ToString("b");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
RegisterSystemInstanceSetRoutine(KnownInstanceGuids.SystemInstanceSetRoutines.GetCurrentUser, delegate (Oms oms, OmsContext context)
|
RegisterSystemInstanceSetRoutine(KnownInstanceGuids.SystemInstanceSetRoutines.GetCurrentUser, delegate (Oms oms, OmsContext context)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("oms: executing system instance set routine {0}", KnownInstanceGuids.SystemUpdateRoutines.LoginUser);
|
Console.Error.WriteLine("oms: executing system instance set routine {0}", KnownInstanceGuids.SystemUpdateRoutines.LoginUser);
|
||||||
@ -1167,7 +1188,7 @@ public abstract class Oms
|
|||||||
bool is_static = GetAttributeValue<bool>(methodOrMethodBinding, GetInstance(KnownAttributeGuids.Boolean.Static));
|
bool is_static = GetAttributeValue<bool>(methodOrMethodBinding, GetInstance(KnownAttributeGuids.Boolean.Static));
|
||||||
if (!is_static && targetInstance == null)
|
if (!is_static && targetInstance == null)
|
||||||
{
|
{
|
||||||
throw new NullReferenceException(String.Format("Attempt to call instance method `{0}` without an instance", methodOrMethodBinding));
|
//sthrow new NullReferenceException(String.Format("Attempt to call instance method `{0}` without an instance", methodOrMethodBinding));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetInstance == null)
|
if (targetInstance == null)
|
||||||
@ -2231,4 +2252,94 @@ public abstract class Oms
|
|||||||
{
|
{
|
||||||
return _tenantStack.Pop();
|
return _tenantStack.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object? ParseValue(string value)
|
||||||
|
{
|
||||||
|
if (value.Contains(',') && (value.Contains('$') || (value.Contains('{') && value.Contains('}') && value.Length > 38)))
|
||||||
|
{
|
||||||
|
List<InstanceHandle> list = new List<InstanceHandle>();
|
||||||
|
string[] values = value.Split(new char[] { ',' });
|
||||||
|
foreach (string value2 in values)
|
||||||
|
{
|
||||||
|
if (TryParseInstanceRef(value2, out InstanceHandle h2))
|
||||||
|
{
|
||||||
|
list.Add(h2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
else if (value.Contains('$') || (value.StartsWith('{') && value.EndsWith('}') && value.Length == 38))
|
||||||
|
{
|
||||||
|
if (TryParseInstanceRef(value, out InstanceHandle h2))
|
||||||
|
{
|
||||||
|
return h2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Boolean.TryParse(value, out bool b))
|
||||||
|
{
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
else if (Decimal.TryParse(value, out decimal d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
else if (DateTime.TryParse(value, out DateTime dt))
|
||||||
|
{
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private object? ParseValueForWorkData__TypeSafeFirst(InstanceHandle h, string value)
|
||||||
|
{
|
||||||
|
if (IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.WorkSet)) || IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.Class)))
|
||||||
|
{
|
||||||
|
if (value.Contains(","))
|
||||||
|
{
|
||||||
|
List<InstanceHandle> list = new List<InstanceHandle>();
|
||||||
|
string[] values = value.Split(new char[] { ',' });
|
||||||
|
foreach (string value2 in values)
|
||||||
|
{
|
||||||
|
if (TryParseInstanceRef(value2, out InstanceHandle h2))
|
||||||
|
{
|
||||||
|
list.Add(h2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (TryParseInstanceRef(value, out InstanceHandle h2))
|
||||||
|
{
|
||||||
|
return h2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.TextAttribute)))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else if (IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.BooleanAttribute)))
|
||||||
|
{
|
||||||
|
if (Boolean.TryParse(value, out bool d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.NumericAttribute)))
|
||||||
|
{
|
||||||
|
if (Decimal.TryParse(value, out decimal d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IsInstanceOf(h, GetInstance(KnownInstanceGuids.Classes.DateAttribute)))
|
||||||
|
{
|
||||||
|
if (DateTime.TryParse(value, out DateTime d))
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new FormatException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,6 +128,20 @@ public class Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InstanceHandle ecinst = OMS.GetRelatedInstance(parentElementContent, OMS.GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
|
||||||
|
object? wdv = context.GetWorkData(ecinst);
|
||||||
|
if (wdv == null)
|
||||||
|
{
|
||||||
|
wdv = context.GetWorkData(parentElementContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wdv is InstanceHandle)
|
||||||
|
{
|
||||||
|
value = ((InstanceHandle)wdv);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useWidget is MonikerList)
|
if (useWidget is MonikerList)
|
||||||
|
|||||||
@ -47,8 +47,12 @@ public class MonikerList : Widget
|
|||||||
obj.Add("relatedTasksUriTemplate", String.Format("/{0}/inst/{1}/rel-tasks", OMS.GetTenantName(OMS.CurrentTenant), OMS.GetInstanceKey(SelectedInstances.First()).ToString()));
|
obj.Add("relatedTasksUriTemplate", String.Format("/{0}/inst/{1}/rel-tasks", OMS.GetTenantName(OMS.CurrentTenant), OMS.GetInstanceKey(SelectedInstances.First()).ToString()));
|
||||||
}
|
}
|
||||||
obj.Add("text", OMS.GetInstanceText(ParentInstance));
|
obj.Add("text", OMS.GetInstanceText(ParentInstance));
|
||||||
|
|
||||||
|
if (OMS.GetAttributeValue<bool>(ParentInstance, OMS.GetInstance(KnownAttributeGuids.Boolean.Singular)))
|
||||||
|
{
|
||||||
obj.Add("singular", true);
|
obj.Add("singular", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool ShouldBeEnabled()
|
protected override bool ShouldBeEnabled()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user