Exemplo n.º 1
0
        static void Main()
        {
            byte[] bt   = Json.Object2Byte("测试 Json Byte 转换");
            string __bt = Json.Byte2Object <string>(bt);

            byte[] a   = Encoding.UTF8.GetBytes("张无忌");
            string __a = Encoding.UTF8.GetString(a);

            byte[] b   = Encoding.Unicode.GetBytes("张无忌");
            string __b = Encoding.Unicode.GetString(b);

            byte[] c   = Encoding.UTF8.GetBytes("ぬゆまほㅙㅚЪЖ");
            string __c = Encoding.UTF8.GetString(c);

            byte[] d   = Encoding.Unicode.GetBytes("ぬゆまほㅙㅚЪЖ");
            string __d = Encoding.Unicode.GetString(d);


            List <int> ports = CMDNetstatTool.GetAvailablePorts(10);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Exemplo n.º 2
0
        private void Do()
        {
            Task.Factory.StartNew(() =>
            {
                List <int> ports = CMDNetstatTool.GetAvailablePorts(10, 52810);
                if (Ls.Ok(ports))
                {
                    foreach (var p in ports)
                    {
                        try
                        {
                            R.Tx.TcppPort   = p;
                            R.Tx.TcppServer = new TcppServer(R.Tx.TcppPort, TcppEvent.ReceiveMessage,
                                                             TcppEvent.OnConnect, TcppEvent.OnDisconnect);
                            R.Tx.TcppServer.Start();//启动 Socket Tcp 通信机制
                            IniTool.Set(R.Files.Settings, "Tx", "TcppPort", R.Tx.TcppPort);
                            IniTool.Set(R.Files.Settings, "Tx", "StartTime", DateTime.Now.ToString());
                            break;
                        }
                        catch { }
                    }
                }

                R.USBListener.Start();        // 启动USB监控
                R.USBStorageListener.Start(); // 启动U盘监控
            });
        }
Exemplo n.º 3
0
        private void BTKillApp_Click(object sender, EventArgs e)
        {
            var list = CMDNetstatTool.FindByPort(int.Parse(TBPort.Text), false);

            if (ListTool.HasElements(list) && list.Count == 1)
            {
                try
                {
                    Process p = Process.GetProcessById(list.First().Item2);
                    p.Kill();
                }
                catch { }
            }
        }
Exemplo n.º 4
0
 public static void Start()
 {
     Task.Factory.StartNew(() =>
     {
         List <int> ports = CMDNetstatTool.GetAvailablePorts(10, 52830);
         if (Ls.Ok(ports))
         {
             foreach (var p in ports)
             {
                 try
                 {
                     R.Tx.Port       = p;
                     R.Tx.TcppServer = new TcppServer(R.Tx.Port, ReceiveMessage,
                                                      OnConnect, OnDisconnect);
                     R.Tx.TcppServer.Start();//启动 Socket Tcp 通信机制
                     break;
                 }
                 catch { }
             }
         }
     });
 }
Exemplo n.º 5
0
 private void BTFindPort_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(TBPort.Text))
     {
         var list = CMDNetstatTool.FindByPort(int.Parse(TBPort.Text));
         if (ListTool.HasElements(list))
         {
             list.ForEach(x =>
             {
                 string name = "-";
                 string file = "-";
                 try
                 {
                     Process p = Process.GetProcessById(x.Item2);
                     name      = p?.ProcessName;
                     file      = p?.MainModule.FileName;
                 }
                 catch { }
                 TBRs.AppendText($"{x.Item1}, {x.Item2}, {name}, {file}");
                 TBRs.AppendText(Environment.NewLine);
             });
         }
     }
 }
Exemplo n.º 6
0
        private List <Tuple <int, int> > Fun2()
        {
            List <Tuple <int, int> > list = CMDNetstatTool.Find(".");

            return(list);
        }