Beispiel #1
0
        /// <summary>
        /// 检查是否更新
        /// </summary>
        protected async void _checkIsUpgrade()
        {
            try
            {
                //获取新版本
                HsLabelValue item = await getLastestIPAInfo();

                //取版本号
                HsVersion version = HsVersion.Parse(item.GetValueByLabel("Version"));

                string upgradeUri = item.GetValueByLabel("UpgradeURI");

                //检查版本最后一位,如果是奇数表明是一般更新,偶数表明是强制更新
                IPlatformExtension pe = DependencyService.Get <IPlatformExtension>();

                HsVersion currentVersion = HsVersion.Parse(pe.GetApplicationVersion());

                if (pe != null && version > currentVersion) //存在新版本
                {
                    if (version.Type == HsVersion.EType.Force)
                    {
                        await this.DisplayAlert($"发现新版本 {version},请立即更新", $"当前版本 {currentVersion}", "确定");

                        pe.OpenURL(upgradeUri);
                    }
                    else
                    {
                        if (await this.DisplayAlert($"发现新版本 {version},是否更新", $"当前版本 {currentVersion}", "是", "否"))
                        {
                            pe.OpenURL(upgradeUri);
                        }
                        else
                        {
                            this.onUpgradeComplete();
                        }
                    }
                }
                else
                {
                    this.onUpgradeComplete();
                }
            }
            catch (Exception e)
            {
                this.ShowError(e.Message);

                this.onUpgradeComplete();
            }
        }
Beispiel #2
0
        protected override async void callAction(HsActionKey actionKey, object item)
        {
            try
            {
                if (actionKey == SysActionKeys.关闭)
                {
                    await PopupNavigation.PopAsync();
                }
                else if (actionKey == SysActionKeys.修改密码)
                {
                    callAction(SysActionKeys.关闭, null);

                    this.onPopupData(actionKey, null);
                }
                else if (actionKey == SysActionKeys.UserDo1)
                {
                    //清除缓存
                    long size = await HsDependencyService <IPlatformExtension> .Instance().DirectoryDelete("Cache");

                    await this.DisplayAlert("缓存删除成功。", size != 0?$"释放空间{size.GetFileSizeString()}" : "无缓存文件", "确定");

                    callAction(SysActionKeys.关闭, null);
                }
                else if (actionKey == SysActionKeys.UserDo2)
                {
                    //获取新版本
                    HsLabelValue lvVersion = await getLastestIPAInfo();

                    //取版本号
                    HsVersion version = HsVersion.Parse(lvVersion.GetValueByLabel("Version"));

                    string upgradeUri = lvVersion.GetValueByLabel("UpgradeURI");

                    //检查版本最后一位,如果是奇数表明是一般更新,偶数表明是强制更新
                    IPlatformExtension pe = DependencyService.Get <IPlatformExtension>();

                    HsVersion currentVersion = HsVersion.Parse(pe.GetApplicationVersion());

                    if (pe != null && version > currentVersion)                     //存在新版本
                    {
                        if (version.Type == HsVersion.EType.Force)
                        {
                            await this.DisplayAlert($"发现新版本 {version},请立即更新", $"当前版本 {currentVersion}", "确定");

                            pe.OpenURL(upgradeUri);
                        }
                        else
                        {
                            if (await this.DisplayAlert($"发现新版本 {version},是否更新", $"当前版本 {currentVersion}", "是", "否"))
                            {
                                pe.OpenURL(upgradeUri);
                            }
                        }
                    }
                    else
                    {
                        await this.DisplayAlert("当前是最新版本", $"当前版本 {currentVersion}", "确定");
                    }

                    callAction(SysActionKeys.关闭, null);
                }
                else if (actionKey == SysActionKeys.注销)
                {
                    //注销
                    if (await this.DisplayAlert("是否要注销?", "", "是", "否"))
                    {
                        this.onPopupData(actionKey, null);

                        callAction(SysActionKeys.关闭, null);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowError(ex.Message);
            }
        }