Esempio n. 1
0
		public OperationResult<bool> Connect(FSAgent fsAgent, bool isPing)
		{
			try
			{
				FiresecSerializedClient = new FiresecSerializedClient();
				FiresecSerializedClient.FSAgent = fsAgent;
				FiresecSerializedClient.SubscribeFsAgentEvents();

                ConfigurationConverter = new ConfigurationConverter(FiresecSerializedClient);
				var result = ConfigurationConverter.ConvertMetadataFromFiresec();
                if (!result.HasError)
                {
                    ConfigurationCash.DriversConfiguration = result.Result;
                    return new OperationResult<bool>() { Result = true };
                }
                else
                {
					return new OperationResult<bool>(result.Error);
                }
			}
			catch (Exception e)
			{
				Logger.Error(e, "FiresecDriver.Synchronyze");
                LoadingErrorManager.Add(e);
                return new OperationResult<bool>(e.Message);
			}
		}
        static public OperationResult<bool> InitializeFiresecDriver(bool isPing)
        {
            try
            {
				FSAgent = new FSAgent(ConnectionSettingsManager.FSAgentServerAddress);
                FiresecDriver = new FiresecDriver();
                var result = FiresecDriver.Connect(FSAgent, isPing);
                return result;
            }
            catch (Exception e)
            {
                Logger.Error(e, "FiresecManager.InitializeFiresecDriver");
                LoadingErrorManager.Add(e);
                return new OperationResult<bool>(e.Message);
            }
        }