|
|
@@ -7,8 +7,10 @@ using Logic.RemoteModel; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Net; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows.Markup; |
|
|
@@ -169,5 +171,28 @@ namespace HKCardOUT.Logic |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 获取网络服务器时间 |
|
|
|
/// </summary> |
|
|
|
public static void GetNetWorkTime() { |
|
|
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.baidu.com"); |
|
|
|
request.Method = "HEAD"; |
|
|
|
request.AllowAutoRedirect = false; |
|
|
|
HttpWebResponse reponse = (HttpWebResponse)request.GetResponse(); |
|
|
|
string cc = reponse.GetResponseHeader("date"); |
|
|
|
reponse.Close(); |
|
|
|
DateTime time; |
|
|
|
bool s = GMTStrParse(cc, out time); |
|
|
|
var dt_time = time.AddHours(8); //GMT要加8个小时才是北京时间 |
|
|
|
DataBus.TodayTime= dt_time; |
|
|
|
} |
|
|
|
public static bool GMTStrParse(string gmtStr, out DateTime gmtTime) //抓取的date是GMT格式的字符串,这里转成datetime |
|
|
|
{ |
|
|
|
CultureInfo enUS = new CultureInfo("en-US"); |
|
|
|
bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime); |
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
} |