Hi all,
Here are some more examples to mess with configuration server.
1) adding new object
{
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();
}
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
{
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();
}