示例#1
0
		static XManager()
		{
			DeviceConfiguration = new XDeviceConfiguration();
			DriversConfiguration = new XDriversConfiguration();
			Delays = new List<XDelay>();
			Pims = new List<XPim>();
		}
		public ObjectsListViewModel (XDevice device, XDeviceConfiguration deviceConfiguration)
		{
			deviceConfiguration.Update();
			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) { ObjectType = ObjectType.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) { ObjectType = ObjectType.PumpStation };
					Objects.Add(objectViewModel);
				}
		}
		public ConfigurationCompareViewModel(XDeviceConfiguration localConfiguration, XDeviceConfiguration remoteConfiguration, XDevice device, bool configFromFile)
		{
			Title = "Сравнение конфигураций " + device.PresentationName;
			ConfigFromFile = configFromFile;
			ChangeCommand = new RelayCommand(OnChange);
			NextDifferenceCommand = new RelayCommand(OnNextDifference, CanNextDifference);
			PreviousDifferenceCommand = new RelayCommand(OnPreviousDifference, CanPreviousDifference);

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

			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();
		}
示例#4
0
		public XHashConfiguration(XDeviceConfiguration deviceConfiguration)
		{
			RootDevice = deviceConfiguration.RootDevice;
			Devices = deviceConfiguration.Devices;
			Zones = deviceConfiguration.Zones;
			Directions = deviceConfiguration.Directions;
			PumpStations = deviceConfiguration.PumpStations;
		}
示例#5
0
 public FullConfiguration()
 {
     DeviceConfiguration = new DeviceConfiguration();
     LibraryConfiguration = new LibraryConfiguration();
     PlansConfiguration = new PlansConfiguration();
     SecurityConfiguration = new SecurityConfiguration();
     SystemConfiguration = new SystemConfiguration();
     XDeviceConfiguration = new XDeviceConfiguration();
 }
		public static void PrepareDescriptors(XDeviceConfiguration deviceConfiguration)
		{
			DeviceConfiguration = deviceConfiguration;
			PrepareZones();
			PrepareInputOutputDependences();
			PrepareDeviceLogicDependences();
			PrepareDirections();
			PreparePumpStations();
		}
示例#7
0
		public static List<byte> CreateHash2(XDeviceConfiguration deviceConfiguration)
		{
			UpdateConfigurationHelper.Update(deviceConfiguration);
			var hashConfiguration = new XHashConfiguration(deviceConfiguration);
			var configMemoryStream = ZipSerializeHelper.Serialize(hashConfiguration);
			ZipSerializeHelper.Serialize(hashConfiguration, "123.xml");
			configMemoryStream.Position = 0;
			var configBytes = configMemoryStream.ToArray();
			return SHA256.Create().ComputeHash(configBytes).ToList();
		}
示例#8
0
		public static void SetEmptyConfiguration()
		{
			DeviceConfiguration = new XDeviceConfiguration();
			var driver = Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System);
			DeviceConfiguration.RootDevice = new XDevice()
			{
				DriverUID = driver.UID
			};
			UpdateConfiguration();
		}
示例#9
0
		public void Initialize(XDeviceConfiguration deviceConfiguration, XDevice gkDevice)
		{
			DescriptorsManager.Create();
			Date = DateTime.Now;
			var gkDatabase = DescriptorsManager.GkDatabases.FirstOrDefault(x => x.RootDevice.UID == gkDevice.UID);
			MinorVersion = (byte)deviceConfiguration.Version.MinorVersion;
			MajorVersion = (byte)deviceConfiguration.Version.MajorVersion;
			if (gkDatabase != null)
				DescriptorsCount = gkDatabase.Descriptors.Count();
			Hash1 = CreateHash1(deviceConfiguration, gkDevice);
			Hash2 = CreateHash2(deviceConfiguration);
			InitializeFileBytes(deviceConfiguration);
			InitializeInfoBlock();
		}
		public static void SaveToZipFile(string fileName, XDeviceConfiguration deviceConfiguration)
		{
			var folderName = AppDataFolderHelper.GetTempFolder();
			if (!Directory.Exists(folderName))
				Directory.CreateDirectory(folderName);

			if (File.Exists(fileName))
				File.Delete(fileName);

			deviceConfiguration.BeforeSave();
			deviceConfiguration.Version = new ConfigurationVersion() { MinorVersion = 1, MajorVersion = 1 };
			ZipSerializeHelper.Serialize(deviceConfiguration, Path.Combine(folderName, "XDeviceConfiguration.xml"));
			var zipFile = new ZipFile(fileName);
			zipFile.AddDirectory(folderName);
			zipFile.Save(fileName);
			zipFile.Dispose();
			if (Directory.Exists(folderName))
				Directory.Delete(folderName, true);
		}
