Ejemplo n.º 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var username = Username.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LoginProcedure();

                try
                {
                    ret = local.Step1(username, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Login2);
                }
            });
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new LogoutProcedure();

                try
                {
                    ret = local.Step1();
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    ApiVendor.SetRenew(null);
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedOut);
                }
            });
            _sr.InteractiveTask(() => SubwindowNavigator.Navigate(SubwindowPage.LoggedOut));
        }
Ejemplo n.º 3
0
        public PageLoggedIn(SubwindowRouter sr)
        {
            _sr = sr;
            InitializeComponent();

            if (_sr.Dispname == " ")
            {
                _sr.InteractiveTask(() =>
                {
                    int ret;
                    string displayName = null;

                    var local = new ProfileProcedure();

                    try
                    {
                        ret = local.Step2(out var status);

                        if (!CheckVendor.NotValidResponseCode(ret) && status != null)
                        {
                            displayName = status.DisplayName;
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                    }
                    catch (Exception)
                    {
                        ret = 02_0000;
                    }

                    if (CheckVendor.NotValidResponseCode(ret))
                    {
                        Growl.Error(MessageVendor.FormatError(ret));
                    }
                    else
                    {
                        _sr.Dispname = displayName;

                        if (this.Dispatcher != null && !this.Dispatcher.CheckAccess())
                        {
                            this.Dispatcher.Invoke(() => NameDisplay.Text = !string.IsNullOrWhiteSpace(_sr.Dispname)
                                ? $"已登录 {_sr.Dispname}"
                                : $"已登录 {_sr.Username}");
                        }
                        else
                        {
                            NameDisplay.Text = !string.IsNullOrWhiteSpace(_sr.Dispname)
                                ? $"已登录 {_sr.Dispname}"
                                : $"已登录 {_sr.Username}";
                        }
                    }
                });
            }

            NameDisplay.Text = !string.IsNullOrWhiteSpace(_sr.Dispname) ? $"已登录 {_sr.Dispname}" : $"已登录 {_sr.Username}";
        }
Ejemplo n.º 4
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var password = Password.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret = 00_0000;

                try
                {
                    if (!(_sr.Procedure is LoginProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(Encoding.UTF8.GetBytes(password));

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3(out token);

                    _sr.RenewToken = token;

                    if (!CheckVendor.NotValidResponseCode(ret))
                    {
                        var prof     = new ProfileProcedure();
                        ret          = prof.Step2(out var status);
                        _sr.Username = status.Username;
                        _sr.Dispname = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = null;
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
        public PageRecoveryAccount1(SubwindowRouter sr)
        {
            _sr = sr;
            InitializeComponent();

            _sr.InteractiveTask(() =>
            {
                int ret;

                if (!SubwindowDataCollector.Collect(5 * 60 * 1000, out var service, out var character))
                {
                    Growl.Error("等待超时,请返回上一页重试");
                }

                _sr.Procedure = null;
                var local     = new RecoveryProcedure();

                try
                {
                    if (string.IsNullOrEmpty(_sr.Username))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step1(_sr.Username, service, character, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Recovery2);
                }
            });
        }
Ejemplo n.º 6
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var password = OldPassword.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new ChangeProcedure();

                try
                {
                    if (string.IsNullOrEmpty(_sr.Username))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step1(_sr.Username, Helper.GetTrace());

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(Encoding.UTF8.GetBytes(password));

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3();
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                    SubwindowNavigator.Navigate(SubwindowPage.Change2);
                }
            });
        }
Ejemplo n.º 7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var displayName = DisplayName.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                _sr.Procedure = null;
                var local     = new ProfileProcedure();

                try
                {
                    ret = local.Step1(displayName, Helper.GetTrace(), null);

                    AccountStatus status = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2(out status);

                    if (!CheckVendor.NotValidResponseCode(ret) && status != null)
                    {
                        displayName = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    Growl.Success("成功修改显示名称");
                    _sr.Dispname = displayName;
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var code = VerifyCode.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;

                try
                {
                    if (!(_sr.Procedure is RecoveryProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step2(code);
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    SubwindowNavigator.Navigate(SubwindowPage.Recovery2);
                }
            });
        }
Ejemplo n.º 9
0
        private void ElementView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = ElementView.SelectedItem as OverviewPresenter;

            if (item != null)
            {
                br.OverlayItemId = item.ItemId;

                Task.Run(() =>
                {
                    RETRY:
                    int ret = 0;
                    br.OverlayListingData.Clear();
                    br.OverlayHistoryData.Clear();
                    var listing            = new List <ListingData>();
                    var history            = new List <HistoryData>();
                    PackedResultBundle res = null;

                    try
                    {
                        var local = new ExchangeProcedure();

                        try
                        {
                            ret = local.Step2(item.ItemId, out res);
                        }
                        catch (HttpRequestException exception)
                        {
                            ret = 02_0000 + (int)exception.Data["StatusCode"];
                        }


                        if (!CheckVendor.NotValidResponseCode(ret))
                        {
                            listing.AddRange(res.Listings.Select(x =>
                                                                 ListingData.FromResultItem(x.RawItem, x.ReportTime, 0, x.WorldId)));
                            history.AddRange(res.Histories.Select(x =>
                                                                  HistoryData.FromResultItem(x.RawItem, x.ReportTime, 0, x.WorldId)));
                        }

                        if (ret % 10000 == 0511 && ApiVendor.ValidateAndRenewToken())
                        {
                            goto RETRY;
                        }

                        br.OverlayListingData = listing.OrderBy(x => x.UnitPrice).ToList();
                        br.OverlayHistoryData = history.OrderByDescending(x => x.PurchaseTime).ToList();
                    }
                    catch (HttpRequestException ex)
                    {
                        ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                        if (ret == 02_0511 && ApiVendor.ValidateAndRenewToken())
                        {
                            goto RETRY;
                        }
                    }
                    catch (Exception)
                    {
                        ret = 02_0000;
                    }

                    if (CheckVendor.NotValidResponseCode(ret))
                    {
                        LoggingManagementService.WriteLine(
                            $"Api Error: {MessageVendor.FormatError(ret)} on requesting {DictionaryManagementService.Item[item.ItemId]}",
                            "ApiSys");
                    }
                });
            }
        }
Ejemplo n.º 10
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var password    = NewPassword.Password.ToCharArray();
            var passconfirm = NewConfirm.Password.ToCharArray();
            var username    = Username.Text;
            var display     = DisplayName.Text;
            var email       = Email.Text;

            _sr.InteractiveTask(() =>
            {
                int ret;


                if (!password.SequenceEqual(passconfirm))
                {
                    Growl.Error("密码输入不一致");
                    return;
                }

                if (password.Length < 8)
                {
                    Growl.Error("请使用八位及以上长度的密码");
                    return;
                }

                if (!password.Intersect("0123456789".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含数字");
                    return;
                }

                if (!password.Intersect("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含大写字母");
                    return;
                }

                if (!password.Intersect("abcdefghijklmnopqrstuvwxyz".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含小写字母");
                    return;
                }

                _sr.Procedure = null;
                var local     = new RegisterProcedure();

                try
                {
                    ret = local.Step1(_sr.Service, _sr.Character, username, display, email,
                                      Encoding.UTF8.GetBytes(password), Helper.GetTrace());

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step2();

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step3(out token);

                    _sr.RenewToken = token;

                    if (!CheckVendor.NotValidResponseCode(ret))
                    {
                        var prof     = new ProfileProcedure();
                        ret          = prof.Step2(out var status);
                        _sr.Username = status.Username;
                        _sr.Dispname = status.DisplayName;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    Growl.Success("欢迎," + (!string.IsNullOrWhiteSpace(_sr.Dispname) ? _sr.Dispname : _sr.Username));
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }
Ejemplo n.º 11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var email = _sr.Email;

            Task.Run(() =>
            {
                if (this.Dispatcher != null && !this.Dispatcher.CheckAccess())
                {
                    this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = false);
                    for (var i = 60; i > 0; i--)
                    {
                        this.Dispatcher.Invoke(() => SendCaptcha.Content = $"请稍候({i}s)");
                        Thread.Sleep(1000);
                    }
                    this.Dispatcher.Invoke(() => SendCaptcha.IsEnabled = true);
                }
                else
                {
                    SendCaptcha.IsEnabled = false;
                    for (var i = 60; i > 0; i--)
                    {
                        SendCaptcha.Content = $"请稍候({i}s)";
                        Thread.Sleep(1000);
                    }
                    SendCaptcha.IsEnabled = true;
                }
            });

            _sr.InteractiveTask(() =>
            {
                int ret;

                if (CheckVendor.NotValidEmail(email))
                {
                    Growl.Error("无效邮件地址");
                }

                _sr.Procedure = null;
                var local     = new RecoveryProcedure();

                try
                {
                    if (string.IsNullOrEmpty(_sr.Username))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = local.Step1(_sr.Username, email, Helper.GetTrace());
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = local;
                }
            });
        }
Ejemplo n.º 12
0
        public void OnCommandLineEnter(object sender, ExecutedRoutedEventArgs e)
        {
            br.UiActiveTab = 0;
            MainFrame.Navigate(ip);
            var dic = DictionaryManagementService.SearchItem(br.UiSearchLine);

            br.OverlayOverviewData =
                dic.Select(x => new OverviewData {
                ItemId = x.Key, UpdateTime = DateTime.MinValue
            }).ToList();

            Task.Run(() =>
            {
                RETRY:

                int ret = 0;

                try
                {
                    var local            = new ExchangeProcedure();
                    var partCnt          = 0;
                    OverviewResponse res = null;

                    do
                    {
                        try
                        {
                            ret = local.Step2(dic.Keys.ToArray(), partCnt++, out res);
                        }
                        catch (HttpRequestException exception)
                        {
                            ret = 02_0000 + (int)exception.Data["StatusCode"];
                        }


                        if (!CheckVendor.NotValidResponseCode(ret))
                        {
                            var overviewDic = br.OverlayOverviewData.ToDictionary(x => x.ItemId, x => x);

                            foreach (var item in res.Results)
                            {
                                overviewDic[item.ItemId] =
                                    OverviewData.FromResultItem(overviewDic[item.ItemId], item);
                            }

                            br.OverlayOverviewData = overviewDic.Values.ToList();
                        }
                    } while (!CheckVendor.NotValidResponseCode(ret) && !res.FinalPart);

                    if (ret % 10000 == 0511 && ApiVendor.ValidateAndRenewToken())
                    {
                        goto RETRY;
                    }
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                    if (ret == 02_0511 && ApiVendor.ValidateAndRenewToken())
                    {
                        goto RETRY;
                    }
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    LoggingManagementService.WriteLine(
                        $"Api Error: {MessageVendor.FormatError(ret)} on searching {br.UiSearchLine}", "ApiSys");
                }
            });
        }
Ejemplo n.º 13
0
        private void LocalHandler(int gameId, PackedResult result)
        {
            var worldId = pool.GetContext(gameId).World;

            if (result.Type == PackedResultType.MarketRequest)
            {
                var itemid = ((MarketRequestResult)result.Result).ItemId;
                Task.Run(() =>
                {
                    RETRY:
                    int ret                = 0;
                    var listing            = new List <ListingData>();
                    var history            = new List <HistoryData>();
                    PackedResultBundle res = null;

                    try
                    {
                        var local = new ExchangeProcedure();

                        try
                        {
                            ret = local.Step2(itemid, out res);
                        }
                        catch (HttpRequestException exception)
                        {
                            ret = 02_0000 + (int)exception.Data["StatusCode"];
                        }

                        if (!CheckVendor.NotValidResponseCode(ret))
                        {
                            listing.AddRange(res.Listings.Select(x =>
                                                                 ListingData.FromResultItem(x.RawItem, x.ReportTime, 0, x.WorldId)));
                            history.AddRange(res.Histories.Select(x =>
                                                                  HistoryData.FromResultItem(x.RawItem, x.ReportTime, 0, x.WorldId)));
                        }

                        if (ret % 10000 == 0511 && ApiVendor.ValidateAndRenewToken())
                        {
                            goto RETRY;
                        }

                        var lst = (List <ListingData>)DataHolder.GetCache(worldId, itemid, 0);
                        var hst = (List <HistoryData>)DataHolder.GetCache(worldId, itemid, 1);

                        if (lst != null)
                        {
                            listing.RemoveAll(x => x.World == worldId);
                            br.OverlayListingData = listing.Concat(lst)
                                                    .OrderBy(x => x.UnitPrice).ToList();
                        }
                        else
                        {
                            lst = br.OverlayListingData.Where(x => x.World == worldId && x.ItemId == itemid).ToList();

                            if (lst.Any())
                            {
                                listing.RemoveAll(x => x.World == worldId);
                                br.OverlayListingData = listing.Concat(lst)
                                                        .OrderBy(x => x.UnitPrice).ToList();
                            }

                            br.OverlayListingData = listing.OrderBy(x => x.UnitPrice).ToList();
                        }

                        if (hst != null)
                        {
                            history.RemoveAll(x => x.World == worldId);
                            br.OverlayHistoryData = history.Concat(hst)
                                                    .OrderByDescending(x => x.PurchaseTime).ToList();
                        }
                        else
                        {
                            hst = br.OverlayHistoryData.Where(x => x.World == worldId && x.ItemId == itemid).ToList();

                            if (hst.Any())
                            {
                                history.RemoveAll(x => x.World == worldId);
                                br.OverlayHistoryData = history.Concat(hst)
                                                        .OrderByDescending(x => x.PurchaseTime).ToList();
                            }

                            br.OverlayHistoryData = history.OrderByDescending(x => x.PurchaseTime).ToList();
                        }
                    }
                    catch (HttpRequestException ex)
                    {
                        ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                        if (ret == 02_0511 && ApiVendor.ValidateAndRenewToken())
                        {
                            goto RETRY;
                        }
                    }
                    catch (Exception)
                    {
                        ret = 02_0000;
                    }

                    if (CheckVendor.NotValidResponseCode(ret))
                    {
                        LoggingManagementService.WriteLine(
                            $"Api Error: {MessageVendor.FormatError(ret)} on requesting {DictionaryManagementService.Item[itemid]}",
                            "ApiSys");
                    }
                });
            }

            if (result.Type == PackedResultType.MarketHistory)
            {
                var r = (MarketHistoryResult)result.Result;
                br.OverlayItemId = r.ItemId;
                var t = new List <HistoryData>();
                foreach (var i in r.HistoryItems)
                {
                    t.Add(new HistoryData
                    {
                        BuyerName    = i.BuyerName,
                        IsHq         = i.IsHq == 1,
                        ItemId       = i.ItemId,
                        OnMannequin  = i.OnMannequin == 1,
                        PurchaseTime = Helper.UnixTimeStampToDateTime(i.PurchaseTime),
                        Quantity     = i.Quantity,
                        UnitPrice    = i.UnitPrice,
                        UpdateTime   = DateTime.Now,
                        World        = worldId,
                        Zone         = 0
                    });
                }

                DataHolder.AddCache(worldId, r.ItemId, 1, t, 120);
            }

            if (result.Type == PackedResultType.MarketListing)
            {
                var r = (MarketListingResult)result.Result;
                var t = new List <ListingData>();
                foreach (var i in r.ListingItems)
                {
                    t.Add(new ListingData
                    {
                        ItemId           = i.ItemId,
                        IsHq             = i.IsHq == 1,
                        Materia          = new int[] { i.Materia1, i.Materia2, i.Materia3, i.Materia4, i.Materia5 },
                        UnitPrice        = i.UnitPrice,
                        Quantity         = i.Quantity,
                        Tax              = i.TotalTax,
                        Retainer         = i.RetainerName,
                        Artisan          = i.ArtisanId.ToString("X"),
                        OnMannequin      = i.OnMannequin == 1,
                        PlayerName       = i.PlayerName,
                        RetainerLocation = i.RetainerLocation,
                        DyeId            = i.DyeId,
                        ListingTime      = Helper.UnixTimeStampToDateTime(i.UpdateTime),
                        UpdateTime       = DateTime.Now,
                        World            = worldId,
                        Zone             = 0,
                    });
                }

                var sample = t.FirstOrDefault();
                if (sample != null)
                {
                    DataHolder.AddCache(worldId, sample.ItemId, 0, t, 120);
                }
            }

            LoggingManagementService.WriteLine($"Data Received: {result.Type.ToString()} @ {DictionaryManagementService.World[worldId]}", $"Game {gameId}");
        }
Ejemplo n.º 14
0
        public static void UpdateLogic(bool hideNoUpdateMessage = true, bool includeOptional = true)
        {
            var         up         = new UpdateProcedure();
            var         needUpdate = false;
            VersionInfo info       = null;
            int         ret;

            try
            {
                ret = up.Step1(out needUpdate, out info);
            }
            catch (HttpRequestException e)
            {
                ret = 02_0000 + (int)e.Data["StatusCode"];
            }

            if (CheckVendor.NotValidResponseCode(ret))
            {
                MessageBox.Show($"客户端检查更新失败:{MessageVendor.FormatError(ret)}", "Milvaneth 客户端更新");
                return;
            }

            if (!needUpdate)
            {
                if (!hideNoUpdateMessage)
                {
                    MessageBox.Show($"已经是最新版本", "Milvaneth 客户端更新");
                }

                return;
            }

            if (!info.ForceUpdate)
            {
                if (!includeOptional)
                {
                    return;
                }

                var result =
                    MessageBox.Show(
                        $"有可用新版本 {info.EligibleMilvanethVersion} (D-{info.EligibleDataVersion} / G-{info.EligibleGameVersion})\n" +
                        $"版本说明:{info.DisplayMessage}\n" + "是否现在更新?", "Milvaneth 客户端更新", MessageBoxButton.YesNo);

                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }
            else
            {
                Task.Run(() => MessageBox.Show(
                             $"有可用新版本 {info.EligibleMilvanethVersion} (D-{info.EligibleDataVersion} / G-{info.EligibleGameVersion})\n" +
                             $"版本说明:{info.DisplayMessage}\n" + "本版本为必要更新,将自动下载并安装更新\n请不要关闭或退出程序,程序将在更新完成后自动重启", "Milvaneth 客户端更新", MessageBoxButton.OK));
            }

            VersionDownload download = null;

            try
            {
                ret = up.Step2(out download);
            }
            catch (HttpRequestException e)
            {
                ret = 02_0000 + (int)e.Data["StatusCode"];
            }

            if (CheckVendor.NotValidResponseCode(ret))
            {
                MessageBox.Show($"客户端下载更新失败:{MessageVendor.FormatError(ret)}", "Milvaneth 客户端更新");
                return;
            }

            var patches = UpdateVendor.DownloadPatches(download, null);

            UpdateVendor.WaitAllFinish(patches);

            if (!info.ForceUpdate)
            {
                MessageBox.Show($"更新即将开始,请不要关闭或退出程序\n程序将在更新完成后自动重启", "Milvaneth 客户端更新");
            }

            SupportStatic.ExitAll();
            UpdateVendor.InvokeUpdateAndExitProgram(download, true);
        }
Ejemplo n.º 15
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var password    = NewPassword.Password.ToCharArray();
            var passconfirm = NewConfirm.Password.ToCharArray();

            _sr.InteractiveTask(() =>
            {
                int ret = 00_0000;

                if (!password.SequenceEqual(passconfirm))
                {
                    Growl.Error("密码输入不一致");
                    return;
                }

                if (password.Length < 8)
                {
                    Growl.Error("请使用八位及以上长度的密码");
                    return;
                }

                if (!password.Intersect("0123456789".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含数字");
                    return;
                }

                if (!password.Intersect("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含大写字母");
                    return;
                }

                if (!password.Intersect("abcdefghijklmnopqrstuvwxyz".ToCharArray()).Any())
                {
                    Growl.Error("密码应包含小写字母");
                    return;
                }

                try
                {
                    if (!(_sr.Procedure is ChangeProcedure local))
                    {
                        ret = 02_0009;
                        goto FAIL;
                    }

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step4(Encoding.UTF8.GetBytes(password));

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step5();

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step6();

                    byte[] token = null;

                    ret = CheckVendor.NotValidResponseCode(ret) ? ret : local.Step7(out token);

                    _sr.RenewToken = token;
                }
                catch (HttpRequestException ex)
                {
                    ret = 02_0000 + (int)(ex.Data["StatusCode"]);
                }
                catch (Exception)
                {
                    ret = 02_0000;
                }

                FAIL:
                if (CheckVendor.NotValidResponseCode(ret))
                {
                    Growl.Error(MessageVendor.FormatError(ret));
                }
                else
                {
                    _sr.Procedure = null;
                    Growl.Success("成功修改密码");
                    SubwindowNavigator.Navigate(SubwindowPage.LoggedIn);
                }
            });
        }