예제 #1
0
        public UpdatingViewModel(UpdatingView updatingView)
        {
            _updatingView = updatingView;

            Message = "请勿关闭程序,正在升级中......\r\n升级完成后会自动启动新版本。";

            UpdatingCommand = new DelegateCommand(UpdatingAsync);
        }
예제 #2
0
파일: Program.cs 프로젝트: wshPrt/facebook-
        private static async Task <bool> CheckUpdate()
        {
            var hasUpdate = false;

            try
            {
                string updateUrl = ConfigurationManager.AppSettings["UpdateUrl"];
                using (var updateMgr = new UpdateManager(updateUrl))
                {
                    var updateInfo = await updateMgr.CheckForUpdate();

                    if (updateInfo != null && updateInfo.ReleasesToApply?.Any() == true)
                    {
                        // 包含更新
                        hasUpdate = true;
                    }
                }

                if (hasUpdate)
                {
                    //LogUtils.Information($"是否包含更新:{hasUpdate}");

                    //var updateMsg = "检测到有新版本,是否升级?";
                    //var result = MessageBox.Show(updateMsg, "更新提示", MessageBoxButtons.YesNo);
                    //LogUtils.Information($"是否选择更新:{result}");
                    //if (result != DialogResult.Yes)
                    //{
                    //    LogUtils.Debug("【refuse to update】");
                    //}
                    //else
                    //{
                    LogUtils.Debug("【ready to update】");

                    int formsCount = Application.OpenForms.Count;

                    if (formsCount > 0)
                    {
                        Form form = Application.OpenForms[0];

                        form.BeginInvoke(new Action(() =>
                        {
                            UpdatingView updatingView = new UpdatingView();
                            updatingView.ShowDialog();
                        }));
                    }

                    return(true);
                    //}
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error($"CheckUpdate => {ex}");
            }
            return(false);
        }
예제 #3
0
        private async Task <bool> CheckUpdate()
        {
            var hasUpdate = false;

            try
            {
                var updateUrl = GlobalData.Instance.LocalSetting.UpdateUrl;
                Log.Logger.Debug($"CheckUpdate => {updateUrl}");

                using (var updateMgr = new UpdateManager(updateUrl))
                {
                    var updateInfo = await updateMgr.CheckForUpdate();

                    if (updateInfo != null && updateInfo.ReleasesToApply?.Any() == true)
                    {
                        // 包含更新
                        hasUpdate = true;
                    }
                }
                Log.Logger.Information($"是否包含更新:{hasUpdate}");
                if (hasUpdate)
                {
                    var updateMsg    = "检测到有新版本,是否升级?";
                    var updateDialog = new Dialog($"{updateMsg}", "是", "否");
                    var result       = updateDialog.ShowDialog();
                    if (!result.HasValue || !result.Value)
                    {
                        Log.Logger.Debug("【refuse to update】");
                    }
                    else
                    {
                        Log.Logger.Debug("【agree to update】");
                        var updatingView = new UpdatingView();
                        updatingView.ShowDialog();
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"CheckUpdate => {ex}");
            }
            return(false);
        }