示例#11
0
		public static List<byte> CreateHash1(XDeviceConfiguration deviceConfiguration, XDevice gkDevice)
		{
			UpdateConfigurationHelper.Update(deviceConfiguration);
			UpdateConfigurationHelper.PrepareDescriptors(deviceConfiguration);
			var stringBuilder = new StringBuilder();
			stringBuilder.Append("devices:");
			foreach (var device in deviceConfiguration.Devices)
			{
				if (device.IsRealDevice && device.GKParent == gkDevice)
					stringBuilder.Append(device.PresentationName).Append("@");
			}
			stringBuilder.Append("zones:");
			foreach (var zone in deviceConfiguration.Zones)
			{
				if (zone.GkDatabaseParent == gkDevice)
					stringBuilder.Append(zone.No).Append("@");
			}
			stringBuilder.Append("directions:");
			foreach (var direction in deviceConfiguration.Directions)
			{
				if (direction.GkDatabaseParent == gkDevice)
					stringBuilder.Append(direction.No).Append("@");
			}
			stringBuilder.Append("pumpStations:");
			foreach (var pumpStation in deviceConfiguration.PumpStations)
			{
				if (pumpStation.GkDatabaseParent == gkDevice)
				{
					stringBuilder.Append(pumpStation.No).Append("@");
					if (pumpStation.NSDevices != null)
					{
						stringBuilder.Append("nsDevices:");
						foreach (var nsDevice in pumpStation.NSDevices)
						{
							if (nsDevice.GKParent == gkDevice)
								stringBuilder.Append(nsDevice.PresentationName).Append("@");
						}
					}
				}
			}
			return SHA256.Create().ComputeHash(Encoding.GetEncoding(1251).GetBytes(stringBuilder.ToString())).ToList();
		}
		public static void Update(XDeviceConfiguration deviceConfiguration)
		{
			DeviceConfiguration = deviceConfiguration;
			if (DeviceConfiguration == null)
			{
				DeviceConfiguration = new XDeviceConfiguration();
			}
			if (DeviceConfiguration.RootDevice == null)
			{
				var systemDriver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System);
				if (systemDriver != null)
				{
					DeviceConfiguration.RootDevice = new XDevice()
					{
						DriverUID = systemDriver.UID,
						Driver = systemDriver
					};
				}
				else
				{
					Logger.Error("XManager.SetEmptyConfiguration systemDriver = null");
				}
			}
			DeviceConfiguration.ValidateVersion();

			DeviceConfiguration.Update();
			foreach (var device in DeviceConfiguration.Devices)
			{
				device.Driver = XManager.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
				if (device.Driver == null)
				{
					//MessageBoxService.Show("Ошибка при сопоставлении драйвера устройств ГК");
				}
			}
			DeviceConfiguration.Reorder();

			InitializeProperties();
			Invalidate();
		}
