" /> Read values from objects in CME - Genesys CTI User Forum

Author Topic: Read values from objects in CME  (Read 4251 times)

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline MatSzafraniec

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Read values from objects in CME
« on: June 13, 2018, 12:21:19 PM »
Advertisement
Hi,

I've created new section with one parameter in Environment -> Application -> application_folder.
[img width=640 height=370]http://i68.tinypic.com/107q7vm.png[/img]

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

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Read values from objects in CME
« Reply #1 on: June 13, 2018, 01:27:00 PM »
Nope, you need to do something with PSDK to access it.

Enviado de meu E6633 usando o Tapatalk


Offline MatSzafraniec

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Read values from objects in CME
« Reply #2 on: June 18, 2018, 07:43:27 AM »
[quote author=cavagnaro link=topic=11010.msg50028#msg50028 date=1528896420]
Nope, you need to do something with PSDK to access it.

Enviado de meu E6633 usando o Tapatalk
[/quote]

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

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Read values from objects in CME
« Reply #3 on: June 18, 2018, 12:17:21 PM »
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


Offline genesysguru

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: 12
    • Genesys Guru Blog
Re: Read values from objects in CME
« Reply #4 on: June 18, 2018, 12:17:45 PM »
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.

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1419
  • Karma: 18
Re: Read values from objects in CME
« Reply #5 on: June 20, 2018, 08:59:07 PM »
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.


Offline MatSzafraniec

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Read values from objects in CME
« Reply #6 on: November 14, 2018, 11:16:07 AM »
Hi, I'm back :)

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 [i]1TestPFR[/i] in Business Attributes which contains two values. I want to read this.
[img width=640 height=260]http://i65.tinypic.com/2zs4gp5.png[/img]

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)
[img]http://i64.tinypic.com/2cmxg8k.png[/img]

[quote]
                Platform.Commons.Collections.KeyValueCollection filterKey = new Platform.Commons.Collections.KeyValueCollection
                {
                    { "object_dbid", 1304 }
                };

                RequestReadObjects requestReadObjects =
                        RequestReadObjects.Create(
                        (int)CfgObjectType.CFGFolder,
                            filterKey);
[/quote]

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"

[quote]
                Platform.Commons.Collections.KeyValueCollection filterKey = new Platform.Commons.Collections.KeyValueCollection
                {
                    { "name", "Business Attributes" }
                };

                RequestReadObjects requestReadObjects =
                        RequestReadObjects.Create(
                        (int)CfgObjectType.CFGFolder,
                            filterKey);
[/quote]

But how can I find values from [i]1TestPFR[/i]? Maybe I try to find unapropriate objectType? Unfortunately, any of available [url=http://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/ConfigLayerObjectsList]Layer objects[/url] not fit directly. Have you any idea, how to handle with this?
« Last Edit: November 14, 2018, 11:51:12 AM by MatSzafraniec »

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2755
  • Karma: 44
Re: Read values from objects in CME
« Reply #7 on: November 14, 2018, 11:39:49 AM »
use CfgQuery instead of RequestReadObject

Offline MatSzafraniec

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Read values from objects in CME
« Reply #8 on: November 14, 2018, 02:10:23 PM »
[quote author=Kubig link=topic=11010.msg50911#msg50911 date=1542195589]
use CfgQuery instead of RequestReadObject
[/quote]

Thank you for your respond.

Could you describe something more? I read [url=https://docs.genesys.com/Documentation/PSDK/9.0.x/Developer/UsingtheCOMAB#t-1]docs[/url], but can't find how initialize query and how to set filter on object which I want to find.

[quote]IProtocol protocol = confServerProtocol;
IConfService service = ConfServiceFactory.CreateConfService(protocol);
CfgQuery cfgQuery = new CfgQuery(service);[/quote]

Marked as best answer by MatSzafraniec on November 16, 2018, 12:13:32 AM

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Read values from objects in CME
« Reply #9 on: November 14, 2018, 03:32:40 PM »
Check ConfServer logs to get an idea on what kind of Query you need


Example


At CfgServer logs I see:
[code]



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')][/code]


Meaning that WDE is looking for a[font=verdana]  CfgEnumerator when looking for a Business Attribute, now change WDE for any app that consumes what you need.[/font]


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

[code]Namespaces ► Genesyslab.Platform.ApplicationBlocks.ConfigurationObjectModel.QueriesC#Visual BasicVisual C++[/code]

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

[code]
            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();


[/code]

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


And done
« Last Edit: November 14, 2018, 03:53:46 PM by cavagnaro »

Offline MatSzafraniec

  • Newbie
  • *
  • Posts: 10
  • Karma: 1
Re: Read values from objects in CME
« Reply #10 on: November 15, 2018, 10:24:15 AM »
Thank you, it works. I've share some code for anyone who will have that problem in future.

[quote]
[color=green]//Connect to ConfServer[/color]
            ConfServerProtocol confServerProtocol =
                    new ConfServerProtocol(
                        new Endpoint(
                            "default",
                            "someIP",
                            somePortNumber));

                confServerProtocol.UserName = "someUserName";
                confServerProtocol.UserPassword = "somePassword";

                IProtocol protocol = confServerProtocol;
                protocol.Open();
               
[color=green]//Retrive object from ConfServer (I knew[/color] [b]ID[/b] [color=green]of it)[/color]
                IConfService confService = ConfServiceFactory.CreateConfService(protocol);
                ICfgObject cfgObject = confService.RetrieveObject([b]1304[/b], CfgObjectType.CFGEnumerator);

[color=green]//Get values from retrieved object[/color]
                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();
[/quote]
« Last Edit: November 20, 2018, 11:03:03 AM by MatSzafraniec »

Offline msd86911

  • Newbie
  • *
  • Posts: 20
  • Karma: 4
Re: Read values from objects in CME
« Reply #11 on: November 19, 2018, 10:48:06 PM »
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, [b]IConfigurationService configService[/b], IAgent agentObject)
        {
            this.container = container;
            [b]this.configService = configService;[/b]
            this.channelManager = channelManager;
            agent = agentObject;
            viewManager = viewManagerObject;
            wdeApp = configService.RetrieveObject<CfgApplication>(new CfgApplicationQuery() { Name = configService.ApplicationName });
            this.log = container.Resolve<ILogger>().CreateChildLogger("Initialization");
            staticLog = container.Resolve<ILogger>().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;
        }
    }