Skip to content

Commit

Permalink
Merge branch 'hotfix/dnn92'
Browse files Browse the repository at this point in the history
  • Loading branch information
sachatrauwaen committed Apr 3, 2018
2 parents f8b06c1 + ab96da4 commit 5159aee
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ packages/
custom.targets
obj/
Install/
OpenContent/OpenContent920.csproj.user
8 changes: 6 additions & 2 deletions OpenContent/Components/Utils/OpenContentUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Services.FileSystem;
using ICSharpCode.SharpZipLib.Zip;
//using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -386,8 +386,12 @@ public static string ImportFromWeb(int portalId, string fileName, string newTemp
folder = FolderManager.Instance.AddFolder(portalId, folderName);
var req = (HttpWebRequest)WebRequest.Create(fileName);
Stream stream = req.GetResponse().GetResponseStream();
//var file = FileManager.Instance.AddFile(folder, fileName, stream, true);
//FileManager.Instance.UnzipFile(file);

FileSystemUtils.UnzipResources(new ZipInputStream(stream), folder.PhysicalPath);
//FileSystemUtils.UnzipResources(new ZipInputStream(stream), folder.PhysicalPath);
var zip = new ZipUtils();
zip.UnzipFiles(stream, folder.PhysicalPath);
return GetDefaultTemplate(folder.PhysicalPath);
}
}
Expand Down
66 changes: 66 additions & 0 deletions OpenContent/Components/Utils/ZipUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using DotNetNuke.Common.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;

namespace Satrabel.OpenContent.Components
{
public class ZipUtils
{
private Type ZipInputStreamType;
private Type ZipOutputStreamType;
public ZipUtils()
{
ZipInputStreamType = Type.GetType("ICSharpCode.SharpZipLib.Zip.ZipInputStream, ICSharpCode.SharpZipLib");
if (ZipInputStreamType == null)
{
ZipInputStreamType = Type.GetType("ICSharpCode.SharpZipLib.Zip.ZipInputStream, SharpZipLib");
}
ZipOutputStreamType = Type.GetType("ICSharpCode.SharpZipLib.Zip.ZipInputStream, ICSharpCode.SharpZipLib");
if (ZipOutputStreamType == null)
{
ZipOutputStreamType = Type.GetType("ICSharpCode.SharpZipLib.Zip.ZipOutputStream, SharpZipLib");
}
}

public void ZipFiles(int CompressionLevel, FileStream strmZipFile, string[] files)
{
//ICSharpCode.SharpZipLib.Zip.ZipOutputStream strmZipStream = null;
object strmZipStream = null;
try
{
//strmZipStream = new ZipOutputStream(strmZipFile);
strmZipStream = ZipOutputStreamType.InvokeMember("", BindingFlags.CreateInstance, null, null, new object[] { strmZipFile }, null);
//strmZipStream.SetLevel(CompressionLevel);
ZipOutputStreamType.InvokeMember("SetLevel", BindingFlags.InvokeMethod, null, strmZipStream, new object[] { CompressionLevel });
foreach (var item in files)
{
//FileSystemUtils.AddToZip(ref strmZipStream, Path.GetFullPath(item), Path.GetFileName(item), "");
typeof(FileSystemUtils).InvokeMember("AddToZip", BindingFlags.InvokeMethod, null, null, new object[] { strmZipStream, Path.GetFullPath(item), Path.GetFileName(item), "" });
}
}
finally
{
if (strmZipStream != null)
{
//strmZipStream.Finish();
ZipOutputStreamType.InvokeMember("Finish", BindingFlags.InvokeMethod, null, strmZipStream, null);
//strmZipStream.Close();
ZipOutputStreamType.InvokeMember("Close", BindingFlags.InvokeMethod, null, strmZipStream, null);
}
}
}

public void UnzipFiles(Stream stream, string PhysicalPath)
{
//ICSharpCode.SharpZipLib.Zip.ZipOutputStream strmZipStream = null;
object strmZipStream = null;
strmZipStream = ZipInputStreamType.InvokeMember("", BindingFlags.CreateInstance, null, null, new object[] { stream }, null);
//FileSystemUtils.UnzipResources(new ZipInputStream(fuFile.FileContent), folder.PhysicalPath);
typeof(FileSystemUtils).InvokeMember("UnzipResources", BindingFlags.InvokeMethod, null, null, new object[] { strmZipStream, PhysicalPath });
}
}
}
6 changes: 1 addition & 5 deletions OpenContent/OpenContent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@
<HintPath>..\ref\dnn732\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SharpZipLib, Version=0.81.0.1407, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ref\dnn732\SharpZipLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations" />
Expand Down Expand Up @@ -370,6 +365,7 @@
<Compile Include="Components\Common\Utils.cs" />
<Compile Include="Components\UrlRewriter\OpenContentUrlRule.cs" />
<Compile Include="Components\UrlRewriter\OpenContentUrlProvider.cs" />
<Compile Include="Components\Utils\ZipUtils.cs" />
<Compile Include="EditNotifications.ascx.cs">
<DependentUpon>EditNotifications.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
Expand Down
2 changes: 1 addition & 1 deletion OpenContent/OpenContent.dnn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="OpenContent" type="Module" version="03.05.02">
<package name="OpenContent" type="Module" version="03.05.03">
<friendlyName>OpenContent</friendlyName>
<description>OpenContent module by Satrabel.be</description>
<iconFile>~/DesktopModules/OpenContent/Images/icon_extensions.png</iconFile>
Expand Down
17 changes: 15 additions & 2 deletions OpenContent/ShareTemplate.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Entities.Host;
using DotNetNuke.Common.Utilities;
using ICSharpCode.SharpZipLib.Zip;
//using ICSharpCode.SharpZipLib.Zip;
using System.Web;
using Satrabel.OpenContent.Components.Localization;
using Satrabel.OpenContent.Components.Rss;
Expand Down Expand Up @@ -130,7 +130,9 @@ protected void cmdImport_Click(object sender, EventArgs e)
{
folder = FolderManager.Instance.AddFolder(PortalId, FolderName);
}
FileSystemUtils.UnzipResources(new ZipInputStream(fuFile.FileContent), folder.PhysicalPath);
//FileSystemUtils.UnzipResources(new ZipInputStream(fuFile.FileContent), folder.PhysicalPath);
var zip = new ZipUtils();
zip.UnzipFiles(fuFile.FileContent, folder.PhysicalPath);
}
}
catch (PermissionsNotMetException)
Expand Down Expand Up @@ -238,11 +240,15 @@ private void CreateZipFile(string zipFileName, string Folder)
int CompressionLevel = 9;
var zipFile = new System.IO.FileInfo(zipFileName);
FileStream strmZipFile = null;

