Files
wwtools/graccesscli/analysis/ide-edit-investigation/cac/ArchestrA.IDE.ConfigurationAccessComponent.decompiled.cs
Joseph Doherty c52d8d0171 graccesscli: correct script-edit docs to TN-537 truth (writes DO persist)
I was wrong. AVEVA Tech Note 537 ("Creating an Application Object Script
Using GRAccess", April 2008) documents the supported pattern:
ConfigurableAttributes[<script>.<field>].SetValue(MxValue) inside a
CheckOut/Save/CheckIn cycle. graccesscli's existing
FindAttributeForMutation already follows this — writes to MxCategoryPackageOnly_Lockable
script-text fields persist correctly.

The earlier "writeback gap" diagnosis was a phantom caused by a reader-side
issue. `object attribute value get` against a script body returns
"Supported: False / Attribute value is not exposed" because
MxValueDetails uses a case-sensitive `ReadProperty(attr, "Value")` lookup
plus an accessor probe (GetBoolean -> GetInteger -> GetFloat -> GetDouble
-> GetString) that can fall through silently for some MxValue shapes. The
COM-side property is exposed as `value` (lowercase), readable as
`attr.value.GetString()` -- which the live probe at
`analysis/ide-edit-investigation/probe_setvalue/` does and confirms the
post-write content matches the marker exactly.

Live verification on $TestMachine.UpdateTestChangingInt.DeclarationsText
and $DelmiaReceiver.ProcessRecipe.{ExecuteText,DeclarationsText}:

  === verdict ===
    marker landed on same-proxy   ConfigurableAttributes: True
    marker landed on same-proxy   Attributes            : True
    marker landed on fresh-proxy  ConfigurableAttributes: True
    marker landed on fresh-proxy  Attributes            : True

The probe also confirmed that two earlier graccesscli `object scripts set`
invocations (which I had wrongly believed failed) had persisted -- the
marker text I wrote previously was still on disk in
ProcessRecipe.{ExecuteText,DeclarationsText} when read directly via
attr.value.GetString(). The probe restored both fields to their original
values.

This commit:

- Updates the misleading [Command(...)] / [CommandOption(...)]
  descriptions in GRAccessSurfaceCommands.cs back to honest versions
  citing TN-537.
- Restores the --file-using examples for `object scripts set` and
  `object scripts create` across script-editing.md, llm-integration.md,
  usage.md, and zb-testmachine.md.
- Removes the test that asserted the (wrong) EnsureMutableViaSetValue
  guard. Re-aims ScriptCommandDescriptions_… at the corrected wording.
- Removes two leftover EnsureMutableViaSetValue calls in the trigger-period
  / trigger-type write paths (both targeted MxCategoryWriteable_C_Lockable
  attributes; would never have fired even if the helper still existed).
- Adds analysis/ide-edit-investigation/REPORT.md (replacing the earlier
  wrong report) plus the probe sources under probe_setvalue/.

The MxValueDetails reader gap (case-sensitive ReadProperty + accessor
probe) is a real follow-up: `object attribute value get` should
case-insensitively read `value` and try GetString first when the
underlying MxValue.DataType is MxString. Out of scope here -- that's a
separate, smaller fix.

Test count delta: 67 -> 66 (-2 wrong tests, +1 corrected description test).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 21:33:51 -04:00

1073 lines
30 KiB
C#

using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ArchestrA.Configuration;
using ArchestrA.Core;
using ArchestrA.Diagnostics;
using ArchestrA.IDE.Extensibility;
using ArchestrA.Security;
using CASLib;
using IaaEditorFormLib;
using Microsoft.Win32;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("5400.0017.1005.2")]
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("AVEVA Software, LLC")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright 2020 AVEVA Group plc and its subsidiaries. All rights reserved.")]
[assembly: AssemblyTrademark("Refer to: https://sw.aveva.com/legal/trademarks")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AcmeBuildVersion
{
internal sealed class Versioning
{
public const string Company = "AVEVA Software, LLC";
public const string Product = "";
public const string Copyright = "Copyright 2020 AVEVA Group plc and its subsidiaries. All rights reserved.";
public const string Trademark = "Refer to: https://sw.aveva.com/legal/trademarks";
public const string Configuration = "Release";
public const string BuildNumber = "5400";
public const string BuildMaintenanceNumber = "1005";
public const string BldRevision = "2";
private Versioning()
{
}
}
internal sealed class ComponentVersioning
{
public const string ComponentVersion = "0017";
public const string ComponentMaintenanceVersion = "0000";
public const string ComponentName = "ConfigurationAccessComponent";
private ComponentVersioning()
{
}
}
}
namespace ArchestrA.IDE
{
public class CASParameters
{
private IConfigurationEditorSite2 m_IObjectManage;
private IGalaxyConfiguration m_IObjectConfiguration;
private bool m_bReadOnly;
private bool m_bKeepCheckedOut;
private string m_DerivedFrom;
private bool m_bTagnameIsReadOnly;
private bool m_bContainedNameIsReadOnly;
private bool m_bShowStandardTabs = true;
private bool m_bPartialReadOnly;
private Image m_imgIcon;
public IConfigurationEditorSite2 inObjectManage
{
get
{
return m_IObjectManage;
}
set
{
m_IObjectManage = value;
}
}
public IGalaxyConfiguration inObjectConfiguration
{
get
{
return m_IObjectConfiguration;
}
set
{
m_IObjectConfiguration = value;
}
}
public string DerivedFrom
{
get
{
return m_DerivedFrom;
}
set
{
m_DerivedFrom = value;
}
}
public bool ReadOnly
{
get
{
return m_bReadOnly;
}
set
{
m_bReadOnly = value;
}
}
public bool KeepCheckedOut
{
get
{
return m_bKeepCheckedOut;
}
set
{
m_bKeepCheckedOut = value;
}
}
public bool TagnameIsReadOnly
{
get
{
return m_bTagnameIsReadOnly;
}
set
{
m_bTagnameIsReadOnly = value;
}
}
public bool ContainedNameIsReadOnly
{
get
{
return m_bContainedNameIsReadOnly;
}
set
{
m_bContainedNameIsReadOnly = value;
}
}
public bool ShowStandardTabs
{
get
{
return m_bShowStandardTabs;
}
set
{
m_bShowStandardTabs = value;
}
}
public bool PartialReadOnly
{
get
{
return m_bPartialReadOnly;
}
set
{
m_bPartialReadOnly = value;
}
}
public Image EditorLogo
{
get
{
return m_imgIcon;
}
set
{
m_imgIcon = value;
}
}
}
public class ConfigurationAccessComponent : IaaEditorFormLib.IConfigurationAccess, IDisposable, IBaseEditorSite, IPackageErrorSubscription, DConfigurationAccessEvents
{
private IConfigurationAccess2 m_comCAS;
private int m_intAdviseCookie;
private string m_strLastError;
internal string m_strSupportedLocales;
internal bool m_bError;
internal IaaServices m_services;
internal CASParameters m_CASParams;
internal IConfigurationEditorSite m_ICESite;
internal DictionaryLoader m_DictionaryLoader;
public object GalaxyBrowser => m_comCAS.GalaxyBrowser;
public bool ShowStandardTabs => m_CASParams.ShowStandardTabs;
public Image EditorLogo => m_CASParams.EditorLogo;
public IaaServices IDEServices => m_services;
public bool PartialReadOnly => m_CASParams.PartialReadOnly;
public string ShapeInfo
{
get
{
string bstrShapeInfo = null;
m_ICESite.GetPackageShapeInfo(ref bstrShapeInfo);
return bstrShapeInfo;
}
}
public event OnBeforeDataChangeEventHandler BeforeDataChange;
public event OnDataChangeEventHandler DataChange;
public event OnSetDataErrorEventHandler SetDataError;
public event OnMarkDirtyEventHandler MarkDirty;
public event OnSaveAndCloseEventHandler SaveAndClose;
public event OnCloseEditorEventHandler CloseEditor;
public event OnObjectHelpEventHandler ObjectHelp;
public event OnEditObjectHelpEventHandler EditObjectHelp;
public ConfigurationAccessComponent(IaaServices services, CASParameters CASParams)
{
m_services = services;
m_CASParams = CASParams;
m_bError = false;
m_DictionaryLoader = new DictionaryLoader();
Type typeFromProgID = Type.GetTypeFromProgID("ConfigurationAccessComponent.ConfigurationAccessServer", throwOnError: true);
m_comCAS = (IConfigurationAccess2)Activator.CreateInstance(typeFromProgID);
m_ICESite = m_CASParams.inObjectManage;
IConfigurationEditor configurationEditor = (IConfigurationEditor)m_comCAS;
configurationEditor.Initialize("", m_ICESite, this, m_CASParams.ReadOnly);
m_CASParams.inObjectManage.SetSubscriberInfo(configurationEditor);
m_CASParams.inObjectManage.SetSubscriberInfo(this);
UCOMIConnectionPointContainer uCOMIConnectionPointContainer = (UCOMIConnectionPointContainer)m_comCAS;
Guid riid = typeof(DConfigurationAccessEvents).GUID;
UCOMIConnectionPoint ppCP = null;
uCOMIConnectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
ppCP.Advise(this, out m_intAdviseCookie);
m_strSupportedLocales = GetSupportedLocales();
set_Data("ww:SupportedLocales", "value", m_strSupportedLocales);
set_Data("ww:IPackageManager", "value", m_CASParams.inObjectConfiguration);
string pVal = (string)get_Data("Tagname", "value");
set_Data("ww:Tagname", "Value", pVal);
set_Data("ww:Tagname", "ValueReadOnly", m_CASParams.TagnameIsReadOnly);
try
{
pVal = (string)get_Data("ContainedName", "value");
}
catch (Exception)
{
pVal = "";
}
set_Data("ww:ContainedName", "Value", pVal);
if (pVal.Length == 0)
{
m_CASParams.ContainedNameIsReadOnly = true;
}
set_Data("ww:ContainedName", "ValueReadOnly", m_CASParams.ContainedNameIsReadOnly);
set_Data("ww:DerivedFrom", "Value", m_CASParams.DerivedFrom);
set_Data("ww:KeepCheckedOut", "Value", m_CASParams.KeepCheckedOut);
set_Data("ww:SupportedLocales", "Value", m_strSupportedLocales);
}
private string GetSupportedLocales()
{
string result = "";
int processLocale = m_DictionaryLoader.ProcessLocale;
IMxValue configuredLocales = m_CASParams.inObjectConfiguration.GetConfiguredLocales();
if (configuredLocales != null && configuredLocales.GetDataType() == ArchestrA.Core.MxDataType.MxInteger)
{
configuredLocales.GetDimensionSize(out var pSize);
result = "<internationalizedtext>";
CultureInfo cultureInfo = new CultureInfo(processLocale);
result += $"<text localeName= \"{cultureInfo.EnglishName}\" localeID=\"{processLocale}\"/>";
for (int i = 1; i <= pSize; i++)
{
IMxValue mxValue = new MxValueClass();
configuredLocales.GetElement(i, mxValue);
int integer = mxValue.GetInteger();
if (integer != processLocale)
{
cultureInfo = new CultureInfo(integer);
result += $"<text localeName= \"{cultureInfo.EnglishName}\" localeID=\"{integer}\"/>";
}
}
result += "</internationalizedtext>";
}
return result;
}
public void set_Data(object Item, object SubItem, object pVal)
{
if (this.BeforeDataChange != null)
{
BeforeDataChangeEventArgs e = new BeforeDataChangeEventArgs();
e.Item = Item;
e.SubItem = SubItem;
e.Value = pVal;
this.BeforeDataChange(this, e);
if (e.Cancel)
{
OnError(e.Message);
return;
}
}
m_comCAS.set_Data(Item, SubItem, pVal);
}
public object get_Data(object Item, object SubItem)
{
if (Item as string == "beo:LastError")
{
return m_strLastError;
}
return m_comCAS.get_Data(Item, SubItem);
}
public void Execute(string Action, object Options)
{
switch (Action.ToLower())
{
case "markdirty":
if (!(bool)get_Data("BEO:InhibitDirtySet", ""))
{
OnStatusChange();
}
break;
case "loginfo":
ArchestrA.Diagnostics.Logger.LogInfo((string)Options);
break;
case "logwarning":
ArchestrA.Diagnostics.Logger.LogWarning((string)Options);
break;
case "logerror":
ArchestrA.Diagnostics.Logger.LogError((string)Options);
break;
case "saveandclose":
OnSaveAndClose();
break;
case "editobjecthelp":
{
string objectPath = GetObjectPath(2);
bool isTemplate = (bool)get_Data("_IsTemplate", "");
string objectName = (string)get_Data("ww:tagname", "");
OnEditObjectHelp(objectPath, objectName, isTemplate);
break;
}
case "readobjecthelp":
OnObjectHelp(Options);
break;
default:
ArchestrA.Diagnostics.Logger.LogWarning("Execute method called with invalid command: " + (string)Options);
break;
}
}
public string get_LocalizedText(object phraseID, object Options)
{
string strVendorDictionary = (string)Options;
string strPhraseId = (string)phraseID;
return m_DictionaryLoader.GetString(strVendorDictionary, strPhraseId);
}
public void SubscribeData(object Item, object SubItem)
{
m_comCAS.SubscribeData(Item, SubItem);
}
public void UnsubscribeData(object Item, object SubItem)
{
m_comCAS.UnsubscribeData(Item, SubItem);
}
public string GetObjectPath(int ObjectPathSectionEnum)
{
return m_CASParams.inObjectManage.GetObjectPath((EObjectPathSection)ObjectPathSectionEnum);
}
public void Apply(IaaEditorForm IEditorForm)
{
IEditorForm?.OnDataChange("BEO:Apply", "BEO:Apply", true);
}
public void GetErrorsAndWarnings(out string[] Warnings, out string[] Errors)
{
short nDimensions = 0;
int pSize = 0;
IMxValue mxValue = new MxValueClass();
IMxValue mxValue2 = new MxValueClass();
Warnings = null;
Errors = null;
m_CASParams.inObjectManage.Validate();
IConfigurationEditorSite inObjectManage = m_CASParams.inObjectManage;
int attributeCookie = inObjectManage.GetAttributeCookie("_Warnings");
inObjectManage.GetAttribute(attributeCookie, 10, mxValue);
ArchestrA.Diagnostics.Logger.LogTrace("IConfigurationAccess::Apply: Retreived warnings");
mxValue.GetDimensionCount(out nDimensions);
if (nDimensions == 1)
{
mxValue.GetDimensionSize(out pSize);
if (pSize > 0)
{
Warnings = new string[pSize];
for (int i = 1; i <= pSize; i++)
{
mxValue.GetElement(i, mxValue2);
Warnings[i - 1] = mxValue2.GetString();
}
}
}
attributeCookie = inObjectManage.GetAttributeCookie("Errors");
inObjectManage.GetAttribute(attributeCookie, 10, mxValue);
ArchestrA.Diagnostics.Logger.LogTrace("IConfigurationAccess::Apply: Retreived errors");
mxValue.GetDimensionCount(out nDimensions);
if (nDimensions != 1)
{
return;
}
mxValue.GetDimensionSize(out pSize);
if (pSize > 0)
{
Errors = new string[pSize];
for (int i = 1; i <= pSize; i++)
{
mxValue.GetElement(i, mxValue2);
Errors[i - 1] = mxValue2.GetString();
}
}
}
public bool Commit(out string Error)
{
Error = null;
EPACKAGEOPERATIONSTATUS ePACKAGEOPERATIONSTATUS = m_CASParams.inObjectManage.Commit(out Error);
return ePACKAGEOPERATIONSTATUS == EPACKAGEOPERATIONSTATUS.ePackageSuccess;
}
public void CheckConfigurationPermissionForHostObject(out EPERMISSION_ACCESS ePermissionAccess, out EPERMISSION_ACCESS eGraphicsAccess)
{
ePermissionAccess = EPERMISSION_ACCESS.eAccessdeny;
eGraphicsAccess = EPERMISSION_ACCESS.eAccessdeny;
m_CASParams.inObjectManage.GetSecurityAccessForEditor(out var securityAccess);
if (securityAccess is IFxSecurityAccess fxSecurityAccess)
{
fxSecurityAccess.CheckConfigurationPermissionForHostObject(out ePermissionAccess, out eGraphicsAccess);
}
}
public void GetSGetScriptCompiledAttributesWarningtext(out string strScriptWarning)
{
strScriptWarning = "";
try
{
IConfigurationEditorSite7 configurationEditorSite = (IConfigurationEditorSite7)m_CASParams.inObjectManage;
configurationEditorSite.GetScriptCompiledAttributesWarningtext(out strScriptWarning);
}
catch (Exception ex)
{
ArchestrA.Diagnostics.Logger.LogTrace("Unable to retrieve Scirpt attributes modification status" + ex.Message);
}
}
public void EditorClose()
{
if (this.CloseEditor != null)
{
this.CloseEditor();
}
}
public void OnDataChange(object Item, object SubItem, object Value)
{
if (this.DataChange != null)
{
this.DataChange(Item, SubItem, Value);
}
}
public void OnSaveAndClose()
{
if (this.SaveAndClose != null)
{
this.SaveAndClose();
}
}
public void OnObjectHelp(object options)
{
if (this.ObjectHelp != null)
{
this.ObjectHelp(options);
}
}
public void OnEditObjectHelp(string ObjectPath, string ObjectName, bool IsTemplate)
{
if (this.EditObjectHelp != null)
{
this.EditObjectHelp(ObjectPath, ObjectName, IsTemplate);
}
}
public void OnStatusChange()
{
if (this.MarkDirty != null && !(bool)get_Data("BEO:InhibitDirtySet", ""))
{
this.MarkDirty();
}
}
public void OnError(string errorWarningString)
{
m_bError = true;
m_comCAS.set_Data((object)"beo:ErrorCode", (object)"value", (object)m_bError);
m_strLastError = errorWarningString;
if (this.SetDataError != null)
{
this.SetDataError(errorWarningString);
}
}
public void Dispose()
{
int num = 1;
try
{
if (m_comCAS == null)
{
return;
}
UCOMIConnectionPointContainer uCOMIConnectionPointContainer = (UCOMIConnectionPointContainer)m_comCAS;
Guid riid = typeof(DConfigurationAccessEvents).GUID;
UCOMIConnectionPoint ppCP = null;
uCOMIConnectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
if (ppCP != null)
{
ppCP.Unadvise(m_intAdviseCookie);
while (num != 0)
{
num = Marshal.ReleaseComObject(ppCP);
}
ppCP = null;
}
for (num = 1; num != 0; num = Marshal.ReleaseComObject(m_comCAS))
{
}
m_comCAS = null;
if (m_CASParams.inObjectManage != null)
{
for (num = 1; num != 0; num = Marshal.ReleaseComObject(m_CASParams.inObjectManage))
{
}
m_CASParams.inObjectManage = null;
}
}
catch
{
}
}
}
public class DictionaryLoader
{
private const string m_strDefaultVendor = "Archestra";
private const string m_strDefaultDictionary = "baseeditor.aadct";
private string m_strDefaultVendorDictionary;
private HybridDictionary m_DictionaryMap;
public int ProcessLocale
{
get
{
IaaDictionary iaaDictionary = (IaaDictionary)m_DictionaryMap[m_strDefaultVendorDictionary];
return iaaDictionary.ProcessLocale;
}
}
public DictionaryLoader()
{
m_DictionaryMap = new HybridDictionary(caseInsensitive: true);
m_strDefaultVendorDictionary = "Archestra:baseeditor.aadct";
m_DictionaryMap.Add(m_strDefaultVendorDictionary, new Dictionary("baseeditor.aadct"));
}
public string GetString(string strVendorDictionary, string strPhraseId)
{
IaaDictionary iaaDictionary = null;
if (strVendorDictionary != null)
{
iaaDictionary = (IaaDictionary)m_DictionaryMap[strVendorDictionary];
if (iaaDictionary == null)
{
int num = strVendorDictionary.IndexOf(":");
if (num != -1)
{
string strVendorName = strVendorDictionary.Substring(0, num);
string text = strVendorDictionary.Substring(num + 1, strVendorDictionary.Length - num - 1);
text = text.ToLower();
if (!text.EndsWith(".aadct"))
{
text += ".xxdct";
}
iaaDictionary = new Dictionary(strVendorName, "", text);
m_DictionaryMap.Add(strVendorDictionary, iaaDictionary);
}
}
}
if (iaaDictionary == null)
{
int count = m_DictionaryMap.Count;
if (count > 0)
{
IaaDictionary[] array = new IaaDictionary[count];
m_DictionaryMap.Values.CopyTo(array, 0);
iaaDictionary = array[count - 1];
}
}
if (iaaDictionary == null)
{
return "";
}
return iaaDictionary[strPhraseId];
}
}
}
namespace ArchestrA.Diagnostics
{
internal static class Logger
{
public static int ErrorCount
{
get
{
if (InitLoggerDll())
{
int errorCount = 0;
int warningCount = 0;
long ftLastError = 0L;
long ftLastWarning = 0L;
int loggerStats = ArchestrA.Diagnostics.NativeMethods.GetLoggerStats(string.Empty, ref errorCount, ref ftLastError, ref warningCount, ref ftLastWarning);
if (loggerStats <= 0)
{
return -1;
}
return errorCount;
}
return -1;
}
}
public static bool IsLoaded { get; private set; }
public static int WarningCount
{
get
{
if (InitLoggerDll())
{
int errorCount = 0;
int warningCount = 0;
long ftLastError = 0L;
long ftLastWarning = 0L;
int loggerStats = ArchestrA.Diagnostics.NativeMethods.GetLoggerStats(string.Empty, ref errorCount, ref ftLastError, ref warningCount, ref ftLastWarning);
if (loggerStats <= 0)
{
return -1;
}
return warningCount;
}
return -1;
}
}
private static bool CheckRegistry { get; set; }
private static bool DomainUnloaded { get; set; }
private static int LoggerClientIdentity { get; set; }
static Logger()
{
LoggerClientIdentity = 0;
CheckRegistry = true;
}
public static void LogConnection(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogConnection(LoggerClientIdentity, errorMessage);
}
}
public static void LogCtorDtor(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogCtorDtor(LoggerClientIdentity, errorMessage);
}
}
public static void LogCustom(int cookie, string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogCustom(LoggerClientIdentity, cookie, errorMessage);
}
}
public static void LogEntryExit(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogEntryExit(LoggerClientIdentity, errorMessage);
}
}
public static void LogError(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogError(LoggerClientIdentity, errorMessage);
}
}
public static void LogInfo(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogInfo(LoggerClientIdentity, errorMessage);
}
}
public static void LogRefCount(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogRefCount(LoggerClientIdentity, errorMessage);
}
}
public static int LogRegisterCustomFlag(string flagName)
{
if (!Initialize())
{
return 0;
}
return ArchestrA.Diagnostics.NativeMethods.RegisterLogFlag(LoggerClientIdentity, 11, flagName);
}
public static int LogRegisterCustomFlagEx(string flagName, int defaultValue)
{
if (!Initialize())
{
return 0;
}
return ArchestrA.Diagnostics.NativeMethods.RegisterLogFlagEx(LoggerClientIdentity, 11, flagName, defaultValue);
}
public static void LogSQL(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogSQL(LoggerClientIdentity, errorMessage);
}
}
public static void LogSetIdentityName(string identityName)
{
if (Initialize())
{
int num = ArchestrA.Diagnostics.NativeMethods.SetIdentityName(LoggerClientIdentity, identityName);
}
}
public static void LogStartStop(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogStartStop(LoggerClientIdentity, errorMessage);
}
}
public static void LogThreadStartStop(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogThreadStartStop(LoggerClientIdentity, errorMessage);
}
}
public static void LogTrace(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogTrace(LoggerClientIdentity, errorMessage);
}
}
public static void LogWarning(string errorMessage)
{
if (Initialize())
{
ArchestrA.Diagnostics.NativeMethods.InternalLogWarning(LoggerClientIdentity, errorMessage);
}
}
public static void ResetLoggerCheck()
{
CheckRegistry = true;
}
private static bool InitLoggerDll()
{
bool flag = IsLoaded;
if (flag)
{
return true;
}
if (CheckRegistry)
{
IntPtr intPtr = IntPtr.Zero;
CheckRegistry = false;
new RegistryPermission(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\\Software\\ArchestrA\\Framework\\Logger").Assert();
try
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\ArchestrA\\Framework\\Logger", writable: false);
if (registryKey != null)
{
string text = Convert.ToString(registryKey.GetValue("InstallPath", string.Empty), CultureInfo.InvariantCulture);
if (text.Length > 0)
{
intPtr = ArchestrA.Diagnostics.NativeMethods.LoadLibraryExW(wParam: new IntPtr(0), lpMdoule: Path.Combine(text, "LoggerDll.dll"), flag: 8);
}
}
}
finally
{
CodeAccessPermission.RevertAssert();
}
flag = intPtr != IntPtr.Zero;
}
IsLoaded = flag;
return flag;
}
private static bool Initialize()
{
if (DomainUnloaded)
{
return false;
}
if (LoggerClientIdentity != 0)
{
return true;
}
if (InitLoggerDll())
{
int hIdentity = 0;
int num = ArchestrA.Diagnostics.NativeMethods.RegisterLoggerClient(ref hIdentity);
LoggerClientIdentity = hIdentity;
if (num != 0 && LoggerClientIdentity != 0)
{
new FileIOPermission(PermissionState.Unrestricted).Assert();
try
{
num = ArchestrA.Diagnostics.NativeMethods.SetIdentityName(LoggerClientIdentity, Assembly.GetExecutingAssembly().GetName().Name);
}
finally
{
CodeAccessPermission.RevertAssert();
}
AppDomain.CurrentDomain.DomainUnload += OnCurrentDomainUnload;
return true;
}
}
return false;
}
private static void OnCurrentDomainUnload(object sender, EventArgs e)
{
UnInitialize();
DomainUnloaded = true;
}
private static void UnInitialize()
{
if (LoggerClientIdentity != 0)
{
int num = ArchestrA.Diagnostics.NativeMethods.UnregisterLoggerClient(LoggerClientIdentity);
LoggerClientIdentity = 0;
}
}
}
internal static class NativeMethods
{
[DllImport("kernel32")]
public static extern IntPtr LoadLibraryExW([MarshalAs(UnmanagedType.LPWStr)] string lpMdoule, IntPtr wParam, int flag);
[DllImport("kernel32")]
internal static extern IntPtr LoadLibraryW([MarshalAs(UnmanagedType.LPWStr)] string lpMdoule);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "REGISTERLOGGERCLIENT", ExactSpelling = true)]
internal static extern int RegisterLoggerClient(ref int hIdentity);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "UNREGISTERLOGGERCLIENT", ExactSpelling = true)]
internal static extern int UnregisterLoggerClient(int hIdentity);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "SETIDENTITYNAME", ExactSpelling = true)]
internal static extern int SetIdentityName(int hIdentity, string strIdentity);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGERROR", ExactSpelling = true)]
internal static extern void InternalLogError(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGWARNING", ExactSpelling = true)]
internal static extern void InternalLogWarning(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGINFO", ExactSpelling = true)]
internal static extern void InternalLogInfo(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGTRACE", ExactSpelling = true)]
internal static extern void InternalLogTrace(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGSTARTSTOP", ExactSpelling = true)]
internal static extern void InternalLogStartStop(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGENTRYEXIT", ExactSpelling = true)]
internal static extern void InternalLogEntryExit(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGTHREADSTARTSTOP", ExactSpelling = true)]
internal static extern void InternalLogThreadStartStop(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGSQL", ExactSpelling = true)]
internal static extern void InternalLogSQL(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGCONNECTION", ExactSpelling = true)]
internal static extern void InternalLogConnection(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGCTORDTOR", ExactSpelling = true)]
internal static extern void InternalLogCtorDtor(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGREFCOUNT", ExactSpelling = true)]
internal static extern void InternalLogRefCount(int hIdentity, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "REGISTERLOGFLAG", ExactSpelling = true)]
internal static extern int RegisterLogFlag(int hIdentity, int nCustomFlag, [MarshalAs(UnmanagedType.LPWStr)] string strFlag);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "REGISTERLOGFLAGEX", ExactSpelling = true)]
internal static extern int RegisterLogFlagEx(int hIdentity, int nCustomFlag, [MarshalAs(UnmanagedType.LPWStr)] string strFlag, int nDefaultVal);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LOGCUSTOM2", ExactSpelling = true)]
internal static extern void InternalLogCustom(int hIdentity, int nCustomFlag, [MarshalAs(UnmanagedType.LPWStr)] string errorMessage);
[DllImport("LoggerDLL.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "GETLOGGERSTATS", ExactSpelling = true)]
internal static extern int GetLoggerStats([MarshalAs(UnmanagedType.LPWStr)] string hostName, ref int errorCount, ref long ftLastError, ref int warningCount, ref long ftLastWarning);
}
}
namespace CASLib
{
[ComImport]
[CompilerGenerated]
[InterfaceType(2)]
[Guid("1859E2AD-59A3-4F24-82D8-EDD1E2129B5C")]
[TypeIdentifier]
public interface DConfigurationAccessEvents
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(1)]
void OnDataChange([MarshalAs(UnmanagedType.Struct)] object Item, [MarshalAs(UnmanagedType.Struct)] object SubItem, [MarshalAs(UnmanagedType.Struct)] object value);
}
[ComImport]
[CompilerGenerated]
[Guid("91DC002C-E2D0-40E8-8418-15965CF0F287")]
[TypeIdentifier]
public interface IConfigurationAccess
{
}
[ComImport]
[CompilerGenerated]
[Guid("EDB7C645-3152-4862-8BBF-AD7A04662CDA")]
[TypeIdentifier]
public interface IConfigurationAccess2 : IConfigurationAccess
{
[DispId(101)]
object Data
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(101)]
[return: MarshalAs(UnmanagedType.Struct)]
get;
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(101)]
[param: In]
[param: MarshalAs(UnmanagedType.Struct)]
set;
}
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(102)]
void SubscribeData([MarshalAs(UnmanagedType.Struct)] object Item, [MarshalAs(UnmanagedType.Struct)] object SubItem);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(103)]
void UnsubscribeData([MarshalAs(UnmanagedType.Struct)] object Item, [MarshalAs(UnmanagedType.Struct)] object SubItem);
void _VtblGap1_2();
[DispId(205)]
object GalaxyBrowser
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[DispId(205)]
[return: MarshalAs(UnmanagedType.IUnknown)]
get;
}
}
}