コード例 #1
0
        void do连接_Click(object sender, EventArgs e)
        {
            var __ip   = this.inIP2.Text;
            var __port = this.in端口号.Text;
            var __最后访问 = _访问记录.Find(q => q.IP.ToString() == __ip && q.端口号.ToString() == __port);

            if (__最后访问 == null)
            {
                if (!H检测网络.IsHostAlive(__ip, int.Parse(__port), 2000))
                {
                    new F对话框_确定("连接失败").ShowDialog();
                    return;
                }
                else
                {
                    __最后访问 = new M访问记录 {
                        IP = __ip, 端口号 = int.Parse(__port)
                    };
                }
            }
            else
            {
                _访问记录.Remove(__最后访问);
            }
            _访问记录.Insert(0, __最后访问);

            H程序配置.设置("访问记录", H序列化.ToJSON字符串(_访问记录));
            H日志输出.设置(q =>
            {
                if (q.等级 <= TraceEventType.Information)
                {
                    if (q.异常 != null)
                    {
                        H日志.记录异常(q.异常, q.概要, q.详细, q.等级, q.方法, q.文件, q.行号);
                    }
                    else
                    {
                        H日志.记录(q.概要, q.等级, q.详细, q.方法, q.文件, q.行号);
                    }
                }
            });
            _IT客户端 = FT通用访问工厂.创建客户端();
            H容器.注入 <IT客户端>(_IT客户端, false);
            _IT客户端.自动重连 = true;
            _IT客户端.已断开 += q => 设置连接状态();
            _IT客户端.已连接 += 设置连接状态;
            _IT客户端.连接(new IPEndPoint(IPAddress.Parse(__ip), int.Parse(__port)));
            this.ParentForm.ShowInTaskbar = false;
            this.ParentForm.Visible       = false;
            _F主窗口 = new F空窗口(new F主窗口(), "");
            设置连接状态();
            _F主窗口.FormClosing += OnClosing;
            _F主窗口.ShowDialog();
        }
コード例 #2
0
ファイル: F登录.cs プロジェクト: xiaomiwk/K_gps
        void do登录_Click(object sender, EventArgs e)
        {
            var __ip   = this.inIP2.Text;
            var __port = this.in端口号.Text;
            var __最后访问 = _访问记录.Find(q => q.IP.ToString() == __ip && q.端口号.ToString() == __port);

            if (__最后访问 == null)
            {
                if (!H检测网络.IsHostAlive(__ip, int.Parse(__port), 2000))
                {
                    new F对话框_确定("连接失败").ShowDialog();
                    return;
                }
                else
                {
                    __最后访问 = new M访问记录 {
                        IP = __ip, 端口号 = int.Parse(__port)
                    };
                }
            }
            else
            {
                _访问记录.Remove(__最后访问);
            }
            _访问记录.Insert(0, __最后访问);
            H程序配置.设置("访问记录", H序列化.ToJSON字符串(_访问记录));
            B入口.已断开 += q => 设置连接状态();
            B入口.已连接 += 设置连接状态;
            B入口.连接(new IPEndPoint(IPAddress.Parse(__ip), int.Parse(__port)), true);
            this.ParentForm.ShowInTaskbar = false;
            this.ParentForm.Visible       = false;
            _窗口 = new F空窗口(new F主窗口(), 获取标题())
            {
                允许设置 = true,
                点击设置 = () => new F空窗口(new F配置(), "配置").ShowDialog()
            };
            _窗口.ShowDialog();
            Application.Exit();
        }