[mapguide-commits] r6202 - in trunk/Tools/Maestro:
Maestro.Editors/FeatureSource/Preview
Maestro.Editors/LayerDefinition/Vector/Thematics
Maestro.Editors/Properties OSGeo.MapGuide.MaestroAPI
OSGeo.MapGuide.MaestroAPI.Local
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Nov 7 10:57:46 EST 2011
Author: jng
Date: 2011-11-07 07:57:45 -0800 (Mon, 07 Nov 2011)
New Revision: 6202
Modified:
trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.Designer.cs
trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.cs
trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.resx
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
Log:
This submission includes the following changes:
- Measure the elapsed query time for queries in Feature Source Preview
- Update the Theme Creator Dialog to use the UNIQUE() aggregate function for fetching distinct values. The traditional way exists as a fallback should the UNIQUE() approach throw any exceptions
Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.Designer.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.Designer.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -35,9 +35,12 @@
this.btnClear = new System.Windows.Forms.ToolStripButton();
this.queryPane = new System.Windows.Forms.Panel();
this.statusBar = new System.Windows.Forms.StatusStrip();
+ this.lblCount = new System.Windows.Forms.ToolStripStatusLabel();
+ this.lblElapsed = new System.Windows.Forms.ToolStripStatusLabel();
this.grdResults = new System.Windows.Forms.DataGridView();
this.queryWorker = new System.ComponentModel.BackgroundWorker();
this.toolStrip1.SuspendLayout();
+ this.statusBar.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.grdResults)).BeginInit();
this.SuspendLayout();
//
@@ -78,9 +81,23 @@
//
// statusBar
//
+ this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.lblCount,
+ this.lblElapsed});
resources.ApplyResources(this.statusBar, "statusBar");
this.statusBar.Name = "statusBar";
//
+ // lblCount
+ //
+ this.lblCount.Name = "lblCount";
+ resources.ApplyResources(this.lblCount, "lblCount");
+ //
+ // lblElapsed
+ //
+ this.lblElapsed.Name = "lblElapsed";
+ resources.ApplyResources(this.lblElapsed, "lblElapsed");
+ this.lblElapsed.Spring = true;
+ //
// grdResults
//
this.grdResults.AllowUserToAddRows = false;
@@ -108,6 +125,8 @@
resources.ApplyResources(this, "$this");
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
+ this.statusBar.ResumeLayout(false);
+ this.statusBar.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.grdResults)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -124,5 +143,7 @@
private System.Windows.Forms.ToolStripButton btnStop;
private System.Windows.Forms.ToolStripButton btnClear;
private System.ComponentModel.BackgroundWorker queryWorker;
+ private System.Windows.Forms.ToolStripStatusLabel lblCount;
+ private System.Windows.Forms.ToolStripStatusLabel lblElapsed;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -100,6 +100,7 @@
btnClear.Enabled = false;
btnStop.Enabled = true;
btnRunQuery.Enabled = false;
+ lblCount.Text = lblElapsed.Text = string.Empty;
queryWorker.RunWorkerAsync();
}
@@ -122,8 +123,10 @@
InitTable(reader, res.Result);
while (reader.ReadNext())
{
- if (e.Cancel)
+ if (queryWorker.CancellationPending)
{
+ e.Cancel = true;
+ _cancelResult = res.Result;
break;
}
@@ -142,6 +145,10 @@
{
reader.Close();
sw.Stop();
+ if (queryWorker.CancellationPending)
+ {
+ _cancelDuration = sw.Elapsed;
+ }
}
e.Result = res;
}
@@ -158,6 +165,9 @@
}
}
+ DataTable _cancelResult;
+ TimeSpan? _cancelDuration;
+
private void queryWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
@@ -166,11 +176,22 @@
}
else
{
- var res = e.Result as QueryResult;
- if (res != null)
+ if (e.Cancelled)
{
- grdResults.DataSource = res.Result;
+ grdResults.DataSource = _cancelResult;
+ lblElapsed.Text = string.Format(Properties.Resources.PreviewQueryElapsed, _cancelDuration.Value.TotalMilliseconds);
+ lblCount.Text = string.Format(Properties.Resources.PreviewRecordCount, _cancelResult.Rows.Count);
}
+ else
+ {
+ var res = e.Result as QueryResult;
+ if (res != null)
+ {
+ grdResults.DataSource = res.Result;
+ lblElapsed.Text = string.Format(Properties.Resources.PreviewQueryElapsed, res.Duration.TotalMilliseconds);
+ lblCount.Text = string.Format(Properties.Resources.PreviewRecordCount, res.Result.Rows.Count);
+ }
+ }
}
btnRunQuery.Enabled = true;
Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.resx 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Preview/PreviewPane.resx 2011-11-07 15:57:45 UTC (rev 6202)
@@ -207,6 +207,15 @@
<metadata name="statusBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>
+ <data name="lblCount.Size" type="System.Drawing.Size, System.Drawing">
+ <value>0, 17</value>
+ </data>
+ <data name="lblElapsed.Size" type="System.Drawing.Size, System.Drawing">
+ <value>655, 17</value>
+ </data>
+ <data name="lblElapsed.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
+ <value>MiddleRight</value>
+ </data>
<data name="statusBar.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 453</value>
</data>
@@ -282,6 +291,18 @@
<data name=">>btnClear.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
+ <data name=">>lblCount.Name" xml:space="preserve">
+ <value>lblCount</value>
+ </data>
+ <data name=">>lblCount.Type" xml:space="preserve">
+ <value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
+ <data name=">>lblElapsed.Name" xml:space="preserve">
+ <value>lblElapsed</value>
+ </data>
+ <data name=">>lblElapsed.Type" xml:space="preserve">
+ <value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
<data name=">>queryWorker.Name" xml:space="preserve">
<value>queryWorker</value>
</data>
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -34,6 +34,7 @@
using OSGeo.MapGuide.ObjectModels.LayerDefinition;
using Ldf = OSGeo.MapGuide.ObjectModels.LayerDefinition;
using OSGeo.MapGuide.MaestroAPI.Schema;
+using System.Collections.Specialized;
namespace Maestro.Editors.LayerDefinition.Vector.Thematics
{
@@ -228,22 +229,53 @@
try
{
IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
- using (var rd = m_editor.FeatureService.QueryFeatureSource(vl.ResourceId, m_schema.QualifiedName, filter, new string[] { col.Name }))
+ try
{
- while (rd.ReadNext() && m_values.Count < 100000) //No more than 100.000 records in memory
+ //Either UNIQUE() is an undocumented FDO expression function (!!!)
+ //Or it is FDO expression sugar to work around the fact there is no distinct
+ //flag in the SELECTAGGREGATES operation that's exposed over HTTP. Either
+ //case, try this method first.
+ using (var rd = m_editor.FeatureService.AggregateQueryFeatureSource(
+ vl.ResourceId,
+ m_schema.QualifiedName,
+ filter,
+ new NameValueCollection() {
+ { "value", "UNIQUE(\"" + col.Name + "\")" }
+ }))
{
- if (!rd.IsNull(col.Name))
+ while (rd.ReadNext() && m_values.Count < 100000) //No more than 100.000 records in memory
{
- object value = rd[col.Name];
- if (!m_values.ContainsKey(value))
- m_values.Add(value, 0);
+ if (!rd.IsNull("value"))
+ {
+ object value = rd["value"];
+ if (!m_values.ContainsKey(value))
+ m_values.Add(value, 0);
- m_values[value]++;
+ m_values[value]++;
+ }
}
+ rd.Close();
}
- rd.Close();
}
+ catch
+ {
+
+ using (var rd = m_editor.FeatureService.QueryFeatureSource(vl.ResourceId, m_schema.QualifiedName, filter, new string[] { col.Name }))
+ {
+ while (rd.ReadNext() && m_values.Count < 100000) //No more than 100.000 records in memory
+ {
+ if (!rd.IsNull(col.Name))
+ {
+ object value = rd[col.Name];
+ if (!m_values.ContainsKey(value))
+ m_values.Add(value, 0);
+ m_values[value]++;
+ }
+ }
+ rd.Close();
+ }
+ }
rawEx = null; //Clear error
}
Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4959
+// Runtime Version:2.0.50727.4961
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -2270,6 +2270,24 @@
}
/// <summary>
+ /// Looks up a localized string similar to Preview Completed in {0}ms.
+ /// </summary>
+ internal static string PreviewQueryElapsed {
+ get {
+ return ResourceManager.GetString("PreviewQueryElapsed", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to {0} results found.
+ /// </summary>
+ internal static string PreviewRecordCount {
+ get {
+ return ResourceManager.GetString("PreviewRecordCount", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The Preview URL is not currently available.
/// </summary>
internal static string PreviewUrlNotAvailable {
Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx 2011-11-07 15:57:45 UTC (rev 6202)
@@ -1268,4 +1268,10 @@
<data name="PromptRepairBrokenFeatureSource" xml:space="preserve">
<value>The resource id {0} could not be found. You will now be prompted to select the correct feature source</value>
</data>
+ <data name="PreviewQueryElapsed" xml:space="preserve">
+ <value>Preview Completed in {0}ms</value>
+ </data>
+ <data name="PreviewRecordCount" xml:space="preserve">
+ <value>{0} results found</value>
+ </data>
</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -1565,27 +1565,32 @@
fun.Add("extent", "SpatialExtents(\"" + geometry + "\")");
using (IReader fsr = AggregateQueryFeatureSource(resourceID, schema, filter, fun))
{
- if (fsr.ReadNext())
+ try
{
- IGeometry geom = fsr["extent"] as IGeometry;
- if (geom == null)
+ if (fsr.ReadNext())
{
- throw new Exception("No data found in resource: " + resourceID);
+ IGeometry geom = fsr["extent"] as IGeometry;
+ if (geom == null)
+ {
+ throw new Exception("No data found in resource: " + resourceID);
+ }
+ else
+ {
+ var env = geom.EnvelopeInternal;
+ return OSGeo.MapGuide.ObjectModels.ObjectFactory.CreateEnvelope(
+ env.MinX,
+ env.MinY,
+ env.MaxX,
+ env.MaxY);
+ }
}
else
- {
- var env = geom.EnvelopeInternal;
- return OSGeo.MapGuide.ObjectModels.ObjectFactory.CreateEnvelope(
- env.MinX,
- env.MinY,
- env.MaxX,
- env.MaxY);
- }
+ throw new Exception("No data found in resource: " + resourceID);
}
- else
- throw new Exception("No data found in resource: " + resourceID);
-
- fsr.Close();
+ finally
+ {
+ fsr.Close();
+ }
}
}
catch
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs 2011-11-07 12:13:28 UTC (rev 6201)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs 2011-11-07 15:57:45 UTC (rev 6202)
@@ -652,7 +652,8 @@
foreach (string s in computedProperties.Keys)
mgf.AddComputedProperty(s, computedProperties[s]);
- MgFeatureReader mr = fes.SelectFeatures(new MgResourceIdentifier(resourceID), schema, mgf);
+ var fsId = new MgResourceIdentifier(resourceID);
+ MgFeatureReader mr = fes.SelectFeatures(fsId, schema, mgf);
LogMethodCall("MgFeatureService::SelectFeatures", true, resourceID, schema, "MgFeatureQueryOptions");
More information about the mapguide-commits
mailing list