Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            version = new HslCommunication.BasicFramework.SystemVersion(textBox1.Text);
            File.WriteAllBytes("version.txt", Encoding.Default.GetBytes(textBox1.Text));

            MessageBox.Show("更新成功");
        }
Esempio n. 2
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("服务器有新版本:" + 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);
                     }
                 }
             }));
         }
     }
 }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // 加载版本号
            if (File.Exists("version.txt"))
            {
                textBox1.Text = Encoding.Default.GetString(File.ReadAllBytes("version.txt"));
                version       = new HslCommunication.BasicFramework.SystemVersion(textBox1.Text);
            }

            if (!Directory.Exists(Application.StartupPath + @"\Demo"))
            {
                Directory.CreateDirectory(Application.StartupPath + @"\Demo");
            }
        }
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
            {
            }
        }
Esempio n. 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // 加载版本号
            if (File.Exists("version.txt"))
            {
                textBox1.Text = Encoding.Default.GetString(File.ReadAllBytes("version.txt"));
                version       = new HslCommunication.BasicFramework.SystemVersion(textBox1.Text);
            }


            if (File.Exists("version2.txt"))
            {
                textBox3.Text = Encoding.Default.GetString(File.ReadAllBytes("version2.txt"));
                version2      = new HslCommunication.BasicFramework.SystemVersion(textBox3.Text);
            }

            if (File.Exists("version3.txt"))
            {
                textBox4.Text = Encoding.Default.GetString(File.ReadAllBytes("version3.txt"));
                version3      = new HslCommunication.BasicFramework.SystemVersion(textBox4.Text);
            }

            if (!Directory.Exists(Application.StartupPath + @"\Demo"))
            {
                Directory.CreateDirectory(Application.StartupPath + @"\Demo");
            }


            if (!Directory.Exists(Application.StartupPath + @"\Controls"))
            {
                Directory.CreateDirectory(Application.StartupPath + @"\Controls");
            }

            lognet = new HslCommunication.LogNet.LogNetSingle("logs.txt");
            lognet.BeforeSaveToFile += LogNet_BeforeSaveToFile;

            LoadData( );
            timer.Interval = 3000;
            timer.Tick    += Timer_Tick;
            timer.Start( );
        }