private void _menuItemProjectSaveAs_Click(object sender, RoutedEventArgs e) { try { string file = PathRequest.SaveFileCde( "filter", FileFormat.MergeFilters(Format.Sde), "fileName", Path.GetFileName(ProjectConfiguration.ConfigAsker.ConfigFile)); if (file != null) { if (file == ProjectConfiguration.ConfigAsker.ConfigFile) { } else { try { GrfPath.Delete(file); File.Copy(ProjectConfiguration.ConfigAsker.ConfigFile, file); } catch (Exception err) { ErrorHandler.HandleException(err); return; } _recentFilesManager.AddRecentFile(file); ReloadSettings(file); } } } catch (Exception err) { ErrorHandler.HandleException(err.Message, ErrorLevel.Warning); } }
public void ReloadSettings(string fileNameSettings = null) { try { if (ShouldCancelDbReload()) { return; } if (fileNameSettings != null) { if (fileNameSettings == ProjectConfiguration.DefaultFileName) { GrfPath.Delete(ProjectConfiguration.DefaultFileName); } ProjectConfiguration.ConfigAsker = new ConfigAsker(fileNameSettings); _recentFilesManager.AddRecentFile(fileNameSettings); } _setTitle(Methods.CutFileName(ProjectConfiguration.ConfigAsker.ConfigFile), false); _loadDatabaseFiles(); _loadItemTxtFiles(); _loadItemLuaFiles(); _cbUseLuaFiles.IsChecked = ProjectConfiguration.UseLuaFiles; _cbClientDbSync.IsChecked = ProjectConfiguration.SynchronizeWithClientDatabases; _metaGrfViewer.LoadResourcesInfo(); _asyncOperation.SetAndRunOperation(new GrfThread(_updateMetaGrf, this, 200, null, false, true)); IOHelper.Close(); } catch (Exception err) { ErrorHandler.HandleException(err); } }
public void Backup(string file) { if (!SdeAppConfiguration.BackupsManagerState || !_isStarted || _isCrashed) { return; } if (file == null) { throw new ArgumentNullException("file"); } try { string relativePath = file.ReplaceFirst(GrfPath.GetDirectoryName(SdeFiles.ServerDbPath) + "\\", ""); if (String.IsNullOrEmpty(relativePath)) { return; } _validateOpened(); if (!_paths.ContainsKey(_currentId)) { _paths[_currentId] = _getGrfPath(); } string fullPath = GrfPath.Combine(_paths[_currentId], relativePath); string tempFile = TemporaryFilesManager.GetTemporaryFilePath("backup_local_copy_{0:0000}"); File.Copy(file, tempFile); _grf.Commands.AddFileAbsolute(fullPath, tempFile); } catch { } }
private static string _getInCurrentPath(string fileInput) { string path = ProjectConfiguration.DatabasePath; string[] files = fileInput.GetExtension() == null ? new string[] { fileInput + ".txt", fileInput + ".conf" } : new string[] { fileInput }; return(files.Select(file => GrfPath.CombineUrl(path, file)).FirstOrDefault(FtpHelper.Exists)); }
/// <summary> /// Restores the specified backup. /// </summary> /// <param name="backup">The backup path.</param> /// <exception cref="ArgumentNullException">backup</exception> public void Restore(string backup) { if (backup == null) { throw new ArgumentNullException("backup"); } _validateOpened(); BackupInfo info = new BackupInfo(new ReadonlyConfigAsker(_grf.FileTable[GrfPath.Combine(backup, InfoName)].GetDecompressedData())); if (!Directory.Exists(info.DestinationPath)) { Directory.CreateDirectory(info.DestinationPath); } foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories)) { if (entry.RelativePath.EndsWith(InfoName)) { continue; } entry.ExtractFromAbsolute(GrfPath.Combine(info.DestinationPath, entry.RelativePath.ReplaceFirst(backup + "\\", ""))); } _grf.Close(); }
private string _convertPath(string path) { //return GrfPath.Combine(DestPath, path.Replace(ProjectConfiguration.DatabasePath, "").TrimStart('/', '\\').Replace("/", "\\")); FtpUrlInfo url = new FtpUrlInfo(GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath)); return(path.Replace(GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath), "").TrimStart('/', '\\').Replace(url.Path.TrimStart('/', '\\'), "").TrimStart('/', '\\')); }
/// <summary> /// Exports the specified folder from the GRF. /// </summary> /// <param name="folder">The extraction folder path.</param> /// <param name="backup">The backup path.</param> /// <exception cref="ArgumentNullException"> /// folder /// or /// backup /// </exception> public void Export(string folder, string backup) { if (folder == null) { throw new ArgumentNullException("folder"); } if (backup == null) { throw new ArgumentNullException("backup"); } _validateOpened(); foreach (FileEntry entry in _grf.FileTable.EntriesInDirectory(backup, SearchOption.AllDirectories)) { if (entry.RelativePath.EndsWith(InfoName)) { continue; } entry.ExtractFromAbsolute(GrfPath.Combine(folder, entry.RelativePath.ReplaceFirst(backup + "\\", ""))); } _grf.Close(); }
public void Backup(string file) { if (!SdeAppConfiguration.BackupsManagerState || !IsStarted || _backupThread.IsCrashed) { return; } if (file == null) { throw new ArgumentNullException("file"); } try { string relativePath = file.ReplaceFirst(GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath) + IOHelper.Slash, ""); if (String.IsNullOrEmpty(relativePath)) { return; } _validateOpened(); string fullPath = GrfPath.Combine(_paths[_currentId], relativePath); string tempFile = TemporaryFilesManager.GetTemporaryFilePath("backup_local_copy_{0:0000}"); IOHelper.Copy(file, tempFile); _localToGrfPath[_currentId][tempFile] = fullPath; } catch { } }
public void ReloadSettings(string fileNameSettings = null) { try { if (ShouldCancelDbReload()) { return; } if (fileNameSettings != null) { if (fileNameSettings == ProjectConfiguration.DefaultFileName) { GrfPath.Delete(ProjectConfiguration.DefaultFileName); } ProjectConfiguration.ConfigAsker = new ConfigAsker(fileNameSettings); _recentFilesManager.AddRecentFile(fileNameSettings); } Title = "Server database editor - " + Methods.CutFileName(ProjectConfiguration.ConfigAsker.ConfigFile); _loadDatabaseFiles(); _metaGrfViewer.LoadResourcesInfo(); _asyncOperation.SetAndRunOperation(new GrfThread(_updateMetaGrf, this, 200, null, false, true)); } catch (Exception err) { ErrorHandler.HandleException(err); } }
private CmdInfo _generateMissingCmd(string icon, string displayName, string sdeResource, Func <ValidationErrorView, bool> canExecute) { return(new CmdInfo { CmdName = displayName, Icon = icon, DisplayName = displayName, CanExecute = canExecute, _execute = t => { var cpy = sdeResource; if (String.IsNullOrEmpty(cpy.GetExtension())) { cpy = cpy + ((ResourceError)t).MissingPath.GetExtension(); } var path = GrfPath.Combine(SdeAppConfiguration.TempPath, cpy); if (!File.Exists(path)) { File.WriteAllBytes(path, ApplicationManager.GetResource(cpy)); } ValidationEngine.Grf.Commands.AddFileAbsolute(((ResourceError)t).MissingPath.ToDisplayEncoding(), path); return true; } }); }
public void BackupClient(string file, byte[] data) { if (!SdeAppConfiguration.BackupsManagerState || !IsStarted || _backupThread.IsCrashed) { return; } if (file == null) { throw new ArgumentNullException("file"); } if (data == null) { return; } try { string relativePath = GrfPath.Combine("client", Path.GetFileName(file)); //.ReplaceFirst(GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath) + (isFtp ? "/" : "\\"), ""); if (String.IsNullOrEmpty(relativePath)) { return; } _validateOpened(); string tempFile = TemporaryFilesManager.GetTemporaryFilePath("backup_local_copy_{0:0000}"); File.WriteAllBytes(tempFile, data); string fullPath = GrfPath.Combine(_paths[_currentId], relativePath); _localToGrfPath[_currentId][tempFile] = fullPath; } catch { } }
public App() { Configuration.ConfigAsker = SdeAppConfiguration.ConfigAsker; ProjectConfiguration.ConfigAsker = SdeAppConfiguration.ConfigAsker; Settings.TempPath = GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"); ErrorHandler.SetErrorHandler(new SdeErrorHandler()); TemporaryFilesManager.ClearTemporaryFiles(); }
public SftpDb(string path) { DestPath = GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, path.GetHashCode().ToString(CultureInfo.InvariantCulture)); var file = GrfPath.Combine(DestPath, "files.dat"); GrfPath.CreateDirectoryFromFile(file); _config = new ConfigAsker(file); }
public App() { Configuration.ConfigAsker = SdeAppConfiguration.ConfigAsker; ProjectConfiguration.ConfigAsker = SdeAppConfiguration.ConfigAsker; Settings.TempPath = GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp\\" + SdeAppConfiguration.ProcessId); ErrorHandler.SetErrorHandler(new DefaultErrorHandler()); ClearTemporaryFiles(); }
private Dictionary <int, int> _getWeaponClasses() { Dictionary <int, int> table = new Dictionary <int, int>(); var accIdPath = ProjectConfiguration.SyncAccId; for (int i = 0; i <= 30; i++) { table[i] = i; } if (_database.MetaGrf.GetData(ProjectConfiguration.SyncAccId) == null || _database.MetaGrf.GetData(ProjectConfiguration.SyncAccName) == null) { return(table); } var weaponPath = GrfPath.Combine(GrfPath.GetDirectoryName(accIdPath), "weapontable" + Path.GetExtension(accIdPath)); var weaponData = _database.MetaGrf.GetData(weaponPath); if (weaponData == null) { return(table); } var weaponTable = new LuaParser(weaponData, true, p => new Lub(p).Decompile(), EncodingService.DetectEncoding(weaponData), EncodingService.DisplayEncoding); var weaponIds = LuaHelper.GetLuaTable(weaponTable, "Weapon_IDs"); var weaponExpansionNameTable = LuaHelper.GetLuaTable(weaponTable, "Expansion_Weapon_IDs"); var ids = LuaHelper.SetIds(weaponIds, "Weapon_IDs"); foreach (var id in ids) { if (id.Value == 24) { continue; } if (id.Value <= 30) { table[id.Value] = id.Value; } else { string sval; if (weaponExpansionNameTable.TryGetValue("[" + id.Key + "]", out sval)) { int ival; if (ids.TryGetValue(sval, out ival)) { table[id.Value] = ival; } } } } return(table); }
public SettingsDialog() : base("Advanced settings", "settings.png") { InitializeComponent(); int row; Binder.Bind(_pbNotepad.TextBox, () => SdeAppConfiguration.NotepadPath); _add(_gridComments, row = 0, "Add comments in item_trade.txt", "Displays the item name as a comment at the end of the line for item_trade.txt.", () => SdeAppConfiguration.AddCommentForItemTrade, v => SdeAppConfiguration.AddCommentForItemTrade = v); _add(_gridComments, ++row, "Add comments in item_avail.txt", "Displays the item names as a comment at the end of the line for item_avail.txt.", () => SdeAppConfiguration.AddCommentForItemAvail, v => SdeAppConfiguration.AddCommentForItemAvail = v); _add(_gridComments, ++row, "Add comments in item_nouse.txt", "Displays the item names as a comment at the end of the line for item_nouse.txt.", () => SdeAppConfiguration.AddCommentForItemNoUse, v => SdeAppConfiguration.AddCommentForItemNoUse = v); _add(_gridGeneral, row = 3, "Switch item types 4 and 5 for text based databases (requires a software restart)", "Switches the armor and weapon types when reading the databases.", () => SdeAppConfiguration.RevertItemTypes, v => SdeAppConfiguration.RevertItemTypes = v); _add(_gridGeneral, ++row, "Always reopen the latest opened project", "Always reopen the most recently opened project when starting the application.", () => SdeAppConfiguration.AlwaysReopenLatestProject, v => SdeAppConfiguration.AlwaysReopenLatestProject = v); _add(_gridGeneral, ++row, "Associate the .sde file extension with this tool", null, () => (SdeAppConfiguration.FileShellAssociated & FileAssociation.Sde) == FileAssociation.Sde, v => { if (v) { SdeAppConfiguration.FileShellAssociated |= FileAssociation.Sde; ApplicationManager.AddExtension(Methods.ApplicationFullPath, "Server database editor", ".sde", true); } else { SdeAppConfiguration.FileShellAssociated &= ~FileAssociation.Sde; GrfPath.Delete(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "sde.ico")); ApplicationManager.RemoveExtension(Methods.ApplicationFullPath, ".sde"); } }); _add(_gridGeneral, ++row, "Enable backups manager", null, () => SdeAppConfiguration.BackupsManagerState, v => SdeAppConfiguration.BackupsManagerState = v); _add(_gridGeneral, ++row, "Apply modifications to all selected items", "If checked, every field that you edit will modify all the currently selected items.", () => SdeAppConfiguration.EnableMultipleSetters, v => SdeAppConfiguration.EnableMultipleSetters = v); _add(_gridGeneral, ++row, "Bind item tabs together", "If checked, both the Client Items and Items tab will sync.", () => SdeAppConfiguration.BindItemTabs, v => SdeAppConfiguration.BindItemTabs = v); _add(_gridGeneral, ++row, "Always overwrite non-modified files", "If checked, non-modified files will be overwritten in your db folder.", () => SdeAppConfiguration.AlwaysOverwriteFiles, v => SdeAppConfiguration.AlwaysOverwriteFiles = v); _add(_gridDbWriter, row = 0, "Remove NoUse entry if the flag is 0 (ignore override)", "This will remove the line regardless of the override property, which must be normally at 100 for the line to be removed.", () => SdeAppConfiguration.DbNouseIgnoreOverride, v => SdeAppConfiguration.DbNouseIgnoreOverride = v); _add(_gridDbWriter, ++row, "Remove Trade entry if the flag is 0 (ignore override)", "This will remove the line regardless of the override property, which must be normally at 100 for the line to be removed.", () => SdeAppConfiguration.DbTradeIgnoreOverride, v => SdeAppConfiguration.DbTradeIgnoreOverride = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedDisplayName", null, () => SdeAppConfiguration.DbWriterItemInfoUnDisplayName, v => SdeAppConfiguration.DbWriterItemInfoUnDisplayName = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedResourceName", null, () => SdeAppConfiguration.DbWriterItemInfoUnResource, v => SdeAppConfiguration.DbWriterItemInfoUnResource = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedDescriptionName", null, () => SdeAppConfiguration.DbWriterItemInfoUnDescription, v => SdeAppConfiguration.DbWriterItemInfoUnDescription = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedDisplayName", null, () => SdeAppConfiguration.DbWriterItemInfoIdDisplayName, v => SdeAppConfiguration.DbWriterItemInfoIdDisplayName = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedResourceName", null, () => SdeAppConfiguration.DbWriterItemInfoIdResource, v => SdeAppConfiguration.DbWriterItemInfoIdResource = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedDescriptionName", null, () => SdeAppConfiguration.DbWriterItemInfoIdDescription, v => SdeAppConfiguration.DbWriterItemInfoIdDescription = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write slotCount", null, () => SdeAppConfiguration.DbWriterItemInfoSlotCount, v => SdeAppConfiguration.DbWriterItemInfoSlotCount = v); _add(_gridDbWriter, ++row, "itemInfo.lua : Write ClassNum", null, () => SdeAppConfiguration.DbWriterItemInfoClassNum, v => SdeAppConfiguration.DbWriterItemInfoClassNum = v); _add(_gridDbWriter, ++row, "item_group : force write in single file", "'Import' fields won't be used when saving the item groups", () => SdeAppConfiguration.DbWriterItemInfoClassNum, v => SdeAppConfiguration.DbWriterItemInfoClassNum = v); _add(_gridDialogs, row = 0, "Use integrated dialogs for flags", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForFlags, v => SdeAppConfiguration.UseIntegratedDialogsForFlags = v); _add(_gridDialogs, ++row, "Use integrated dialogs for scripts", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForScripts, v => SdeAppConfiguration.UseIntegratedDialogsForScripts = v); _add(_gridDialogs, ++row, "Use integrated dialogs for levels", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForLevels, v => SdeAppConfiguration.UseIntegratedDialogsForLevels = v); _add(_gridDialogs, ++row, "Use integrated dialogs for jobs", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForJobs, v => SdeAppConfiguration.UseIntegratedDialogsForJobs = v); _add(_gridDialogs, ++row, "Use integrated dialogs for time", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForTime, v => SdeAppConfiguration.UseIntegratedDialogsForTime = v); _add(_gridRAthena, row = 0, "Use old rAthena mob mode", "If checked, this will use the old mob mode.", () => ProjectConfiguration.UseOldRAthenaMode, v => ProjectConfiguration.UseOldRAthenaMode = v); _loadEncoding(); _comboBoxCompression.Init(); _loadAutocomplete(); _loadShortcuts(); }
public Backup(string backup) { if (backup == null) { throw new ArgumentNullException("backup"); } BackupDate = backup; Entry = BackupEngine.Instance.Grf.FileTable[GrfPath.Combine(BackupDate, BackupEngine.InfoName)]; Info = new BackupInfo(new ReadonlyConfigAsker(Entry.GetDecompressedData())); }
public void Set(string dataPath, string urlPath, ChannelSftp.LsEntry entry) { urlPath = _convertPath(urlPath); _config[urlPath] = entry.getAttrs().getMTime().ToString(CultureInfo.InvariantCulture); var dest = _convertLocalPath(urlPath); GrfPath.CreateDirectoryFromFile(dest); GrfPath.Delete(dest); File.Copy(dataPath, dest); }
private void _buttonOk_Click(object sender, RoutedEventArgs e) { try { string t; CurrentPath = GrfPath.Combine(_currentPath, _listViewResults.SelectedItem != null ? ((t = ((FtpEntry)_listViewResults.SelectedItem).Name) == ".." ? "" : t) : "").Replace("\\", "/"); DialogResult = true; Close(); } catch (Exception err) { ErrorHandler.HandleException(err); } }
public static void DbDirectCopyWriter <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db) { try { if (debug.OldPath != debug.FilePath) { GrfPath.Delete(debug.FilePath); File.Copy(debug.OldPath, debug.FilePath); } } catch (Exception err) { debug.ReportException(err); } }
public static void UpdateStoredFiles() { foreach (var pair in _storedFiles) { if (File.Exists(pair.Key)) { if (GrfPath.Delete(pair.Value)) { File.Copy(pair.Key, pair.Value); } } } }
private void _buttonExport_Click(object sender, RoutedEventArgs e) { try { var tuple = ViewIdPreviewDialog.LatestTupe; if (tuple == null) { return; } var sprite = LuaHelper.GetSpriteFromViewId(tuple.GetIntNoThrow(ServerItemAttributes.ClassNumber), LuaHelper.ViewIdTypes.Headgear, SdeEditor.Instance.ProjectDatabase.GetDb <int>(ServerDbs.Items), tuple); string[] files = new string[] { @"data\sprite\¾ÆÀÌÅÛ\" + sprite + ".spr", @"data\sprite\¾ÆÀÌÅÛ\" + sprite + ".act", @"data\sprite\¾Ç¼¼»ç¸®\³²\³²_" + sprite + ".spr", @"data\sprite\¾Ç¼¼»ç¸®\³²\³²_" + sprite + ".act", @"data\sprite\¾Ç¼¼»ç¸®\¿©\¿©_" + sprite + ".spr", @"data\sprite\¾Ç¼¼»ç¸®\¿©\¿©_" + sprite + ".act", @"data\texture\À¯ÀúÀÎÅÍÆäÀ̽º\collection\" + sprite + ".bmp", @"data\texture\À¯ÀúÀÎÅÍÆäÀ̽º\item\" + sprite + ".bmp" }; string path = PathRequest.FolderEditor(); if (path == null) { return; } var grf = SdeEditor.Instance.ProjectDatabase.MetaGrf; foreach (var file in files) { var data = grf.GetData(file); if (data != null) { string subPath = GrfPath.Combine(path, file); GrfPath.CreateDirectoryFromFile(subPath); File.WriteAllBytes(subPath, data); } } OpeningService.OpenFolder(path); } catch (Exception err) { ErrorHandler.HandleException(err); } }
private string _getPath(string path) { if (path == null) { return("_"); } try { return(path.ReplaceFirst(GrfPath.GetDirectoryNameKeepSlash(ProjectConfiguration.DatabasePath), "%DB_PATH%\\")); } catch { return(path); } }
private void _listViewResults_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var item = _listViewResults.SelectedItem as FtpEntry; if (item != null) { if (item.Name == "..") { _setListing(GrfPath.GetDirectoryName(_currentPath)); return; } _setListing(GrfPath.CombineUrl(_currentPath, item.Name)); } }
/// <summary> /// Clears the temporary files, this method is different than GRFE's (and it is better). /// </summary> public static void ClearTemporaryFiles() { GrfThread.Start(delegate { int errorCount = 0; // Clear root files only if (Directory.Exists(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"))) { foreach (string file in Directory.GetFiles(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"), "*", SearchOption.TopDirectoryOnly)) { if (!GrfPath.Delete(file)) { errorCount++; } if (errorCount > 20) { break; } } // There will be no files in the temporary folder anymore foreach (var directory in Directory.GetDirectories(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"), "*")) { string folderName = Path.GetFileName(directory); int processId; if (Int32.TryParse(folderName, out processId)) { try { Process.GetProcessById(processId); // Do not bother if the process exists, even if it's not SDE } catch (ArgumentException) { // The process is not running try { Directory.Delete(directory, true); } catch { } } catch { // Do nothing } } } } }, "GRF - TemporaryFilesManager cleanup"); }
/// <summary> /// Saves the database. /// </summary> /// <param name="ap">The progress object.</param> /// <param name="progress"> </param> public virtual void Save(AsyncOperation ap, IProgress progress) { string dbPath = GrfPath.GetDirectoryName(ProjectConfiguration.DatabasePath); string subPath = ProjectConfiguration.DatabasePath.Replace(dbPath, "").TrimStart('\\', '/'); ServerType serverType = DbPathLocator.GetServerType(); DbDebugHelper.OnUpdate("Saving tables."); MetaGrf.Clear(); try { BackupEngine.Instance.Start(ProjectConfiguration.DatabasePath); var dbs = _dbs.Values.ToList(); IOHelper.SetupFileManager(); for (int i = 0; i < dbs.Count; i++) { var db = dbs[i]; db.WriteDb(dbPath, subPath, serverType); if (progress != null) { progress.Progress = AProgress.LimitProgress((i + 1f) / dbs.Count * 100f); } } foreach (var db in dbs) { db.SaveCommandIndex(); } Commands.SaveCommandIndex(); } catch (Exception err) { ErrorHandler.HandleException(err); } finally { if (ap != null && progress != null) { progress.Progress = ap.ProgressBar.GetIntermediateState("Backup manager"); } BackupEngine.Instance.Stop(); DbDebugHelper.OnUpdate("Finished saving tables."); } }
public App() { Configuration.ConfigAsker = MapcacheConfiguration.ConfigAsker; Settings.TempPath = GrfPath.Combine(MapcacheConfiguration.ProgramDataPath, "~tmp\\" + MapcacheConfiguration.ProcessId); ErrorHandler.SetErrorHandler(new DefaultErrorHandler()); if (!Directory.Exists(Settings.TempPath)) { try { GrfPath.CreateDirectoryFromFile(Settings.TempPath); } catch { } } ClearTemporaryFiles(); }
private void _save(string path = null) { _async.SetAndRunOperation(new GrfThread(delegate { try { Progress = -1; LuaParser accId = new LuaParser(new byte[0], true, p => new Lub(p).Decompile(), EncodingService.DisplayEncoding, EncodingService.DisplayEncoding); Dictionary <string, string> accIdT = new Dictionary <string, string>(); accId.Tables["ACCESSORY_IDs"] = accIdT; LuaParser accName = new LuaParser(new byte[0], true, p => new Lub(p).Decompile(), EncodingService.DisplayEncoding, EncodingService.DisplayEncoding); Dictionary <string, string> accNameT = new Dictionary <string, string>(); accName.Tables["AccNameTable"] = accNameT; foreach (var item in _obItems.Where(item => item.Id > 0).Where(item => !String.IsNullOrEmpty(item.AccId))) { accIdT[item.AccId] = item.Id.ToString(CultureInfo.InvariantCulture); } if (path == null) { _multiGrf.Clear(); string file = TemporaryFilesManager.GetTemporaryFilePath("tmp2_{0:0000}.lua"); _writeAccName(file, EncodingService.DisplayEncoding); _multiGrf.SetData(ProjectConfiguration.SyncAccName, File.ReadAllBytes(file)); file = TemporaryFilesManager.GetTemporaryFilePath("tmp2_{0:0000}.lua"); accId.Write(file, EncodingService.DisplayEncoding); _multiGrf.SetData(ProjectConfiguration.SyncAccId, File.ReadAllBytes(file)); _multiGrf.SaveAndReload(); } else { Directory.CreateDirectory(path); _writeAccName(GrfPath.Combine(path, "accname.lub"), EncodingService.DisplayEncoding); accId.Write(GrfPath.Combine(path, "accessoryid.lub"), EncodingService.DisplayEncoding); } } catch (Exception err) { ErrorHandler.HandleException(err); } finally { Progress = 100f; } }, this, 200)); }
private void _listViewResults_KeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Enter) { e.Handled = true; _listViewResults_MouseDoubleClick(null, null); } else if (e.Key == Key.Back) { e.Handled = true; _setListing(GrfPath.GetDirectoryName(_currentPath)); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _map() { if (_hasBeenMapped) { return; } // List all files var basePath = GrfPath.GetDirectoryName(_info.Path).TrimEnd('/'); DbDebugHelper.OnSftpUpdate("listing files..."); List <ChannelSftp.LsEntry> files = _sftp.GetFileListAdv(basePath); DbDebugHelper.OnSftpUpdate("listing " + basePath); foreach (var file in files) { var cur = file.getFilename(); if (file.getAttrs().isDir() && cur != "." && cur != ".." && (cur == "re" || cur == "pre-re" || cur == "import")) { var subPath = basePath + "/" + cur; DbDebugHelper.OnSftpUpdate("listing " + subPath); List <ChannelSftp.LsEntry> filesSub = _sftp.GetFileListAdv(subPath); foreach (var subfile in filesSub) { if (!subfile.getAttrs().isDir()) { _entries[subPath + "/" + subfile.getFilename()] = subfile; } } } else { _entries[basePath + "/" + cur] = file; } } DbDebugHelper.OnSftpUpdate("" + _entries.Count + " files found."); _hasBeenMapped = true; }