示例#13
0
		override public bool ReadConfiguration(XDevice kauDevice)
		{
			KauDevice = (XDevice) kauDevice.Clone();
			KauDevice.Children = new List<XDevice>();
			descriptorAddresses = new List<int>();
			for (int i = 0; i < 8; i++)
			{
				var shleif = new XDevice();
				shleif.Driver = KauDevice.DriverType == XDriverType.KAU ? XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.KAU_Shleif) : XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.RSR2_KAU_Shleif);
				shleif.DriverUID = shleif.Driver.UID;
				shleif.IntAddress = (byte)(i + 1);
				KauDevice.Children.Add(shleif);
			}
			DeviceConfiguration = new XDeviceConfiguration { RootDevice = KauDevice };
			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации", "Перевод КАУ в технологический режим", 1, false, GKProgressClientType.Administrator);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(kauDevice, progressCallback))
				{ Error = "Не удалось перевести КАУ в технологический режим"; return false; }
			GKProcessorManager.DoProgress("Получение дескрипторов устройств", progressCallback);
			if (GetDescriptorAddresses(kauDevice))
			{
				GKProcessorManager.StartProgress("Чтение конфигурации " + kauDevice.PresentationName, "", descriptorAddresses.Count + 1, true, GKProgressClientType.Administrator);
				for (int i = 1; i < descriptorAddresses.Count; i++)
				{
					if (progressCallback.IsCanceled)
					{
						Error = "Операция отменена";
						break;
					}
					GKProcessorManager.DoProgress("Чтение базы данных объектов. " + i + " из " + descriptorAddresses.Count, progressCallback);
					if (!GetDescriptorInfo(kauDevice, descriptorAddresses[i]))
						break;
				}
			}
			GKProcessorManager.DoProgress("Перевод КАУ в рабочий режим", progressCallback);
			DeviceBytesHelper.GoToWorkingRegime(kauDevice, progressCallback);
			GKProcessorManager.StopProgress(progressCallback);
			return String.IsNullOrEmpty(Error);
		}
		void MergeXDeviceConfiguration()
		{
			var errors = new StringBuilder();
			var maxZoneNo = 0;
			if (XManager.Zones.Count > 0)
				maxZoneNo = XManager.Zones.Max(x=>x.No);

			var maxDirectionNo = 0;
			if (XManager.Directions.Count > 0)
				maxDirectionNo = XManager.Directions.Max(x => x.No);

			if (XDeviceConfiguration == null)
				XDeviceConfiguration = new XDeviceConfiguration();
			if (PlansConfiguration == null)
				PlansConfiguration = new PlansConfiguration();

			XDeviceConfiguration.Update();
			PlansConfiguration.Update();
			CreateNewUIDs();
			XDeviceConfiguration.Update();
			PlansConfiguration.Update();

			foreach (var gkDevice in XDeviceConfiguration.RootDevice.Children)
			{
				var ipAddress = "";
				var ipProperty = gkDevice.Properties.FirstOrDefault(x => x.Name == "IPAddress");
				if (ipProperty != null)
				{
					ipAddress = ipProperty.StringValue;
				}
				var existingGKDevice = XManager.DeviceConfiguration.RootDevice.Children.FirstOrDefault(x => x.Address == ipAddress);
				if (existingGKDevice != null)
				{
					foreach (var device in gkDevice.Children)
					{
						var driver = XManager.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
						if (driver.DriverType == XDriverType.KAU || driver.DriverType == XDriverType.RSR2_KAU)
						{
							var existingKAUDevice = existingGKDevice.Children.FirstOrDefault(x => x.Driver != null && (x.DriverType == XDriverType.KAU || x.DriverType == XDriverType.RSR2_KAU) && x.IntAddress == device.IntAddress);
							if (existingKAUDevice == null)
							{
								existingGKDevice.Children.Add(device);
							}
							else
							{
								errors.AppendLine("Устройство " + existingKAUDevice.PresentationName + " не было добавленно в конфигурацию из за совпадения адресов");
							}
						}
					}
				}
				else
				{
					XManager.DeviceConfiguration.RootDevice.Children.Add(gkDevice);
				}
			}
			foreach (var zone in XDeviceConfiguration.Zones)
			{
				zone.No = (ushort)(zone.No + maxZoneNo);
				XManager.Zones.Add(zone);
			}
			foreach (var direction in XDeviceConfiguration.Directions)
			{
				direction.No = (ushort)(direction.No + maxDirectionNo);
				XManager.Directions.Add(direction);
			}

			foreach (var plan in PlansConfiguration.Plans)
			{
				FiresecManager.PlansConfiguration.Plans.Add(plan);
			}

			XManager.UpdateConfiguration();
			FiresecManager.UpdateConfiguration();

			var errorsString = errors.ToString();
			if (!string.IsNullOrEmpty(errorsString))
			{
				MessageBoxService.ShowError(errorsString, "В результате слияния конфигурации возникли ошибки");
			}
		}
