Ejemplo n.º 1
0
		public static void Load()
		{
			MetadataHelper.Initialize();

			var serverConfigName = AppDataFolderHelper.GetServerAppDataPath("Config.fscp");
			var folderName = AppDataFolderHelper.GetFolder("Server2");
			var configFileName = Path.Combine(folderName, "Config.fscp");
			if (Directory.Exists(folderName))
				Directory.Delete(folderName, true);
			Directory.CreateDirectory(folderName);
			File.Copy(serverConfigName, configFileName);

			var zipFile = ZipFile.Read(configFileName, new ReadOptions { Encoding = Encoding.GetEncoding("cp866") });
			var fileInfo = new FileInfo(configFileName);
			var unzipFolderPath = Path.Combine(fileInfo.Directory.FullName, "Unzip");
			zipFile.ExtractAll(unzipFolderPath);

			var configurationFileName = Path.Combine(unzipFolderPath, "DeviceConfiguration.xml");
			DeviceConfiguration = ZipSerializeHelper.DeSerialize<DeviceConfiguration>(configurationFileName);

			configurationFileName = Path.Combine(unzipFolderPath, "DriversConfiguration.xml");
			DriversConfiguration = ZipSerializeHelper.DeSerialize<DriversConfiguration>(configurationFileName);
			DriversConfiguration.Drivers.ForEach(x => x.Properties.RemoveAll(z => z.IsAUParameter));
			DriverConfigurationParametersHelper.CreateKnownProperties(DriversConfiguration.Drivers);
			AddTempStates();
			Update();
		}
Ejemplo n.º 2
0
 static ConfigurationCash()
 {
     DriversConfiguration = new DriversConfiguration();
     DeviceConfiguration = ConfigurationFileManager.GetDeviceConfiguration();
     SecurityConfiguration = ConfigurationFileManager.GetSecurityConfiguration();
     LibraryConfiguration = ConfigurationFileManager.GetLibraryConfiguration();
     SystemConfiguration = ConfigurationFileManager.GetSystemConfiguration();
     PlansConfiguration = ConfigurationFileManager.GetPlansConfiguration();
     DeviceConfigurationStates = new DeviceConfigurationStates();
 }
Ejemplo n.º 3
0
		public OperationResult<DriversConfiguration> ConvertMetadataFromFiresec()
		{
			var driversConfiguration = new DriversConfiguration();
			var metadataResult = FiresecSerializedClient.GetMetaData();
			if (metadataResult.HasError)
			{
				LoadingErrorManager.Add(metadataResult.Error);
				return new OperationResult<DriversConfiguration>(metadataResult.Error);
			}
			var coreDriversConfig = metadataResult.Result;
			if (coreDriversConfig == null)
			{
				return new OperationResult<DriversConfiguration>("Список драйверов пуст");
			}

			foreach (var innerDriver in coreDriversConfig.drv)
			{
				var driver = DriverConverter.Convert(coreDriversConfig, innerDriver);
				if (driver == null)
				{
					if (innerDriver.name != "БУНС-2" && innerDriver.name != "USB БУНС-2")
					{
						Logger.Error("Не удается найти данные для драйвера " + innerDriver.name);
						LoadingErrorManager.Add("Не удается найти данные для драйвера " + innerDriver.name);
					}
				}
				else
				{
					if (driver.IsIgnore == false)
						driversConfiguration.Drivers.Add(driver);
				}
			}

			DriverConfigurationParametersHelper.CreateKnownProperties(driversConfiguration.Drivers);
#if DEBUG
			//ZipSerializeHelper.Serialize<DriversConfiguration>(driversConfiguration, "C:/DriversConfiguration.xml");
#endif
			return new OperationResult<DriversConfiguration>() { Result = driversConfiguration };
		}