How can I add a new profile instance from an automation script using C# code?
Hi Gina,
Below a sample about how to create a profile instance.
var parentProfileInstance = srmHelpers.ProfileHelper.GetProfileInstanceByName(serviceProfileData.Name);
var profileInstance = new Skyline.DataMiner.Net.Profiles.ProfileInstance
{
Name = name,
AppliesToID = parentProfileInstance.AppliesToID,
};profileInstance.BasedOnIDs.Add(parentProfileInstance.ID);
var txDataRateProfileParameter = srmHelpers.ProfileHelper.GetProfileParameterByName("SCPC Modem_Tx Data Rate");
profileInstance.Values = new ProfileParameterEntry[] {
new ProfileParameterEntry
{
Parameter = new Skyline.DataMiner.Net.Profiles.Parameter(txDataRateProfileParameter.ID),
Value = new Skyline.DataMiner.Net.Profiles.ParameterValue
{
Type = Skyline.DataMiner.Net.Profiles.ParameterValue.ValueType.Double,
DoubleValue = bookingData.DataRate,
},
},
};srmHelpers.ProfileHelper.ProfileInstances.Create(profileInstance);
NOTES
srmHelper is a wrapper class that I use to group SRM related helpers together. In your case you need the ProfileHelper.
ProfileHelper profileHelper = new ProfileHelper(engine.SendSLNetMessages);
I also made below extensions on this class
public static class ProfileHelperExtensions
{
public static Skyline.DataMiner.Net.Profiles.Parameter GetProfileParameterByName(this Skyline.DataMiner.Net.Profiles.ProfileHelper profileHelper, string name)
{
return profileHelper.ProfileParameters.Read(Skyline.DataMiner.Net.Profiles.ParameterExposers.Name.Equal(name)).FirstOrDefault();
}public static Skyline.DataMiner.Net.Profiles.ProfileInstance GetProfileInstanceByName(this Skyline.DataMiner.Net.Profiles.ProfileHelper profileHelper, string name)
{
return profileHelper.ProfileInstances.Read(Skyline.DataMiner.Net.Profiles.ProfileInstanceExposers.Name.Equal(name)).FirstOrDefault();
}
}
Thank you so much Jens, it worked !