public void RunMethod(Plugin plugin, ICore core) { _plugin = plugin; _core = core; using (FrameworkDataUpdater updater = new FrameworkDataUpdater(core)) { _actionReady = new ManualResetEvent(false); Thread thrd = new Thread(new ThreadStart(this.threadMethod)); thrd.Start(); while (!_actionReady.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } thrd.Join(); if (!string.IsNullOrEmpty(_errormessage)) { System.Windows.Forms.MessageBox.Show(_errormessage, LanguageSupport.Instance.GetTranslation(LanguageSupport.Instance.GetTranslation("Error")), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } }
public override bool PrepareRepair() { bool result = false; if (_fileCollection != null) { _fileCollection.Dispose(); _fileCollection = null; using (FrameworkDataUpdater upd = new FrameworkDataUpdater(Core)) { Core.Geocaches.Clear(); Core.Logs.Clear(); Core.LogImages.Clear(); Core.Waypoints.Clear(); Core.UserWaypoints.Clear(); } result = true; } return result; }
public static bool Run(Plugin plugin, ICore core) { using (FrameworkDataUpdater upd = new FrameworkDataUpdater(core)) { //reset current selection //foreach (Geocache gc in core.Geocaches) foreach(Geocache gc in DataAccess.GetSelectedGeocaches(core.Geocaches)) { //you can have more than one, then just pick the last one UserWaypoint uwp = DataAccess.GetUserWaypointsFromGeocache(core.UserWaypoints, gc.Code).LastOrDefault(); if (uwp != null) { gc.CustomLat = uwp.Lat; gc.CustomLon = uwp.Lon; } } } return true; }
public static void DeleteGeocache(Framework.Interfaces.ICore core, Framework.Data.Geocache gc) { using (FrameworkDataUpdater upd = new FrameworkDataUpdater(core)) { List <Framework.Data.Waypoint> wps = GetWaypointsFromGeocache(core.Waypoints, gc.Code); foreach (Framework.Data.Waypoint wp in wps) { core.Waypoints.Remove(wp); } List <Framework.Data.GeocacheImage> imgs = GetGeocacheImages(core.GeocacheImages, gc.Code); foreach (Framework.Data.GeocacheImage img in imgs) { core.GeocacheImages.Remove(img); } List <Framework.Data.Log> logs = GetLogs(core.Logs, gc.Code); foreach (Framework.Data.Log lg in logs) { DeleteLog(core, lg); } core.Geocaches.Remove(gc); } }
public static void DeleteGeocache(Framework.Interfaces.ICore core, Framework.Data.Geocache gc) { using (FrameworkDataUpdater upd = new FrameworkDataUpdater(core)) { List<Framework.Data.Waypoint> wps = GetWaypointsFromGeocache(core.Waypoints, gc.Code); foreach (Framework.Data.Waypoint wp in wps) { core.Waypoints.Remove(wp); } List<Framework.Data.GeocacheImage> imgs = GetGeocacheImages(core.GeocacheImages, gc.Code); foreach (Framework.Data.GeocacheImage img in imgs) { core.GeocacheImages.Remove(img); } List<Framework.Data.Log> logs = GetLogs(core.Logs, gc.Code); foreach (Framework.Data.Log lg in logs) { DeleteLog(core, lg); } core.Geocaches.Remove(gc); } }
public override bool PrepareNew() { bool result = false; using (System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog()) { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(PluginSettings.Instance.ActiveDataFile); dlg.Filter = "*.gpp|*.gpp"; dlg.FileName = ""; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { if (System.IO.File.Exists(dlg.FileName)) { System.IO.File.Delete(dlg.FileName); } string fn = FileCollection.getFilename(dlg.FileName, EXT_GEOCACHES); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } fn = FileCollection.getFilename(dlg.FileName, EXT_LOGIMAGES); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } fn = FileCollection.getFilename(dlg.FileName, EXT_GEOCACHEIMAGES); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } fn = FileCollection.getFilename(dlg.FileName, EXT_LOGS); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } fn = FileCollection.getFilename(dlg.FileName, EXT_USERWAYPOINTS); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } fn = FileCollection.getFilename(dlg.FileName, EXT_WAYPPOINTS); if (System.IO.File.Exists(fn)) { System.IO.File.Delete(fn); } PluginSettings.Instance.ActiveDataFile = dlg.FileName; SetDataSourceName(PluginSettings.Instance.ActiveDataFile); using (FrameworkDataUpdater upd = new FrameworkDataUpdater(Core)) { Core.Geocaches.Clear(); Core.Logs.Clear(); Core.LogImages.Clear(); Core.Waypoints.Clear(); Core.UserWaypoints.Clear(); Core.GeocacheImages.Clear(); } FileCollection newFileCollection = new FileCollection(PluginSettings.Instance.ActiveDataFile); if (_fileCollection != null) { _fileCollection.Dispose(); _fileCollection = null; } _fileCollection = newFileCollection; return true; } catch { } } } return result; }
public override bool PrepareNew() { bool result = false; using (DatabaseSelectionForm dlg = new DatabaseSelectionForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { MySqlConnection dbcon = GetMySqlConnectionAndCreateDatabase(dlg.SqlServer, dlg.Database, dlg.Password, dlg.Username, dlg.IntegratedSecurity, dlg.SqlServerPort); if (dbcon != null && InitDatabase(dbcon, dlg.Database)) { Properties.Settings.Default.SqlServer = dlg.SqlServer; Properties.Settings.Default.Database = dlg.Database; Properties.Settings.Default.SqlServerUseIS = dlg.IntegratedSecurity; Properties.Settings.Default.SqlServerUsername = dlg.Username; Properties.Settings.Default.SqlServerPwd = dlg.Password; Properties.Settings.Default.SqlServerPort = dlg.SqlServerPort; Properties.Settings.Default.Save(); SetDataSourceName(Properties.Settings.Default.Database ?? ""); ClearCache(); using (FrameworkDataUpdater upd = new FrameworkDataUpdater(Core)) { Core.Geocaches.Clear(); Core.Logs.Clear(); Core.LogImages.Clear(); Core.Waypoints.Clear(); Core.UserWaypoints.Clear(); } if (_dbcon != null) { _dbcon.Dispose(); _dbcon = null; } _dbcon = dbcon; result = true; } } catch { } } } return result; }
public override bool PrepareNew() { bool result = false; using (System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog()) { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(Properties.Settings.Default.ActiveDataFile); dlg.Filter = "*.db3|*.db3"; dlg.FileName = ""; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { if (System.IO.File.Exists(dlg.FileName)) { System.IO.File.Delete(dlg.FileName); } SQLiteConnection dbcon = new SQLiteConnection(string.Format("Data Source={0}", dlg.FileName)); if (InitDatabase(dbcon)) { Properties.Settings.Default.ActiveDataFile = dlg.FileName; Properties.Settings.Default.Save(); SetDataSourceName(Properties.Settings.Default.ActiveDataFile); ClearCache(); using (FrameworkDataUpdater upd = new FrameworkDataUpdater(Core)) { Core.Geocaches.Clear(); Core.Logs.Clear(); Core.LogImages.Clear(); Core.Waypoints.Clear(); Core.UserWaypoints.Clear(); } if (_dbcon != null) { _dbcon.Dispose(); _dbcon = null; } _dbcon = dbcon; result = true; } } catch { } } } return result; }
public override bool PrepareNew() { bool result = false; using (System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog()) { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(PluginSettings.Instance.ActiveDataFile); dlg.Filter = "*.gsf|*.gsf"; dlg.FileName = ""; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { if (System.IO.File.Exists(dlg.FileName)) { System.IO.File.Delete(dlg.FileName); } PluginSettings.Instance.ActiveDataFile = dlg.FileName; SetDataSourceName(PluginSettings.Instance.ActiveDataFile); using (FrameworkDataUpdater upd = new FrameworkDataUpdater(Core)) { Core.Geocaches.Clear(); Core.Logs.Clear(); Core.LogImages.Clear(); Core.Waypoints.Clear(); Core.UserWaypoints.Clear(); Core.GeocacheImages.Clear(); } FileStream newFileStream = File.Open(PluginSettings.Instance.ActiveDataFile, FileMode.Create, FileAccess.ReadWrite); closeCurrentFile(); _fileStream = newFileStream; return true; } catch { } } } return result; }