From acc8caee31c4be90bd38d1af18136b0e84f6fe94 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期五, 27 九月 2024 14:01:19 +0800
Subject: [PATCH] Merge branch 'feature/v2.7_迭代' into feature/V2.7_Google

---
 HDL_ON/UI/UI1-Login/RegisterPageBLL.cs |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
index 50aa11f..d055779 100644
--- a/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
+++ b/HDL_ON/UI/UI1-Login/RegisterPageBLL.cs
@@ -1,9 +1,11 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Net.Http;
 using System.Text.RegularExpressions;
 using System.Threading;
 using HDL_ON.DAL.Server;
 using HDL_ON.UI.CSS;
+using Newtonsoft.Json.Linq;
 using Shared;
 
 namespace HDL_ON.UI.UI1Login
@@ -776,13 +778,30 @@
             waitPage.Start(Language.StringByID(StringId.PleaseWait));
 
 
-            System.Threading.Tasks.Task.Run(() =>
-            {
+            System.Threading.Tasks.Task.Run(() => {
                 try
                 {
-                    Console.WriteLine("GetCountryByIP");
-                    var ddd = JLCountrycode.CountryCodeView.Current.GetCountryByIP();
-                    Console.WriteLine(ddd);
+                    //string country = "CN";
+                    //try
+                    //{
+                    //    using (HttpClient client = new HttpClient())
+                    //    {
+                    //        // 浣跨敤 ipinfo.io 鑾峰彇浣嶇疆淇℃伅
+                    //        HttpResponseMessage response = await client.GetAsync("https://ipinfo.io/json");
+                    //        if (response.IsSuccessStatusCode)
+                    //        {
+                    //            string json = await response.Content.ReadAsStringAsync();
+                    //            JObject jsonObject = JObject.Parse(json);
+                    //            // 浠庤繑鍥炵殑 JSON 涓彁鍙栧浗瀹朵俊鎭�
+                    //            country = jsonObject["country"].ToString();
+                    //        }
+                    //    }
+                    //}
+                    //catch (Exception ex)
+                    //{
+                    //    MainPage.Log("Error",$"Error fetching IP info: {ex.StackTrace}");
+                    //}
+
                     serverList = new List<GlobalRegionListRes>();
                     var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark });
                     var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost);
@@ -796,12 +815,12 @@
                                 serverList = responseDataObj;
                                 if (serverList.Count > 0)
                                 {
-                                    if (Language.CurrentLanguage == "Chinese")
+                                    if (Language.CurrentLanguage == "Chinese")//if (country == "CN")//
                                     {
                                         var server = serverList.Find((obj) => obj.regionUrl.Contains("china-gateway"));
                                         if (server != null)
                                         {
-                                            OnAppConfig.Instance.GlobalRegion.regionUrl = server.regionUrl;
+                                            OnAppConfig.Instance.GlobalRegion = server;
                                             SetServerText();
                                         }
                                     }
@@ -810,7 +829,7 @@
                                         var server = serverList.Find((obj) => obj.regionUrl.Contains("bahrain-gateway"));
                                         if (server != null)
                                         {
-                                            OnAppConfig.Instance.GlobalRegion.regionUrl = server.regionUrl;
+                                            OnAppConfig.Instance.GlobalRegion = server;
                                             SetServerText();
                                         }
                                     }
@@ -824,9 +843,9 @@
                         IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code);
                     }
                 }
-                catch
+                catch (Exception ex)
                 {
-
+                    MainPage.Log("Error", $"鑾峰彇鏈嶅姟鍣ㄥ紓甯革細{ex.StackTrace}");
                 }
                 finally
                 {

--
Gitblit v1.8.0