Ejemplo n.º 1
0
        private static void RegisterRabbitMqByCefsharpDummy()
        {
            string path = "";

            try
            {
                var login_name = Globals.myComputerInfo.UserName;
#if DEBUG
                //login_name = "aohsadmin";
#endif

                path = Configuration.configuration["aohs.baseurl"] + @"/webapi/client_notify?do_act=register&login_name=" + login_name;

                var pathPure = Configuration.configuration["aohs.baseurl"] + @"/webapi/client_notify";
                var data     = @"{'do_act':'register','login_name':'" + login_name + "'}";

#if DEBUG
                //path = path + "xxx";
#endif

                Globals.log.Debug("Register Notification by CefbrowserDummy through: " + path);

                //FormNotificationPanel.LoadPageToRegisterRabbitMq(@"http://192.168.1.88:3002/webapi/client_notify?do_act=register&login_name=Sirisak");
                //AmivoiceWatcher.myFormCefsharpDummy.RegisterRabbitMq(pathPure, data);
                //AmivoiceWatcher.myFormCefsharpDummy.RegisterRabbitMq(path);
            }
            catch (Exception e)
            {
                Globals.log.Debug(e.ToString());
                Globals.log.Debug("Disable Notification function because UNABLE to set rabbitMq para from server:" + path);
                _rabbitMQ = null;
            }
        }
Ejemplo n.º 2
0
        public static void RegisterNotificationByJson(string jsonstring)
        {
            try
            {
                Globals.log.Debug("RabbitMQWrapper:> RegisterNotificationByJson()");

                myState = State.registering;

                var jsonObject = JsonConvert.DeserializeObject <ClientNotifyResponse>(jsonstring);

                if (jsonObject == null)
                {
                    Globals.log.Debug("Disable Notification function because UNABLE to set rabbitMq para from server");
                    _rabbitMQ = null;
                    //currentState = State.waiting_for_configuration;
                    //currentState = State.connected;
                    myState = State.register_fail;

                    return;
                }

                if (jsonObject.success == "true")
                {
                    Globals.log.Debug("Get rabbitMq para from server >>" + jsonstring);

                    _rabbitMQ = jsonObject;

                    //ConnectionInitialize();

                    myState = State.registered;
                }
                else
                {
                    Globals.log.Debug("Disable Notification function because UNABLE to set rabbitMq para from server");
                    _rabbitMQ = null;
                    //currentState = State.waiting_for_configuration;
                    //currentState = State.connected;
                    myState = State.register_fail;
                }
            }
            catch (Exception e)
            {
                Globals.log.Debug(e.ToString());
                Globals.log.Debug("Disable Notification function because UNABLE to set rabbitMq para from server");
                _rabbitMQ = null;
                myState   = State.register_fail;
            }

            Globals.log.Debug("RabbitMQWrapper:> Finished RegisterNotificationByJson()");
        }
Ejemplo n.º 3
0
        private static void RegisterNotification()
        {
            try
            {
                var login_name = Globals.myComputerInfo.UserName;
#if DEBUG
                //login_name = "aohsadmin";
#endif

                string path = Globals.configuration["notification.register_url"] + @"?do_act=register&login_name=" + login_name;

                Globals.log.Debug("Register Notification through: " + path);

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(path);
                httpWebRequest.ContentType = "application/json; charset=utf-8";

                httpWebRequest.Method = "POST";

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();

                    var jsonObject = JsonConvert.DeserializeObject <ClientNotifyResponse> (result);

                    if (jsonObject.success == "true")
                    {
                        Globals.log.Debug("Get rabbitMq para from server >>" + result);

                        _rabbitMQ = jsonObject;
                    }
                    else
                    {
                        Globals.log.Debug("Disable Notification function because UNABLE to set rabbitMq para from server:" + path);
                        _rabbitMQ = null;
                    }
                }
            }
            catch (Exception e)
            {
                Globals.log.Error(e.ToString());
            }
        }