public static bool TryParse(string data, out PrepatchVersion result) { try { string[] splitted = null; if (data.IndexOf(Microsoft.VisualBasic.ControlChars.Tab) > -1) { splitted = data.Split(new char[] { Microsoft.VisualBasic.ControlChars.Tab }, 2, StringSplitOptions.RemoveEmptyEntries); } else if (data.IndexOf(' ') > -1) { splitted = data.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); } if (splitted != null) { result = new PrepatchVersion(splitted[0], Leayal.NumberHelper.Parse(splitted[1])); } else { result = new PrepatchVersion(data); } return(true); } catch { result = new PrepatchVersion(); return(false); } }
public bool Equals(PrepatchVersion target) { if (Leayal.StringHelper.IsEqual(this.Version, target.Version, true)) { if (this.ListCount == target.ListCount) { return(true); } } return(false); }
private void BWorker_DoWork(object sender, DoWorkEventArgs e) { this.OnProgressStateChanged(new ProgressBarStateChangedEventArgs(Forms.MyMainMenu.ProgressBarVisibleState.Infinite)); PrepatchWorkerParams wp = e.Argument as PrepatchWorkerParams; // Let's get to see how many patchlist{0}.txt there are var remoteresult = CheckForUpdates(); if (remoteresult.IsPrepatchExisted) { if (wp.Force || remoteresult.IsNewVersion) { if (GetFilesList(remoteresult.Latest.ListCount) > 0) { string pso2precedePath = Path.Combine(wp.PSO2Path, "_precede"); System.Collections.Concurrent.ConcurrentDictionary <string, PSO2File> myPSO2filesList = ParseFilelist(this.myFileList); if (!myPSO2filesList.IsEmpty) { Microsoft.VisualBasic.FileIO.FileSystem.CreateDirectory(pso2precedePath); this.ProgressTotal = myPSO2filesList.Count; this.OnProgressStateChanged(new ProgressBarStateChangedEventArgs(Forms.MyMainMenu.ProgressBarVisibleState.Percent, new Forms.MyMainMenuCode.CircleProgressBarProperties(true))); PrepatchVersion verstring = wp.NewVersion; if (string.IsNullOrWhiteSpace(verstring.Version)) { verstring = remoteresult.Latest; } /*if (string.IsNullOrWhiteSpace(verstring)) * verstring = this.myWebClient.DownloadString(DefaultValues.PatchInfo.VersionLink);//*/ anothersmallthreadpool = new PrepatchSmallThreadPool(pso2precedePath, myPSO2filesList); anothersmallthreadpool.StepChanged += Anothersmallthreadpool_StepChanged; anothersmallthreadpool.ProgressChanged += Anothersmallthreadpool_ProgressChanged; anothersmallthreadpool.KaboomFinished += Anothersmallthreadpool_KaboomFinished; anothersmallthreadpool.StartWork(new PrepatchWorkerParams(pso2precedePath, verstring, wp.Force)); e.Result = null; } else { e.Result = new PSO2UpdateResult(UpdateResult.Failed); } } else { e.Result = new PSO2UpdateResult(UpdateResult.Unknown); throw new PSO2UpdateException(LanguageManager.GetMessageText("PSO2PrepatchManager_GetPatchListFailed", "Failed to get PSO2's pre-patch file list.")); } } } else { throw remoteresult.Error; } }
/*public void CheckForUpdatesAsync() * { * * }*/ public PrepatchVersionCheckResult CheckForUpdates() { PrepatchVersionCheckResult result; try { string latestver = this.myWebClient.DownloadString(DefaultValues.PatchInfo.PrecedeVersionLink); if (string.IsNullOrWhiteSpace(latestver)) { throw new NullReferenceException("Latest version is null. Something bad happened."); } else { this._LastKnownLatestVersion = latestver; if (PrepatchVersion.TryParse(latestver, out var latestversion)) { result = new PrepatchVersionCheckResult(latestversion, MySettings.PSO2PrecedeVersion); } else { result = new PrepatchVersionCheckResult(latestver, MySettings.PSO2PrecedeVersion); } } } catch (WebException webEx) { if (webEx.Response != null) { HttpWebResponse webRep = webEx.Response as HttpWebResponse; if (webRep != null && webRep.StatusCode == HttpStatusCode.NotFound) { result = new PrepatchVersionCheckResult(new NoPrepatchExistedException()); } else { result = new PrepatchVersionCheckResult(webEx); } } else { result = new PrepatchVersionCheckResult(webEx); } } catch (Exception ex) { result = new PrepatchVersionCheckResult(ex); } return(result); }
public void UpdatePrepatch(string _pso2path, PrepatchVersion latestver) { this.UpdatePrepatch(new PrepatchWorkerParams(_pso2path, latestver)); }
public PrepatchVersionCheckResult(PrepatchVersion _latest, PrepatchVersion _current) { this.Current = _current; this.Latest = _latest; this.Error = null; }
public PrepatchVersionCheckResult(string latest, PrepatchVersion current, int prepatchListCount) : this(new PrepatchVersion(latest, prepatchListCount), current) { }
public PrepatchVersionCheckResult(string latest, PrepatchVersion current) : this(latest, current, 1) { }