public override void FinalizeRun() { TotalProcessTime.Start(); List <GSAKWrapper.MapProviders.GeocachePoco> gcl = null; double?cLat = null; double?cLon = null; using (var db = new NPoco.Database(DatabaseConnection.Connection, NPoco.DatabaseType.SQLite)) { gcl = db.Fetch <GSAKWrapper.MapProviders.GeocachePoco>(string.Format("select Code, Name, CacheType, Found, IsOwner, Latitude, Longitude, kAfterLat, kAfterLon from Caches inner join {0} on Caches.Code={0}.gccode left join Corrected on Caches.Code=Corrected.kCode", ActionInputTableName)); } if (gcl.Count > 0) { var dr = DatabaseConnection.ExecuteReader(string.Format("select AVG(Latitude), AVG(Longitude) from Caches inner join {0} on Caches.Code={0}.gccode left join Corrected on Caches.Code=Corrected.kCode", ActionInputTableName)); if (dr.Read()) { cLat = dr.GetDouble(0); cLon = dr.GetDouble(1); } } _context.Send(new SendOrPostCallback(delegate(object state) { var wnd = new Dialogs.WindowOSMOfflineMap(gcl, cLat, cLon, 16); wnd.Show(); }), null); TotalProcessTime.Stop(); base.FinalizeRun(); }
public override void FinalizeRun() { if (!string.IsNullOrEmpty(_value)) { TotalProcessTime.Start(); string target = "target"; var s = Settings.Settings.Default.SelectedDatabase; if (string.Compare(_value, s, true) != 0) { DatabaseConnection.ExecuteNonQuery(string.Format("ATTACH DATABASE '{0}' as {1}", Utils.GSAK.GetFullDatabasePath(_value), target)); CopyTable(target, "Caches", "Code", _overwrite); CopyTable(target, "Attributes", "aCode", _overwrite); CopyTable(target, "CacheMemo", "Code", _overwrite); CopyTable(target, "Corrected", "kCode", _overwrite); CopyTable(target, "Logs", "lParent", _overwrite); CopyTable(target, "LogImages", "iCode", _overwrite); CopyTable(target, "LogMemo", "lParent", _overwrite); CopyTable(target, "Waypoints", "cParent", _overwrite); CopyTable(target, "WayMemo", "cParent", _overwrite); CopyTable(target, "CacheImages", "iCode", _overwrite); DatabaseConnection.ExecuteNonQuery(string.Format("DETACH DATABASE {0}", target)); } TotalProcessTime.Stop(); } base.FinalizeRun(); }
public override void FinalizeRun() { TotalProcessTime.Start(); if (!string.IsNullOrEmpty(_collection)) { var col = Settings.Settings.Default.GetCollection(_collection, createIfNotExists: _option == Option.Add); if (col != null) { string target = "target"; DatabaseConnection.ExecuteNonQuery(string.Format("ATTACH DATABASE '{0}' as {1}", System.IO.Path.Combine(Settings.Settings.Default.SettingsFolder, "settings.db3"), target)); switch (_option) { case Option.Add: DatabaseConnection.ExecuteNonQuery(string.Format("insert or ignore into {1}.GeocacheCollectionItem (CollectionID, GeocacheCode, Name) select {2} as CollectionID, main.Caches.Code as GeocacheCode, main.Caches.Name as Name from main.Caches inner join {0} on main.Caches.Code = {0}.gccode", ActionInputTableName, target, col.CollectionID)); break; case Option.Remove: DatabaseConnection.ExecuteNonQuery(string.Format("delete from {1}.GeocacheCollectionItem where exists (select 1 from {0} where {0}.gccode={1}.GeocacheCollectionItem.GeocacheCode) and GeocacheCollectionItem.CollectionID = {2}", ActionInputTableName, target, col.CollectionID)); break; } DatabaseConnection.ExecuteNonQuery(string.Format("DETACH DATABASE {0}", target)); } } TotalProcessTime.Stop(); base.FinalizeRun(); }
public override void FinalizeRun() { if (_scriptInterface != null) { TotalProcessTime.Start(); _scriptInterface.FinalizeRun(this); TotalProcessTime.Stop(); } base.FinalizeRun(); }
public virtual void FinalizeRun() { TotalProcessTime.Start(); foreach (var t in _createdTables) { DatabaseConnection.ExecuteNonQuery(string.Format("drop table {0}", t)); } _createdTables.Clear(); TotalProcessTime.Stop(); }
public void UpdateCachesFromInputTable(string setters) { TotalProcessTime.Start(); var cnt = (long)DatabaseConnection.ExecuteScalar(string.Format("select count(1) from {0}", ActionInputTableName)); if (cnt > 0) { DatabaseConnection.ExecuteNonQuery(string.Format("update Caches set {1} where exists (select 1 from {0} where {0}.gccode=Caches.Code)", ActionInputTableName, setters)); } TotalProcessTime.Stop(); }
public override void FinalizeRun() { TotalProcessTime.Start(); try { PerformExport(_settings); } finally { TotalProcessTime.Stop(); } base.FinalizeRun(); }
public void Run(string inputTableName) { ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("RunningAction"), Localization.TranslationManager.Instance.Translate(this.Name)); //get input list TotalProcessTime.Start(); CreateTableInDatabase(ActionInputTableName, emptyIfExists: false); if (string.IsNullOrEmpty(inputTableName)) { DatabaseConnection.ExecuteNonQuery(string.Format("insert into {0} select Code as gccode from Caches", ActionInputTableName)); } else { DatabaseConnection.ExecuteNonQuery(string.Format("insert or ignore into {0} select * from {1}", ActionInputTableName, inputTableName)); } TotalGeocachesAtInput = (long)DatabaseConnection.ExecuteScalar(string.Format("select count(1) from {0}", ActionInputTableName)); TotalProcessTime.Stop(); if (_outputConnectionInfo.Count == 0 && this is ActionImplementationExecuteOnce) { string connectorTable = ConnectorOutputTableName(Operator.Equal); TotalProcessTime.Start(); CreateTableInDatabase(connectorTable, emptyIfExists: false); Process(Operator.Equal, inputTableName, connectorTable); TotalProcessTime.Stop(); } List <string> processedOps = new List <string>(); foreach (var c in _outputConnectionInfo) { if (c.ConnectedAction != null) { string connectorTable = ConnectorOutputTableName(c.OutputOperator); if (!processedOps.Contains(connectorTable)) { TotalProcessTime.Start(); CreateTableInDatabase(connectorTable, emptyIfExists: false); Process(c.OutputOperator, inputTableName, connectorTable); TotalProcessTime.Stop(); processedOps.Add(connectorTable); c.PassCounter = (int)(long)DatabaseConnection.ExecuteScalar(string.Format("select count(1) from {0}", connectorTable)); } else { } c.ConnectedAction.Run(connectorTable); } } }
public override void FinalizeRun() { if (!string.IsNullOrEmpty(_field)) { if (string.Compare(_field, "Country", true) == 0 || string.Compare(_field, "State", true) == 0 || string.Compare(_field, "County", true) == 0) { UpdateCachesFromInputTable(string.Format("{0}=AREANAME(Latitude, Longitude, '{1}', '{2}')", _field, _level.ToString(), _prefix.Replace("'", "''"))); } else { TotalProcessTime.Start(); DatabaseConnection.ExecuteNonQuery(string.Format("update Custom set {1} = (select AREANAME(Latitude, Longitude, '{2}', '{3}') as {1} from Caches where Caches.Code=Custom.cCode) where exists (select 1 from {0} where {0}.gccode=Custom.cCode)", ActionInputTableName, _field, _level.ToString(), _prefix.Replace("'", "''"))); TotalProcessTime.Stop(); } } base.FinalizeRun(); }
public override void FinalizeRun() { TotalProcessTime.Start(); string target = "target"; var s = Settings.Settings.Default.SelectedDatabase; if (string.IsNullOrEmpty(_value) || string.Compare(_value, s, true) == 0) { target = "main"; } else { DatabaseConnection.ExecuteNonQuery(string.Format("ATTACH DATABASE '{0}' as {1}", Utils.GSAK.GetFullDatabasePath(_value), target)); } DatabaseConnection.ExecuteNonQuery(string.Format("insert or ignore into {1}.Ignore (iCode, iName) select main.Caches.Code as iCode, main.Caches.Name as iName from main.Caches inner join {0} on main.Caches.Code = {0}.gccode", ActionInputTableName, target)); if (target != "main") { DatabaseConnection.ExecuteNonQuery(string.Format("DETACH DATABASE {0}", target)); } TotalProcessTime.Stop(); base.FinalizeRun(); }
public override void FinalizeRun() { TotalProcessTime.Start(); string target = "target"; var s = Settings.Settings.Default.SelectedDatabase; if (string.IsNullOrEmpty(_value) || string.Compare(_value, s, true) == 0) { target = "main"; } else { DatabaseConnection.ExecuteNonQuery(string.Format("ATTACH DATABASE '{0}' as {1}", Utils.GSAK.GetFullDatabasePath(_value), target)); } DatabaseConnection.ExecuteNonQuery(string.Format("delete from {1}.Caches where exists (select 1 from {0} where {0}.gccode={1}.Caches.Code)", ActionInputTableName, target)); if (target != "main") { DatabaseConnection.ExecuteNonQuery(string.Format("DETACH DATABASE {0}", target)); } TotalProcessTime.Stop(); base.FinalizeRun(); }
public override void FinalizeRun() { TotalProcessTime.Start(); //generate map HTML string html = Utils.ResourceHelper.GetEmbeddedTextFile("/Resources/ActionShowOnlineMap.html"); //icons StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("var foundIcon = new google.maps.MarkerImage(\"{0}\");", Utils.ResourceHelper.GetEmbeddedHtmlImageData("/Resources/Map/found.png"))); sb.AppendLine(string.Format("var unknownIcon = new google.maps.MarkerImage(\"{0}\");", Utils.ResourceHelper.GetEmbeddedHtmlImageData("/Resources/Map/0.png"))); sb.AppendLine(string.Format("var myownIcon = new google.maps.MarkerImage(\"{0}\");", Utils.ResourceHelper.GetEmbeddedHtmlImageData("/Resources/Map/myown.png"))); foreach (var gctype in ApplicationData.Instance.GeocacheTypes) { sb.AppendLine(string.Format("var gct{0}Icon = new google.maps.MarkerImage(\"{1}\");", gctype.ID.ToString().Replace("-", "_"), Utils.ResourceHelper.GetEmbeddedHtmlImageData(string.Format("/Resources/Map/{0}.png", gctype.ID)))); sb.AppendLine(string.Format("var gct{0}IconC = new google.maps.MarkerImage(\"{1}\");", gctype.ID.ToString().Replace("-", "_"), Utils.ResourceHelper.GetEmbeddedHtmlImageData(string.Format("/Resources/Map/c{0}.png", gctype.ID)))); } foreach (var wptype in ApplicationData.Instance.WaypointTypes) { sb.AppendLine(string.Format("var wpt{0}Icon = new google.maps.MarkerImage(\"{1}\");", wptype.ID.ToString().Replace("-", "_"), Utils.ResourceHelper.GetEmbeddedHtmlImageData(string.Format("/Resources/Map/{0}.gif", wptype.ID)))); } html = html.Replace("//icons", sb.ToString()); sb.Length = 0; using (var db = new NPoco.Database(DatabaseConnection.Connection, NPoco.DatabaseType.SQLite)) { var gcl = db.Fetch <GeocachePoco>(string.Format("select Code, Name, CacheType, Found, IsOwner, Latitude, Longitude, kAfterLat, kAfterLon from Caches inner join {0} on Caches.Code={0}.gccode left join Corrected on Caches.Code=Corrected.kCode", ActionInputTableName)); foreach (var gc in gcl) { var gcicon = "gct0Icon"; if (gc.IsOwner != 0) { gcicon = "myownIcon"; } else if (gc.Found != 0) { gcicon = "foundIcon"; } else { var gctype = (from a in ApplicationData.Instance.GeocacheTypes where a.GSAK == gc.CacheType select a).FirstOrDefault(); if (gctype != null) { if (gc.kAfterLat != null) { gcicon = string.Format("gct{0}IconC", gctype.ID); } else { gcicon = string.Format("gct{0}Icon", gctype.ID); } } } sb.AppendFormat("markers.push(addClickListener(new MarkerWithLabel({{position: new google.maps.LatLng({1},{2}),icon:{3},title:'{0}',labelContent:'{0}',labelAnchor: new google.maps.Point(10, 0),labelClass:'labels'}})));", string.Format("{0}-{1}", gc.Code, gc.Name.Replace("'", "").Replace("\\", "")), gc.kAfterLat == null ? gc.Latitude : gc.kAfterLat, gc.kAfterLon == null ? gc.Longitude : gc.kAfterLon, gcicon); } sb.AppendLine(); sb.AppendLine("markerClusterer = new MarkerClusterer(map, markers, clusterOptions);"); if (gcl.Count > 0) { var dr = DatabaseConnection.ExecuteReader(string.Format("select AVG(Latitude), AVG(Longitude) from Caches inner join {0} on Caches.Code={0}.gccode left join Corrected on Caches.Code=Corrected.kCode", ActionInputTableName)); if (dr.Read()) { var lat = dr.GetDouble(0); var lon = dr.GetDouble(1); sb.AppendLine(string.Format("map.setCenter(new google.maps.LatLng({0}, {1}));", lat.ToString(CultureInfo.InvariantCulture), lon.ToString(CultureInfo.InvariantCulture))); } } } html = html.Replace("//geocachelist", sb.ToString()); _context.Send(new SendOrPostCallback(delegate(object state) { var wnd = new Dialogs.WindowWebBrowser(html, new WebBrowserControl.JSCallback() { Name = "bound", Instance = new JSCallBack() }); wnd.Show(); }), null); TotalProcessTime.Stop(); base.FinalizeRun(); }