[mapguide-commits] r4412 - in trunk/Tools/Maestro: Maestro Maestro/PackageManager MaestroAPI/PackageBuilder

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Dec 11 12:23:53 EST 2009


Author: ksgeograf
Date: 2009-12-11 12:23:52 -0500 (Fri, 11 Dec 2009)
New Revision: 4412

Modified:
   trunk/Tools/Maestro/Maestro/FormMain.cs
   trunk/Tools/Maestro/Maestro/PackageManager/PackageEditor.cs
   trunk/Tools/Maestro/MaestroAPI/PackageBuilder/PackageBuilder.cs
Log:
Maestro:
Fixed issue #1179.
Also fixed a few error messages so they are more helpful.
Also fixed it so packages created by MapGuide are now editable, even if they contain international characters.

Modified: trunk/Tools/Maestro/Maestro/FormMain.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormMain.cs	2009-12-11 16:29:40 UTC (rev 4411)
+++ trunk/Tools/Maestro/Maestro/FormMain.cs	2009-12-11 17:23:52 UTC (rev 4412)
@@ -2315,6 +2315,9 @@
             }
             catch(Exception ex)
             {
+                if (ex is System.Reflection.TargetInvocationException && ex.InnerException != null)
+                    ex = ex.InnerException;
+
                 MessageBox.Show(this, string.Format(Strings.FormMain.PackageRestoreError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }

Modified: trunk/Tools/Maestro/Maestro/PackageManager/PackageEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/PackageManager/PackageEditor.cs	2009-12-11 16:29:40 UTC (rev 4411)
+++ trunk/Tools/Maestro/Maestro/PackageManager/PackageEditor.cs	2009-12-11 17:23:52 UTC (rev 4412)
@@ -58,8 +58,8 @@
             dlg.CheckPathExists = true;
             dlg.DefaultExt = ".mgp";
             dlg.Filter =
-                string.Format(Strings.PackageEditor.FiletypeMGP + "|{0}", "*.mgp") +
-                string.Format(Strings.PackageEditor.FiletypeZip + "|{0}", "*.zip") +
+                string.Format(Strings.PackageEditor.FiletypeMGP + "|{0}|", "*.mgp") +
+                string.Format(Strings.PackageEditor.FiletypeZip + "|{0}|", "*.zip") +
                 string.Format(Strings.PackageEditor.FiletypeAll + "|{0}", "*.*");
             dlg.FilterIndex = 0;
             dlg.Multiselect = false;
@@ -92,6 +92,9 @@
             }
             catch (Exception ex)
             {
+                if (ex is System.Reflection.TargetInvocationException && ex.InnerException != null)
+                    ex = ex.InnerException;
+
                 MessageBox.Show(this, string.Format(Strings.PackageEditor.PackageReadError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.DialogResult = DialogResult.Cancel;
                 this.Close();
@@ -461,6 +464,8 @@
             }
             catch (Exception ex)
             {
+                if (ex is System.Reflection.TargetInvocationException && ex.InnerException != null)
+                    ex = ex.InnerException;
                 MessageBox.Show(this, string.Format(Strings.PackageEditor.PackageBuildError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }

Modified: trunk/Tools/Maestro/MaestroAPI/PackageBuilder/PackageBuilder.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/PackageBuilder/PackageBuilder.cs	2009-12-11 16:29:40 UTC (rev 4411)
+++ trunk/Tools/Maestro/MaestroAPI/PackageBuilder/PackageBuilder.cs	2009-12-11 17:23:52 UTC (rev 4412)
@@ -221,7 +221,6 @@
                     foreach (ResourceDataListResourceData rd in rdl.ResourceData)
                         resourceData[doc.ResourceId].Add(rd);
 
-                    int i = 0;
                     int itemCount = resourceData[doc.ResourceId].Count + 1;
 
                     filemap.Add(new KeyValuePair<string, string>(filebase + "_CONTENT.xml", System.IO.Path.Combine(temppath, Guid.NewGuid().ToString())));
@@ -235,7 +234,7 @@
 
                     foreach (ResourceDataListResourceData rd in rdl.ResourceData)
                     {
-                        filemap.Add(new KeyValuePair<string, string>(filebase + "_DATA_" + rd.Name, System.IO.Path.Combine(temppath, Guid.NewGuid().ToString())));
+                        filemap.Add(new KeyValuePair<string, string>(filebase + "_DATA_" + EncodeFilename(rd.Name), System.IO.Path.Combine(temppath, Guid.NewGuid().ToString())));
                         System.IO.FileInfo fi = new System.IO.FileInfo(filemap[filemap.Count - 1].Value);
                         using (System.IO.FileStream fs = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                             m_connection.GetResourceData(doc.ResourceId, rd.Name).WriteTo(fs);
@@ -551,6 +550,7 @@
 
         private void ZipDirectory(string zipfile, string folder, string comment, List<KeyValuePair<string, string>> filemap)
         {
+            ICSharpCode.SharpZipLib.Zip.ZipConstants.DefaultCodePage = System.Text.Encoding.UTF8.CodePage;
             ICSharpCode.SharpZipLib.Checksums.Crc32 crc = new ICSharpCode.SharpZipLib.Checksums.Crc32();
             using (System.IO.FileStream ofs = new System.IO.FileStream(zipfile, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
             using (ICSharpCode.SharpZipLib.Zip.ZipOutputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipOutputStream(ofs))
@@ -578,7 +578,6 @@
 
                         if (Progress != null)
                             Progress(ProgressType.Compressing, f.Key, filemap.Count, i++);
-
                     }
 
                     zip.Finish();
@@ -629,6 +628,7 @@
 
                 List<KeyValuePair<string, string>> filemap = new List<KeyValuePair<string, string>>();
 
+                ICSharpCode.SharpZipLib.Zip.ZipConstants.DefaultCodePage = System.Text.Encoding.UTF8.CodePage;
                 using (ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(sourcePackageFile))
                 {
                     zipfilecomment = zipfile.ZipFileComment;
@@ -717,16 +717,16 @@
 
                         foreach (ResourceDataItem rdi in ri.Items)
                         {
-                            string targetpath = filebase + "_DATA_" + rdi.ResourceName;
+                            string targetpath = filebase + "_DATA_" + EncodeFilename(rdi.ResourceName);
                             if (rdi.EntryType == EntryTypeEnum.Added)
                             {
-                                filemap.Add(new KeyValuePair<string, string>(targetpath, rdi.Filename));
+                                filemap.Add(new KeyValuePair<string, string>(targetpath, System.IO.Path.Combine(tempfolder, Guid.NewGuid().ToString())));
                             }
                             else
                             {
                                 int index = FindZipEntry(zipfile, rdi.Filename);
                                 if (index < 0)
-                                    throw new Exception(string.Format(Strings.PackageBuilder.FileMissingError, ri.Contentpath));
+                                    throw new Exception(string.Format(Strings.PackageBuilder.FileMissingError, rdi.Filename));
 
                                 filemap.Add(new KeyValuePair<string, string>(targetpath, System.IO.Path.Combine(tempfolder, Guid.NewGuid().ToString())));
                                 using (System.IO.FileStream fs = new System.IO.FileStream(filemap[filemap.Count - 1].Value, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.None))
@@ -861,6 +861,7 @@
             Dictionary<string, ResourceItem> resourceList = new Dictionary<string, ResourceItem>();
 
             ResourcePackageManifest manifest;
+            ICSharpCode.SharpZipLib.Zip.ZipConstants.DefaultCodePage = System.Text.Encoding.UTF8.CodePage;
             using (ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(packageFile))
             {
                 int index = FindZipEntry(zipfile, "MgResourcePackageManifest.xml");



More information about the mapguide-commits mailing list