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<RviServer> GetServers(string url, string login, string password, List<Camera> existingCameras)
		{
			List<RviServer> rviServers = new List<RviServer>();
			try
			{
				Server[] servers = null;
				bool isNotConnected;
				using (IntegrationClient client = CreateIntegrationClient(url))
				{
					var sessionUID = Guid.NewGuid();

					var sessionInitialiazationIn = new SessionInitialiazationIn();
					sessionInitialiazationIn.Header = new HeaderRequest()
					{
						Request = Guid.NewGuid(),
						Session = sessionUID
					};
					sessionInitialiazationIn.Login = login;
					sessionInitialiazationIn.Password = password;
					var sessionInitialiazationOut = client.SessionInitialiazation(sessionInitialiazationIn);
					//var errorMessage = sessionInitialiazationOut.Header.HeaderResponseMessage.Information;

					var serverListIn = new ServerListIn();
					serverListIn.Header = new HeaderRequest()
					{
						Request = Guid.NewGuid(),
						Session = sessionUID
					};
					var serverListOut = client.GetServerList(serverListIn);
					servers = serverListOut.ServerList;

					var sessionCloseIn = new SessionCloseIn();
					sessionCloseIn.Header = new HeaderRequest()
					{
						Request = Guid.NewGuid(),
						Session = sessionUID
					};
					var sessionCloseOut = client.SessionClose(sessionCloseIn);
					foreach (var server in servers)
					{
						var rviServer = new RviServer { Ip = server.IP, Port = server.Port, Protocol = server.Protocol, Url = server.Url };
						rviServer.RviDevices = GetRviDevices(server.Url, login, password, existingCameras, out isNotConnected);
						rviServer.Status = isNotConnected ? RviStatus.ConnectionLost : RviStatus.Connected;
						rviServers.Add(rviServer);
					}
				}
			}
			catch { }
			return rviServers;
		}
示例#3
0
		public RviState(RviServer rviServer, RviStatus rviStatus)
		{
			RviServerUrl = rviServer.Url;
			Status = rviStatus;
		}