We are trying to create / delete / save VMS items from Smart Client plugin interface.
We are already able to read the VMS items from SC plugin using:
Configuration.Instance.GetItemConfigurations(PluginId, null, ItemKind);
Now we would need to modify and save the same VMS items using a function like:
Configuration.Instance.SaveItemConfiguration(ServerId, PluginId, Item);
However, when we try to run this function in the SC plugin, we get the erro message that the “Operation or Method is not implemented” in (VideoOS.RemoteClient.Application)
What is the problem?
Is it possible to save VMS item from Smart Client plugins?
We had no problems using the same function in Administration / Service plugin environment. I would like to avoid to deploy a dedicated Background plugin on Event server just to listen to save/modify requests from SC and fullfill them.
I would prefer to keep all the code in the SC.
I’d also rather prefer not to use the functions described in Property plugin sample as I need to save more items, with the same kind and internal structure.
SaveItemConfiguration is not implemented in the Smart Client.
My guess is that to design is so as to support the original idea was that operation was Smart Client and configuration was Management Client.
We will here at Milestone make sure the documentation is improved to document which environments are supported. Thank you for putting it to our attention
My aim is to design / select / apply / save custom ViewLayouts using the SmartClient interface.
At this stage I can use the Smart Client to design a new custom ViewLayout and then create a new View based on it.
My next target is to be able to store these custom ViewLayouts “somewhere”, in order to be able to use / modify them later for all Smart Client users.
If only Management Client or Management Application can store the VMS Items I will need to find a different solution to store / share them.
You should do this using Configuration API. Let me prepare a sample and post it here for you tomorrow. Please be patient.
In your plugin code the following:
string definitionXml = System.IO.File.ReadAllText(DEFINTIONXMLNAME);
ManagementServer mgtServer = new ManagementServer(EnvironmentManager.Instance.MasterSite.ServerId);
LayoutFolder layoutFolder = mgtServer.LayoutGroupFolder.LayoutGroups.FirstOrDefault().LayoutFolder;
layoutFolder.AddLayout(LAYOUTNAME, LAYOUTDESCRIPTION, definitionXml);
That is it!
Perhaps not quite, where LAYOUTNAME and LAYOUTDESCRIPTION are simply small texts containing the name and the description of the new layout the definitionXml will need further explanation.
The xml starts with content like this
<ViewLayout>
<ViewItems>
<ViewItem>
<Position><X>0</X><Y>0</Y></Position>
<Size><Width>1000</Width><Height>200</Height></Size>
</ViewItem>
<ViewItem>
<Position><X>0</X><Y>200</Y></Position>
<Size><Width>1000</Width><Height>800</Height></Size>
</ViewItem>
</ViewItems>
</ViewLayout>
I will assume that you realize how this is used, and how the above snippet of XML can be modified to achieve the layout you want.
You can in this xml inject a icon to be used for the layout. You convert the icon graphics to a Base64String and insert this in a tag after the . Sample snippet of code doing this:
byte[] content = File.ReadAllBytes(filename);
string base64 = Convert.ToBase64String(content);
XmlDocument doc = new XmlDocument();
try
{
doc.Load(filename2);
}
catch (XmlException ex)
{
Console.WriteLine("Invalid xml:" + ex.Message);
return;
}
XmlNode node = doc.SelectSingleNode("/ViewLayout");
XmlNode iconNode;
if (node["ViewLayoutIcon"] != null)
{
iconNode = node["ViewLayoutIcon"];
iconNode.InnerText = base64;
}
else
{
iconNode = doc.CreateNode(XmlNodeType.Element, "ViewLayoutIcon", "");
iconNode.InnerText = base64;
node.AppendChild(iconNode);
}
I hope this is sufficient to get you working. We will have a formal sample on this in the next MIP SDK..
Thank you Bo!
These snippets are exactly what I need.
The next step will be to use the Configuration API in SC Plugin to save the definitionXml strings.
Then I I have time I will have to deal with Access Rights in order to decide which users can see / use / modify / delete the custom ViewLayout.
Is it safe to read VMS cfg Items in the Init method of SC Plugin Definition class, in order to run the first snippet of your code and add the custom layouts in the plugin?
Yes, I believe that will be fine.