In dataminer i'm creating services for monitoring using automation scripts under a common view in DM called Monitoring. Below is the code i use to create the service. Im facing issue like, if i create services in bulk, 3 out of 8 services are created outside of my view.
private object CreateService(string serviceName, List<ServiceInfoParams> serviceParams, string viewNewName)
{
_engine.GenerateInformation("Create service starts here");
var service = new ServiceInfoEventMessage { Name = serviceName };
service.ServiceParams = serviceParams.ToArray();
var addServiceMessage = new AddServiceMessage
{
Service = service,
var viewIDs = new[] { GetViewForServiceCreation(viewNewName).Id };
};
_engine.GenerateInformation("Create service ends here");
return engine.AddService(service, viewIDs);
}private object AddService(AddServiceMessage addService)
{
try
{
_engine.GenerateInformation("Add service starts here"+addService.ViewIDs);
var dmsMessage = _engine.SendSLNetMessage(addService);
var response = (AddServiceResponseMessage)dmsMessage[0];
var dmaInfo = GetLocalDataMinerInfo();
_engine.GenerateInformation("Add service ends here");
return $"{dmaInfo.ID}/{response.NewID}";
}
catch (Exception e)
{
throw new InvalidDataException($"Failed to create service:{addService.Service.Name}. {e.Message}");
}
}private IDmsView GetViewForServiceCreation(string viewName)
{
IDmsView view;
var getdms = (_engine as Engine).GetDms();
try
{
_engine.GenerateInformation("Get view starts here");
view = getdms.GetView(viewName);
}
catch (ViewNotFoundException)
{
view = getdms.GetView(-1);
}_engine.GenerateInformation("Get view ends here");
return view;
}private GetDataMinerInfoResponseMessage GetLocalDataMinerInfo()
{
try
{
_engine.GenerateInformation("Get DM info starts here");
GetInfoMessage message = new GetInfoMessage(InfoType.LocalDataMinerInfo);
_engine.GenerateInformation("Get DM info ends here");
return (_engine.SendSLNetSingleResponseMessage(message) as GetDataMinerInfoResponseMessage) ??
throw new DataMinerException("Failed to get Local DataMiner info");
}
catch (Exception innerException)
{
throw new DataMinerException("Failed to get Local DataMiner info", innerException);
}
}
Hi Baranisudha,
The code below is ok.
After a deeper investigation, it was discovered that the problem was caused by a synchronization issue, which resulted from the time on the server being out of sync.