コード例 #1
0
 /// <summary>
 /// 窗体加载事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void CheckUpdate_Load(object sender, EventArgs e, int type)
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //解决极少部分系统(window server 2008R2 和极少部分win7)显示Could not create SSL/TLS secure channel
     Jnw.Common.AutoUpdate au = GetJnWCommonAutoUpdateInstance();
     au.KillProcess("KentCraft", true, false);
     //au.KillProcess("java", true);
     //au.KillProcess("javaw", true);
     //判断是否需要更新
     if (type == 1)
     {
         if (!au.CheckUpdate(_tipString))
         {
             NewestCallback newestCallback = new NewestCallback(delegate()
             {
                 au.OpenUpdate("KentCraft.exe");//程序文件名
                 Application.Exit();
             });
             newestCallback();
         }
     }
     else if (type == 2)
     {
         if (!au.CheckUpdate("192.168.1.1", "FileShare", "LoginAccount", "LoginPassword", _tipString))
         {
             NewestCallback newestCallback = new NewestCallback(() => Application.Exit());
             newestCallback();
         }
     }
 }
コード例 #2
0
        private void PromptUpdateRootNotification()
        {
            TopMost = false;
            DialogResult dr = MessageBox.Show("更新成功,是否立即查看更新日志?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            Jnw.Common.AutoUpdate au = GetJnWCommonAutoUpdateInstance();
            if (dr == DialogResult.Yes)
            {
                au.OpenUpdateLog();
            }
            //如果有多个启动器,则打开最新的启动器
            var exe = Jnw.Common.FileHelper.GetFileNames(_winformPath, "KentCraft启动器 v*.exe", false);

            if (exe.Length > 1)
            {
                string newExe = "";
                foreach (var temp in exe)
                {
                    if (newExe == "" ||
                        Convert.ToInt32(temp.Substring((_winformPath + "KentCraft启动器 v").Length, 6)) >
                        Convert.ToInt32(newExe.Substring((_winformPath + "KentCraft启动器 v").Length, 6)))
                    {
                        newExe = temp;
                    }
                }
                au.OpenUpdate(newExe);
            }
            else
            {
                au.OpenUpdate("KentCraft.exe");//程序文件名
            }
        }
コード例 #3
0
        /// <summary>
        /// 执行线程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        protected virtual void bgwUpdate_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bgw = sender as BackgroundWorker;

            //允许报告进度
            bgw.WorkerReportsProgress = true;
            Jnw.Common.AutoUpdate au = GetJnWCommonAutoUpdateInstance();
            IsSuccess = au.UpdateFile(bgw, PbUpdateAll);
        }
コード例 #4
0
 protected virtual void btnCancel2_Click(object sender, EventArgs e)
 {
     PromptCancelMessageBox2(delegate()
     {
         Jnw.Common.AutoUpdate au = GetJnWCommonAutoUpdateInstance();
         au.OpenUpdate("KentCraft.exe");//程序文件名
         Application.Exit();
     });
 }
コード例 #5
0
        protected virtual void btnConfirm_Click(object sender, EventArgs e)
        {
            Jnw.Common.AutoUpdate au = GetJnWCommonAutoUpdateInstance();
            //提示
            PromptConfirmMessageBox(delegate
                                    ()
            {
                //测试
                //au.KillProcess("FileName.vshost");
                au.KillProcess("KentCraft", true, false);
                au.KillProcess("java", true);
                au.KillProcess("javaw", true);

                this.Hide();
                AutoUpdate2 winFormau = new AutoUpdate2();
                winFormau.Show();
            });
        }