Author Topic: Accessing CME via ActiveX  (Read 17248 times)

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« on: August 17, 2007, 03:44:59 PM »
Hi Guys,

Some time ago ( 2 years or so ) I wrote configuration synchronizator for A4400 and Genesys. I found COM component called COMCfgManager. It allowed me to manipulate configuration objects ( create, delete, update ) in configuration database. As far as I know it is unsupported but it works as this is foundation for all wizards. Here is sample code to log in to CME. When I find the rest of this project I will post some more usefull demo

Dim y As COMCFGMGRLib.COMCfgManager
   
Set y = New COMCfgManager

y.Connect "GenesysCore01", "9020", CFGSCE, "default", "default", "password"
y.Disconnect
Set y = Nothing

One more thing this api is very memory consuming under .NET

PS.

In Platform SDK there is separate class for communicating directly with OCS. Also on gendev there is sample how to use it to build web base OCM.
« Last Edit: August 17, 2007, 03:46:58 PM by bublepaw »

Offline dbudi

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Accessing CME via ActiveX
« Reply #1 on: August 20, 2007, 06:52:50 AM »
Hi bublepaw,

I am trying to make a function to change password in CME using ActiveX app - because our project deployment does not allow installing CME to every agent just for changing password only.

Is this possible using COMCfgManager? If you have a sample code pls post it here.

Many thanks in advance

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Accessing CME via ActiveX
« Reply #2 on: August 21, 2007, 11:02:12 AM »
I don't think you can actually pro-actively change something using ActiveX in CME. At least I did not know you could, because I was under the impression it was a read-only component.

If you figure out how to do it, can you please share it with the rest of us?

Best regards,
Vic

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #3 on: August 21, 2007, 03:39:57 PM »
Hi,

I didn't find old code but luckily I've managed to recreate some simple operations. First of all program is based on "COMCfgMgr 1.4.1 Type Library" which is instaled with wizards ( by default in \Program Files\Common Files\GCTI\CFG Wizards y.x ).

All samples are C# because I don't have VB6 installed but it should be fairly easy to convert them to VB

1) Changing password

[code]
{
      COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "user", "password");
      // this line is need if You don't want to use standard genesys window for changing password
      server.UseGUIElements = 0;
      server.ChangePassword("old password", "new password");
      server.Disconnect();
}
[/code]

2) Finding some object

[code]
{    COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "user", "password");
      COMCFGMGRLib.ICfgQuery query = server.CreateQuery();
      // what we want to find
      query.ObjectType = COMCFGMGRLib.enum_COMCfgObjectType.COMCFGApplication;
      // some filters to narrow search
      object value;
      // we will be searching for all OCS servers
      value = ( object )COMCFGMGRLib._CfgAppType.CFGCMServer;
      query.AddFilterValue(COMCFGMGRLib._CfgFilterType.FILTER_APP_TYPE , ref value);
      // 1,0 - wait for query to finish for infinity
      query.Execute(1, 0);
      if (query.Count > 0) {
        // we found something
        // result is 1 based array
        for (int i = 1; i <= query.Count ;i++) {
          COMCFGMGRLib.ICfgObject foundObject = (COMCFGMGRLib.ICfgObject)query[i];

          Console.WriteLine(" Object :{0} dbid = {1} ", foundObject.Name, foundObject.DBID);
        }
      }
      server.Disconnect();
}
[/code]

I will post soon some other samples for changing data.

Victor - as for changing object - this api is internaly used by all wizards so it must be able to change data in configserver :)

Paul
« Last Edit: August 21, 2007, 03:48:58 PM by bublepaw »

Offline dbudi

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Accessing CME via ActiveX
« Reply #4 on: August 22, 2007, 02:23:28 AM »
Hi bublepaw,

Thanks for your sample code. I will try the ChangePassword() method. Looking at the class method, there seems to be no return value to check if the change password is successful or not.. but still a very good solution for web based CTI app. Great code!

Regards,

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #5 on: August 23, 2007, 08:43:00 AM »
Hi dbudi,

When there is an error during password change method will throw exception. In C# in is enough to put ChangePassword inside try/catch block. In VB "On Error ..." statement should work

Paul

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #6 on: August 30, 2007, 04:03:51 PM »
Hi all,

Here are some more examples to mess with configuration server.

1) adding new object

[code]
{
      COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "default", "password");
      // here we create new empty DN object
      COMCFGMGRLib.ICfgObject newDN = server.CreateObject(COMCFGMGRLib.enum_COMCfgObjectType.COMCFGDN);
      // object name
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_number] = "112345";
      // switchDBID contains id of switch in which we create object - can be found using previous sample
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_switchDBID] = 101;
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_switchSpecificType] = 1;
      // new DN is extension
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_type] = 1;
      // filed Register is set to true
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_registerAll] = 2;
      // route type is set to default
      newDN[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_routeType] = 1;
      // we send update request to configuration server
      newDN.Create(server);
      server.Disconnect();
}
[/code]

