Example #1
0
        public void Run()
        {
            ClusterConfigManager.Get((cfg) =>
            {
                Cfg    = cfg;
                Worker = new EventQueue();
                Worker.Start();

                Listener = new UdpSocket(cfg.IpInterna, cfg.PuertoInterno);
                Listener.NewDataEvent += OnNewData;
                Listener.BeginReceive();

                StartWebService();
            });
        }
Example #2
0
 protected void OnWebRequestConfig(HttpListenerContext context, StringBuilder sb)
 {
     context.Response.ContentType = "application/json";
     if (context.Request.HttpMethod == "GET")
     {
         string data = JsonHelper.ToString(new { res = "Error al obtener configuracion" }, false);
         context.Response.StatusCode = 500;
         ClusterConfigManager.Get((cfg) =>
         {
             data = JsonHelper.ToString(new { res = "ok", cfg }, false);
             context.Response.StatusCode = 200;
         });
         sb.Append(data);
     }
     else if (context.Request.HttpMethod == "POST")
     {
         using (var reader = new StreamReader(context.Request.InputStream, context.Request.ContentEncoding))
         {
             string strData = reader.ReadToEnd();
             if (ClusterConfigManager.Set(strData))
             {
                 ///** Reiniciar el Servicio */
                 //Reset();
                 ///** Historico */
                 //History.Add(HistoryItems.UserConfigChange, SystemUsers.CurrentUserId);
                 context.Response.StatusCode = 200;
                 sb.Append(JsonHelper.ToString(new { res = "ok" }, false));
             }
             else
             {
                 context.Response.StatusCode = 500;
                 sb.Append(JsonHelper.ToString(new { res = "Error actualizando la configuracion" }, false));
             }
         }
     }
     else
     {
         context.Response.StatusCode = 404;
         sb.Append(JsonHelper.ToString(new { res = context.Request.HttpMethod + ": Metodo No Permitido" }, false));
     }
 }