Hello Dojo
Im creating service with automation core library and works well, im want to add a logic to update the service if existe but i cant find the funciton to remove elements and add the news
if (dms.ServiceExists(grupoCunico.Key))
{
var serviceExist = dms.GetService(grupoCunico.Key);
}
This is my code working in 10.5.0.0-16294-CU6
ServiceConfiguration serviceConfig = new ServiceConfiguration(dms, grupoCunico.Key);
serviceConfig.Views.Add(dms.GetView(63));
serviceConfig.AdvancedSettings.Protocol = dmsProtocol;
serviceConfig.AdvancedSettings.AlarmTemplate = alarmTemplate;
var gruposTroncales = grupoCunico
.GroupBy(x => new
{
// x.Troncal,
x.HostName,
});
int i = 0;
foreach (var grupo in gruposTroncales)
{
i++;
if (dms.ElementExists(grupo.Key.HostName) )
{
engine.GenerateInformation("=======================================");
//engine.GenerateInformation($"Troncal: {grupo.Key.Troncal}");
engine.GenerateInformation($"Host: {grupo.Key.HostName}");
engine.GenerateInformation("---- Registros del grupo ----");
var filters1 = new List<ElementParamFilterConfiguration>();
var filters2 = new List<ElementParamFilterConfiguration>();
foreach (var item in grupo)
{
engine.GenerateInformation(
$"{item.Itm} | {item.IE_Name} | {item.MAC_IE_Local} | {item.MAC_CajaRemota}"
);
filters1.Add(new ElementParamFilterConfiguration(5003, "*", true));
filters1.Add(new ElementParamFilterConfiguration(5004, "*", true));
filters1.Add(new ElementParamFilterConfiguration(5005, "*", true));
filters1.Add(new ElementParamFilterConfiguration(1407, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1419, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1420, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1407, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1405, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1408, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1427, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1412, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1413, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1417, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1418, "*" + item.IE_Name + " * ", true));
filters1.Add(new ElementParamFilterConfiguration(1431, "*" + item.IE_Name + " * ", true));
}
var element1 = dms.GetElement(grupo.Key.HostName);
serviceConfig.AddElement(element1.DmsElementId, filters1);
var includedElements = serviceConfig.IncludedElements;
int j = 1;
foreach (var includedElement in includedElements)
{
//includedElement.Alias = "device" + j;
includedElement.IncludedCapped = Skyline.DataMiner.Core.DataMinerSystem.Common.AlarmLevel.Normal;
j++;
}
}
}
agent.CreateService(serviceConfig);
Thanks
Hi Juan,
While the IDmsService interface does provide an Update() method that allows you to persist changes after modifying the service object, it is currently not possible to change the ElementParamFilters through the IDmsService object.
So even though you can retrieve the service and update certain properties, you won’t be able to remove, or add ElementParamFilters on existing service elements using that API.
If you would like this functionality to be added, you can submit a request on the feature suggestions page: https://community.dataminer.services/feature-suggestions/
hi thomas, could i use an other way to update the service on the automation?
correct, creating again the service gets error for existing.