2) modifying and deleting object - before we can update or modify object we have to acquire ICfgObject interface for our instance - this can be done by using query

[code]
{
    COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "default", "password");
      // first lets find object to modify/delete
      COMCFGMGRLib.ICfgQuery query = server.CreateQuery();
      query.ObjectType = COMCFGMGRLib.enum_COMCfgObjectType.COMCFGDN;
      object value;
      object value2;
      // DN number
      value = "112345";
      query.AddFilterValue(COMCFGMGRLib._CfgFilterType.FILTER_DN_NUMBER, ref value);
      // switch to which object belongs
      value2 = 101;
      query.AddFilterValue(COMCFGMGRLib._CfgFilterType.FILTER_SWITCH_DBID, ref value2);
      // 1,0 - wait for query to finish for infinity
      query.Execute(1, 0);
      if ( query.Count > 0 ) {
        // we found our object
        // lets modify it
        COMCFGMGRLib.ICfgObject objectToChange = (COMCFGMGRLib.ICfgObject)query[1];
        // change fileds values
        // here we change alias field
        objectToChange[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgDN_name] = "New_alias";
        // send update to server
        objectToChange.Update();
        // we no longer need this object so lets delete it
        objectToChange.Erase();
      }
      server.Disconnect();
}
[/code]

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Accessing CME via ActiveX
« Reply #7 on: August 31, 2007, 07:50:23 AM »
bubblepaw,

:o :o :o :o :o :o :o :o :o :o

Nice!!! This will save us hundreds of hours adding and deleting new DNs. Damn, why didn't I think of it. Of course, if Wizards can do it, there must be an interface out there somewhere... I am very uneasy about having people touch configuration manager, because it creates a potential for total havoc. (imagine a disgruntled employee with a supervisor or admin access!)

This is ingenious!!!

Let me prepare a tool that would easily add DNs to config server - a proof of concept if you will!

So, I see we can add DNs... How about modifying existing one?

Best regards,
Vic



Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #8 on: August 31, 2007, 07:12:42 PM »
Victor,

Code for modifying DN's is in second example. The only problem is that not all fields can be modified - for example if You want to change number or type of DN You have to first delete it and then create it with new number or new type. There is also some more work if You want to create folders and put newly created objects in those folder or You want to create link to object like in places but I will try to cover this topic in next tutorial :).

Also when writing those samples I found that in version 7.5 there is new method for update that takes xml as parameter - I will check if this is the same xml as one generated by configuration export wizard - if so it would be much simpler to write tool for modifying dn's

BR

Paul

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Accessing CME via ActiveX
« Reply #9 on: September 03, 2007, 06:40:03 AM »
Hi, bubblepaw,

I have been looking at this for the last few days, and it seems like there is a lot of possibilities there (Active X 7.0)
I cannot find a way to create new section for application object or add some keyword:value inside that section.

I was thinking about using it to modifying someof the options for Genesys applications...

As for 7.5 - what are you using?

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Accessing CME via ActiveX
« Reply #10 on: September 05, 2007, 04:15:20 AM »
I tried it and it works, but somehow I cannot figure out how to add skill to a person.

[code]        COMCFGMGRLib.COMCfgManagerClass server = new
COMCFGMGRLib.COMCfgManagerClass();
          server.Connect(ServerName.Text, ServerPort.Text,
COMCFGMGRLib._CfgAppType.CFGSCE, AppName.Text, UserId.Text, UserPaswd.Text);
          // here we create new empty DN object
          COMCFGMGRLib.ICfgObject newSkill =
server.CreateObject(COMCFGMGRLib.enum_COMCfgObjectType.CFGLINKSkillLevel);
          // object name
          newSkill[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgSkillLevel] =
128;
          newSkill[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgSkillLevel_level]
= 2;
          newSkill[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgSkillLevel_skillDBID]
= 122;

          newSkill.Create(server);
          server.Disconnect();
[/code]

and in config server, it seems like it is retrieving some info from config server and ...does nothing...
Any pointers?

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #11 on: September 05, 2007, 12:22:23 PM »
Hi Victor,

Here is sample code to modify application options. You need to add additional activex objects from ComKVList 1.0 Type Library

