public static bool TryParse(string rawdatastring, Infos.PSO2VersionCheckResult baseUrl, out PSO2File _pso2file) { string[] splitbuffer = null; if (rawdatastring.IndexOf(Microsoft.VisualBasic.ControlChars.Tab) > -1) { splitbuffer = rawdatastring.Split(_tabonly, 5, StringSplitOptions.RemoveEmptyEntries); } else if (rawdatastring.IndexOf(" ") > -1) { splitbuffer = rawdatastring.Split(_spaceonly, 5, StringSplitOptions.RemoveEmptyEntries); } if (splitbuffer != null && splitbuffer.Length >= 4) { if (Leayal.StringHelper.IsEqual(splitbuffer[3], "m", true)) { _pso2file = new PSO2File(splitbuffer[0], splitbuffer[2], splitbuffer[1], baseUrl.MasterURL); } else { _pso2file = new PSO2File(splitbuffer[0], splitbuffer[2], splitbuffer[1], baseUrl.PatchURL); } return(true); } else { _pso2file = null; return(false); } }
protected virtual bool GetFilesList(Infos.PSO2VersionCheckResult patchinfo) { if (!this.IsBusy) { this.myFileList.Clear(); int i = 0; // this.ProgressTotal = DefaultValues.PatchInfo.PatchListFiles.Count; this.ProgressTotal = 3; // patchurl RecyclableMemoryStream memStream; if (MySettings.MinimizeNetworkUsage) { this.myWebClient.CacheStorage = Components.CacheStorage.DefaultStorage; } else { this.myWebClient.CacheStorage = null; } this.ProgressCurrent = 1; this.CurrentStep = string.Format(LanguageManager.GetMessageText("PSO2UpdateManager_DownloadingPatchList", "Downloading {0} list"), DefaultValues.PatchInfo.called_masterlist); memStream = this.myWebClient.DownloadToMemory(Leayal.UriHelper.URLConcat(patchinfo.MasterURL, DefaultValues.PatchInfo.file_patch), DefaultValues.PatchInfo.called_masterlist); if (memStream != null && memStream.Length > 0) { this.myFileList.Add(DefaultValues.PatchInfo.called_masterlist, memStream); } this.ProgressCurrent = 2; this.CurrentStep = string.Format(LanguageManager.GetMessageText("PSO2UpdateManager_DownloadingPatchList", "Downloading {0} list"), DefaultValues.PatchInfo.called_patchlist); memStream = this.myWebClient.DownloadToMemory(Leayal.UriHelper.URLConcat(patchinfo.PatchURL, DefaultValues.PatchInfo.file_patch), DefaultValues.PatchInfo.called_patchlist); if (memStream != null && memStream.Length > 0) { this.myFileList.Add(DefaultValues.PatchInfo.called_patchlist, memStream); } this.ProgressCurrent = 3; this.CurrentStep = string.Format(LanguageManager.GetMessageText("PSO2UpdateManager_DownloadingPatchList", "Downloading {0} list"), DefaultValues.PatchInfo.file_launcher); memStream = this.myWebClient.DownloadToMemory(Leayal.UriHelper.URLConcat(patchinfo.PatchURL, DefaultValues.PatchInfo.file_launcher), DefaultValues.PatchInfo.file_launcher); if (memStream != null && memStream.Length > 0) { this.myFileList.Add(DefaultValues.PatchInfo.file_launcher, memStream); } this.myWebClient.CacheStorage = null; if (this.myFileList.Count == 3) { return(true); } else { return(false); } } else { return(false); } }
/*public void CheckForUpdatesAsync() * { * * }*/ public Infos.PSO2VersionCheckResult CheckForUpdates() { Infos.PSO2VersionCheckResult result; try { string management = this.myWebClient.DownloadString(DefaultValues.PatchInfo.PatchManagement); if (MySettings.MinimizeNetworkUsage) { this.myWebClient.CacheStorage = Components.CacheStorage.DefaultStorage; } else { this.myWebClient.CacheStorage = null; } if (string.IsNullOrWhiteSpace(management)) { throw new NullReferenceException("Latest version is null. Something bad happened."); } else { string currentline, master = null, patch = null; string[] splitedline; using (StringReader sr = new StringReader(management)) while (sr.Peek() > -1) { currentline = sr.ReadLine(); if (!string.IsNullOrWhiteSpace(currentline)) { splitedline = currentline.Split(bangonly, 2, StringSplitOptions.RemoveEmptyEntries); if (Leayal.StringHelper.IsEqual(splitedline[0], "MasterURL", true)) { master = splitedline[1]; } else if (Leayal.StringHelper.IsEqual(splitedline[0], "PatchURL", true)) { patch = splitedline[1]; } if (!string.IsNullOrWhiteSpace(master) && !string.IsNullOrWhiteSpace(patch)) { break; } } } if (string.IsNullOrWhiteSpace(master)) { result = new Infos.PSO2VersionCheckResult(new ArgumentNullException("MasterURL is not found")); } else if (string.IsNullOrWhiteSpace(patch)) { result = new Infos.PSO2VersionCheckResult(new ArgumentNullException("PatchURL is not found")); } else { string latestver = this.myWebClient.DownloadString(Leayal.UriHelper.URLConcat(patch, "version.ver")); if (string.IsNullOrWhiteSpace(latestver)) { result = new Infos.PSO2VersionCheckResult(new ArgumentNullException("Latest version file is not found")); } else { this._LastKnownLatestVersion = latestver; result = new Infos.PSO2VersionCheckResult(latestver, MySettings.PSO2Version, master, patch); } } } this.myWebClient.CacheStorage = null; } catch (Exception ex) { result = new Infos.PSO2VersionCheckResult(ex); } return(result); }
protected virtual System.Collections.Concurrent.ConcurrentDictionary <string, PSO2File> ParseFilelist(MemoryFileCollection filelist, Infos.PSO2VersionCheckResult patchinfo) { Dictionary <string, PSO2File> result = new Dictionary <string, PSO2File>(); if (filelist != null && filelist.Count > 0) { string linebuffer; PSO2File pso2filebuffer; this.ProgressTotal = filelist.Count; this.CurrentStep = LanguageManager.GetMessageText("PSO2UpdateManager_BuildingFileList", "Building file list"); int i = 0; foreach (var _pair in filelist.GetEnumerator()) { i++; using (StreamReader sr = new StreamReader(_pair.Value)) while (!sr.EndOfStream) { linebuffer = sr.ReadLine(); if (!string.IsNullOrWhiteSpace(linebuffer)) { if (_pair.Key == DefaultValues.PatchInfo.called_masterlist) { if (PSO2File.TryParse(linebuffer, patchinfo.MasterURL, out pso2filebuffer)) { if (!result.ContainsKey(pso2filebuffer.WindowFilename)) { result.Add(pso2filebuffer.WindowFilename, pso2filebuffer); } } } else { if (PSO2File.TryParse(linebuffer, patchinfo, out pso2filebuffer)) { if (!result.ContainsKey(pso2filebuffer.WindowFilename)) { result.Add(pso2filebuffer.WindowFilename, pso2filebuffer); } else { if (_pair.Key == DefaultValues.PatchInfo.file_patch) { result[pso2filebuffer.WindowFilename] = pso2filebuffer; } } } } } } this.ProgressCurrent = i; } } return(new System.Collections.Concurrent.ConcurrentDictionary <string, PSO2File>(result)); }