protected async override void OnAppearing()
        {
            try
            {
                if (_commonFun != null)
                {
                    var name = _commonFun.GetCach(CommonContext.USERNAMEKEY);

                    if (!string.IsNullOrEmpty(name))
                    {
                        userName.Text = name;
                    }
                }

                info = await App.CheckUpdate();

                if (info != null && !string.IsNullOrEmpty(info.appKey))
                {
                    UpdateNewVersion();
                }
            }
            catch
            {
            }
            base.OnAppearing();
        }
Beispiel #2
0
 private async void UpdateNewVersion()
 {
     try
     {
         if (await _commonFun.Confirm("新的版本已发布,是否更新?"))
         {
             MessagingCenter.Send <IOSVersionInfoDto>(info, "UpdateApp");
             IsDoaning = true;
             info      = null;
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #3
0
        protected async override void OnAppearing()
        {
            try
            {
                info = await App.CheckUpdate();

                if (info != null && !string.IsNullOrEmpty(info.appKey))
                {
                    lblCheckUpdate.Text      = "有新版本发布";
                    lblCheckUpdate.TextColor = Color.Red;
                }
                else
                {
                    lblCheckUpdate.Text      = "检查更新";
                    lblCheckUpdate.TextColor = Color.FromHex("A0A0A0");
                }
            }
            catch (Exception)
            {
            }
            base.OnAppearing();
        }
Beispiel #4
0
        void UpdateApp(IOSVersionInfoDto info)
        {
            NSUrl downloadURL = NSUrl.FromString("itms-services://?action=download-manifest&url=https://www.pgyer.com/app/plist/" + info.appKey);

            UIApplication.SharedApplication.OpenUrl(downloadURL);
        }
Beispiel #5
0
        public async static Task <IOSVersionInfoDto> CheckUpdate()
        {
            try
            {
                IOSVersionInfoDto info = new IOSVersionInfoDto();
                var    commonHelper    = Resolver.Resolve <CommonHelper>();
                var    commonFun       = Resolver.Resolve <ICommonFun>();
                string shortcutName    = "";
                if (Device.OS == TargetPlatform.iOS)
                {
                    shortcutName = "pcm_ios";
                    //shortcutName = "maxinsight_ios";
                }
                else
                {
                    shortcutName = "pcm_android";
                    //shortcutName = "maxinsight_droid";
                }

                List <RequestParameter> shortcutList = new List <RequestParameter>()
                {
                    new RequestParameter()
                    {
                        Name  = "shortcut",
                        Value = shortcutName
                    },
                    new RequestParameter()
                    {
                        Name = "_api_key",
                        //Value = "9e59ce985118440f3c0b753d2fa8f923"
                        Value = "b2b9d7af1d81a3a596be546390fc7d22"
                    }
                };
                PgyAppInfoShortcutInfo shortcutDto = null;
                try
                {
                    shortcutDto = await commonHelper.HttpGetPOST <PgyAppInfoShortcutInfo>("https://www.pgyer.com", "/apiv1/app/getAppKeyByShortcut", shortcutList);
                }
                catch (Exception)
                {
                    return(info);
                }

                if (shortcutDto == null || shortcutDto.data == null)
                {
                    return(info);
                }
                List <RequestParameter> appInfoList = new List <RequestParameter>()
                {
                    new RequestParameter()
                    {
                        Name  = "aKey",
                        Value = shortcutDto.data.appKey
                    },
                    new RequestParameter()
                    {
                        Name = "uKey",
                        //Value = "690728932ff4cabc4a3b2e0ec96f0e24"
                        Value = "dc9a543b1b03cb81e077ddaa07640898"
                    },
                    new RequestParameter()
                    {
                        Name = "_api_key",
                        //Value = "9e59ce985118440f3c0b753d2fa8f923"
                        Value = "b2b9d7af1d81a3a596be546390fc7d22"
                    }
                };

                PgyAppInfoDetail appInfoDto = null;
                try
                {
                    appInfoDto = await commonHelper.HttpGetPOST <PgyAppInfoDetail>("https://www.pgyer.com", "/apiv1/app/view", appInfoList);
                }
                catch (Exception)
                {
                    return(info);
                }

                if (appInfoDto == null || appInfoDto.data == null)
                {
                    return(info);
                }
                int version = commonFun.GetVersionNo();

                if (Convert.ToInt32(appInfoDto.data.appBuildVersion) > version)
                {
                    //return appInfoDto.data.appUpdateDescription;
                    info.updateMsg  = appInfoDto.data.appUpdateDescription;
                    info.appKey     = appInfoDto.data.appKey;
                    info.newVersion = Convert.ToInt32(appInfoDto.data.appVersionNo);
                    info.nowVersion = version;
                }
                return(info);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #6
0
        public UserPage()
        {
            InitializeComponent();
            try
            {
                _commonFun    = Resolver.Resolve <ICommonFun>();
                _commonHelper = Resolver.Resolve <CommonHelper>();

                lblDisName.Text      = CommonContext.Account.DisName;
                lblUserTypeName.Text = CommonContext.Account.UserTypeName;
                txtTelNo.Text        = CommonContext.Account.Phone;
                layPassword.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(async() =>
                    {
                        try
                        {
                            await Navigation.PushAsync(ViewFactory.CreatePage <ChangePasswordViewModel, ChangePasswordPage>() as Page, true);
                        }
                        catch (System.Exception)
                        {
                        }
                    })
                });
                layCheckUpdate.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = new Command(async() =>
                    {
                        try
                        {
                            if (IsDoaning)
                            {
                                string msg = "";
                                if (App.SysOS == "Android")
                                {
                                    msg = "安装程序正在后台下载";
                                }
                                else
                                {
                                    msg = "按Home键回到桌面即可看到更新进度";
                                }
                                _commonFun.AlertLongText(msg);
                            }
                            else
                            {
                                if (info != null && !string.IsNullOrEmpty(info.appKey))
                                {
                                    UpdateNewVersion();
                                }
                                else
                                {
                                    _commonFun.ShowLoading("检查中...");
                                    info = await App.CheckUpdate();
                                    _commonFun.HideLoading();
                                    if (info != null && !string.IsNullOrEmpty(info.appKey))
                                    {
                                        UpdateNewVersion();
                                    }
                                    else
                                    {
                                        _commonFun.AlertLongText("恭喜你,你已经是最新版本了。");
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    })
                });
            }
            catch (Exception)
            {
            }
        }