[code]
{
      COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "default", "password");
      // first lets find object to modify/delete
      COMCFGMGRLib.ICfgQuery query = server.CreateQuery();
      query.ObjectType = COMCFGMGRLib.enum_COMCfgObjectType.COMCFGApplication;
      object value;
      // application name
      value = "DEV_MS_PRI";
      query.AddFilterValue(COMCFGMGRLib._CfgFilterType.FILTER_NAME, ref value);
      // 1,0 - wait for query to finish for infinity
      query.Execute(1, 0);
      if ( query.Count > 0 ) {
        // we found our object
        // lets modify it
        COMCFGMGRLib.ICfgObject objectToChange = (COMCFGMGRLib.ICfgObject)query[1];
        // change fileds values
        COMKVLISTLib.IKVList sections = ( COMKVLISTLib.IKVList )objectToChange[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgApplication_options];
        for ( int i = 1; i <= sections.Count; i++ ) {
          Console.WriteLine("Section : {0}", sections.get_Pair(i).Key);
          COMKVLISTLib.IKVList options = ( COMKVLISTLib.IKVList )sections.get_Pair(i).Value;
          for ( int j = 1; j <= options.Count; j++ ) {
            Console.WriteLine(" key({0}) = {1}", options.get_Pair(j).Key, options.get_Pair(j).Value);
          }
          if ( sections.get_Pair(i).Key == "log" ) {
            // lets add some options
            options.AddValue("debug", "stderr");
            // lets modify some
            COMKVLISTLib.IKVPair option = options.FindPair("verbose");
            if ( option != null ) {
              option.Value = "debug";
            }
            // lets delete some
            options.RemovePairByKey("all");
          }
        }
        // update all sections/options
        objectToChange[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgApplication_options] = sections;
        // send update to server
        objectToChange.Update();
      }
      server.Disconnect();
}
[/code]

BR

Paul
« Last Edit: September 05, 2007, 12:37:20 PM by bublepaw »

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Accessing CME via ActiveX
« Reply #12 on: September 05, 2007, 01:02:31 PM »
Hi,

Next samples covers adding skill to agent object

[code]
{
      COMCFGMGRLib.COMCfgManagerClass server = new COMCFGMGRLib.COMCfgManagerClass();
      server.Connect("server", "port", COMCFGMGRLib._CfgAppType.CFGSCE, "default", "default", "password");
      // first lets find agent to modify skills
      COMCFGMGRLib.ICfgQuery query = server.CreateQuery();
      query.ObjectType = COMCFGMGRLib.enum_COMCfgObjectType.COMCFGPerson;
      object value;
      // person username
      value = "agent1";
      query.AddFilterValue(COMCFGMGRLib._CfgFilterType.FILTER_USER_NAME, ref value);
      // 1,0 - wait for query to finish for infinity
      query.Execute(1, 0);
      if ( query.Count > 0 ) {
        // we found our person
        // lets modify it
        COMCFGMGRLib.ICfgObject objectToChange = (COMCFGMGRLib.ICfgObject)query[1];
        // list of skills
        COMCFGMGRLib.ICfgFolder skills = ( COMCFGMGRLib.ICfgFolder )objectToChange[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgPerson_agentInfo_skillLevels];
        // lets create skill assigment object
        COMCFGMGRLib.ICfgObject skill = server.CreateObject(COMCFGMGRLib.enum_COMCfgObjectType.CFGLINKSkillLevel);
        // skill level
        skill[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgSkillLevel_level] = 6;
        // skill id retrived with another query
        skill[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgSkillLevel_skillDBID] = 101;
        skill.Create(server);
        skills.Add(skill);
        // very important line :) - we need to assign modified list of skills
        objectToChange[COMCFGMGRLib.enum_CFG_PropertyID.PID_CfgPerson_agentInfo_skillLevels] = skills;
        // send update to server
        objectToChange.Update();
      }
      server.Disconnect();
    }
}
[/code]

BR

Paul

PS 

Victor mayby we can move our converstation to separate topic called "Configuration modification" ?
« Last Edit: September 05, 2007, 01:04:12 PM by bublepaw »

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Re: Accessing CME via ActiveX
« Reply #13 on: September 06, 2007, 02:01:27 AM »
Paul,

ok, you are a freaking genuis!!!! I am looking throught the code and I am wondering: how the hell did you figure you need ( (COMCFGMGRLib.ICfgFolder ) ? Did some Russian programmer visited you in your sleep and told you about it?

Best regards,
Vic

Offline bublepaw

  • Sr. Member
  • ****
  • Posts: 283
  • Karma: 10
Re: Accessing CME via ActiveX
« Reply #14 on: September 06, 2007, 06:42:23 AM »
Hi Victor,

Although Russia is very close to Poland where I live Russian programers didn't visit me :) - actually I spent a lot of time with VB6 - it shows object types and in the same time I was looking and logs from confserv to see what is happening when some actions are done from CME or from my program. The worst part was to find out that You need to assign already modified collection back to is property.
Component as solution to modifying configuration was shown by one of our Genesys partner in Poland - normaly I was trying to use ActiveX that comes with toolkit - so I'am not that geneuis

Br

Paul
« Last Edit: September 06, 2007, 06:45:59 AM by bublepaw »