protected override void OnStop()
 {
     JLogger.LogInfo(this, "OnStop() Start");
     base.OnStop();
     if (_wl != null)
     {
         _wl.StopWatchers();
         _wl = null;
     }
     JLogger.LogInfo(this, "OnStop() End");
 }
        protected override void OnStart(string[] args)
        {
            JLogger.LogInfo(this, "OnStart() Start");

            if (_wl == null)
            {
                _wl = new WatcherLoader();
            }

            _wl.StartWatchers();

            JLogger.LogInfo(this, "OnStart() End");
        }
Example #3
0
        public void Start()
        {
            JLogger.LogInfo(this, "Start() In");

            //INIT REMOTE OPERATIONS
            _factHandlerClient = new SRMServerAccess();

            //Enroll Machine
            //JMachine.Id = _factHandlerClient.EnrollMachine(JMachine.GetMachine());

            //Get Configuration
            //_factHandlerClient.GetMachineConfiguration(_machine);

            //Start CommandService
            try
            {
                JLogger.LogDebug(this, "Se crea el service host con la direccion base.");
                var baseAddress = new Uri("http://localhost:8080/CommandService");
                _commandService = new ServiceHost(typeof(CommandService), baseAddress);

                JLogger.LogDebug(this, "Se configura para presentar el metadata.");
                var smb = new ServiceMetadataBehavior
                {
                    HttpGetEnabled   = true,
                    MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 }
                };
                _commandService.Description.Behaviors.Add(smb);

                JLogger.LogDebug(this, "Se Abre la comunicacion.");
                _commandService.Open();
            }
            catch (Exception ex)
            {
                JLogger.LogError(this, "Error al crear el host.", ex);
            }

            //Start Watchers
            _watcherLoader = new WatcherLoader();
            _watcherLoader.StartWatchers();

            JLogger.LogInfo(this, "Stop() Out");
        }
Example #4
0
        public void Stop()
        {
            JLogger.LogInfo(this, "Stop() In");

            //STOP COMMANDSERVICE
            if (_commandService != null)
            {
                _commandService.Close();
                _commandService = null;
            }

            //STOP WATCHERS
            if (_watcherLoader != null)
            {
                _watcherLoader.StopWatchers();
                _watcherLoader = null;
            }

            JLogger.LogInfo(this, "Stop() Out");
        }
        public AgentServiceWatcher()
        {
            JLogger.LogInfo(this, "AgentServiceWatcher() Start");
            _wl = new WatcherLoader();

            ServiceName  = "SRMAgentServiceWatcher";
            EventLog.Log = "Application";

            // These Flags set whether or not to handle that specific
            //  type of event. Set to true if you need it, false otherwise.
            CanHandlePowerEvent         = true;
            CanHandleSessionChangeEvent = true;
            CanPauseAndContinue         = true;
            CanShutdown = true;
            CanStop     = true;

            InitializeComponent();

            JLogger.LogInfo(this, "AgentServiceWatcher() End");
        }
Example #6
0
        // ReSharper disable once UnusedParameter.Local
        private static void Main(string[] args)
        {
            //ENROLL MACHINE
            var hostName   = Dns.GetHostName();
            var ipHostInfo = Dns.GetHostEntry(hostName);
            var ipAddress  = Convert.ToString(ipHostInfo.AddressList.FirstOrDefault(address => address.AddressFamily == AddressFamily.InterNetwork));

            int id = ServerAccess.EnrollMachine(new Machine()
            {
                Ip = ipAddress, Name = hostName
            });
            //GET CONFIGURATION

            //ENABLE WATCHERS
            var wl = new WatcherLoader();

            wl.StartWatchers();

            Console.WriteLine("Press Any Key to stop");
            Console.ReadKey();
            wl.StopWatchers();
        }