Exemplo n.º 1
0
        public UpdatingViewModel(UpdatingView updatingView)
        {
            _updatingView = updatingView;

            _updatingView.Title = SystemLanguageManager.Instance.ResourceManager.GetString("Updating", SystemLanguageManager.Instance.CultureInfo);

            Message = SystemLanguageManager.Instance.ResourceManager.GetString("Updating_Tips", SystemLanguageManager.Instance.CultureInfo);

            UpdatingCommand = new DelegateCommand(UpdatingAsync);
        }
Exemplo n.º 2
0
        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 = MessageDialogManager.ShowDialogAsync(updateMsg, "更新提示", MessageBoxButtons.YesNo);
                    //LogUtils.Information($"是否选择更新:{result}");
                    //if (result != DialogResult.Yes)
                    //{
                    //    LogUtils.Debug("【refuse to update】");
                    //}
                    //else
                    //{
                    LogUtils.Debug("【ready to update】");

                    await Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        UpdatingView updatingView = new UpdatingView();
                        updatingView.ShowDialog();
                    }));

                    return(true);
                    //}
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error($"CheckUpdate => {ex}");
            }
            return(false);
        }
Exemplo n.º 3
0
        public UpdatingViewModel(UpdatingView updatingView)
        {
            resourceManager = new ResourceManager("Wx.Qunkong360.Wpf.Languages.Res", typeof(UpdatingView).Assembly);

            if (ConfigVals.Lang == 1)
            {
                cultureInfo = CultureInfo.CreateSpecificCulture("zh-cn");
            }
            else if (ConfigVals.Lang == 2)
            {
                cultureInfo = CultureInfo.CreateSpecificCulture("en-us");
            }

            _updatingView = updatingView;

            _updatingView.Title = resourceManager.GetString("Updating", cultureInfo);

            Message = resourceManager.GetString("Updating_Tips", cultureInfo);

            UpdatingCommand = new DelegateCommand(UpdatingAsync);
        }