-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Version 4.0.0 - May 22, 2018 - **Added:** "ASP.NET Core on .NET Framework" support. ASP.NET Core uses a completely new web engine different than System.Web but now you can use GleamTech products on both classic ASP.NET and ASP.NET Core with the same net40 DLL as we abstracted classes like HttpContext, HttpRequest and HttpResponse etc. and we implemented a Middleware for mimicking HttpModule and HttpHandler. So our DLL auto-magically works regardless of whether you are running under classic ASP.NET or ASP.NET Core. Note that "ASP.NET Core on .NET Core" is a different platform and it's not supported yet because it requires porting all the code from .NET Framework runtime to .NET Core runtime so it requires a new DLL and .NET Core runtime does not provide all of the APIs yet. Minimum supported version is ASP.NET Core MVC 2.0.3 on .NET Framework 4.6.1 (this is because 2.0.3 fixes a bug related to referencing external DLLs in a razor page). - **Added:** New example project for "ASP.NET Core on .NET Framework", please refer to it for info on sample usage. Also updated docs with Getting Started article for the new platform. - **Changed:** License keys are changed so please go to https://www.gleamtech.com/upgrade and acquire a new license key if you want to use this version (or higher). If your one year maintenance has not ended, you will receive a new free license key on the same page. - **Improved**: Improved stability, accuracy for Portable, Presentation and Spreadsheet formats.
- Loading branch information
Showing
82 changed files
with
2,034 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27703.2000 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.CS", "AspNetCore.CS\AspNetCore.CS.csproj", "{2AD943F9-8CEA-402A-AE92-16E007AC2166}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2AD943F9-8CEA-402A-AE92-16E007AC2166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2AD943F9-8CEA-402A-AE92-16E007AC2166}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2AD943F9-8CEA-402A-AE92-16E007AC2166}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2AD943F9-8CEA-402A-AE92-16E007AC2166}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {D7BCA4B6-9637-494B-B778-707EB19E36B7} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<AssemblyName>GleamTech.DocumentUltimateExamples.AspNetCore.CS</AssemblyName> | ||
<RootNamespace>GleamTech.DocumentUltimateExamples.AspNetCore.CS</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<_CustomFiles Include="Controllers\**\*"/> | ||
<_CustomFiles Include="Views\**\*"/> | ||
<_CustomFiles Include="Descriptions\**\*"/> | ||
<DotnetPublishFiles Include="@(_CustomFiles)"> | ||
<DestinationRelativePath>%(Identity)</DestinationRelativePath> | ||
</DotnetPublishFiles> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.2"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.3" PrivateAssets="All"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.2"/> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2"/> | ||
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.2"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="GleamTech.Core"> | ||
<HintPath>..\..\Bin\GleamTech.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="GleamTech.DocumentUltimate"> | ||
<HintPath>..\..\Bin\GleamTech.DocumentUltimate.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
191 changes: 191 additions & 0 deletions
191
Examples/AspNetCore.CS/Controllers/DocumentConverterController.Overview.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using GleamTech.AspNet; | ||
using GleamTech.DocumentUltimate; | ||
using GleamTech.DocumentUltimateExamples.AspNetCore.CS.Models; | ||
using GleamTech.Examples; | ||
using GleamTech.IO; | ||
using GleamTech.Util; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
namespace GleamTech.DocumentUltimateExamples.AspNetCore.CS.Controllers | ||
{ | ||
public partial class DocumentConverterController | ||
{ | ||
public IActionResult Overview() | ||
{ | ||
var model = new OverviewViewModel | ||
{ | ||
ExampleFileSelector = new ExampleFileSelector | ||
{ | ||
Id = "exampleFileSelector", | ||
InitialFile = "Default.pdf" | ||
} | ||
}; | ||
|
||
var inputDocument = model.ExampleFileSelector.SelectedFile; | ||
var fileInfo = new FileInfo(inputDocument); | ||
var inputFormat = DocumentFormatInfo.Get(inputDocument); | ||
model.InputFormat = inputFormat != null ? inputFormat.Description : "(not supported)"; | ||
|
||
PopulatePossibleOutputFormats(inputDocument, model); | ||
|
||
model.ConvertHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl( | ||
ConvertHandlerName, | ||
new NameValueCollection | ||
{ | ||
{"inputDocument", ExamplesConfiguration.ProtectString(inputDocument)}, | ||
{"version", fileInfo.LastWriteTimeUtc.Ticks + "-" + fileInfo.Length} | ||
}); | ||
|
||
return View(model); | ||
} | ||
|
||
private void PopulatePossibleOutputFormats(string inputDocument, OverviewViewModel model) | ||
{ | ||
foreach (var format in DocumentConverter.EnumeratePossibleOutputFormats(inputDocument)) | ||
{ | ||
var formatInfo = DocumentFormatInfo.Get(format); | ||
|
||
List<SelectListItem> groupData; | ||
if (!model.OutputFormats.TryGetValue(formatInfo.Group.Description, out groupData)) | ||
{ | ||
groupData = new List<SelectListItem>(); | ||
model.OutputFormats.Add(formatInfo.Group.Description, groupData); | ||
} | ||
groupData.Add(new SelectListItem | ||
{ | ||
Text = formatInfo.Description, | ||
Value = formatInfo.Value.ToString() | ||
}); | ||
} | ||
|
||
if (model.OutputFormats.Count == 0) | ||
model.OutputFormats.Add("(not supported)", new List<SelectListItem>()); | ||
} | ||
|
||
public static void ConvertHandler(IHttpContext context) | ||
{ | ||
DocumentConverterResult result; | ||
|
||
try | ||
{ | ||
var inputDocument = new BackSlashPath(ExamplesConfiguration.UnprotectString(context.Request["inputDocument"])); | ||
var outputFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), context.Request["outputFormat"]); | ||
var fileName = inputDocument.FileNameWithoutExtension + "." + DocumentFormatInfo.Get(outputFormat).DefaultExtension; | ||
var outputPath = ConvertedPath.Append(context.Session.Id).Append(fileName); | ||
var outputDocument = outputPath.Append(fileName); | ||
|
||
if (Directory.Exists(outputPath)) | ||
Directory.Delete(outputPath, true); | ||
Directory.CreateDirectory(outputPath); | ||
result = DocumentConverter.Convert(inputDocument, outputDocument, outputFormat); | ||
} | ||
catch (Exception exception) | ||
{ | ||
context.Response.Output.Write("<span style=\"color: red; font-weight: bold\">Conversion failed</span><br/>"); | ||
context.Response.Output.Write(exception.Message); | ||
return; | ||
} | ||
|
||
context.Response.Output.Write("<span style=\"color: green; font-weight: bold\">Conversion successful</span>"); | ||
context.Response.Output.Write("<br/>Conversion time: " + result.ElapsedTime); | ||
context.Response.Output.Write("<br/>Output files:"); | ||
|
||
if (result.OutputFiles.Length > 1) | ||
context.Response.Output.Write(" - " + GetZipDownloadLink(new FileInfo(result.OutputFiles[0]).Directory)); | ||
|
||
context.Response.Output.Write("<br/><ol>"); | ||
foreach (var outputFile in result.OutputFiles) | ||
{ | ||
if (outputFile.EndsWith("\\")) | ||
{ | ||
var directoryInfo = new DirectoryInfo(outputFile); | ||
context.Response.Output.Write(string.Format( | ||
"<br/><li><b>{0}\\</b> - {1}</li>", | ||
directoryInfo.Name, | ||
GetZipDownloadLink(directoryInfo)) | ||
); | ||
} | ||
else | ||
{ | ||
var fileInfo = new FileInfo(outputFile); | ||
context.Response.Output.Write(string.Format( | ||
"<br/><li><b>{0}</b> ({1} bytes) - {2}</li>", | ||
fileInfo.Name, | ||
fileInfo.Length, | ||
GetDownloadLink(fileInfo)) | ||
); | ||
} | ||
} | ||
context.Response.Output.Write("<br/></ol>"); | ||
} | ||
|
||
private static string GetDownloadLink(FileInfo fileInfo) | ||
{ | ||
return string.Format( | ||
"<a href=\"{0}\">Download</a>", | ||
ExamplesConfiguration.GetDownloadUrl(fileInfo.FullName, fileInfo.LastWriteTimeUtc.Ticks.ToString())); | ||
} | ||
|
||
private static string GetZipDownloadLink(DirectoryInfo directoryInfo) | ||
{ | ||
return string.Format( | ||
"<a href=\"{0}\">Download as Zip</a>", | ||
ExamplesConfiguration.GetDynamicDownloadUrl( | ||
ZipDownloadHandlerName, | ||
new NameValueCollection | ||
{ | ||
{"path", ExamplesConfiguration.ProtectString(directoryInfo.FullName)}, | ||
{"version", directoryInfo.LastWriteTimeUtc.Ticks.ToString()}, | ||
})); | ||
} | ||
|
||
public static void ZipDownloadHandler(IHttpContext context) | ||
{ | ||
var path = new BackSlashPath(ExamplesConfiguration.UnprotectString(context.Request["path"])).RemoveTrailingSlash(); | ||
|
||
var fileResponse = new FileResponse(context, 0); | ||
fileResponse.Transmit((targetStream, copyFileCallback) => | ||
{ | ||
QuickZip.Zip(targetStream, Directory.EnumerateFileSystemEntries(path)); | ||
}, path.FileName + ".zip", 0); | ||
|
||
} | ||
|
||
private static string ConvertHandlerName | ||
{ | ||
get | ||
{ | ||
if (convertHandlerName == null) | ||
{ | ||
convertHandlerName = "ConvertHandler"; | ||
ExamplesConfiguration.RegisterDynamicDownloadHandler(convertHandlerName, ConvertHandler); | ||
} | ||
|
||
return convertHandlerName; | ||
} | ||
} | ||
private static string convertHandlerName; | ||
|
||
private static string ZipDownloadHandlerName | ||
{ | ||
get | ||
{ | ||
if (zipDownloadHandlerName == null) | ||
{ | ||
zipDownloadHandlerName = "ZipDownloadHandler"; | ||
ExamplesConfiguration.RegisterDynamicDownloadHandler(zipDownloadHandlerName, ZipDownloadHandler); | ||
} | ||
|
||
return zipDownloadHandlerName; | ||
} | ||
} | ||
private static string zipDownloadHandlerName; | ||
|
||
private static readonly BackSlashPath ConvertedPath = Hosting.ResolvePhysicalPath("~/App_Data/ConvertedDocuments"); | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
Examples/AspNetCore.CS/Controllers/DocumentConverterController.Possible.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using GleamTech.AspNet; | ||
using GleamTech.DocumentUltimate; | ||
using GleamTech.DocumentUltimateExamples.AspNetCore.CS.Models; | ||
using GleamTech.Examples; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
|
||
namespace GleamTech.DocumentUltimateExamples.AspNetCore.CS.Controllers | ||
{ | ||
public partial class DocumentConverterController | ||
{ | ||
public IActionResult Possible() | ||
{ | ||
var model = new PossibleViewModel(); | ||
|
||
PopulateInputFormats(model); | ||
PopulateOutputFormats(model); | ||
|
||
model.ResultHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl( | ||
ResultHandlerName, | ||
new NameValueCollection | ||
{ | ||
{"version", DateTime.UtcNow.Ticks.ToString()} | ||
}); | ||
|
||
return View(model); | ||
} | ||
|
||
private void PopulateInputFormats(PossibleViewModel model) | ||
{ | ||
foreach (var formatInfo in DocumentFormatInfo.Enumerate(DocumentFormatSupport.Load)) | ||
{ | ||
List<SelectListItem> groupData; | ||
if (!model.InputFormats.TryGetValue(formatInfo.Group.Description, out groupData)) | ||
{ | ||
groupData = new List<SelectListItem>(); | ||
model.InputFormats.Add(formatInfo.Group.Description, groupData); | ||
} | ||
groupData.Add(new SelectListItem | ||
{ | ||
Text = formatInfo.Description, | ||
Value = formatInfo.Value.ToString() | ||
}); | ||
model.InputFormatCount++; | ||
} | ||
} | ||
|
||
private void PopulateOutputFormats(PossibleViewModel model) | ||
{ | ||
foreach (var formatInfo in DocumentFormatInfo.Enumerate(DocumentFormatSupport.Save)) | ||
{ | ||
List<SelectListItem> groupData; | ||
if (!model.OutputFormats.TryGetValue(formatInfo.Group.Description, out groupData)) | ||
{ | ||
groupData = new List<SelectListItem>(); | ||
model.OutputFormats.Add(formatInfo.Group.Description, groupData); | ||
} | ||
groupData.Add(new SelectListItem | ||
{ | ||
Text = formatInfo.Description, | ||
Value = formatInfo.Value.ToString() | ||
}); | ||
model.OutputFormatCount++; | ||
} | ||
} | ||
|
||
public static void ResultHandler(IHttpContext context) | ||
{ | ||
var inputFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), context.Request["inputFormat"]); | ||
var outputFormat = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), context.Request["outputFormat"]); | ||
|
||
context.Response.Output.Write("<center>"); | ||
|
||
if (DocumentConverter.CanConvert(inputFormat, outputFormat)) | ||
{ | ||
context.Response.Output.Write(string.Format( | ||
"<span style=\"color: green; font-weight: bold\">Direct conversion from {0} to {1} is possible</span>", | ||
inputFormat, outputFormat) | ||
); | ||
|
||
foreach (var engine in Enum<DocumentEngine>.GetValues()) | ||
{ | ||
if (DocumentConverter.CanConvert(inputFormat, outputFormat, engine)) | ||
context.Response.Output.Write(string.Format( | ||
"<br/><span style=\"color: green; font-weight: bold\">Via {0} Engine ✓</span>", | ||
engine)); | ||
else | ||
context.Response.Output.Write(string.Format( | ||
"<br/><span style=\"color: red; font-weight: bold\">Via {0} Engine ✗</span>", | ||
engine)); | ||
} | ||
} | ||
else | ||
context.Response.Output.Write(string.Format( | ||
"<span style=\"color: red; font-weight: bold\">Direct conversion from {0} to {1} is not possible</span>", | ||
inputFormat, outputFormat) | ||
); | ||
|
||
context.Response.Output.Write("</center>"); | ||
} | ||
|
||
private static string ResultHandlerName | ||
{ | ||
get | ||
{ | ||
if (resultHandlerName == null) | ||
{ | ||
resultHandlerName = "ResultHandler"; | ||
ExamplesConfiguration.RegisterDynamicDownloadHandler(resultHandlerName, ResultHandler); | ||
} | ||
|
||
return resultHandlerName; | ||
} | ||
} | ||
private static string resultHandlerName; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Examples/AspNetCore.CS/Controllers/DocumentConverterController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace GleamTech.DocumentUltimateExamples.AspNetCore.CS.Controllers | ||
{ | ||
public partial class DocumentConverterController : Controller | ||
{ | ||
} | ||
} |
Oops, something went wrong.