Author Topic: Trying to read from CME >Application>options in.Net  (Read 4984 times)

Offline Vegeta

  • Newbie
  • *
  • Posts: 23
  • Karma: 0
Trying to read from CME >Application>options in.Net
« on: June 22, 2016, 12:52:00 PM »
Hi Genesys Wizards,

I am trying to read the values from CME servers Application -> Properties -> Options (via .Net PSDK API)

I am trying to read it manually like Configuration>environment>applications>Desktop ( Right click on listed application Name>properties>options).

if its the cfgapplication object , then I am looking at a method called getoptions() to probably achieve the same in JAVA
URL :http://www.genesyslab.info/repository/PSDK/8.0-Java_API_Reference/com/genesyslab/platform/applicationblocks/com/objects/CfgApplication.html#getOptions()

But I don't see a similar method listed in .Net PSDK chm file :(

So I tried to do it like the below in .net as a first step I was trying to read the application Name but no luck. (then I would want to read the options )

Could you please advice if am missing anything or is there a equivalent method like getoptions in .net?

[code]

var CfgapplicQuery = new CfgApplicationQuery(service) { Name = "MY APPLIC NAME"};
var CfgApplication_Query_Values = CfgapplicQuery.Execute();
foreach (CfgApplication values in CfgApplication_Query_values)
{
MessageBox.Show(Values.Name); // I would expect it to display the Applic Name passed in query while it isn't!!
}
[/code]
« Last Edit: June 22, 2016, 12:53:53 PM by Vegeta »

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Trying to read from CME >Application>options in.Net
« Reply #1 on: June 22, 2016, 02:30:04 PM »
You have to work with CfgApplication object to allow using method getOptions(). Did you try to retype the retrieved object to the CfgApplication?

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Trying to read from CME >Application>options in.Net
« Reply #2 on: June 23, 2016, 06:50:55 AM »



That code works for me..

In .Net to get the options use .Options


                [code]var CfgapplicQuery = new CfgApplicationQuery(confService) { Name = "Stat_Server" };
                var CfgApplication_Query_Values = CfgapplicQuery.Execute();
                foreach (CfgApplication values in CfgApplication_Query_Values)
                {
                    Console.WriteLine(values.Name);
                    var kvLog = values.Options["Log"];
                    if (kvLog != null)
                    {
                    }
                }[/code]

Offline daniel_san

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
Re: Trying to read from CME >Application>options in.Net
« Reply #3 on: June 24, 2016, 07:05:22 AM »
Another way to do the same...

CfgApplication app = configService.MyApplication;

And then, app.UserProperties (annex) , appOptions (options)

Regards!


Offline Vegeta

  • Newbie
  • *
  • Posts: 23
  • Karma: 0
Re: Trying to read from CME >Application>options in.Net
« Reply #4 on: June 29, 2016, 01:56:57 PM »
[quote author=PeteHoyle link=topic=9681.msg43811#msg43811 date=1466664655]



That code works for me..

In .Net to get the options use .Options


                [code]var CfgapplicQuery = new CfgApplicationQuery(confService) { Name = "Stat_Server" };
                var CfgApplication_Query_Values = CfgapplicQuery.Execute();
                foreach (CfgApplication values in CfgApplication_Query_Values)
                {
                    Console.WriteLine(values.Name);
                    var kvLog = values.Options["Log"];
                    if (kvLog != null)
                    {
                    }
                }[/code]
[/quote]

Thanks PeteHoyle :) with your code I got some idea how to do this .. :)

Offline Vegeta

  • Newbie
  • *
  • Posts: 23
  • Karma: 0
Re: Trying to read from CME >Application>options in.Net
« Reply #5 on: June 29, 2016, 01:58:18 PM »
Thanks Kubig and Daniel San for your responses.

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Trying to read from CME >Application>options in.Net
« Reply #6 on: September 20, 2017, 12:54:21 AM »
[quote author=daniel_san link=topic=9681.msg43821#msg43821 date=1466751922]
Another way to do the same...

CfgApplication app = configService.MyApplication;

And then, app.UserProperties (annex) , appOptions (options)

Regards!
[/quote]


Need a clarification here...this code would be for WDE, right? [color=rgb(51, 51, 51)][font=Arial][size=13px]IConfigurationService?[/size][/font][/color]

Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Trying to read from CME >Application>options in.Net
« Reply #7 on: September 21, 2017, 06:40:49 AM »
Yes, just for WDE.

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Trying to read from CME >Application>options in.Net
« Reply #8 on: September 21, 2017, 02:28:32 PM »
I have made the following code to read options from an app (URS option has URI and other values)
APP
  |__> URL1
            |__>URI: [url=http://www.yahoo.com]http://www.yahoo.com[/url]
            |__>q=123456


[code]

IConfService confService = ConfServiceFactory.CreateConfService(p);
            CfgApplicationQuery cfgapp = new CfgApplicationQuery(confService) { Name = "SampleAPP" };
            //var cfgApp_Values = cfgapp.Execute();


            //foreach (CfgApplication values in cfgApp_Values)
            //{
            //    Console.WriteLine(values.Name);
            //    writeToLogArea("Option values: " + values.Name);
            //}


            CfgApplication app = confService.RetrieveObject<CfgApplication>(cfgapp);




            KeyValueCollection kvp1 = new KeyValueCollection(app.Options);
            writeToLogArea("SampleAPP Options: " + kvp1.ToString());


            //kvp1.GetAsKeyValueCollection("URL1");


            foreach (DictionaryEntry x in kvp1)
            {
                if (x.Key.ToString().StartsWith("URL")) {
                    writeToLogArea("URL Section >" + x.Key + ":" + x.Value);
                    KeyValueCollection values = new KeyValueCollection();
                    values = kvp1.GetAsKeyValueCollection(x.Key.ToString());
                    foreach(DictionaryEntry val in values)
                    {
                        writeToLogArea("URL Parameters > " + val.Key + ":" + val.Value);
                        if(val.Key.ToString().StartsWith("URI"))
                        writeToLogArea("URI for " + x.Key + " is " + val.Value.ToString());
                    }
                   
            }
            }
[/code]


What do you think? Works for me but wondering if there is a more effective way?