Hi all! in order to avoid adding too much elements into a service, we want to use "ElementsToConsider" when trying to create a service under a QAction.
Our code:
string[] aElements = elementlist.ToArray(); //list of elements to be consider
TryCreateServiceMessage myServiceMessage = new TryCreateServiceMessage();
myServiceMessage.HostingDataMinerID = -1;
myServiceMessage.CreateAll = false;
myServiceMessage.DataMinerID = -1;
myServiceMessage.Options = TryCreateServiceOptions.None;
myServiceMessage.ServiceTemplateID = sServiceDMATemplateID;
myServiceMessage.EditInputDataOnUpdate = true; //UPDATE
myServiceMessage.IsReApply = true; // UPDATE
myServiceMessage.ElementsToConsider = aElements;
myServiceMessage.ExtraData = new TCSExtraData[3];
for (int i = 0; i < myServiceMessage.ExtraData.Length; i++)
{
myServiceMessage.ExtraData[i] = new TCSExtraData();
myServiceMessage.ExtraData[i].Options = TCSExtraData.TCSExtraDataOptions.None;
myServiceMessage.ExtraData[i].IsFromOriginalService = false;
}
myServiceMessage.ExtraData[0].Name = "serviceID";
myServiceMessage.ExtraData[0].Value = sServiceDMAServiceID;
myServiceMessage.ExtraData[1].Name = "serviceName";
myServiceMessage.ExtraData[1].Value = sServicename;
myServiceMessage.ExtraData[2].Name = "data:Service";
myServiceMessage.ExtraData[2].Value = sServiceIndex;
TryCreateServiceResult response = (TryCreateServiceResult)protocol.SLNet.SendMessage(myServiceMessage)[0];
We have tried to use the above code but seems to be not working (response = success but all the elements still included)
Could someone help us in order to know how ElementsToConsider should be used?
Thanks in advance!
Hi Pedro,
The ElementsToConsider property only supports filtering to the list of elements below a certain view. It cannot be used to filter to specific elements.
The syntax of the entries is "view:123" where 123 is the ID of the view (right-click in Cube Surveyor to see the view properties window, which also shows the ID).
Other options for limiting the list of included elements could be to filter on protocol or on element name from the child element configuration.
Hi Pedro,
I did some quick experiments which showed that the options to filter on element properties are rather limited.
In case it can be of any help: I could get something to work with the config below:
– a child element is configured without the “Include all matching elements”
– in the conditions section, a condition was added where value1 refers to a property of that element and value2 defines the requested property value
When I then run the service template and have it “create all options” for the child element, the template only gets applied for elements that have a matching property name (and each generated service contains just one of those elements).
Thanks Wouter! This feature will help us in the future but right now it is not the best solution because all the elements filtered by protocol and name are already included in the same view (called “[Site]-elements”).
In that QAction we tried to filter down by an specific property of the elements checking it before to create the array but seems that it’s not possible.
Do you have an idea about how to filter them in that way?