Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better feedback in export #3698

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
mitchelsellers marked this conversation as resolved.
Show resolved Hide resolved
{
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