[mapguide-commits] r4942 - in sandbox/maestro-2.5: Maestro.Base/UI
Maestro.Editors Maestro.Editors/Common
Maestro.Editors/Generic Maestro.Editors/Properties
Maestro.Login Maestro.Shared.UI OSGeo.MapGuide.MaestroAPI
OSGeo.MapGuide.MaestroAPI/Exceptions OSGeo.MapGuide.MaestroAPI.Http
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Jun 15 06:34:05 EDT 2010
Author: jng
Date: 2010-06-15 10:34:05 +0000 (Tue, 15 Jun 2010)
New Revision: 4942
Added:
sandbox/maestro-2.5/Maestro.Shared.UI/DialogFactory.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/NestedExceptionMessageProcessor.cs
Modified:
sandbox/maestro-2.5/Maestro.Base/UI/MessageViewer.cs
sandbox/maestro-2.5/Maestro.Editors/Common/ResourceDataCtrl.cs
sandbox/maestro-2.5/Maestro.Editors/Generic/XmlEditorCtrl.cs
sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj
sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs
sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx
sandbox/maestro-2.5/Maestro.Login/HttpLoginCtrl.cs
sandbox/maestro-2.5/Maestro.Login/ILoginCtrl.cs
sandbox/maestro-2.5/Maestro.Login/LocalNativeLoginCtrl.cs
sandbox/maestro-2.5/Maestro.Login/LoginDialog.cs
sandbox/maestro-2.5/Maestro.Login/Maestro.Login.csproj
sandbox/maestro-2.5/Maestro.Shared.UI/Maestro.Shared.UI.csproj
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
Log:
This submission includes the following changes:
- (forward)port the nested exception message processing code from Maestro 2.1
- (forward)port r4933 to 2.5 sandbox
- Add a DialogFactory helper class to work around an ANNOYING bug (feature?) where changing directories in a OpenFileDialog/SaveFileDialog will actually mess up the current working directory, causing file/assembly loading using relative paths to fail.
Modified: sandbox/maestro-2.5/Maestro.Base/UI/MessageViewer.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Base/UI/MessageViewer.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Base/UI/MessageViewer.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -26,6 +26,7 @@
using System.Windows.Forms;
using ICSharpCode.Core;
using System.IO;
+using Maestro.Shared.UI;
namespace Maestro.Base.UI
{
@@ -65,7 +66,7 @@
private void btnSave_Click(object sender, EventArgs e)
{
- using (var save = new SaveFileDialog())
+ using (var save = DialogFactory.SaveFile())
{
save.Filter = "*.log|*.log";
if (save.ShowDialog() == DialogResult.OK)
Modified: sandbox/maestro-2.5/Maestro.Editors/Common/ResourceDataCtrl.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Common/ResourceDataCtrl.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Editors/Common/ResourceDataCtrl.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -28,6 +28,7 @@
using OSGeo.MapGuide.ObjectModels.Common;
using System.IO;
using Maestro.Shared.UI;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
namespace Maestro.Editors.Common
{
@@ -135,7 +136,7 @@
private void btnAdd_Click(object sender, EventArgs e)
{
- using (var open = new OpenFileDialog())
+ using (var open = DialogFactory.OpenFile())
{
if (open.ShowDialog() == DialogResult.OK)
{
@@ -152,7 +153,7 @@
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message);
+ MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Properties.Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
@@ -182,7 +183,7 @@
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message);
+ MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Properties.Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
@@ -194,7 +195,7 @@
var item = this.SelectedItem;
if (item != null)
{
- using (var save = new SaveFileDialog())
+ using (var save = DialogFactory.SaveFile())
{
if (save.ShowDialog() == DialogResult.OK)
{
@@ -209,7 +210,7 @@
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message);
+ MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Properties.Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Modified: sandbox/maestro-2.5/Maestro.Editors/Generic/XmlEditorCtrl.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Generic/XmlEditorCtrl.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Editors/Generic/XmlEditorCtrl.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -30,6 +30,7 @@
using System.IO;
using OSGeo.MapGuide.MaestroAPI.ObjectModels;
using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
namespace Maestro.Editors.Generic
{
@@ -245,7 +246,7 @@
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message);
+ MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Properties.Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (!string.IsNullOrEmpty(content))
Modified: sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Editors/Maestro.Editors.csproj 2010-06-15 10:34:05 UTC (rev 4942)
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5AD2CDBA-952E-4148-98A1-31D2E0D540D5}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -517,9 +517,11 @@
</EmbeddedResource>
<EmbeddedResource Include="LayerDefinition\DrawingLayerEditorCtrl.resx">
<DependentUpon>DrawingLayerEditorCtrl.cs</DependentUpon>
+ <SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="LayerDefinition\Drawing\DrawingLayerSettingsCtrl.resx">
<DependentUpon>DrawingLayerSettingsCtrl.cs</DependentUpon>
+ <SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="LayerDefinition\LayerPropertiesSectionCtrl.resx">
<DependentUpon>LayerPropertiesSectionCtrl.cs</DependentUpon>
@@ -804,4 +806,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
\ No newline at end of file
Modified: sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.Designer.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
+// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -448,6 +448,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to Error.
+ /// </summary>
+ internal static string TitleError {
+ get {
+ return ResourceManager.GetString("TitleError", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Transparent.
/// </summary>
internal static string TransparentName {
Modified: sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx
===================================================================
--- sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Editors/Properties/Resources.resx 2010-06-15 10:34:05 UTC (rev 4942)
@@ -288,4 +288,7 @@
<data name="TestConnectionNoErrors" xml:space="preserve">
<value>Provider reported no errors</value>
</data>
+ <data name="TitleError" xml:space="preserve">
+ <value>Error</value>
+ </data>
</root>
\ No newline at end of file
Modified: sandbox/maestro-2.5/Maestro.Login/HttpLoginCtrl.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Login/HttpLoginCtrl.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Login/HttpLoginCtrl.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -76,7 +76,7 @@
cmbLanguage.SelectedIndex = selected;
_loading = false;
- UpdateButtonStatus();
+ UpdateLoginStatus();
}
public PreferedSite[] GetSites()
@@ -142,17 +142,9 @@
private void txtPassword_TextChanged(object sender, EventArgs e)
{
- UpdateButtonStatus();
+ UpdateLoginStatus();
}
- private void UpdateButtonStatus()
- {
- if (this.Username.Trim().Length > 0 && this.Server.Trim().Length > 0)
- EnableOk(this, EventArgs.Empty);
- else
- DisabledOk(this, EventArgs.Empty);
- }
-
public PreferedSiteList SiteList
{
get;
@@ -204,5 +196,13 @@
CheckSavedPassword(this, EventArgs.Empty);
}
+
+ public void UpdateLoginStatus()
+ {
+ if (this.Username.Trim().Length > 0 && this.Server.Trim().Length > 0)
+ EnableOk(this, EventArgs.Empty);
+ else
+ DisabledOk(this, EventArgs.Empty);
+ }
}
}
Modified: sandbox/maestro-2.5/Maestro.Login/ILoginCtrl.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Login/ILoginCtrl.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Login/ILoginCtrl.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -28,6 +28,8 @@
string Username { get; }
string Password { get; }
+ void UpdateLoginStatus();
+
event EventHandler EnableOk;
event EventHandler DisabledOk;
event EventHandler CheckSavedPassword;
Modified: sandbox/maestro-2.5/Maestro.Login/LocalNativeLoginCtrl.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Login/LocalNativeLoginCtrl.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Login/LocalNativeLoginCtrl.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -25,6 +25,7 @@
using System.Text;
using System.Windows.Forms;
using System.IO;
+using Maestro.Shared.UI;
namespace Maestro.Login
{
@@ -68,6 +69,11 @@
private void txtWebConfig_TextChanged(object sender, EventArgs e)
{
+ UpdateLoginStatus();
+ }
+
+ public void UpdateLoginStatus()
+ {
if (this.WebConfigPath.Trim().Length > 0 && File.Exists(this.WebConfigPath))
EnableOk(this, EventArgs.Empty);
else
@@ -76,8 +82,11 @@
private void btnBrowse_Click(object sender, EventArgs e)
{
- using (var dlg = new OpenFileDialog())
+ using (var dlg = DialogFactory.OpenFile())
{
+ //WTF does this default to false??? Does MS not realize that changing directories
+ //via this dialog absolutely screws up file/assembly loading from relative paths?
+ dlg.RestoreDirectory = true;
dlg.Filter = "*.ini|*.ini";
if (dlg.ShowDialog() == DialogResult.OK)
{
Modified: sandbox/maestro-2.5/Maestro.Login/LoginDialog.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Login/LoginDialog.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Login/LoginDialog.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -25,6 +25,7 @@
using System.Text;
using System.Windows.Forms;
using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
namespace Maestro.Login
{
@@ -124,19 +125,17 @@
private void rdHttp_CheckedChanged(object sender, EventArgs e)
{
- _selectedIndex = 0;
- SetLoginControl((Control)_controls[_selectedIndex]);
+ UpdateLoginControl();
}
private void rdTcpIp_CheckedChanged(object sender, EventArgs e)
{
- _selectedIndex = 1;
- SetLoginControl((Control)_controls[_selectedIndex]);
+ UpdateLoginControl();
}
private void btnCancel_Click(object sender, EventArgs e)
{
-
+ this.DialogResult = DialogResult.Cancel;
}
private void btnOK_Click(object sender, EventArgs e)
@@ -205,7 +204,7 @@
}
catch (Exception ex)
{
- string s = ex.Message;
+
}
}
else //Native
@@ -225,9 +224,21 @@
}
catch (Exception ex)
{
- MessageBox.Show(this, string.Format(Strings.FormLogin.ConnectionFailedError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
+ MessageBox.Show(this, string.Format(Strings.FormLogin.ConnectionFailedError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
+
+ private void UpdateLoginControl()
+ {
+ if (rdHttp.Checked)
+ _selectedIndex = 0;
+ else
+ _selectedIndex = 1;
+
+ SetLoginControl((Control)_controls[_selectedIndex]);
+ _controls[_selectedIndex].UpdateLoginStatus();
+ }
}
}
Modified: sandbox/maestro-2.5/Maestro.Login/Maestro.Login.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Login/Maestro.Login.csproj 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Login/Maestro.Login.csproj 2010-06-15 10:34:05 UTC (rev 4942)
@@ -87,6 +87,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Maestro.Shared.UI\Maestro.Shared.UI.csproj">
+ <Project>{CFD19053-2172-41D3-8460-0FD2123A1E88}</Project>
+ <Name>Maestro.Shared.UI</Name>
+ </ProjectReference>
<ProjectReference Include="..\OSGeo.MapGuide.MaestroAPI\OSGeo.MapGuide.MaestroAPI.csproj">
<Project>{80FA3158-8B5F-48D1-A393-0378AFE48A7E}</Project>
<Name>OSGeo.MapGuide.MaestroAPI</Name>
Added: sandbox/maestro-2.5/Maestro.Shared.UI/DialogFactory.cs
===================================================================
--- sandbox/maestro-2.5/Maestro.Shared.UI/DialogFactory.cs (rev 0)
+++ sandbox/maestro-2.5/Maestro.Shared.UI/DialogFactory.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+
+namespace Maestro.Shared.UI
+{
+ /// <summary>
+ /// Helper class to overcome some of the bad default values assigned to the <see cref="OpenFileDialog"/> and <see cref="SaveFileDialog"/>
+ ///
+ /// It is preferable to use this class instead of creating the <see cref="OpenFileDialog"/> or <see cref="SaveFileDialog"/> yourself.
+ /// </summary>
+ public static class DialogFactory
+ {
+ static string _lastOpenDir;
+ static string _lastSaveDir;
+
+ /// <summary>
+ /// Creates an <see cref="OpenFileDialog"/> with sensible default values
+ /// </summary>
+ /// <returns></returns>
+ public static OpenFileDialog OpenFile()
+ {
+ var dlg = new OpenFileDialog();
+
+ // I guess someone at MSFT must've went over the wrong side of the ballmer peak
+ // because RestoreDirectory should not default to false. Defaulting to false
+ // means that attempting to load files/assemblies using relative paths
+ // will most likely fail because for some reason, using this dialog will
+ // actually modify the current working directory!
+ //
+ // So we set this to true, but to preserve the existing behaviour, we store
+ // the directory of the selected file in a static variable on dialog close (OK),
+ // and assign this dir to the InitialDirectory property on each dialog request,
+ // effectively replicating the old behaviour (w/o the nasty side effects)
+ //
+ // Or maybe my usage scenario does not qualify as a common use case.
+
+ dlg.RestoreDirectory = true;
+ if (Directory.Exists(_lastOpenDir))
+ {
+ dlg.InitialDirectory = _lastOpenDir;
+ }
+ dlg.FileOk += (sender, e) =>
+ {
+ _lastOpenDir = Path.GetDirectoryName(dlg.FileName);
+ };
+
+ return dlg;
+ }
+
+ /// <summary>
+ /// Creates a <see cref="SaveFileDialog"/> with sensible default values
+ /// </summary>
+ /// <returns></returns>
+ public static SaveFileDialog SaveFile()
+ {
+ var dlg = new SaveFileDialog();
+
+ // I guess someone at MSFT must've went over the wrong side of the ballmer peak
+ // because RestoreDirectory should not default to false. Defaulting to false
+ // means that attempting to load files/assemblies using relative paths
+ // will most likely fail because for some reason, using this dialog will
+ // actually modify the current working directory!
+ //
+ // So we set this to true, but to preserve the existing behaviour, we store
+ // the directory of the selected file in a static variable on dialog close (OK),
+ // and assign this dir to the InitialDirectory property on each dialog request,
+ // effectively replicating the old behaviour (w/o the nasty side effects)
+ //
+ // Or maybe my usage scenario does not qualify as a common use case.
+
+ dlg.RestoreDirectory = true;
+ if (Directory.Exists(_lastSaveDir))
+ {
+ dlg.InitialDirectory = _lastSaveDir;
+ }
+ dlg.FileOk += (sender, e) =>
+ {
+ _lastSaveDir = Path.GetDirectoryName(dlg.FileName);
+ };
+
+ return dlg;
+ }
+ }
+}
Modified: sandbox/maestro-2.5/Maestro.Shared.UI/Maestro.Shared.UI.csproj
===================================================================
--- sandbox/maestro-2.5/Maestro.Shared.UI/Maestro.Shared.UI.csproj 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/Maestro.Shared.UI/Maestro.Shared.UI.csproj 2010-06-15 10:34:05 UTC (rev 4942)
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CFD19053-2172-41D3-8460-0FD2123A1E88}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -44,6 +44,7 @@
<Compile Include="CollapsiblePanel.designer.cs">
<DependentUpon>CollapsiblePanel.cs</DependentUpon>
</Compile>
+ <Compile Include="DialogFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
Added: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/NestedExceptionMessageProcessor.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/NestedExceptionMessageProcessor.cs (rev 0)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/NestedExceptionMessageProcessor.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -0,0 +1,53 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OSGeo.MapGuide.MaestroAPI.Exceptions
+{
+ /// <summary>
+ /// Helper class to process exception messages for exceptions that may contain one or more nested inner exceptions
+ /// </summary>
+ public static class NestedExceptionMessageProcessor
+ {
+ /// <summary>
+ /// Returns a formatted string containing the main exception message and all messages within the <see cref="InnerException"/> properties
+ /// </summary>
+ /// <param name="error"></param>
+ /// <returns></returns>
+ public static string GetFullMessage(Exception error)
+ {
+ if (error == null)
+ return string.Empty;
+
+ Exception ex = error;
+ string innerPrefix = Environment.NewLine + "\t";
+ StringBuilder sb = new StringBuilder();
+ while (ex.InnerException != null)
+ {
+ sb.Append(innerPrefix + ex.Message);
+ ex = ex.InnerException;
+ }
+ sb.Append(innerPrefix + ex.Message);
+ return sb.ToString();
+ }
+ }
+}
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj 2010-06-15 10:34:05 UTC (rev 4942)
@@ -166,6 +166,7 @@
<Compile Include="Commands\ICommand.cs" />
<Compile Include="Exceptions\CustomPropertyNotFoundException.cs" />
<Compile Include="Exceptions\MaestroException.cs" />
+ <Compile Include="Exceptions\NestedExceptionMessageProcessor.cs" />
<Compile Include="Exceptions\ResourceConversionException.cs" />
<Compile Include="Exceptions\SerializationException.cs" />
<Compile Include="Exceptions\UnsupportedResourceTypeException.cs" />
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-06-14 22:50:23 UTC (rev 4941)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2010-06-15 10:34:05 UTC (rev 4942)
@@ -128,7 +128,7 @@
catch { }
if (!ok) //Report original error
- throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
+ throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + NestedExceptionMessageProcessor.GetFullMessage(ex), ex);
}
if (!allowUntestedVersion)
ValidateVersion(sv);
@@ -156,7 +156,7 @@
}
catch (Exception ex)
{
- throw new Exception("Failed to connect, please check network connection and login information.\nExtended error info: " + ex.Message, ex);
+ throw new Exception("Failed to connect, please check network connection and login information.\nExtended error info: " + NestedExceptionMessageProcessor.GetFullMessage(ex), ex);
}
if (!allowUntestedVersion)
@@ -266,27 +266,29 @@
}
catch (WebException wex)
{
- if (wex.Response != null)
- try
- {
- string result = "";
- using(System.IO.MemoryStream ms = new System.IO.MemoryStream())
- {
- Utility.CopyStream(wex.Response.GetResponseStream(), ms);
- result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
- }
+ if (wex.Response != null)
+ {
+ try
+ {
+ string result = "";
+ using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
+ {
+ Utility.CopyStream(wex.Response.GetResponseStream(), ms);
+ result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
+ }
- if (result.ToLower().IndexOf("<body>") > 0)
- result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
+ if (result.ToLower().IndexOf("<body>") > 0)
+ result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
- if (result.ToLower().IndexOf("</body>") > 0)
- result = result.Substring(0, result.ToLower().IndexOf("</body>"));
+ if (result.ToLower().IndexOf("</body>") > 0)
+ result = result.Substring(0, result.ToLower().IndexOf("</body>"));
- return result;
- }
- catch
- {
- }
+ return result;
+ }
+ catch
+ {
+ }
+ }
if (wex.InnerException == null)
return wex.Message;
@@ -295,7 +297,7 @@
}
catch (Exception ex)
{
- return ex.Message;
+ return NestedExceptionMessageProcessor.GetFullMessage(ex);
}
return string.Empty;
@@ -317,27 +319,29 @@
}
catch (WebException wex)
{
- if (wex.Response != null)
- try
- {
- string result = "";
- using(System.IO.MemoryStream ms = new System.IO.MemoryStream())
- {
- Utility.CopyStream(wex.Response.GetResponseStream(), ms);
- result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
- }
+ if (wex.Response != null)
+ {
+ try
+ {
+ string result = "";
+ using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
+ {
+ Utility.CopyStream(wex.Response.GetResponseStream(), ms);
+ result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
+ }
- if (result.ToLower().IndexOf("<body>") > 0)
- result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
+ if (result.ToLower().IndexOf("<body>") > 0)
+ result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
- if (result.ToLower().IndexOf("</body>") > 0)
- result = result.Substring(0, result.ToLower().IndexOf("</body>"));
+ if (result.ToLower().IndexOf("</body>") > 0)
+ result = result.Substring(0, result.ToLower().IndexOf("</body>"));
- return result;
- }
- catch
- {
- }
+ return result;
+ }
+ catch
+ {
+ }
+ }
if (wex.InnerException == null)
return wex.Message;
@@ -346,7 +350,7 @@
}
catch (Exception ex)
{
- return ex.Message;
+ return NestedExceptionMessageProcessor.GetFullMessage(ex);
}
return string.Empty;
@@ -1185,7 +1189,7 @@
if (!ok)
{
if (throwException) //Report original error
- throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
+ throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + NestedExceptionMessageProcessor.GetFullMessage(ex), ex);
else
return false;
}
More information about the mapguide-commits
mailing list