Read values from objects in CME

Hi,

I’ve created new section with one parameter in Environment → Application → application_folder.

http://i68.tinypic.com/107q7vm.png

Is there any way to read this value from Interaction Workspace application? Cannot find (or look for it badly) any reference in documentation.

Regards,
Matthew

Nope, you need to do something with PSDK to access it.

Enviado de meu E6633 usando o Tapatalk

Ok, but where can I find any doc which explain how to achieve this?

Docs.genesyslab.com is one way, other is that similar questions have been asked here in the forum so you can search too

Enviado de meu E6633 usando o Tapatalk

Basically you need to use the PDSK to connect to the configuration layer (confserv or a proxy), read the application object and then iterate through the flexible and user attribute properties.

Platform SDK will be easiest way to move forward.

I had a code from a while back where we were using it to retrieve CME values. The version is old, but the concept should be pretty much the same.

Hi, I’m back :slight_smile:

I can connect to ConfServer via PSDK, studied a lot of docs, but can’t handle with problem described below.

I’ve created new object 1TestPFR in Business Attributes which contains two values. I want to read this.

http://i65.tinypic.com/2zs4gp5.png

I tried to read this by set filterKey object_dbid. If I right understand, this is value after object name (in red box on image below)

http://i64.tinypic.com/2cmxg8k.png

Platform.Commons.Collections.KeyValueCollection filterKey = new Platform.Commons.Collections.KeyValueCollection { { "object_dbid", 1304 } };
            RequestReadObjects requestReadObjects =
                    RequestReadObjects.Create(
                    (int)CfgObjectType.CFGFolder,
                        filterKey);</blockquote>

But when I did it, ConfServer returns me list of all folders. My request works properly when I set key on name and search phrase f.e. “Business Attributes”

Platform.Commons.Collections.KeyValueCollection filterKey = new Platform.Commons.Collections.KeyValueCollection { { "name", "Business Attributes" } };
            RequestReadObjects requestReadObjects =
                    RequestReadObjects.Create(
                    (int)CfgObjectType.CFGFolder,
                        filterKey);</blockquote>

But how can I find values from 1TestPFR? Maybe I try to find unapropriate objectType? Unfortunately, any of available Layer objects not fit directly. Have you any idea, how to handle with this?

use CfgQuery instead of RequestReadObject

Thank you for your respond.

Could you describe something more? I read docs, but can’t find how initialize query and how to set filter on object which I want to find.

IProtocol protocol = confServerProtocol; IConfService service = ConfServiceFactory.CreateConfService(protocol); CfgQuery cfgQuery = new CfgQuery(service);

Check ConfServer logs to get an idea on what kind of Query you need

Example

At CfgServer logs I see:





