Ejemplo n.º 1
0
    public void Connect(
        string name,
        int delayMs = 5000
        )
    {
        Directory.CreateDirectory(Path
                                  .GetDirectoryName(offlineLogsPath));

        remote.Connect(name);

        remote.OnEvent.Subscribe(async _ => {
            if (_.Type == NetEventType.ConnectionFailed)
            {
                await Task.Delay(delayMs);

                remote.Connect(name);
            }

            if (_.Type == NetEventType.NewConnection &&
                File.Exists(offlineLogsPath)
                )
            {
                foreach (var message in LoadMessages())
                {
                    Send(message);
                }
            }
        });
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            RemoteServer rso = null;
            string       request;
            string       response;

            try
            {
                rso     = new RemoteServer();
                request = "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"subtract\" , \"params\": {\"subtrahend\": 23.4, \"minuend\": 42.8}}";
                rso.Connect("jsonrpcservertest", null, null);
                response = rso.JsonRpcRequest(request);
                Console.WriteLine("#### Response ####");
                Console.WriteLine(response);
            }
            finally
            {
                if (rso != null)
                {
                    rso.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
Archivo: UCLogin.cs Proyecto: SHKCB/RF
        /// <summary>
        /// 登录
        /// </summary>
        private void LoadData()
        {
            this.btnLogin.Enabled = false;

            string username = this.txtUserName.Text.Trim();

            string password = this.txtPassWord.Text.Trim();

            if (username.Length == 0)
            {
                base.ShowMessage("请输入用户名!", false, EnMessageType.A, false);

                return;
            }

            if (password.Length == 0)
            {
                base.ShowMessage("请输入密码!", false, EnMessageType.B, false);

                return;
            }

            //bool hasError = false;

            //bool needUpdate = SCM.RF.Client.BizProcess.Sys.InstanceBP.NeedUpdate(out hasError);

            //if (needUpdate)
            //{
            //    base.ShowMessage("系统有更新!", false, EnMessageType.C);

            //    return;
            //}
            //else
            //{
            //    if (hasError)
            //    {
            //        base.ShowMessage("与服务器同步失败,请重试!", false, EnMessageType.A, false);

            //        return;
            //    }
            //}

            #region 登录验证

            IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress   ip     = ipHost.AddressList[0];

            RemoteServer param = new RemoteServer(SCM.RF.Client.BizProcess.Sys.InstanceBP.SystemInstance.ServerIp, SCM.RF.Client.BizProcess.Sys.InstanceBP.SystemInstance.ServerPort);
            param.Connect();

            if (param.Connected)
            {
                UserViewEntity entity = new UserViewEntity();

                entity.UName   = username;
                entity.PWD     = password;
                entity.LocalIP = ip.ToString();
                entity.Device  = SCM.RF.Client.BizProcess.Sys.InstanceBP.SystemInstance.Device;
                entity.CID     = SCM.RF.Client.BizProcess.Sys.InstanceBP.SystemInstance.CID;

                entity = new SCM.RF.Client.BizProcess.Login.LoginBP().LoginIn(entity, param);

                if (entity != null && entity.IsLoggedIn)
                {
                    base.RF.RemoteServer = param;

                    base.RF.UserViewEntity = entity;

                    base.RF.ShowMenu();

                    this.btnLogin.Enabled = true;

                    base.RF.SetUser(entity.UName);
                }
                else
                {
                    base.ShowMessage("用户名或密码错误!", false, EnMessageType.A, false);
                }
            }
            else
            {
                base.ShowMessage("服务器连接失败!", false, EnMessageType.A, false);
            }

            #endregion
        }