示例#15
0
文件: XManager.cs 项目: hjlfmy/Rubezh
 static XManager()
 {
     DeviceConfiguration = new XDeviceConfiguration();
     DriversConfiguration = new XDriversConfiguration();
     DeviceStates = new XDeviceConfigurationStates();
 }
示例#16
0
文件: XManager.cs 项目: hjlfmy/Rubezh
        public static void UpdateConfiguration()
        {
            if (DeviceConfiguration == null)
            {
                DeviceConfiguration = new XDeviceConfiguration();
            }
            if (DeviceConfiguration.Directions == null)
                DeviceConfiguration.Directions = new List<XDirection>();

            DeviceConfiguration.Update();

            foreach (var device in DeviceConfiguration.Devices)
            {
                device.Driver = DriversConfiguration.Drivers.FirstOrDefault(x => x.UID == device.DriverUID);
                if (device.Driver == null)
                {
                    System.Windows.MessageBox.Show("Ошибка при сопоставлении драйвера устройств ГК");
                }
            }

            InitializeMissingDefaultProperties();
        }
示例#17
0
文件: XManager.cs 项目: hjlfmy/Rubezh
        public static void SetEmptyConfiguration()
        {
            DeviceConfiguration = new XDeviceConfiguration();

            var systemDriver = DriversConfiguration.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System);
            if (systemDriver != null)
            {
                DeviceConfiguration.RootDevice = new XDevice()
                {
                    DriverUID = systemDriver.UID,
                    Driver = systemDriver
                };
            }
            else
            {
                Logger.Error("XManager.SetEmptyConfiguration systemDriver = null");
            }

            UpdateConfiguration();
        }
示例#18
0
		override public bool ReadConfiguration(XDevice device)
		{
			IpAddress = device.GetGKIpAddress();
			var allbytes = BytesHelper.BytesFromFile("GKConfiguration.txt");
			ControllerDevices = new Dictionary<ushort, XDevice>();
			DeviceConfiguration = new XDeviceConfiguration();
			var rootDriver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System);
			var rootDevice = new XDevice()
			{
				Driver = rootDriver,
				DriverUID = rootDriver.UID
			};
			DeviceConfiguration.RootDevice = rootDevice;
			ushort descriptorNo = 0;
			int count = 0;
			GKProcessorManager.OnStartProgress("Чтение конфигурации " + device.PresentationName);
			while (true)
			{
				descriptorNo++;
				byte packNo = 1;
				var descriptorNoBytes = new List<byte>(BitConverter.GetBytes(descriptorNo));
				var data = new List<byte>(descriptorNoBytes);
				data.Add(packNo);
				var bytes = allbytes[count];
				count++;
				if (bytes.Count < 5)
					break;
				if (bytes[3] == 0xff && bytes[4] == 0xff)
					break;
				if (!Parse(bytes.Skip(3).ToList(), descriptorNo))
					break;
			}
			GKProcessorManager.OnStopProgress();
			if (Error != null)
			{
				return false;
			}
			DeviceConfiguration.Update();
			XManager.UpdateGKPredefinedName(GkDevice);
			return true;
		}
		public static void InvalidateOneLogic(XDeviceConfiguration deviceConfiguration, XDevice device, XDeviceLogic deviceLogic)
		{
			var clauses = new List<XClause>();
			foreach (var clause in deviceLogic.Clauses)
			{
				InvalidateOneClause(deviceConfiguration, device, clause);

				if (clause.Zones.Count > 0 || clause.Devices.Count > 0 || clause.Directions.Count > 0)
					clauses.Add(clause);
			}
			deviceLogic.Clauses = clauses;

			var offClauses = new List<XClause>();
			if (deviceLogic.OffClauses != null)
			{
				foreach (var clause in deviceLogic.OffClauses)
				{
					InvalidateOneClause(deviceConfiguration, device, clause);

					if (clause.Zones.Count > 0 || clause.Devices.Count > 0 || clause.Directions.Count > 0)
						offClauses.Add(clause);
				}
				deviceLogic.OffClauses = offClauses;
			}
		}
