Merge branch 'master' of gitea.azcona-becker.net:mochapowered/mocha-dotnet
This commit is contained in:
commit
6fe8dfa914
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,9 +1,9 @@
|
|||||||
[submodule "framework-dotnet"]
|
[submodule "framework-dotnet"]
|
||||||
path = framework-dotnet
|
path = framework-dotnet
|
||||||
url = git@gitea.azcona-becker.net:alcetech/framework-dotnet
|
url = gitea@gitea.azcona-becker.net:alcetech/framework-dotnet
|
||||||
[submodule "web-framework-dotnet"]
|
[submodule "web-framework-dotnet"]
|
||||||
path = web-framework-dotnet
|
path = web-framework-dotnet
|
||||||
url = git@gitea.azcona-becker.net:alcetech/web-framework-dotnet
|
url = gitea@gitea.azcona-becker.net:alcetech/web-framework-dotnet
|
||||||
[submodule "mocha-common"]
|
[submodule "mocha-common"]
|
||||||
path = mocha-common
|
path = mocha-common
|
||||||
url = git@gitea.azcona-becker.net:mochapowered/mocha-common
|
url = gitea@gitea.azcona-becker.net:mochapowered/mocha-common
|
||||||
|
|||||||
@ -11,6 +11,7 @@ using Mocha.Core.UI.Server;
|
|||||||
using Mocha.Core.Logging;
|
using Mocha.Core.Logging;
|
||||||
using Mocha.Core.Logging.Loggers;
|
using Mocha.Core.Logging.Loggers;
|
||||||
using Mocha.Core.Storage;
|
using Mocha.Core.Storage;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides the entry point for a simple application which starts a Web server
|
/// Provides the entry point for a simple application which starts a Web server
|
||||||
@ -25,7 +26,20 @@ public class Program : WebApplication
|
|||||||
|
|
||||||
public Dictionary<string, OmsSession> _Sessions = new Dictionary<string, OmsSession>();
|
public Dictionary<string, OmsSession> _Sessions = new Dictionary<string, OmsSession>();
|
||||||
|
|
||||||
protected override int DefaultPort => 4436;
|
protected override int DefaultPort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (System.Environment.GetEnvironmentVariable("OMS_SERVERPORT") != null)
|
||||||
|
{
|
||||||
|
if (Int32.TryParse(System.Environment.GetEnvironmentVariable("OMS_SERVERPORT"), out int port))
|
||||||
|
{
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 4436;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Program()
|
public Program()
|
||||||
{
|
{
|
||||||
@ -106,19 +120,46 @@ public class Program : WebApplication
|
|||||||
|
|
||||||
if (!System.IO.Directory.Exists(path))
|
if (!System.IO.Directory.Exists(path))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("path not found: " + path);
|
Log.WriteLine("path not found: " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TryLoadLibrary(Oms, path, "net.alcetech.Mocha.System.mcl"))
|
string[] requiredLibraries = new string[]
|
||||||
{
|
{
|
||||||
return;
|
"net.alcetech.Mocha.System.mcl",
|
||||||
}
|
"net.alcetech.Mocha.Web.mcl"
|
||||||
if (!TryLoadLibrary(Oms, path, "net.alcetech.Mocha.Web.mcl"))
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < requiredLibraries.Length; i++)
|
||||||
{
|
{
|
||||||
return;
|
Log.WriteLine("loading prerequisite library '{0}'... ", requiredLibraries[i]);
|
||||||
|
if (!TryLoadLibrary(Oms, path, requiredLibraries[i]))
|
||||||
|
{
|
||||||
|
Log.WriteLine("[^b^1FAILED^0] loading prerequisite library '{0}'", requiredLibraries[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.WriteLine("[^b^2SUCCESS^0] loading prerequisite library '{0}'", requiredLibraries[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Log.WriteLine("registering system routines");
|
||||||
|
RegisterSystemRoutines();
|
||||||
|
Oms.SystemRoutineExecuted += oms_SystemRoutineExecuted;
|
||||||
|
|
||||||
|
Log.WriteLine("updating Mochafile");
|
||||||
|
UpdateMochafile();
|
||||||
|
|
||||||
|
Log.WriteLine("reloading storages");
|
||||||
|
Oms.ReloadStorages();
|
||||||
|
|
||||||
|
Log.WriteLine("initial startup routine finished!");
|
||||||
|
// now we can start the Web server
|
||||||
|
base.OnStartup(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void RegisterSystemRoutines()
|
||||||
|
{
|
||||||
// implement functions to get user IP address
|
// implement functions to get user IP address
|
||||||
Oms.RegisterSystemAttributeRoutine<string>(KnownInstanceGuids.SystemAttributeRoutines.GetIPAddress, delegate (Oms oms2, OmsContext ctx2)
|
Oms.RegisterSystemAttributeRoutine<string>(KnownInstanceGuids.SystemAttributeRoutines.GetIPAddress, delegate (Oms oms2, OmsContext ctx2)
|
||||||
{
|
{
|
||||||
@ -132,14 +173,6 @@ public class Program : WebApplication
|
|||||||
bool b = UpdateMochafile();
|
bool b = UpdateMochafile();
|
||||||
return b;
|
return b;
|
||||||
});
|
});
|
||||||
Oms.SystemRoutineExecuted += oms_SystemRoutineExecuted;
|
|
||||||
|
|
||||||
UpdateMochafile();
|
|
||||||
|
|
||||||
Oms.ReloadStorages();
|
|
||||||
|
|
||||||
// now we can start the Web server
|
|
||||||
base.OnStartup(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateMochafile()
|
private bool UpdateMochafile()
|
||||||
@ -174,6 +207,15 @@ public class Program : WebApplication
|
|||||||
|
|
||||||
private bool LoadMochafile(string mochafilename)
|
private bool LoadMochafile(string mochafilename)
|
||||||
{
|
{
|
||||||
|
if (!System.IO.File.Exists(mochafilename))
|
||||||
|
{
|
||||||
|
Log.WriteLine("[ ^1ERROR ^0] Mochafile not found: '{0}'", mochafilename);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string curdir = System.Environment.CurrentDirectory;
|
||||||
|
System.Environment.CurrentDirectory = System.IO.Path.GetDirectoryName(mochafilename);
|
||||||
|
|
||||||
Log.WriteLine("oms-dotnet: loading Mochafile at '{0}'", mochafilename);
|
Log.WriteLine("oms-dotnet: loading Mochafile at '{0}'", mochafilename);
|
||||||
|
|
||||||
JsonObject? json = JsonNode.Parse(System.IO.File.ReadAllText(mochafilename)) as JsonObject;
|
JsonObject? json = JsonNode.Parse(System.IO.File.ReadAllText(mochafilename)) as JsonObject;
|
||||||
@ -183,6 +225,13 @@ public class Program : WebApplication
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> appLibraryRefs = new List<string>();
|
||||||
|
if (json.ContainsKey("application") && json["application"] is JsonObject objApp)
|
||||||
|
{
|
||||||
|
Log.WriteLine("loading application library references...");
|
||||||
|
LoadLibraryRefs(objApp, appLibraryRefs);
|
||||||
|
}
|
||||||
|
|
||||||
if (json.ContainsKey("tenants"))
|
if (json.ContainsKey("tenants"))
|
||||||
{
|
{
|
||||||
if (json["tenants"] is JsonArray aryTenants)
|
if (json["tenants"] is JsonArray aryTenants)
|
||||||
@ -200,7 +249,133 @@ public class Program : WebApplication
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
CreateTenant2(name);
|
TenantHandle th = CreateTenant2(name);
|
||||||
|
Oms.SelectTenant(th);
|
||||||
|
|
||||||
|
if (appLibraryRefs.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (string l in appLibraryRefs)
|
||||||
|
{
|
||||||
|
LibraryHandle lh = Oms.LoadLibrary(l);
|
||||||
|
if (lh != LibraryHandle.Empty)
|
||||||
|
{
|
||||||
|
Oms.AddLibraryReference(lh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.WriteLine("loading tenant library references...");
|
||||||
|
List<string> tenantLibraryRefs = new List<string>();
|
||||||
|
LoadLibraryRefs(jo, tenantLibraryRefs);
|
||||||
|
if (tenantLibraryRefs.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (string l in tenantLibraryRefs)
|
||||||
|
{
|
||||||
|
LibraryHandle lh = Oms.LoadLibrary(l);
|
||||||
|
if (lh != LibraryHandle.Empty)
|
||||||
|
{
|
||||||
|
Oms.AddLibraryReference(lh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Oms.SelectTenant(th);
|
||||||
|
if (jo.ContainsKey("attributeValues") && jo["attributeValues"] is JsonArray aryAttrs)
|
||||||
|
{
|
||||||
|
foreach (JsonNode? attval in aryAttrs)
|
||||||
|
{
|
||||||
|
if (attval is JsonObject objatt)
|
||||||
|
{
|
||||||
|
InstanceHandle ihSrc = InstanceHandle.Empty;
|
||||||
|
InstanceHandle ihAtt = InstanceHandle.Empty;
|
||||||
|
if (!objatt.ContainsKey("value"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
JsonNode nvalue = objatt["value"];
|
||||||
|
string srckey = "", attkey = "";
|
||||||
|
if (objatt.ContainsKey("sourceInstance"))
|
||||||
|
{
|
||||||
|
srckey = objatt["sourceInstance"]?.GetValue<string>() ?? "";
|
||||||
|
if (!Oms.TryParseInstanceRef(srckey, out ihSrc))
|
||||||
|
{
|
||||||
|
Log.WriteLine("assignAttribute failed - invalid source instance ref '{0}'", srckey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (objatt.ContainsKey("attributeInstance"))
|
||||||
|
{
|
||||||
|
attkey = objatt["attributeInstance"]?.GetValue<string>() ?? "";
|
||||||
|
if (!Oms.TryParseInstanceRef(attkey, out ihAtt))
|
||||||
|
{
|
||||||
|
Log.WriteLine("assignAttribute failed - invalid attribute instance ref '{0}'", attkey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nvalue.GetValueKind() == System.Text.Json.JsonValueKind.String)
|
||||||
|
{
|
||||||
|
string val = nvalue.GetValue<string>();
|
||||||
|
Log.WriteLine("assignAttribute {0} - {1} : '{2}'", srckey, attkey, val);
|
||||||
|
Oms.SetAttributeValue(ihSrc, ihAtt, val);
|
||||||
|
}
|
||||||
|
else if (nvalue.GetValueKind() == System.Text.Json.JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
string? val = ParseValueEx(nvalue as JsonObject);
|
||||||
|
if (val != null)
|
||||||
|
{
|
||||||
|
Log.WriteLine("assignAttribute {0} - {1} : '{2}'", srckey, attkey, val);
|
||||||
|
Oms.SetAttributeValue(ihSrc, ihAtt, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jo.ContainsKey("themeOverrides") && jo["themeOverrides"] is JsonArray aryThemes)
|
||||||
|
{
|
||||||
|
StringBuilder sbStyleSheet = new StringBuilder();
|
||||||
|
foreach (JsonNode? thm in aryThemes)
|
||||||
|
{
|
||||||
|
if (thm is JsonObject objthm)
|
||||||
|
{
|
||||||
|
if (!objthm.ContainsKey("type"))
|
||||||
|
continue;
|
||||||
|
if (!objthm.ContainsKey("filename"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string type = objthm["type"].GetValue<string>();
|
||||||
|
string filename = objthm["filename"].GetValue<string>();
|
||||||
|
|
||||||
|
if (type.Equals("stylesheet"))
|
||||||
|
{
|
||||||
|
string content = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
content = System.IO.File.ReadAllText(filename);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException ex)
|
||||||
|
{
|
||||||
|
Log.WriteLine("[ ^1ERROR^0 ] file not found: '{0}'", System.IO.Path.Join(new string[] { System.Environment.CurrentDirectory, filename }));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sbStyleSheet.AppendLine(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sbStyleSheet.Length > 0)
|
||||||
|
{
|
||||||
|
InstanceHandle a_Name = Oms.GetInstance(KnownAttributeGuids.Text.Name);
|
||||||
|
InstanceHandle a_ContentType = Oms.GetInstance(KnownAttributeGuids.Text.ContentType);
|
||||||
|
InstanceHandle a_Value = Oms.GetInstance(KnownAttributeGuids.Text.Value);
|
||||||
|
|
||||||
|
InstanceHandle c_StyleSheet = Oms.GetInstance(KnownInstanceGuids.Classes.StyleSheet);
|
||||||
|
InstanceHandle i_StyleSheet = Oms.CreateInstanceOf(c_StyleSheet);
|
||||||
|
Oms.SetAttributeValue(i_StyleSheet, a_Name, "Mochafile Overrides");
|
||||||
|
Oms.SetAttributeValue(i_StyleSheet, a_ContentType, "text/css");
|
||||||
|
Oms.SetAttributeValue(i_StyleSheet, a_Value, sbStyleSheet.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,10 +383,50 @@ public class Program : WebApplication
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log.WriteLine("oms-dotnet: Mochafile processing complete");
|
Log.WriteLine("oms-dotnet: Mochafile processing complete");
|
||||||
|
System.Environment.CurrentDirectory = curdir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateTenant2(string name)
|
private string? ParseValueEx(JsonObject o)
|
||||||
|
{
|
||||||
|
if (o.ContainsKey("type"))
|
||||||
|
{
|
||||||
|
switch (o["type"].GetValue<string>())
|
||||||
|
{
|
||||||
|
case "base64":
|
||||||
|
{
|
||||||
|
byte[] value = new byte[0];
|
||||||
|
if (o.ContainsKey("value"))
|
||||||
|
{
|
||||||
|
value = System.Text.Encoding.UTF8.GetBytes(o["value"].GetValue<string>());
|
||||||
|
}
|
||||||
|
else if (o.ContainsKey("filename"))
|
||||||
|
{
|
||||||
|
value = System.IO.File.ReadAllBytes(o["filename"].GetValue<string>());
|
||||||
|
}
|
||||||
|
return System.Convert.ToBase64String(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadLibraryRefs(JsonObject toplevel, ICollection<string> appLibraryRefs)
|
||||||
|
{
|
||||||
|
if (toplevel.ContainsKey("libraryReferences") && toplevel["libraryReferences"] is JsonArray aryRefs)
|
||||||
|
{
|
||||||
|
foreach (JsonObject o in aryRefs)
|
||||||
|
{
|
||||||
|
if (o.ContainsKey("path"))
|
||||||
|
{
|
||||||
|
Log.WriteLine("---- {0}", o["path"].GetValue<string>());
|
||||||
|
appLibraryRefs.Add(o["path"].GetValue<string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TenantHandle CreateTenant2(string name)
|
||||||
{
|
{
|
||||||
int ct = 0;
|
int ct = 0;
|
||||||
TenantHandle th = Oms.GetTenantByName(name);
|
TenantHandle th = Oms.GetTenantByName(name);
|
||||||
@ -240,8 +455,9 @@ public class Program : WebApplication
|
|||||||
Oms.SelectTenant(th);
|
Oms.SelectTenant(th);
|
||||||
Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.System"));
|
Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.System"));
|
||||||
Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.Web"));
|
Oms.AddLibraryReference(Oms.GetLibrary("net.alcetech.Mocha.Web"));
|
||||||
|
|
||||||
Log.WriteLine("oms-dotnet: create tenant ok, handle is '{0}'", th);
|
Log.WriteLine("oms-dotnet: create tenant ok, handle is '{0}'", th);
|
||||||
|
return th;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryLoadLibrary(Oms oms, string path, string fileName)
|
private bool TryLoadLibrary(Oms oms, string path, string fileName)
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using MBS.Web;
|
using MBS.Web;
|
||||||
using Mocha.Core;
|
using Mocha.Core;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
using Mocha.Core.UI;
|
using Mocha.Core.UI;
|
||||||
|
|
||||||
namespace Mocha.Core.UI.Server.Commands;
|
namespace Mocha.Core.UI.Server.Commands;
|
||||||
@ -28,6 +29,7 @@ public class AttributesCommand : 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)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("current tenant is {0}", oms.GetTenantName(oms.CurrentTenant));
|
||||||
if (e.Context.Request.PathParts.Length > 7)
|
if (e.Context.Request.PathParts.Length > 7)
|
||||||
{
|
{
|
||||||
// /tenants/{tenantName}/instances/{iid}/attrbutes/{attkey}/current
|
// /tenants/{tenantName}/instances/{iid}/attrbutes/{attkey}/current
|
||||||
@ -53,6 +55,8 @@ public class AttributesCommand : InstanceCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
value = oms.GetAttributeValue<string>(ProcessingInstance, att, String.Empty, dt);
|
value = oms.GetAttributeValue<string>(ProcessingInstance, att, String.Empty, dt);
|
||||||
|
// Log.WriteLine("oms: get attribute value {0} . {1} / {2} : '{3}'", e.Context.Request.PathParts[2], e.Context.Request.PathParts[4], e.Context.Request.PathParts[6], value);
|
||||||
|
|
||||||
e.Context.Response.ResponseCode = 200;
|
e.Context.Response.ResponseCode = 200;
|
||||||
e.Context.Response.ResponseText = "OK";
|
e.Context.Response.ResponseText = "OK";
|
||||||
e.Context.Response.ContentType = "text/plain";
|
e.Context.Response.ContentType = "text/plain";
|
||||||
|
|||||||
@ -64,13 +64,14 @@ public class ElementCommand : InstanceCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// not an element,
|
||||||
// update related work sets
|
// update related work sets
|
||||||
foreach (KeyValuePair<string, string> kvp in e.Context.Request.Form)
|
foreach (KeyValuePair<string, string> kvp in e.Context.Request.Form)
|
||||||
{
|
{
|
||||||
if (kvp.Key == "relatedInstance")
|
if (kvp.Key == "relatedInstance")
|
||||||
{
|
{
|
||||||
object? v = oms.ParseValue(kvp.Value);
|
object? v = oms.ParseValue(kvp.Value);
|
||||||
|
|
||||||
InstanceHandle relatedWorkSet = oms.GetRelatedInstance(ProcessingInstance, oms.GetInstance(KnownRelationshipGuids.Task__has_related__Work_Set));
|
InstanceHandle relatedWorkSet = oms.GetRelatedInstance(ProcessingInstance, oms.GetInstance(KnownRelationshipGuids.Task__has_related__Work_Set));
|
||||||
if (relatedWorkSet != InstanceHandle.Empty)
|
if (relatedWorkSet != InstanceHandle.Empty)
|
||||||
{
|
{
|
||||||
@ -127,7 +128,7 @@ public class ElementCommand : InstanceCommand
|
|||||||
// render the default task for the given instance
|
// render the default task for the given instance
|
||||||
InstanceHandle parentClass = oms.GetParentClass(ProcessingInstance);
|
InstanceHandle parentClass = oms.GetParentClass(ProcessingInstance);
|
||||||
// if (!oms.TryParseInstanceRef())//blahh
|
// if (!oms.TryParseInstanceRef())//blahh
|
||||||
InstanceHandle defaultTask = oms.GetRelatedInstance(parentClass, oms.GetInstance(KnownRelationshipGuids.Class__has_default__Task));
|
InstanceHandle defaultTask = oms.GetRelatedInstance(parentClass, oms.GetInstance(KnownRelationshipGuids.Class__has_default__Task));
|
||||||
if (defaultTask != InstanceHandle.Empty)
|
if (defaultTask != InstanceHandle.Empty)
|
||||||
{
|
{
|
||||||
ctx.InitiatingInstance = ProcessingInstance;
|
ctx.InitiatingInstance = ProcessingInstance;
|
||||||
@ -165,6 +166,11 @@ public class ElementCommand : InstanceCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
InstanceHandle processedByCT = oms.GetRelatedInstance(elem, oms.GetInstance(KnownRelationshipGuids.Element__processed_by__Control_Transaction_Method));
|
||||||
|
InstanceHandle buildsResponseWithBRMB = oms.GetRelatedInstance(processedByCT, oms.GetInstance(KnownRelationshipGuids.Control_Transaction_Method__uses__Build_Response_Method_Binding));
|
||||||
|
InstanceHandle respondsWithElement = oms.GetRelatedInstance(buildsResponseWithBRMB, oms.GetInstance(KnownRelationshipGuids.Build_UI_Response_Method__uses__Executable_returning_Element));
|
||||||
|
|
||||||
|
|
||||||
Response r = oms.ProcessElement(omsContext, elem, null);
|
Response r = oms.ProcessElement(omsContext, elem, null);
|
||||||
JsonObject obj = r.GetResponse(oms, omsContext);
|
JsonObject obj = r.GetResponse(oms, omsContext);
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using MBS.Web;
|
using MBS.Web;
|
||||||
using Mocha.Core;
|
using Mocha.Core;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
|
|
||||||
namespace Mocha.Core.UI.Server.Commands;
|
namespace Mocha.Core.UI.Server.Commands;
|
||||||
|
|
||||||
@ -29,12 +30,16 @@ public abstract class InstanceCommand : TenantedCommand
|
|||||||
protected override bool BeforeProcessInternal(WebServerProcessRequestEventArgs e, Core.Oms oms, Core.OmsContext ctx, StreamWriter sw)
|
protected override bool BeforeProcessInternal(WebServerProcessRequestEventArgs e, Core.Oms oms, Core.OmsContext ctx, StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (e.Context.Request.PathParts.Length < 5)
|
if (e.Context.Request.PathParts.Length < 5)
|
||||||
|
{
|
||||||
|
Log.WriteLine("oms-dotnet ERROR: invalid request for /tenants/???/instances/??? (path parts length {0})", e.Context.Request.PathParts.Length);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
string tenantName = e.Context.Request.PathParts[2];
|
string tenantName = e.Context.Request.PathParts[2];
|
||||||
TenantHandle th = oms.GetTenantByName(tenantName);
|
TenantHandle th = oms.GetTenantByName(tenantName);
|
||||||
if (th != TenantHandle.Empty)
|
if (th != TenantHandle.Empty)
|
||||||
{
|
{
|
||||||
|
Log.WriteLine("oms-dotnet: select tenant '{0}'", tenantName);
|
||||||
oms.SelectTenant(th);
|
oms.SelectTenant(th);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using MBS.Web;
|
using MBS.Web;
|
||||||
using Mocha.Core;
|
using Mocha.Core;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
using Mocha.Core.UI;
|
using Mocha.Core.UI;
|
||||||
|
|
||||||
namespace Mocha.Core.UI.Server.Commands;
|
namespace Mocha.Core.UI.Server.Commands;
|
||||||
@ -54,7 +55,7 @@ public class RelationshipsCommand : InstanceCommand
|
|||||||
string key = String.Format("item{0}", i);
|
string key = String.Format("item{0}", i);
|
||||||
if (e.Context.Request.Form.ContainsKey(key))
|
if (e.Context.Request.Form.ContainsKey(key))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("debug: trying to add inst " + e.Context.Request.Form[key]);
|
Log.WriteLine("debug: trying to add inst " + e.Context.Request.Form[key]);
|
||||||
if (oms.TryParseInstanceRef(e.Context.Request.Form[key], out InstanceHandle inst))
|
if (oms.TryParseInstanceRef(e.Context.Request.Form[key], out InstanceHandle inst))
|
||||||
{
|
{
|
||||||
ary1.Add(JsonRenderer.InstanceToJson(oms, inst));
|
ary1.Add(JsonRenderer.InstanceToJson(oms, inst));
|
||||||
@ -63,7 +64,7 @@ public class RelationshipsCommand : InstanceCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Error.WriteLine("ok assigning relationship");
|
Log.WriteLine("ok assigning relationship");
|
||||||
oms.AssignRelationship(ProcessingInstance, rel, list.ToArray());
|
oms.AssignRelationship(ProcessingInstance, rel, list.ToArray());
|
||||||
|
|
||||||
e.Context.Response.ResponseCode = 200;
|
e.Context.Response.ResponseCode = 200;
|
||||||
|
|||||||
@ -145,6 +145,7 @@ namespace Mocha.Core
|
|||||||
public static Guid Style { get; } = new Guid("{A48C843A-B24B-4BC3-BE6F-E2D069229B0A}");
|
public static Guid Style { get; } = new Guid("{A48C843A-B24B-4BC3-BE6F-E2D069229B0A}");
|
||||||
public static Guid StyleRule { get; } = new Guid("{C269A1F3-E014-4230-B78D-38EAF6EA8A81}");
|
public static Guid StyleRule { get; } = new Guid("{C269A1F3-E014-4230-B78D-38EAF6EA8A81}");
|
||||||
public static Guid StyleClass { get; } = new Guid("{a725f089-7763-4887-af37-da52358c378c}");
|
public static Guid StyleClass { get; } = new Guid("{a725f089-7763-4887-af37-da52358c378c}");
|
||||||
|
public static Guid StyleSheet { get; } = new Guid("{a727f9fa-0688-4203-9acf-7306b88c44fe}");
|
||||||
|
|
||||||
public static Guid Page { get; } = new Guid("{D9626359-48E3-4840-A089-CD8DA6731690}");
|
public static Guid Page { get; } = new Guid("{D9626359-48E3-4840-A089-CD8DA6731690}");
|
||||||
public static Guid ContainerPageComponent { get; } = new Guid("{6AD6BD1C-7D1C-4AC9-9642-FEBC61E9D6FF}");
|
public static Guid ContainerPageComponent { get; } = new Guid("{6AD6BD1C-7D1C-4AC9-9642-FEBC61E9D6FF}");
|
||||||
|
|||||||
@ -21,6 +21,21 @@ public static class Log
|
|||||||
{
|
{
|
||||||
public static List<Logger> Loggers { get; } = new List<Logger>();
|
public static List<Logger> Loggers { get; } = new List<Logger>();
|
||||||
|
|
||||||
|
public static void Write(string text)
|
||||||
|
{
|
||||||
|
foreach (Logger logger in Loggers)
|
||||||
|
{
|
||||||
|
logger.Write(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Write(string text, params object[] format)
|
||||||
|
{
|
||||||
|
foreach (Logger logger in Loggers)
|
||||||
|
{
|
||||||
|
logger.Write(text, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void WriteLine(string text)
|
public static void WriteLine(string text)
|
||||||
{
|
{
|
||||||
foreach (Logger logger in Loggers)
|
foreach (Logger logger in Loggers)
|
||||||
|
|||||||
@ -48,12 +48,22 @@ public class Logger
|
|||||||
Stream = st;
|
Stream = st;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void Write(string text)
|
||||||
|
{
|
||||||
|
StreamWriter?.Write(text);
|
||||||
|
}
|
||||||
|
public void Write(string text, params object?[] format)
|
||||||
|
{
|
||||||
|
Write(String.Format(text, format));
|
||||||
|
}
|
||||||
|
|
||||||
public void WriteLine(string text)
|
public void WriteLine(string text)
|
||||||
{
|
{
|
||||||
StreamWriter?.WriteLine(text);
|
Write(text);
|
||||||
|
Write(System.Environment.NewLine);
|
||||||
}
|
}
|
||||||
public void WriteLine(string text, params object?[] format)
|
public void WriteLine(string text, params object?[] format)
|
||||||
{
|
{
|
||||||
StreamWriter?.WriteLine(text, format);
|
WriteLine(String.Format(text, format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,8 +19,167 @@ namespace Mocha.Core.Logging.Loggers;
|
|||||||
|
|
||||||
public class ConsoleLogger : Logger
|
public class ConsoleLogger : Logger
|
||||||
{
|
{
|
||||||
|
public bool EnableColorization { get; set; } = true;
|
||||||
|
|
||||||
public ConsoleLogger()
|
public ConsoleLogger()
|
||||||
{
|
{
|
||||||
Stream = Console.OpenStandardOutput();
|
Stream = Console.OpenStandardOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Write(string text)
|
||||||
|
{
|
||||||
|
if (text.Contains('^') && EnableColorization)
|
||||||
|
{
|
||||||
|
// Q3 console colors - see https://quake3world.com/forum/viewtopic.php?t=7760
|
||||||
|
// with some modifications by yours truly
|
||||||
|
string[] ps = text.Split(new char[] { '^' });
|
||||||
|
Console.Write(ps[0]);
|
||||||
|
if (ps.Length > 1)
|
||||||
|
{
|
||||||
|
int state = 0; // bold = 1, underline = 2
|
||||||
|
for (int i = 1; i < ps.Length; i++)
|
||||||
|
{
|
||||||
|
if (ps[i][0] == '0')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[0m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '1')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";31m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '2')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";32m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '3')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";33m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '4')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";34m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '5')
|
||||||
|
{
|
||||||
|
// looks like it's exactly ASCII except for these two... why???
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";36m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '6')
|
||||||
|
{
|
||||||
|
// looks like it's exactly ASCII except for these two... why???
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";35m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '7')
|
||||||
|
{
|
||||||
|
Console.Write("\x1b[");
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
Console.Write('1');
|
||||||
|
}
|
||||||
|
else if (state == 2)
|
||||||
|
{
|
||||||
|
Console.Write('4');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write('0');
|
||||||
|
}
|
||||||
|
Console.Write(";37m");
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == 'b')
|
||||||
|
{
|
||||||
|
state = 1;
|
||||||
|
}
|
||||||
|
else if (ps[i][0] == '_')
|
||||||
|
{
|
||||||
|
state = 2;
|
||||||
|
}
|
||||||
|
Console.Write(ps[i].Substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,6 +25,7 @@ using System.Text.Json.Nodes;
|
|||||||
using MBS.Core;
|
using MBS.Core;
|
||||||
using MBS.Core.Collections;
|
using MBS.Core.Collections;
|
||||||
using MBS.Core.Extensibility;
|
using MBS.Core.Extensibility;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
using Mocha.Core.Oop;
|
using Mocha.Core.Oop;
|
||||||
using Mocha.Core.Responses;
|
using Mocha.Core.Responses;
|
||||||
using Mocha.Core.UI;
|
using Mocha.Core.UI;
|
||||||
@ -597,11 +598,16 @@ public abstract class Oms
|
|||||||
}
|
}
|
||||||
|
|
||||||
InstanceHandle ir = CreateInstance(guid);
|
InstanceHandle ir = CreateInstance(guid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// this is done by SetParentClass, below
|
||||||
int ct = CountInstances(ir_class.GetHandle());
|
int ct = CountInstances(ir_class.GetHandle());
|
||||||
InstanceKey pclass_key = GetInstanceKey(ir_class.GetHandle());
|
InstanceKey pclass_key = GetInstanceKey(ir_class.GetHandle());
|
||||||
InstanceKey new_index = new InstanceKey(pclass_key.InstanceIndex, ct);
|
InstanceKey new_index = new InstanceKey(pclass_key.InstanceIndex, ct + 1);
|
||||||
|
|
||||||
|
Log.WriteLine("oms: creating instance of class {0} with instance key {1}", pclass_key, new_index);
|
||||||
SetInstanceKey(ir, new_index);
|
SetInstanceKey(ir, new_index);
|
||||||
|
*/
|
||||||
|
|
||||||
DateTime dt = DateTime.Now;
|
DateTime dt = DateTime.Now;
|
||||||
if (!_InhibitStorage)
|
if (!_InhibitStorage)
|
||||||
@ -669,7 +675,7 @@ public abstract class Oms
|
|||||||
// AssignRelationship(ir_parent, GetInstance(KnownRelationshipGuids.Class__has__Instance), ir);
|
// AssignRelationship(ir_parent, GetInstance(KnownRelationshipGuids.Class__has__Instance), ir);
|
||||||
|
|
||||||
int ct = CountInstances(ir_parent);
|
int ct = CountInstances(ir_parent);
|
||||||
SetInstanceKey(ir, new InstanceKey(GetInstanceKey(ir_parent).InstanceIndex, ct - 1));
|
SetInstanceKey(ir, new InstanceKey(GetInstanceKey(ir_parent).InstanceIndex, ct /* - 1 */));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CountInstances(InstanceHandle ir_parent)
|
public int CountInstances(InstanceHandle ir_parent)
|
||||||
@ -836,6 +842,8 @@ public abstract class Oms
|
|||||||
_derivedData[sh][attribute] = value;
|
_derivedData[sh][attribute] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.WriteLine("oms: setting attribute value {0} . {1} = '{2}'", sh, attribute, value);
|
||||||
SetAttributeValueInternal(sh, attribute, value, dt);
|
SetAttributeValueInternal(sh, attribute, value, dt);
|
||||||
|
|
||||||
if (!_InhibitStorage)
|
if (!_InhibitStorage)
|
||||||
@ -1814,8 +1822,18 @@ public abstract class Oms
|
|||||||
{
|
{
|
||||||
if (_libraries.ContainsKey(name))
|
if (_libraries.ContainsKey(name))
|
||||||
{
|
{
|
||||||
|
Log.WriteLine("[^b^2SUCCESS^0] GetLibrary - using handle '{0}' for '{1}'", _libraries[name], name);
|
||||||
return _libraries[name];
|
return _libraries[name];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.WriteLine("[^b^1FAILURE^0] GetLibrary - not found library '{0}'", name);
|
||||||
|
Log.WriteLine("Available libraries are: ");
|
||||||
|
foreach (KeyValuePair<string, LibraryHandle> kvp in _libraries)
|
||||||
|
{
|
||||||
|
Log.WriteLine("---- {0}", kvp.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
return LibraryHandle.Empty;
|
return LibraryHandle.Empty;
|
||||||
}
|
}
|
||||||
private Dictionary<Guid, LibraryHandle> _librariesGuids = new Dictionary<Guid, LibraryHandle>();
|
private Dictionary<Guid, LibraryHandle> _librariesGuids = new Dictionary<Guid, LibraryHandle>();
|
||||||
@ -1847,6 +1865,7 @@ public abstract class Oms
|
|||||||
// /path/to/directory containing a bunch of XML / JSON / YAML files
|
// /path/to/directory containing a bunch of XML / JSON / YAML files
|
||||||
// .mcz ZIP archive of XML / JSON / YAML files (slowest?)
|
// .mcz ZIP archive of XML / JSON / YAML files (slowest?)
|
||||||
LibraryHandle lh = LibraryHandle.Create();
|
LibraryHandle lh = LibraryHandle.Create();
|
||||||
|
Log.WriteLine("LoadLibrary - registered handle '{0}'", lh);
|
||||||
|
|
||||||
Library lib = new Library();
|
Library lib = new Library();
|
||||||
// _libraries[name] = lh;
|
// _libraries[name] = lh;
|
||||||
@ -1900,7 +1919,6 @@ public abstract class Oms
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public LibraryHandle LoadLibrary(string filename)
|
public LibraryHandle LoadLibrary(string filename)
|
||||||
{
|
{
|
||||||
Console.WriteLine("oms: LoadLibrary '{0}'", filename);
|
|
||||||
// some examples:
|
// some examples:
|
||||||
// .mcl compiled binary library file (fastest?)
|
// .mcl compiled binary library file (fastest?)
|
||||||
// /path/to/directory containing a bunch of XML / JSON / YAML files
|
// /path/to/directory containing a bunch of XML / JSON / YAML files
|
||||||
@ -1908,11 +1926,14 @@ public abstract class Oms
|
|||||||
LibraryHandle lh = LibraryHandle.Create();
|
LibraryHandle lh = LibraryHandle.Create();
|
||||||
|
|
||||||
Library lib = new Library();
|
Library lib = new Library();
|
||||||
// _libraries[name] = lh;
|
string name = System.IO.Path.GetFileNameWithoutExtension(filename);
|
||||||
|
_libraries[name] = lh;
|
||||||
|
|
||||||
if (!System.IO.File.Exists(filename) && !Directory.Exists(filename))
|
if (!System.IO.File.Exists(filename) && !Directory.Exists(filename))
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException(null, filename);
|
Log.WriteLine("[^b^1FAILURE^0] LoadLibrary - file not found '{0}'", filename);
|
||||||
|
return LibraryHandle.Empty;
|
||||||
|
//throw new FileNotFoundException(null, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a list of all library loaders we have implemented
|
// get a list of all library loaders we have implemented
|
||||||
@ -2299,42 +2320,47 @@ public abstract class Oms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Renderer renderer = new Renderer(this);
|
return PresentElement(ctx, element);
|
||||||
string title = GetLabelForUIElement(element);
|
|
||||||
Widget widget = renderer.Parse(ctx, element, InstanceHandle.Empty, InstanceHandle.Empty);
|
|
||||||
if (widget == null)
|
|
||||||
{
|
|
||||||
return FailureResponse.UnexpectedFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PageResponse(delegate (Oms oms, OmsContext ctx)
|
|
||||||
{
|
|
||||||
JsonObject obj3 = widget.ToJSONObject(ctx);
|
|
||||||
|
|
||||||
JsonObject obj2 = new JsonObject();
|
|
||||||
obj2.Add("widget", JsonValue.Create("root"));
|
|
||||||
obj2.Add("body", widget.ToJSONObject(ctx));
|
|
||||||
|
|
||||||
JsonObject objTitle = new JsonObject();
|
|
||||||
// hack
|
|
||||||
if (String.IsNullOrEmpty(title) && ctx.InitiatingTask != InstanceHandle.Empty)
|
|
||||||
{
|
|
||||||
title = oms.GetInstanceText(ctx.InitiatingTask);
|
|
||||||
}
|
|
||||||
objTitle.Add("label", title);
|
|
||||||
// objTitle.Add("src", "Oms");
|
|
||||||
obj2.Add("title", objTitle);
|
|
||||||
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
obj.Add("result", "success");
|
|
||||||
obj.Add("value", obj2);
|
|
||||||
return obj;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return null; // FailureResponse.UnexpectedFailure;
|
return null; // FailureResponse.UnexpectedFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response? ProcessElementContent(OmsContext context, InstanceHandle elementContent, IDictionary<string, string> form, string fqecidPrefix)
|
private Response PresentElement(OmsContext ctx, InstanceHandle element)
|
||||||
|
{
|
||||||
|
Renderer renderer = new Renderer(this);
|
||||||
|
string title = GetLabelForUIElement(element);
|
||||||
|
Widget widget = renderer.Parse(ctx, element, InstanceHandle.Empty, InstanceHandle.Empty);
|
||||||
|
if (widget == null)
|
||||||
|
{
|
||||||
|
return FailureResponse.UnexpectedFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PageResponse(delegate (Oms oms, OmsContext ctx)
|
||||||
|
{
|
||||||
|
JsonObject obj3 = widget.ToJSONObject(ctx);
|
||||||
|
|
||||||
|
JsonObject obj2 = new JsonObject();
|
||||||
|
obj2.Add("widget", JsonValue.Create("root"));
|
||||||
|
obj2.Add("body", widget.ToJSONObject(ctx));
|
||||||
|
|
||||||
|
JsonObject objTitle = new JsonObject();
|
||||||
|
// hack
|
||||||
|
if (String.IsNullOrEmpty(title) && ctx.InitiatingTask != InstanceHandle.Empty)
|
||||||
|
{
|
||||||
|
title = oms.GetInstanceText(ctx.InitiatingTask);
|
||||||
|
}
|
||||||
|
objTitle.Add("label", title);
|
||||||
|
// objTitle.Add("src", "Oms");
|
||||||
|
obj2.Add("title", objTitle);
|
||||||
|
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.Add("result", "success");
|
||||||
|
obj.Add("value", obj2);
|
||||||
|
return obj;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response? ProcessElementContent(OmsContext context, InstanceHandle elementContent, IDictionary<string, string> form, string fqecidPrefix)
|
||||||
{
|
{
|
||||||
InstanceHandle elementContentInstance = GetRelatedInstance(elementContent, GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
|
InstanceHandle elementContentInstance = GetRelatedInstance(elementContent, GetInstance(KnownRelationshipGuids.Element_Content__has__Instance));
|
||||||
if (IsInstanceOf(elementContentInstance, GetInstance(KnownInstanceGuids.Classes.Element)))
|
if (IsInstanceOf(elementContentInstance, GetInstance(KnownInstanceGuids.Classes.Element)))
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Mocha.Core.Logging;
|
||||||
|
|
||||||
namespace Mocha.Core.OmsImplementations;
|
namespace Mocha.Core.OmsImplementations;
|
||||||
|
|
||||||
public class MemoryOms : Oms
|
public class MemoryOms : Oms
|
||||||
@ -270,17 +272,14 @@ public class MemoryOms : Oms
|
|||||||
{
|
{
|
||||||
_Attributes[source] = new Dictionary<InstanceHandle, List<AttributeValue>>();
|
_Attributes[source] = new Dictionary<InstanceHandle, List<AttributeValue>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AttributeValue> list;
|
|
||||||
if (!_Attributes[source].ContainsKey(attribute))
|
if (!_Attributes[source].ContainsKey(attribute))
|
||||||
{
|
{
|
||||||
list = new List<AttributeValue>();
|
_Attributes[source][attribute] = new List<AttributeValue>();
|
||||||
_Attributes[source][attribute] = list;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list = _Attributes[source][attribute];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<AttributeValue> list = _Attributes[source][attribute];
|
||||||
|
|
||||||
|
// Log.WriteLine("memory-oms: SAV {0} . {1} '{2}'", GetInstanceKey(source), GetInstanceKey(attribute), value);
|
||||||
list.Add(new AttributeValue(effectiveDate, value));
|
list.Add(new AttributeValue(effectiveDate, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +296,7 @@ public class MemoryOms : Oms
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("oms: error: trying to add reference to library which hasn't been loaded yet");
|
Log.WriteLine("oms: error: trying to add reference to library which hasn't been loaded yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
|
|
||||||
namespace Mocha.Core.UI;
|
namespace Mocha.Core.UI;
|
||||||
|
|
||||||
@ -71,6 +73,8 @@ public class JsonRenderer : Renderer
|
|||||||
public static JsonArray GetAttributesAsJson(Core.Oms oms, InstanceHandle h, InstanceHandle hAtt = default(InstanceHandle))
|
public static JsonArray GetAttributesAsJson(Core.Oms oms, InstanceHandle h, InstanceHandle hAtt = default(InstanceHandle))
|
||||||
{
|
{
|
||||||
JsonArray a = new JsonArray();
|
JsonArray a = new JsonArray();
|
||||||
|
Log.WriteLine("GAAJ: CT = {0}", oms.GetTenantName(oms.CurrentTenant));
|
||||||
|
|
||||||
IEnumerable<MochaAttribute> atts = oms.GetAttributes(h);
|
IEnumerable<MochaAttribute> atts = oms.GetAttributes(h);
|
||||||
foreach (MochaAttribute att in atts)
|
foreach (MochaAttribute att in atts)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
|
|
||||||
namespace Mocha.Core.UI;
|
namespace Mocha.Core.UI;
|
||||||
|
|
||||||
@ -45,11 +46,12 @@ public class Text : Widget
|
|||||||
{
|
{
|
||||||
value = val.ToString();
|
value = val.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
// no value specified for the target instance, so get default value of the Text Attribute
|
// no value specified for the target instance, so get default value of the Text Attribute
|
||||||
value = OMS.GetAttributeValue<string>(ParentInstance, OMS.GetInstance(KnownAttributeGuids.Text.Value));
|
value = OMS.GetAttributeValue<string>(ParentInstance, OMS.GetInstance(KnownAttributeGuids.Text.Value));
|
||||||
|
Log.WriteLine("TextAttribute from parent instance {0}, value == '{1}' OMS = '{2}'", OMS.GetInstanceKey(ParentInstance), value, OMS.GetTenantName(OMS.CurrentTenant));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using System.Reflection.Metadata.Ecma335;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using MBS.Core;
|
using MBS.Core;
|
||||||
using Mocha.Core;
|
using Mocha.Core;
|
||||||
|
using Mocha.Core.Logging;
|
||||||
using Mocha.Plugins.Libraries.McxMini.EditorMini;
|
using Mocha.Plugins.Libraries.McxMini.EditorMini;
|
||||||
|
|
||||||
public class McxMiniLibraryPlugin : LibraryPlugin
|
public class McxMiniLibraryPlugin : LibraryPlugin
|
||||||
@ -108,7 +109,7 @@ public class McxMiniLibraryPlugin : LibraryPlugin
|
|||||||
|
|
||||||
if (guidsSection.Count != instancesSection.Count)
|
if (guidsSection.Count != instancesSection.Count)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("guid count not equal to instance count?");
|
Log.WriteLine("[^b^3WARNING^0] guid count not equal to instance count?");
|
||||||
}
|
}
|
||||||
|
|
||||||
r.BaseStream.Seek(guidsSection.Offset, SeekOrigin.Begin);
|
r.BaseStream.Seek(guidsSection.Offset, SeekOrigin.Begin);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user