public ConfigurationCompareViewModel(GKDeviceConfiguration localConfiguration, GKDeviceConfiguration remoteConfiguration, GKDevice device, string configFileName = "")
		{
			Title = "Сравнение конфигураций " + device.PresentationName;
			ChangeCurrentGkCommand = new RelayCommand(OnChangeCurrentGk);
			LoadConfigurationFromFileCommand = new RelayCommand(OnLoadConfigurationFromFile);
			NextDifferenceCommand = new RelayCommand(OnNextDifference, CanNextDifference);
			PreviousDifferenceCommand = new RelayCommand(OnPreviousDifference, CanPreviousDifference);

			ConfigFileName = configFileName;
			ConfigFromFile = CanChangeOrOpenConfiguration = !string.IsNullOrEmpty(configFileName);

			var remoteConfig = new ZipFile(ConfigFileName);
			OnlyGKDeviceConfiguration = remoteConfig.Entries.Count == 1;

			LocalConfiguration = localConfiguration;
			RemoteConfiguration = remoteConfiguration;
			RemoteConfiguration.Update();
			RemoteConfiguration.UpdateConfiguration();

			LocalDevice = localConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			RemoteDevice = remoteConfiguration.Devices.FirstOrDefault(x => x.DriverType == device.DriverType && x.Address == device.Address);
			if (RemoteDevice == null)
			{
				Error = "ГК в удаленной конфигурации имеет невалидный IP адрес";
				return;
			}
			LocalObjectsViewModel = new ObjectsListViewModel(LocalDevice, localConfiguration);
			RemoteObjectsViewModel = new ObjectsListViewModel(RemoteDevice, remoteConfiguration);
			CompareObjectLists();
			InitializeMismatchedIndexes();
		}
示例#2
0
		override public bool ReadConfiguration(GKDevice gkControllerDevice, Guid clientUID)
		{
			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + gkControllerDevice.PresentationName, "Проверка связи", 2, true, GKProgressClientType.Administrator, clientUID);
			var result = DeviceBytesHelper.Ping(gkControllerDevice);
			if (result.HasError)
			{
				Error = "Устройство " + gkControllerDevice.PresentationName + " недоступно";
				return false;
			}
			IpAddress = gkControllerDevice.GetGKIpAddress();
			ControllerDevices = new Dictionary<ushort, GKDevice>();
			DeviceConfiguration = new GKDeviceConfiguration();
			var rootDriver = GKManager.Drivers.FirstOrDefault(x => x.DriverType == GKDriverType.System);
			DeviceConfiguration.RootDevice = new GKDevice
			{
				Driver = rootDriver,
				DriverUID = rootDriver.UID
			};
			GKProcessorManager.DoProgress("Перевод ГК в технологический режим", progressCallback, clientUID);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(gkControllerDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести " + gkControllerDevice.PresentationName + " в технологический режим\n" +
						"Устройство не доступно, либо вашего " +
						"IP адреса нет в списке разрешенного адреса ГК";
				GKProcessorManager.StopProgress(progressCallback, clientUID);
				return false;
			}

			ReadConfiguration(gkControllerDevice, progressCallback, clientUID);

			GKProcessorManager.DoProgress("Перевод ГК в рабочий режим", progressCallback, clientUID);
			if (!DeviceBytesHelper.GoToWorkingRegime(gkControllerDevice, progressCallback, clientUID))
			{
				Error = "Не удалось перевести устройство в рабочий режим в заданное время";
			}
			GKProcessorManager.StopProgress(progressCallback, clientUID);
			if (Error != null)
				return false;
			DeviceConfiguration.Update();
			return true;
		}
示例#3
0
		public ObjectsListViewModel (GKDevice device, GKDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.Update();
			deviceConfiguration.UpdateConfiguration();
			deviceConfiguration.PrepareDescriptors();
			Objects = new List<ObjectViewModel>();

			foreach (var childDevice in deviceConfiguration.Devices)
			{
				var objectViewModel = new ObjectViewModel(childDevice);
				var parent = childDevice.AllParents.FirstOrDefault(x => x.ShortName == device.ShortName && x.Address == device.Address);
				if (parent != null && childDevice.IsRealDevice)
					Objects.Add(objectViewModel);
			}
			if (deviceConfiguration.Zones != null)
				foreach (var zone in deviceConfiguration.Zones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(zone);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Directions != null)
				foreach (var direction in deviceConfiguration.Directions.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(direction);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.PumpStations != null)
				foreach (var pumpStation in deviceConfiguration.PumpStations.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(pumpStation);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.MPTs != null)
				foreach (var mpt in deviceConfiguration.MPTs.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(mpt);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Delays != null)
				foreach (var delay in deviceConfiguration.Delays.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(delay);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.GuardZones != null)
				foreach (var guardZone in deviceConfiguration.GuardZones.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(guardZone);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Codes != null)
				foreach (var code in deviceConfiguration.Codes.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(code);
					Objects.Add(objectViewModel);
				}
			if (deviceConfiguration.Doors != null)
				foreach (var door in deviceConfiguration.Doors.Where(x => x.GkDatabaseParent != null && x.GkDatabaseParent.Address == device.Address))
				{
					var objectViewModel = new ObjectViewModel(door);
					Objects.Add(objectViewModel);
				}
		}