//Log.StartJob(Util.WRITER_CreatingPackage);
try
{
//Log.AddInfo(string.Format(Util.WRITER_CreateArchive, ZipFileShortName));
strmZipFile = File.Create(zipFileName);
var zip = new ZipUtils();
zip.ZipFiles(CompressionLevel, strmZipFile, Directory.GetFiles(Folder));
/*
ZipOutputStream strmZipStream = null;
try
{
Expand All @@ -267,6 +273,8 @@ private void CreateZipFile(string zipFileName, string Folder)
}
}
//Log.EndJob(Util.WRITER_CreatedPackage);
*/
WriteFileToHttpContext(zipFileName, ContentDisposition.Attachment);
}
catch (Exception ex)
Expand All @@ -281,6 +289,11 @@ private void CreateZipFile(string zipFileName, string Folder)
strmZipFile.Close();
}
}





}
private void WriteFileToHttpContext(string FileName, ContentDisposition contentDisposition)
{
Expand Down
2 changes: 2 additions & 0 deletions build-local92.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" OpenContent\OpenContent92.csproj /p:Configuration=Debug,Platform=AnyCPU,SolutionDir=Solution,ReferencePath="ref;ref\dnn920" /t:Rebuild >build-local-dnn920.log
pause
Binary file added ref/dnn920/ClientDependency.Core.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.Instrumentation.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.Web.Client.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.Web.Razor.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.Web.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.WebUtility.dll
Binary file not shown.
Binary file added ref/dnn920/DotNetNuke.dll
Binary file not shown.
Binary file added ref/dnn920/ICSharpCode.SharpZipLib.dll
Binary file not shown.
Binary file added ref/dnn920/Newtonsoft.Json.dll
Binary file not shown.
Binary file added ref/dnn920/System.Net.Http.Formatting.dll
Binary file not shown.
Binary file added ref/dnn920/System.Web.Helpers.dll
Binary file not shown.
Binary file added ref/dnn920/System.Web.Http.WebHost.dll
Binary file not shown.
Binary file added ref/dnn920/System.Web.Http.dll
Binary file not shown.
Binary file added ref/dnn920/System.Web.WebPages.dll
Binary file not shown.

0 comments on commit 5159aee

Please sign in to comment.