Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                if (serviceHost != null)
                {
                    serviceHost.Close();
                }

                serviceHost = new ServiceHost(typeof(SyncService));
                serviceHost.Open();

                ConfigWatcher.Startup(configurationFile);

                Console.ReadKey();

                serviceHost.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("{0}", e.StackTrace);
                Console.ReadKey();
            }
        }
Exemplo n.º 2
0
        public static ConfigWatcher Startup(string configurationFile)
        {
            if (instance == null)
            {
                instance = new ConfigWatcher(configurationFile);
                instance.StartWatchers();
            }

            return(instance);
        }
Exemplo n.º 3
0
        public bool ServiceCommand(uint eventId, string objectId)
        {
            ConfigWatcher instance = ConfigWatcher.Instance;

            switch (eventId)
            {
            case STARTUP:
                if (string.IsNullOrEmpty(objectId))
                {
                    instance.StartWatchers();
                }
                else
                {
                    instance.StartWatcher(objectId);
                }
                break;

            case SHUTDOWN:
                if (string.IsNullOrEmpty(objectId))
                {
                    instance.StopWatchers();
                }
                else
                {
                    instance.StopWatcher(objectId);
                }
                break;

            case RESTART:
                instance.RestartWatchers();
                break;

            case STATS:
                instance.RestartWatchers();
                break;
            }
            return(true);
        }