示例#20
0
		void InitializeFileBytes(XDeviceConfiguration deviceConfiguration)
		{
			ZipFileConfigurationHelper.SaveToZipFile("configFileToGK", deviceConfiguration);
			var file = File.OpenRead("configFileToGK");
			FileSize = file.Length;
			FileBytes = File.ReadAllBytes(file.Name).ToList();
			file.Close();
		}
示例#21
0
		override public bool ReadConfiguration(XDevice gkDevice)
		{
			var progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + gkDevice.PresentationName, "Проверка связи", 2, true, GKProgressClientType.Administrator);
			var result = DeviceBytesHelper.Ping(gkDevice);
			if (!result)
			{
				Error = "Устройство " + gkDevice.PresentationName + " недоступно";
				return false;
			}
			IpAddress = gkDevice.GetGKIpAddress();
			ControllerDevices = new Dictionary<ushort, XDevice>();
			DeviceConfiguration = new XDeviceConfiguration();
			var rootDriver = XManager.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System);
			DeviceConfiguration.RootDevice = new XDevice
			{
				Driver = rootDriver,
				DriverUID = rootDriver.UID
			};
			GKProcessorManager.DoProgress("Перевод ГК в технологический режим", progressCallback);
			if (!DeviceBytesHelper.GoToTechnologicalRegime(gkDevice, progressCallback))
			{
				Error = "Не удалось перевести " + gkDevice.PresentationName + " в технологический режим\n" +
				        "Устройство не доступно, либо вашего " +
				        "IP адреса нет в списке разрешенного адреса ГК";
				GKProcessorManager.StopProgress(progressCallback);
				return false;
			}
			var gkFileReaderWriter = new GKFileReaderWriter();
			var gkFileInfo = gkFileReaderWriter.ReadInfoBlock(gkDevice);
			if (gkFileReaderWriter.Error != null)
			{
				Error = gkFileReaderWriter.Error;
				GKProcessorManager.StopProgress(progressCallback);
				return false;
			}
			progressCallback = GKProcessorManager.StartProgress("Чтение конфигурации " + gkDevice.PresentationName, "", gkFileInfo.DescriptorsCount, true, GKProgressClientType.Administrator);
			ushort descriptorNo = 0;
#if SETCONFIGTOFILE
			var allBytes = new List<List<byte>>();
#endif
			while (true)
			{
				if (progressCallback.IsCanceled)
				{
					Error = "Операция отменена";
					break;
				}
				descriptorNo++;
				GKProcessorManager.DoProgress("Чтение базы данных объектов ГК " + descriptorNo, progressCallback);
				const byte packNo = 1;
				var data = new List<byte>(BitConverter.GetBytes(descriptorNo)) {packNo};
				var sendResult = SendManager.Send(gkDevice, 3, 19, ushort.MaxValue, data);
				var bytes = sendResult.Bytes;
#if SETCONFIGTOFILE
				allBytes.Add(bytes);
#endif
				if (sendResult.HasError || bytes.Count < 5)
				{
					Error = "Возникла ошибка при чтении объекта " + descriptorNo;
					break;
				}

				if (bytes[3] == 0xff && bytes[4] == 0xff)
					break;
				
				if (!Parse(bytes.Skip(3).ToList(), descriptorNo))
					break;
			}
#if SETCONFIGTOFILE
			/* Опция включения записи конфигурации в файл */
			BytesHelper.BytesToFile("GKConfiguration.txt", allBytes);
