Exemplo n.º 1
0
 /// <summary>
 /// 检查更新
 /// </summary>
 static void CheckUpdate()
 {
     //检查网络状态
     if (CheckNetWork.CheckServeStatus() == false)
     {
         MessageBox.Show(ErrorCode.NetWorkError, ErrorCode.Caption);
     }
     //版本检测
     try
     {
         var          version      = JsonConvert.DeserializeObject <dynamic>(PostTool.Get("http://loocos.cn/YuYuDown/version.json"));
         Version      newVersion   = new Version(version.version.ToString());
         Version      nowVersion   = new Version(SytemVersion.AssemblyFileVersion.ToString());
         DialogResult updateResult = DialogResult.None;
         if (newVersion > nowVersion)
         {
             updateResult = MessageBox.Show(@"是否进行更新?", @"更新提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         }
         //开始更新
         if (updateResult == DialogResult.OK)
         {
             Console.WriteLine(@"开始更新");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"更新检查失败", @"更新提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         LogHelper.ErrorLog("更新失败", ex);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 检查网络状态
 /// </summary>
 static void CheckNetWorkStatus()
 {
     //检查网络状态
     if (CheckNetWork.CheckServeStatus() == false)
     {
         MessageBox.Show(ErrorCode.NetWorkError, ErrorCode.Caption);
     }
 }
Exemplo n.º 3
0
        public static DateTime?GetStandardDataTime()
        {
            //"time-a.timefreq.bldrdoc.gov"     "132.163.4.101";
            //"time-b.timefreq.bldrdoc.gov"     "132.163.4.102";
            //"time-c.timefreq.bldrdoc.gov"     "132.163.4.103";
            //"utcnist.colorado.edu"                 "128.138.140.44";
            //"nist1.symmetricom.com"            "69.25.96.13";
            //"nist1.aol-va.truetime.com"         "64.236.96.53";
            string[] timeServer = new string[] { "132.163.4.101", "132.163.4.102", "132.163.4.103", "128.138.140.44", "69.25.96.13", "64.236.96.53" };

            TcpClient client  = new TcpClient();
            int       portNum = 13;

            byte[] bytes     = new byte[1024];
            int    bytesRead = 0;

            for (int i = 0; i < timeServer.Length; i++)
            {
                string hostName = timeServer[i];
                if (CheckNetWork.CheckConnectNetWork(hostName))
                {
                    try
                    {
                        client.Connect(hostName, portNum);
                        NetworkStream ns = client.GetStream();
                        bytesRead = ns.Read(bytes, 0, bytes.Length);
                        client.Close();
                        break;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            string strTime = Encoding.ASCII.GetString(bytes, 0, bytesRead);

            string[] s = strTime.Split(' ');
            if (s.Length > 2)
            {
                DateTime dt;
                if (DateTime.TryParse(s[1] + " " + s[2], out dt))
                {
                    //得到标准时间
                    return(dt);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public OCR()
        {
            InitializeComponent();
            timer.Enabled = true;
            this.TopMost  = true;
            CheckNetWork checkNet = new CheckNetWork();

            if (checkNet.IsConnectNetwork())
            {
                ByBaiduEngner.Checked = true;
                ByInnerEngner.Checked = false;
            }
            else
            {
                ByBaiduEngner.Checked = false;
                ByInnerEngner.Checked = true;
            }
        }