void RewriteRviServers()
		{
			var newRviServers = new List<RviServer>();
			foreach (var rviServer in RviServers)
			{
				var newRviDevices = new List<RviDevice>();
				foreach (var rviDevice in rviServer.RviDevices)
				{
					var newCameras = new List<Camera>();
					foreach (var camera in rviDevice.Cameras)
					{
						var cameraViewModel = Cameras.FirstOrDefault(x => x.CameraUid == camera.UID);
						if (cameraViewModel.IsChecked)
						{
							newCameras.Add(camera);
						}
					}
					if (newCameras.Count != 0)
					{
						var newRviDevice = new RviDevice { Uid = rviDevice.Uid, Ip = rviDevice.Ip, Name = rviDevice.Name, Cameras = newCameras };
						newRviDevices.Add(rviDevice);
					}
				}
				if (newRviDevices.Count != 0)
				{
					var newRviServer = new RviServer { Ip = rviServer.Ip, Port = rviServer.Port, Protocol = rviServer.Protocol, Url = rviServer.Url, RviDevices = newRviDevices };
					newRviServers.Add(newRviServer);
				}
				RviServers = newRviServers;
			}
		}
示例#2
0
		public static List<RviDevice> GetRviDevices(string url, string login, string password, List<Camera> existingCameras, out bool isNotConnected)
		{
			var devices = GetDevices(url, login, password, out isNotConnected);
			var rviDevices = new List<RviDevice>();
			var newCameras = new List<Camera>();
			foreach (var device in devices)
			{
				var rviDevice = new RviDevice { Uid = device.Guid, Ip = device.Ip, Name = device.Name, Status = ConvertToRviStatus(device.Status) };
				rviDevices.Add(rviDevice);
				foreach (var channel in device.Channels)
				{
					var camera = new Camera
					{
						UID = channel.Guid,
						Name = channel.Name,
						RviServerUrl = url,
						RviDeviceName = device.Name,
						RviDeviceUID = device.Guid,
						Ip = device.Ip,
						Number = channel.Number,
						Vendor = channel.Vendor,
						CountPresets = channel.CountPresets,
						CountTemplateBypass = channel.CountTemplateBypass,
						CountTemplatesAutoscan = channel.CountTemplatesAutoscan,
						Status = ConvertToRviStatus(device.Status),
						IsRecordOnline = channel.IsRecordOnline,
						IsOnGuard = channel.IsOnGuard
					};
					foreach (var stream in channel.Streams)
					{
						var rviStream = new RviStream { Number = stream.Number, RviDeviceUid = device.Guid, RviChannelNumber = channel.Number };
						camera.RviStreams.Add(rviStream);
					}
					camera.SelectedRviStreamNumber = camera.RviStreams.Count > 0 ? camera.RviStreams.First().Number : 0;
					rviDevice.Cameras.Add(camera);
					newCameras.Add(camera);
				}
			}
			if (existingCameras != null)
			{
				foreach (var existingCamera in existingCameras)
				{
					var camera = newCameras.FirstOrDefault(newCamera => newCamera.UID == existingCamera.UID);
					if (camera != null)
					{
						camera.ShowDetailsHeight = existingCamera.ShowDetailsHeight;
						camera.ShowDetailsWidth = existingCamera.ShowDetailsWidth;
						camera.ShowDetailsMarginLeft = existingCamera.ShowDetailsMarginLeft;
						camera.ShowDetailsMarginTop = existingCamera.ShowDetailsMarginTop;
						camera.PlanElementUIDs = existingCamera.PlanElementUIDs;
					}
				}
			}
			return rviDevices;
		}
示例#3
0
		public RviState(RviDevice rviDevice, RviStatus rviStatus)
		{
			RviDeviceUid = rviDevice.Uid;
			Status = rviStatus;
		}