Beispiel #1
0
        public Update(LatestVersionInfo latestVersionInfo)
        {
            InitializeComponent();

            NewVersion.Text       = $"{latestVersionInfo.LatestVersion} - {latestVersionInfo.Name}";
            UpdateUrl.NavigateUri = new Uri(latestVersionInfo.Url);
        }
Beispiel #2
0
        private void CheckLatest()
        {
            SetResultText("正在查询...");
            string result = "";

            if (chosenServer == SERVER_TYPE.JP) // 查询日服
            {
                result = GetWebRequest("https://api.matsurihi.me/mltd/v1/version/latest");

                if (isResultError(result))
                {
                    SetResultText("查询错误!");
                    return;
                }

                JavaScriptSerializer js   = new JavaScriptSerializer();
                LatestVersionInfo    info = js.Deserialize <LatestVersionInfo>(result);

                cacheVersionInfo = info.res;
                SetResultText("更新成功!" +
                              "\n现在的最新版本是:" + info.res.version +
                              "\n更新时间是:" + info.res.updateTime);

                checkLatestThread = null;
            }
            else if (chosenServer == SERVER_TYPE.CNT) // 查询繁中服
            {
                result = GetWebRequest("https://redive.estertion.win/db/mltd/current.json");

                if (isResultError(result))
                {
                    SetResultText("查询错误!");
                    return;
                }

                JavaScriptSerializer js = new JavaScriptSerializer();
                Res_CNT info            = js.Deserialize <Res_CNT>(result);

                cacheVersionInfo            = new Res();
                cacheVersionInfo.indexName  = info.asset_index_name;
                cacheVersionInfo.updateTime = info.update_time;
                cacheVersionInfo.version    = info.asset_version;

                SetResultText("更新成功!" +
                              "\n现在的最新版本是:" + info.asset_version +
                              "\n更新时间是:" + info.update_time);

                checkLatestThread = null;
            }
        }
Beispiel #3
0
        static UpdatesServerMock()
        {
            WorkDir = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                Resources.WorkDir, "UpdatesServer");

            if (!Directory.Exists(WorkDir))
            {
                Directory.CreateDirectory(WorkDir);
            }

            var upgUrl = Path.Combine(WorkDir, "upgrade.txt");

            File.WriteAllText(upgUrl, "Upgrade");

            var whatsNewUrl = Path.Combine(WorkDir, "whats-new.txt");

            File.WriteAllText(whatsNewUrl, "What's New");

            var latestVers = new LatestVersionInfo()
            {
                Version     = $"2.0.0.0",
                UpgradeUrl  = upgUrl,
                WhatsNewUrl = whatsNewUrl
            };

            var filePath = Path.Combine(WorkDir, "latest-version.json");

            UpdateUrl = "file:///" + filePath.Replace('\\', '/');

            using (var str = File.Create(filePath))
            {
                var ser = new DataContractJsonSerializer(typeof(LatestVersionInfo));
                ser.WriteObject(str, latestVers);
            }
        }