Example #1
0
        public void SetEnabled(string assemblyName, string agentName, bool enabled)
        {
            IAgentConfiguration config = GetAgentConfig(assemblyName, agentName);

            if (config != null)
            {
                config.Enabled = enabled;
            }
        }
Example #2
0
        public bool IsAgentEnabled(string assemblyName, string agentName)
        {
            IAgentConfiguration config = GetAgentConfig(assemblyName, agentName);

            if (config == null)
            {
                return(false);
            }
            return(config.Enabled);
        }
Example #3
0
        protected Connection(IAgentConfiguration agentConfiguration, ILoggerFactory loggerFactory)
        {
            Logger = loggerFactory.CreateLogger <Connection>();
            _agentConfiguration = agentConfiguration;

            CallOptions = new CallOptions();
            CallContext = new CallContext(CallOptions);

            DebugFlag = agentConfiguration.DebugFlag;

            if (DebugFlag)
            {
                Logger.LogTrace("Grpc Agent Connection for: " + _agentConfiguration.ConnectionUrl);
            }
        }
 /// <summary>
 /// Used to clone objects
 /// </summary>
 /// <param name="source"></param>
 public void CloneFrom(IAgentConfiguration source)
 {
     this.AssemblyName = source.AssemblyName;
     this.AgentName    = source.AgentName;
     this.ConfigurationSettingsTypeName = source.ConfigurationSettingsTypeName;
     this.Enabled                = source.Enabled;
     this.HardLockAttempts       = source.HardLockAttempts;
     this.HardLockDurationHrs    = source.HardLockDurationHrs;
     this.SoftLockAttempts       = source.SoftLockAttempts;
     this.SoftLockDurationMins   = source.SoftLockDurationMins;
     this.OverwriteConfiguration = source.OverwriteConfiguration;
     this.NeverUnlock            = source.NeverUnlock;
     if (!String.IsNullOrEmpty(ConfigurationSettingsTypeName) && source.AgentSettings != null)
     {
         AgentSettings = (PluginConfiguration)Activator.CreateInstance(GetConfigurationType());
         this.AgentSettings.CloneFrom(source.AgentSettings);
     }
 }
Example #5
0
        public ShowAgent(IAgentConfiguration config, IAgentManager manager, IResourceManager resourceManager)
        {
            Debug.Assert(config != null, "IAgentConfiguration не может быть null");
            _config = config;
            _resourceManager = resourceManager;
            //TODO
            // пока создается здесь - если нужен будет еще где то на компе, то нужно будет передавать извне
            //_sourceDAL = new SourceDAL(_config);
            _manager = manager;

            StringBuilder text = new StringBuilder(InfoMessage, 1024);

            CurrentDisplay = GetDisplayType(_config);
            if (CurrentDisplay == null)
                throw new WrongAgentUIDException();
            _currentModule = GetModuleByDisplayType(config, CurrentDisplay);
            foreach (IModule module in _config.ModuleList)
            {
                try
                {
                    if (module.VisualizatorModule.Init(config.EventLog))
                    {
                        foreach (Type type in module.SystemModule.Presentation.GetSource())
                        {
                            _sourceTypeMapping[type] = module.VisualizatorModule.IsSupportView ? module.VisualizatorModule : _currentModule.VisualizatorModule;
                        }
                        text.AppendLine(module.Name);
                    }
                }
                catch (Exception ex)
                {
                    _config.EventLog.WriteError(String.Format("Модуль {0}, не был загружен, ошибка: {1}", module.Name,
                                                              ex.Message));
                }
            }
            _config.EventLog.WriteInformation(text.ToString());
            _restoringTimer.Elapsed += new ElapsedEventHandler(_restoringTimer_Elapsed);
            _restoringTimer.Start();
        }
 public AgentConnection()
 {
     Agent = new KSociety.Base.Srv.Agent.AgentConfiguration("http://localhost:5001", true);
 }
Example #7
0
 public DatabaseControl(IAgentConfiguration agentConfiguration, ILoggerFactory loggerFactory)
     : base(agentConfiguration, loggerFactory)
 {
 }
Example #8
0
 private static DisplayType GetDisplayType(IAgentConfiguration config)
 {
                 // TODO - это правильный вариант
                 if (string.IsNullOrEmpty(config.AgentUID)) return null;
                 foreach (DisplayType item in config.ModuleConfiguration.DisplayList)
                 {
                     if (!(item is DisplayTypeUriCapture)) continue;
                     DisplayTypeUriCapture display = (DisplayTypeUriCapture)item;
                     if (String.Compare(config.AgentUID, display.AgentUID, StringComparison.InvariantCultureIgnoreCase) == 0)
                     {
                         return display;
                     }
                 }
                 return null;
     // TODO - это лажа, исключительно для тестирования, надо объяснить тестировщикам как настраивать
     //string name = Environment.MachineName;
     //foreach (DisplayType item in config.ModuleConfiguration.DisplayList)
     //{
     //    if (!(item is DisplayTypeUriCapture)) continue;
     //    DisplayTypeUriCapture display = (DisplayTypeUriCapture)item;
     //    if (String.Compare(name, display.AgentUID, StringComparison.InvariantCultureIgnoreCase) == 0)
     //    {
     //        return display;
     //    }
     //}
     //foreach (DisplayType item in config.ModuleConfiguration.DisplayList)
     //{
     //    if (!(item is DisplayTypeUriCapture)) continue;
     //    DisplayTypeUriCapture display = (DisplayTypeUriCapture)item;
     //    if (String.Compare("localhost", display.AgentUID, StringComparison.InvariantCultureIgnoreCase) == 0)
     //    {
     //        return display;
     //    }
     //}
     //return null;
 }