I'm working on a simple app that sets or modifies resource properties through SiteConfigFreeThreaded.
roughly this is how i'm retrieving the values:
using (SiteConfigFreeThreaded siteConfig = new SiteConfigFreeThreaded())
{
siteConfig.Initialize(siteName);
ADODB.Field field;
ADODB._Recordset properties = (ADODB._Recordset)siteConfig.Fields[resourceName].Value;
field = properties.Fields[propertyName];
}
I'm running into a problem when i try to set a new property that should be an array or simplelist. i can't seem to figure out how to tell which properties should be arrays/simplelists. i tried calling GetIfCollection on field.Value but if the property is "new", field.Value is "~0" and GetIfCollection returns a string, not an array or simplelist.....
Can anyone point me in the right direction on this
Michael.

How do you know what Resource Properties are arrays/SimpleLists?
Nadav Popplewell
Are you working with a custom property you created Or do you want to dynamically identify the value of a property to be an array vs. simplelist.
-Max
Tigerwood2006
I'm working with the standard properties like:
s_NonSecureHostname
s_SecureHostname
s_VirtualRootName
s_DirectoryIndexFiles
s_IPAddress
s_IPPort
s_LocalDomain
s_LogFileCodePage
s_LogFileDirectory
s_LogFilePeriod
s_LogType
s_SecureBindings
s_SecureIPPort
s_ServerBindings
s_URLEncodingCodePage
s_UseHostName
s_WebServerFullName
s_WebServerInstance
s_WebServerMachine
s_WebServerName
When i "create" these properties for a new application, i can't figure out (programmatically) how to tell if the property should be a string, an array or a simplelist....
WizMan
Here's the relevant code:
using (SiteConfigFreeThreaded siteConfig = new SiteConfigFreeThreaded())
{
siteConfig.Initialize(siteName);
ADODB.Field field;
ADODB._Recordset properties = (ADODB._Recordset)siteConfig.Fields[resourceName].Value;
field = properties.Fields[propertyName];
Dictionary fieldProperties = siteConfig.GetResourcePropAttrib(resourceName, propertyName);
if ((int)fieldProperties["i_VarType"] == 8200)
{
ArrayList origValueList = new ArrayList();
if (!overwrite)
{
if ((string)field.Value != "~0")
{
object fieldValue = field.Value.ToString();
origValueList = new ArrayList((object[])siteConfig.MakeArrayFromString(fieldValue));
}
}
origValueList.Add(propertyValue);
object objValueList = origValueList.ToArray(typeof(string));
propertyValue = (string)siteConfig.MakeStringFromArray(objValueList);
}
SetProperty(field, propertyValue);
siteConfig.SaveConfig();
}
This code works fine when propertyName corresponds to one of the extended properties (like s_IPAddress) but GetResourcePropAttrib throws a EOF/BOF exception when propertyName is one of the base properties (like s_ProgIDPUP).
As a bit of background, this i part of a command line app that enables creating and updating Commerce Server resources and their properties without having to use the PUP process. The list of properties that we're setting is based on examining the MSCS_Admin database after running a PUP install.
If the "base" properties like s_ProgIDPUP don't actually need to be set for CS to function properly, I can remove them from the script and ignore this case in my code.
Michael.
John Portnov
Look at the i_Vartype if it's 8200 then it's an array of string.
-Max
meho
Any chance this inconsistency will be addressed later on or is this going be "one of those things"
A.Carter
hmmm looks like the siteconfig object has changed some from the old days
.
Here try the following:
try
{
Dictionary fieldProperties = siteConfig.GetResourcePropAttrib(resourceName, propertyName);
}
catch (COMException comEx)
{
if (!comEx.Message.Contains("EOF"))
{
// log error
}
}
catch (Exception ex)
{
// log these errors
}
What happens is that the GetResourcePropAttrib makes a sql call and returns no records so when the body of the GetResourcePropAttrib method trys to convert the recordset into a dictionary object it fails.
Good luck,
-Max
Thunder2002
I think we may have to live with this
.
-Max
Jason Zhang
I'm calling siteConfig.GetResourcePropAttrib(resourceName, propertyName) to get the properties of the field in order to examine the i_VarType and it works most of the time.
The problem is when i call it with a property that's a field on the resource itself, like s_ProgIDPUP i get this exception:
"Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."
Should these properties exist in MSCS_Admin.ResourceProps or is there a way to identify these fields so i don't try to call GetResourcePropAttrib on them
Thanks,
Michael.
aliasx
Can you send or post your code to exactly what you are trying to do
-Max