Esempio n. 1
0
 private void ThreadPoolCheckVersion(object obj)
 {
     System.Threading.Thread.Sleep(100);
     HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467);
     HslCommunication.OperateResult <string>      read           = simplifyClient.ReadFromServer(1, "");
     if (read.IsSuccess)
     {
         HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content);
         if (version > HslCommunication.BasicFramework.SoftBasic.FrameworkVersion)
         {
             // 有更新
             Invoke(new Action(() =>
             {
                 if (MessageBox.Show("服务器有新版本:" + read.Content + Environment.NewLine + "是否启动更新?", "检测到更新", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     try
                     {
                         System.Diagnostics.Process.Start("软件自动更新.exe");
                         System.Threading.Thread.Sleep(50);
                         Close( );
                     }
                     catch
                     {
                         MessageBox.Show("更新软件丢失,无法启动更新");
                     }
                 }
             }));
         }
     }
 }
Esempio n. 2
0
        private void userButton1_Click(object sender, EventArgs e)
        {
            if (treeView1.Nodes[0].IsSelected)
            {
                // 新增端口操作
                using (FormCreateClient form = new FormCreateClient())
                {
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        HslCommunication.Enthernet.NetSimplifyClient client = form.Client;

                        ClassNetSettings setting = new ClassNetSettings()
                        {
                            Guid      = Guid.NewGuid().ToString(),
                            IpAddress = form.IpAddress,
                            IpPort    = form.Port,
                            Token     = form.Token,
                            TimeOut   = form.ConnectTimeout,
                        };

                        string   name = $"{form.IpAddress} [{form.Port}]";
                        TreeNode node = new TreeNode(name);
                        node.Tag = client;
                        treeView1.Nodes[0].Nodes.Add(node);

                        List.Add(setting);
                    }
                }
            }
        }
Esempio n. 3
0
 private void ThreadPoolCheckVersion(object obj)
 {
     System.Threading.Thread.Sleep(100);
     HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467);
     HslCommunication.OperateResult <HslCommunication.NetHandle, string> read = simplifyClient.ReadCustomerFromServer(1, HslCommunication.BasicFramework.SoftBasic.FrameworkVersion.ToString( ));
     if (read.IsSuccess)
     {
         HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content2);
         if (version > HslCommunication.BasicFramework.SoftBasic.FrameworkVersion)
         {
             // 有更新
             Invoke(new Action(() =>
             {
                 if (MessageBox.Show("New version on server:" + read.Content2 + Environment.NewLine + " Start update?", "Version Check", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     try
                     {
                         System.Diagnostics.Process.Start(Application.StartupPath + "\\软件自动更新.exe");
                         System.Threading.Thread.Sleep(50);
                         Close( );
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show("更新软件丢失,无法启动更新: " + ex.Message);
                     }
                 }
             }));
         }
     }
 }
Esempio n. 4
0
        private void ThreadPoolCheckVersion(object obj)
        {
            System.Threading.Thread.Sleep(100);
            mqttClient = new HslCommunication.MQTT.MqttClient(new HslCommunication.MQTT.MqttConnectionOptions( )
            {
                IpAddress = "118.24.36.220",
                Port      = 1883,
                ClientId  = "HslDemo"
            });
            mqttClient.ConnectServer( );
            HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467);
            HslCommunication.OperateResult <HslCommunication.NetHandle, string> read = simplifyClient.ReadCustomerFromServer(1, HslCommunication.BasicFramework.SoftBasic.FrameworkVersion.ToString( ));
            if (read.IsSuccess)
            {
                HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content2);
                if (version > HslCommunication.BasicFramework.SoftBasic.FrameworkVersion)
                {
                    // 有更新
                    Invoke(new Action(() =>
                    {
                        if (MessageBox.Show("New version on server:" + read.Content2 + Environment.NewLine + " Start update?", "Version Check", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            try
                            {
                                System.Diagnostics.Process.Start(Application.StartupPath + "\\软件自动更新.exe");
                                System.Threading.Thread.Sleep(50);
                                Close( );
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("更新软件丢失,无法启动更新: " + ex.Message);
                            }
                        }
                    }));
                }
            }

            try
            {
                cur    = Process.GetCurrentProcess( );
                curpcp = new PerformanceCounter("Process", "Working Set - Private", cur.ProcessName);
            }
            catch
            {
            }
        }
        private void userButton1_Click(object sender, EventArgs e)
        {
            try
            {
                Client = new HslCommunication.Enthernet.NetSimplifyClient(
                    textBox1.Text, int.Parse(textBox2.Text))
                {
                    Token          = new Guid(textBox3.Text),
                    ConnectTimeOut = int.Parse(textBox4.Text),
                };

                IpAddress      = textBox1.Text;
                Port           = textBox2.Text;
                Token          = textBox3.Text;
                ConnectTimeout = textBox4.Text;

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 6
0
 private void ThreadPoolCheckVersion(object obj)
 {
     System.Threading.Thread.Sleep(100);
     mqttClient = new HslCommunication.MQTT.MqttClient(new HslCommunication.MQTT.MqttConnectionOptions( )
     {
         IpAddress = "118.24.36.220",
         Port      = 1883,
         ClientId  = "HslControls"
     });
     mqttClient.ConnectServer( );
     HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467);
     HslCommunication.OperateResult <HslCommunication.NetHandle, string> read = simplifyClient.ReadCustomerFromServer(100, versionCurr.ToString( ));
     if (read.IsSuccess)
     {
         HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content2);
         if (version > versionCurr)
         {
             // 有更新
             Invoke(new Action(() =>
             {
                 if (MessageBox.Show("服务器有新版本:" + read.Content2 + Environment.NewLine + "是否启动更新?", "检测到更新", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     try
                     {
                         System.Diagnostics.Process.Start(Application.StartupPath + "\\软件自动更新.exe");
                         System.Threading.Thread.Sleep(50);
                         Close( );
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show("更新软件丢失,无法启动更新: " + ex.Message);
                     }
                 }
             }));
         }
     }
 }