示例#1
0
文件: XYTip.cs 项目: yatyricky/XYWE
        public static void UpdateTipAsync()
        {
            // Only updated once a day
            if (DateTime.Now.Subtract(DateTime.Parse(XYIni.Tips["LastCheckTime"])).Days == 0)
            {
                return;
            }
            XYIni.Tips["LastCheckTime"] = DateTime.Now.ToString();

            XYWeb.DownloadXYWikiTextAsync("Tip库", data =>
            {
                var timeText = data[0];
                data.RemoveAt(0);

                for (int i = 0; i < data.Count; i++)
                {
                    data[i] = data[i].Remove(0, 2);
                }

                var serverTime = DateTime.Parse(timeText);
                if (serverTime.Subtract(DateTime.Parse(XYIni.Tips["LastUpdateTime"])).TotalSeconds > 0)
                {
                    File.WriteAllLines(@"data\tips.txt", data);
                    XYIni.Tips["LastUpdateTime"] = timeText;
                }
            });
        }
示例#2
0
        public static void UpdateTipAsync()
        {
#if DEBUG == false
            // Only updated once a day (for release user)
            if (DateTime.Now.Subtract(DateTime.Parse(GetLastCheckTime())).Days == 0)
            {
                return;
            }
#endif
            XYIni.Tips["LastCheckTime"] = DateTime.Now.ToString();

            XYWeb.DownloadXYWikiTextAsync("Tip库", data =>
            {
                var timeText = data[0];
                data.RemoveAt(0);

                for (int i = 0; i < data.Count; i++)
                {
                    data[i] = data[i].Remove(0, 2);
                }

                var serverTime = DateTime.Parse(timeText);
                if (serverTime.Subtract(DateTime.Parse(GetLastUpdateTime())).TotalSeconds > 0)
                {
                    File.WriteAllLines(XYPath.File.DataTip, data);
                    XYIni.Tips["LastUpdateTime"] = timeText;
                }
            });
        }
示例#3
0
        public static void VerifyObsoleteAsync(Action obsoleteAction)
        {
            if (Convert.ToBoolean(XYIni.Config["Obsolete"]))
            {
                obsoleteAction();
                return;
            }

            // Only check once per whole day
            if (DateTime.Now.Subtract(DateTime.Parse(XYIni.Config["LastCheckObsoleteTime"])).Days == 0)
            {
                return;
            }
            XYIni.Config["LastCheckObsoleteTime"] = DateTime.Now.ToString();

            XYWeb.DownloadXYWikiTextAsync("最新版本", data =>
            {
                if (data[0] != XYInfo.Version)
                {
                    XYIni.Config["Obsolete"] = "true";
                    obsoleteAction();
                }
            });
        }