Skip to content

Commit

Permalink
Merge pull request #3698 from donker/fixexport
Browse files Browse the repository at this point in the history
Provide better feedback in export
  • Loading branch information
mitchelsellers committed Apr 23, 2020
2 parents f95196f + f427f80 commit a56c7a0
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions DNN Platform/Website/admin/Modules/Export.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private string ExportModule(int moduleID, string fileName, IFolderInfo folder)
{
var objObject = Reflection.CreateObject(Module.DesktopModule.BusinessControllerClass, Module.DesktopModule.BusinessControllerClass);

//Double-check
if (objObject is IPortable)
//Double-check
if (objObject is IPortable)
{
XmlDocument moduleXml = new XmlDocument { XmlResolver = null };
XmlNode moduleNode = ModuleController.SerializeModule(moduleXml, Module, true);
Expand All @@ -104,20 +104,20 @@ private string ExportModule(int moduleID, string fileName, IFolderInfo folder)
var content = sw.ToString();
if (!String.IsNullOrEmpty(content))
{
//remove invalid chars in content -> DNN 26810: Handled by ModuleController.SerializeModule
//content = Regex.Replace(content, _invalidCharsRegex, string.Empty);
//add attributes to XML document
//remove invalid chars in content -> DNN 26810: Handled by ModuleController.SerializeModule
//content = Regex.Replace(content, _invalidCharsRegex, string.Empty);
//add attributes to XML document
//content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<content type=\"" + CleanName(Module.DesktopModule.ModuleName) + "\" version=\"" +
// Module.DesktopModule.Version + "\">" + content + "</content>";

//First check the Portal limits will not be exceeded (this is approximate)
if (PortalController.Instance.HasSpaceAvailable(PortalId, content.Length))
{
//add file to Files table
using (var fileContent = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
using (var fileContent = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
Services.FileSystem.FileManager.Instance.AddFile(folder, fileName, fileContent, true, true, "application/octet-stream");
}
}
}
else
{
Expand All @@ -134,9 +134,16 @@ private string ExportModule(int moduleID, string fileName, IFolderInfo folder)
strMessage = Localization.GetString("ExportNotSupported", LocalResourceFile);
}
}
catch
catch (Exception ex)
{
strMessage = Localization.GetString("Error", LocalResourceFile);
if (ex is InvalidFileExtensionException || ex is PermissionsNotMetException || ex is InvalidFilenameException)
{
strMessage = ex.Message;
}
else
{
strMessage = Localization.GetString("Error", LocalResourceFile);
}
}
}
else
Expand Down Expand Up @@ -227,7 +234,7 @@ protected void OnExportClick(object sender, EventArgs e)
{
UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
}
}
}

}
else
Expand Down

0 comments on commit a56c7a0

Please sign in to comment.