11:03:06.899 Trc 04541 Message MSGCFG_GETOBJECTINFO received from 1060 (InteractionWorkspace  'WDE')


  MSGCFG_GETOBJECTINFO
  attr: IATRCFG_REQUESTID           value:   60
  attr: BATRCFG_FILTER              value:   
  attr: IATRCFG_OBJECTTYPE          value:   35 [CfgEnumerator]


  Filter :
   key: name                        type:    [String], value : Attach_WDE
   key: tenant_dbid                 type:    [Integer], value : 101
   key: object_path                 type:    [Integer], value : 0
   key: read_folder_dbid            type:    [Integer], value : 0
  Query  : CfgBaseTenant[@DBID = 101]/enumerators/*[ (@name = 'Attach_WDE')]

Meaning that WDE is looking for a CfgEnumerator when looking for a Business Attribute, now change WDE for any app that consumes what you need.

Now at PSDK docs you search for CfgEnumerator type and available Queries:

Namespaces ► Genesyslab.Platform.ApplicationBlocks.ConfigurationObjectModel.QueriesC#Visual BasicVisual C++

And then you do a simple query based on the object type:


            CfgEnumeratorQuery q2 = new CfgEnumeratorQuery(confService);
            q2.Name = "Attach_WDE";
            CfgEnumerator qq2 = q2.ExecuteSingleResult();



CfgEnumeratorValueQuery qqq2 = new CfgEnumeratorValueQuery(confService);
            qqq2.EnumeratorDbid = qq2.DBID;


            var qqqq = qqq2.Execute();



And you read the qqqq collection as you would do normally (for …)

And done

Thank you, it works. I’ve share some code for anyone who will have that problem in future.

//Connect to ConfServer ConfServerProtocol confServerProtocol = new ConfServerProtocol( new Endpoint( "default", "someIP", somePortNumber));
            confServerProtocol.UserName = "someUserName";
            confServerProtocol.UserPassword = "somePassword";

            IProtocol protocol = confServerProtocol;
            protocol.Open();

//Retrive object from ConfServer (I knew ID of it)
IConfService confService = ConfServiceFactory.CreateConfService(protocol);
ICfgObject cfgObject = confService.RetrieveObject(1304, CfgObjectType.CFGEnumerator);

//Get values from retrieved object
CfgEnumeratorValueQuery qqq2 = new CfgEnumeratorValueQuery(confService)
{
EnumeratorDbid = qq2.DBID
};

            var qqqq = qqq2.Execute();

            foreach(var g in qqqq)
            {
                Debug.WriteLine("**** " + g.Name);
                Debug.WriteLine("**** " + g.ObjectPath);
            }

            protocol.Close();</blockquote>

if you are using Interaction Workspace application then the application already creating a connection to Configuration server or configuration proxy to get all its data you can use it like below instead of reopening new connection (consume more resources) and deal with the headache of managing connection disconnection issues.
In module initialization you can use:
readonly IConfigurationService configService;
public XXXXExtensionModule(IObjectContainer container, IViewManager viewManagerObject, IChannelManager channelManager, IConfigurationService configService, IAgent agentObject)
{
this.container = container;
this.configService = configService;
this.channelManager = channelManager;
agent = agentObject;
viewManager = viewManagerObject;
wdeApp = configService.RetrieveObject(new CfgApplicationQuery() { Name = configService.ApplicationName });
this.log = container.Resolve().CreateChildLogger(“Initialization”);
staticLog = container.Resolve().CreateChildLogger(“Initialization”);
}

And here is one of my favorite functions that try to retrieve value from agent/agent group/application then tenant until it is found

//////////////////////////////////////////////////////
// Retrieve option from different configuration levels
public static string retrieveOption(string optionName, string section)
{
// Checking agent for the option
if (agent.ConfPerson.UserProperties.ContainsKey(section) && agent.ConfPerson.UserProperties.GetAsKeyValueCollection(section).ContainsKey(optionName))
return agent.ConfPerson.UserProperties.GetAsKeyValueCollection(section).GetAsString(optionName);
// Checking Agent groups for the option
for (int i = 0; agent.AgentGroupsForAgent.Count > i; i++)
{
if (agent.AgentGroupsForAgent[i].GroupInfo.UserProperties.ContainsKey(section) && agent.AgentGroupsForAgent[i].GroupInfo.UserProperties.GetAsKeyValueCollection(section).ContainsKey(optionName))
return agent.AgentGroupsForAgent[i].GroupInfo.UserProperties.GetAsKeyValueCollection(section).GetAsString(optionName);
}
// Checking WDE application for the option
if (wdeApp.Options.ContainsKey(section) && wdeApp.Options.GetAsKeyValueCollection(section).ContainsKey(optionName))
return wdeApp.Options.GetAsKeyValueCollection(section).GetAsString(optionName);
// Checking Tenant for the option
else if (agent.Tenant.UserProperties.ContainsKey(section) && agent.Tenant.UserProperties.GetAsKeyValueCollection(section).ContainsKey(optionName))
return agent.Tenant.UserProperties.GetAsKeyValueCollection(section).GetAsString(optionName);
else
return null;
}
}