private void MyWebClient_ForAIDA_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { TransarmWorkerInfo meta = null; if (e.UserState != null) { if (e.UserState is TransarmWorkerInfo) { meta = e.UserState as TransarmWorkerInfo; } } if (e.Error != null) { this.OnHandledException(new HandledExceptionEventArgs(e.Error)); } else if (e.Cancelled) { } else { if (meta != null) { this.bWorker_install.RunWorkerAsync(meta); } } }
private void InstallPatchEx_callback(object sender, AsyncCompletedEventArgs e) { TransarmWorkerInfo state = e.UserState as TransarmWorkerInfo; if (e.Error != null) { this.OnPatchInstalled(new PatchFinishedEventArgs(false, (state.Params as PatchNotificationEventArgs).NewPatchVersion)); this.OnHandledException(new HandledExceptionEventArgs(e.Error)); } else if (e.Cancelled) { this.OnPatchInstalled(new PatchFinishedEventArgs(false, (state.Params as PatchNotificationEventArgs).NewPatchVersion)); } else { this.bWorker_install.RunWorkerAsync(state); } }
protected virtual void OnInstalling(object sender, DoWorkEventArgs e) { //return; TransarmWorkerInfo seed = e.Argument as TransarmWorkerInfo; PatchNotificationEventArgs seedEvent = seed.Params as PatchNotificationEventArgs; string pso2datadir = DefaultValues.Directory.PSO2Win32Data; string largefilesBackupFolder = Path.Combine(pso2datadir, DefaultValues.Directory.PSO2Win32DataBackup, DefaultValues.Directory.Backup.LargeFiles); this.OnCurrentStepChanged(new StepEventArgs(string.Format(LanguageManager.GetMessageText("Begin0PatchFiles", "Extracting {0} data"), Infos.DefaultValues.AIDA.Strings.LargeFilesPatchCalled))); string myPatcher = Path.Combine(seed.Path, Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.TransAmEXE); string my7zDB = Path.Combine(seed.Path, Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.LargeFilesDB + "zip"); string myDB = string.Empty; bool isOkay = false; var result = AbstractExtractor.ExtractZip(my7zDB, seed.Path, null); isOkay = result.IsSuccess; myDB = result.SuccessItems[0].Key; File.Delete(my7zDB); if (isOkay) { if (false) { this.OnCurrentStepChanged(new StepEventArgs(string.Format(LanguageManager.GetMessageText("BeginRestoring0PatchFiles", "Getting {0} filelist"), Infos.DefaultValues.AIDA.Strings.LargeFilesPatchCalled))); string rawtbl = this.myWebClient_ForAIDA.DownloadString(Classes.AIDA.WebPatches.PatchesFileListInfos); string sourceTable = string.Empty; using (var theTextReader = new StringReader(rawtbl)) using (var jsonReader = new Newtonsoft.Json.JsonTextReader(theTextReader)) while (jsonReader.Read()) { if (jsonReader.TokenType == Newtonsoft.Json.JsonToken.PropertyName) { if (jsonReader.Value is string && (jsonReader.Value as string).ToLower() == "largefileslist") { sourceTable = jsonReader.ReadAsString(); } } } string[] tbl_files = AIDA.StringToTableString(sourceTable); string originalFile, backupFile, currentIndexString; this.OnCurrentStepChanged(new StepEventArgs(string.Format(LanguageManager.GetMessageText("Creating0PatchBackup", "Creating backup for {0} files"), Infos.DefaultValues.AIDA.Strings.LargeFilesPatchCalled))); int total = tbl_files.Length; this.OnCurrentTotalProgressChanged(new ProgressEventArgs(total)); Directory.CreateDirectory(largefilesBackupFolder); for (int i = 0; i < tbl_files.Length; i++) { currentIndexString = tbl_files[i]; originalFile = Path.Combine(pso2datadir, currentIndexString); backupFile = Path.Combine(largefilesBackupFolder, currentIndexString); File.Copy(originalFile, backupFile, true); this.OnCurrentProgressChanged(new ProgressEventArgs(i + 1)); } } this.OnCurrentStepChanged(new StepEventArgs(LanguageManager.GetMessageText("CallTransarmPatcherBackup", "Call patcher and wait for patcher finish the job"))); this.OnProgressBarStateChanged(new ProgressBarStateChangedEventArgs(Forms.MyMainMenu.ProgressBarVisibleState.Infinite)); patcherProcess = Infos.CommonMethods.MakeProcess(myPatcher); //-i "Backup/" -h largefiles-10-7-2016 lf.stripped.db "Out" string MyBaseDateString = "largefiles-" + seed.Date.Month.ToString() + "-" + seed.Date.Day.ToString() + "-" + seed.Date.Year.ToString(); //lf.stripped.db //Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.LargeFilesBackupFolder List <string> myParams = new List <string>(); myParams.Add(Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.paramNodeForBackupOutput); myParams.Add(Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.LargeFilesBackupFolder); myParams.Add(Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.paramNodeForOutput); myParams.Add(MyBaseDateString); myParams.Add(myDB); myParams.Add(Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.ValidPath(DefaultValues.Directory.PSO2Win32Data)); string pso2bin = DefaultValues.Directory.PSO2Dir; string veda = Path.Combine(pso2bin, Infos.DefaultValues.AIDA.Tweaker.TransArmThingiesOrWatever.VEDA_Filename); string asdadasd = Leayal.ProcessHelper.TableStringToArgs(myParams); //Log.LogManager.GetLog("asdasd.txt", true).Print(asdadasd); patcherProcess.StartInfo.Arguments = asdadasd; patcherProcess.StartInfo.WorkingDirectory = seed.Path; patcherProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal; if (Leayal.OSVersionInfo.Name.ToLower() != "windows xp") { patcherProcess.StartInfo.Verb = "runas"; } Exception exVeda = AIDA.TransarmOrVedaOrWhatever.VEDA_Activate(pso2bin); if (exVeda == null) { patcherProcess.StartInfo.UseShellExecute = false; patcherProcess.Start(); patcherProcess.WaitForExit(); File.Delete(veda); this.OnProgressBarStateChanged(new ProgressBarStateChangedEventArgs(Forms.MyMainMenu.ProgressBarVisibleState.None)); //Log.LogManager.GetLogDefaultPath("LargeFile.txt", true).Print("LargeFile Exit COde: " + patcher.ExitCode.ToString()); try { if ((patcherProcess != null) && (patcherProcess.ExitCode == 0)) { patcherProcess = null; e.Result = seed.Date.ToVersionString(); } else { patcherProcess = null; if (seed.Backup) { if (Directory.Exists(largefilesBackupFolder)) { this.OnProgressBarStateChanged(new ProgressBarStateChangedEventArgs(Forms.MyMainMenu.ProgressBarVisibleState.Percent)); this.OnCurrentStepChanged(new StepEventArgs(string.Format(LanguageManager.GetMessageText("Rollback0Patch", "Rolling back the {0} installation"), Infos.DefaultValues.AIDA.Strings.LargeFilesPatchCalled))); string[] tbl_backup = Directory.GetFiles(largefilesBackupFolder, "*", SearchOption.TopDirectoryOnly); string originalFile, backupFile, currentIndexString; int total = tbl_backup.Length; this.OnCurrentTotalProgressChanged(new ProgressEventArgs(total)); for (int i = 0; i < tbl_backup.Length; i++) { currentIndexString = Path.GetFileName(tbl_backup[i]); originalFile = Path.Combine(pso2datadir, currentIndexString); backupFile = Path.Combine(largefilesBackupFolder, currentIndexString); File.Delete(originalFile); File.Move(backupFile, originalFile); this.OnCurrentProgressChanged(new ProgressEventArgs(i + 1)); } } } throw new Exception(LanguageManager.GetMessageText("CancelLargeFilesPatchFiles", "User cancelled or the patcher closed with Error(s).")); } File.Delete(Path.Combine(seed.Path, myDB)); File.Delete(myPatcher); } catch (System.Net.WebException) { } } else { throw exVeda; } } else { throw new Exception(LanguageManager.GetMessageText("BadArchiveOrUnknownError", "Bad archive file or unknown error happened while") + " " + string.Format(LanguageManager.GetMessageText("Begin0PatchFiles", "Extracting {0} data"), Infos.DefaultValues.AIDA.Strings.LargeFilesPatchCalled)); } try { Directory.Delete(seed.Path, true); } catch (IOException) { try { Leayal.IO.DirectoryHelper.EmptyFolder(seed.Path); Directory.Delete(seed.Path, true); } catch { } } e.Result = seedEvent.NewPatchVersion; }