#endif
			GKProcessorManager.DoProgress("Перевод ГК в рабочий режим", progressCallback);
			if (!DeviceBytesHelper.GoToWorkingRegime(gkDevice, progressCallback))
			{
				Error = "Не удалось перевести устройство в рабочий режим в заданное время";
			}
			GKProcessorManager.StopProgress(progressCallback);
			if(Error != null)
				return false;
			DeviceConfiguration.Update();
			return true;
		}
		public void LoadFromZipFile(string fileName)
		{
			var zipFile = ZipFile.Read(fileName, new ReadOptions { Encoding = Encoding.GetEncoding("cp866") });
			var fileInfo = new FileInfo(fileName);
			var unzipFolderPath = Path.Combine(fileInfo.Directory.FullName, "Unzip");
			zipFile.ExtractAll(unzipFolderPath);

			var zipConfigurationItemsCollectionFileName = Path.Combine(unzipFolderPath, "ZipConfigurationItemsCollection.xml");
			if (!File.Exists(zipConfigurationItemsCollectionFileName))
			{
				Logger.Error("FiresecManager.LoadFromZipFile zipConfigurationItemsCollectionFileName file not found");
				return;
			}
			var zipConfigurationItemsCollection = ZipSerializeHelper.DeSerialize<ZipConfigurationItemsCollection>(zipConfigurationItemsCollectionFileName);
			if (zipConfigurationItemsCollection == null)
			{
				Logger.Error("FiresecManager.LoadFromZipFile zipConfigurationItemsCollection == null");
				return;
			}

			foreach (var zipConfigurationItem in zipConfigurationItemsCollection.GetWellKnownZipConfigurationItems)
			{
				var configurationFileName = Path.Combine(unzipFolderPath, zipConfigurationItem.Name);
				if (File.Exists(configurationFileName))
				{
					switch (zipConfigurationItem.Name)
					{
						case "XDeviceConfiguration.xml":
							XDeviceConfiguration = ZipSerializeHelper.DeSerialize<XDeviceConfiguration>(configurationFileName);
							break;

						case "PlansConfiguration.xml":
							PlansConfiguration = ZipSerializeHelper.DeSerialize<PlansConfiguration>(configurationFileName);
							break;
					}
				}
			}

			var destinationImagesDirectory = AppDataFolderHelper.GetLocalFolder("Administrator/Configuration/Unzip/Content");
			var sourceImagesDirectoryInfo = new DirectoryInfo(Path.Combine(unzipFolderPath, "Content"));
			foreach (var imageFileInfo in sourceImagesDirectoryInfo.GetFiles())
			{
				imageFileInfo.CopyTo(Path.Combine(destinationImagesDirectory, imageFileInfo.Name), true);
			}

			zipFile.Dispose();

			MergeXDeviceConfiguration();
		}
示例#23
0
 public void SetXDeviceConfiguration(XDeviceConfiguration xDeviceConfiguration)
 {
     ConfigurationFileManager.SetXDeviceConfiguration(xDeviceConfiguration);
 }
		static void InvalidateOneClause(XDeviceConfiguration deviceConfiguration, XDevice device, XClause clause)
		{
			clause.Devices = new List<XDevice>();
			clause.Zones = new List<XZone>();
			clause.Directions = new List<XDirection>();

			var zoneUIDs = new List<Guid>();
			foreach (var zoneUID in clause.ZoneUIDs)
			{
				var zone = deviceConfiguration.Zones.FirstOrDefault(x => x.UID == zoneUID);
				if (zone != null)
				{
					zoneUIDs.Add(zoneUID);
					clause.Zones.Add(zone);
					zone.DevicesInLogic.Add(device);
				}
			}
			clause.ZoneUIDs = zoneUIDs;

			var deviceUIDs = new List<Guid>();
			foreach (var deviceUID in clause.DeviceUIDs)
			{
				var clauseDevice = deviceConfiguration.Devices.FirstOrDefault(x => x.UID == deviceUID);
				if (clauseDevice != null && !clauseDevice.IsNotUsed)
				{
					deviceUIDs.Add(deviceUID);
					clause.Devices.Add(clauseDevice);
					clauseDevice.DevicesInLogic.Add(device);
				}
			}
			clause.DeviceUIDs = deviceUIDs;

			var directionUIDs = new List<Guid>();
			foreach (var directionUID in clause.DirectionUIDs)
			{
				var direction = deviceConfiguration.Directions.FirstOrDefault(x => x.UID == directionUID);
				if (direction != null)
				{
					directionUIDs.Add(directionUID);
					clause.Directions.Add(direction);
					direction.OutputDevices.Add(device);
					device.Directions.Add(direction);
				}
			}
			clause.DirectionUIDs = directionUIDs;
		}