Exemple #1
0
        static void Main()
        {
#if DEBUG
            #region 准备MonitorItemList
            //DBParamter dbParamter = new DBParamter() { DBName = "db_cma", Host = "192.168.1.234", Interval = 4000, Password = "******", Port = 3306, Username = "******" };
            //DBParamter dbParamter2 = new DBParamter() { DBName = "test", Host = "127.0.0.1", Interval = 10000, Password = "******", Port = 3306, Username = "******" };
            //WebCollector webCollector = new WebCollector(dbParamter);
            //WebCollector webCollector2 = new WebCollector(dbParamter2);
            //new CollectorInfoDataProvider().Insert(webCollector);
            //new CollectorInfoDataProvider().Insert(webCollector2);
            #endregion

            //开始
            //CollectorCenter centerCollector = new Service.CollectorCenter(CollectorType.Web, dbParamter2);
            //centerCollector.StartMonitor();

            HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://192.168.1.105:9002");
            config.Routes.MapHttpRoute("default", "collect/{controller}/{action}/{id}", new { id = RouteParameter.Optional });
            using (var server = new HttpSelfHostServer(config))
            {
                server.OpenAsync().Wait();
                CollectorCenter.GetInstance().StartMonitor();

                Application.Run(new Form1());
            }
#else
            ServiceBase[] servicesToRun = new ServiceBase[] {
                new CollectCenterService()
            };
            ServiceBase.Run(servicesToRun);
#endif
        }
Exemple #2
0
 public static CollectorCenter GetInstance()
 {
     lock (_lock)
     {
         if (_instance == null)
         {
             _instance = new CollectorCenter();
         }
         return(_instance);
     }
 }
Exemple #3
0
 public void RemoveCollector(long id)
 {
     try
     {
         CollectorCenter.GetInstance().Remove(id);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage()
         {
             StatusCode = System.Net.HttpStatusCode.InternalServerError,
             Content    = new StringContent(ex.Message)
         });
     }
 }
Exemple #4
0
 public void StartCollect()
 {
     try
     {
         //开始
         CollectorCenter.GetInstance().StartMonitor();
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage()
         {
             StatusCode = System.Net.HttpStatusCode.InternalServerError,
             Content    = new StringContent(ex.Message)
         });
     }
 }
Exemple #5
0
 public bool AddDBMonitor(DBParamter paramter)
 {
     try
     {
         CollectorCenter.GetInstance().Add(CollectorType.Web, paramter);
         return(true);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage()
         {
             StatusCode = System.Net.HttpStatusCode.InternalServerError,
             Content    = new StringContent(ex.Message)
         });
     }
 }