Xprotect Videos Views via SDK

We have been asked to import video views from Xprotect to a PSIM vis the SDK. What is the method to retrieve the views + cameras + order of cameras in the views?

You can read the views using the Configuration API (Rest API, Configuration SOAP API, and MIP VideoOS.Platform.ConfigurationItems classes).

To see this in action you can run the Config API Client sample and expand the ViewGroups node.

(Camera can be read from “viewitemxml”…

I also have an example of code using MIP Library:

private void FindViewGroups()
{
	var ms = new ManagementServer(EnvironmentManager.Instance.MasterSite);
	var vgs = ms.ViewGroupFolder.ViewGroups;
	label1.Text = Environment.NewLine;
	foreach (var vg in vgs)
	{
		ShowViews(vg);
	}
}
 
private void ShowViews(ViewGroup viewGroup)
{
	if (viewGroup == null)
	{
		return;
	}
	label1.Text += "ViewGroup " + viewGroup.Name + Environment.NewLine;
	var viewfolder = viewGroup.ViewFolder;
	if (viewfolder != null)
	{
		var views = viewfolder.Views;
		foreach (var view in views)
		{
			label1.Text += "View " + view.Name + Environment.NewLine;
			ShowCameraInView(view);
		}
	}
 
	var vgChildFolder = viewGroup.ViewGroupFolder;
	if (vgChildFolder != null)
	{
		var vgChildGroups = vgChildFolder.ViewGroups;
		if (vgChildGroups != null)
		{
			foreach (var vgGroup in vgChildGroups)
			{
				if (vgGroup != null)
				{
					ShowViews(vgGroup);
				}
			}
		}
	}
}
 
void ShowCameraInView(View view)
{
	var viewItemChildItems = view.ViewItemChildItems;
	foreach (var viewItemChilldItem in viewItemChildItems)
	{
		XDocument viewElementData = XDocument.Parse(viewItemChilldItem.ViewItemDefinitionXml);
		var viewItemElement = viewElementData.Element("viewitem"); 
		var itemInfoElement = viewItemElement.Element("iteminfo");
		if (itemInfoElement != null)
		{
			var cameraidAttribute = itemInfoElement.Attribute("cameraid");
			if (cameraidAttribute != null)
			{
				label1.Text += "Camera id " + cameraidAttribute + Environment.NewLine;
			}
		}
	}            
}