Esempio n. 1
0
        public MonitorService()
        {
            var time = double.Parse(ConfigurationManager.AppSettings["saveTimer"]);

            string address = string.Empty;
            foreach (IPAddress item in Dns.GetHostAddresses(Dns.GetHostName()))
            {
                if (!item.IsIPv6LinkLocal && !item.IsIPv6Multicast && !item.IsIPv6SiteLocal && !item.IsIPv6Teredo)
                    address = item.ToString();
            }

            monitor = new Monitor();
            serviceHost = new ServiceHost(monitor, new Uri(string.Format("http://{0}:4325/", address)));
            saveTimer = new Timer(time);
            saveTimer.Elapsed += (o, args) =>
            {
                monitor.SaveWatchs();
                monitor.SaveStatistics();
            };
        }