-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from leungkimming/michael3
Add Telerik Documents and fix Antiforgrey
- Loading branch information
Showing
29 changed files
with
1,257 additions
and
40 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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,89 @@ | ||
@page "/documentprocessing" | ||
@using System.Diagnostics | ||
@inject HttpUtil _httpUtil | ||
@inject IJSRuntime JsRuntime | ||
|
||
<h3>Document Processing</h3> | ||
|
||
<TelerikButton OnClick="@ExportPDF" Icon="file-pdf" Title="Export PDF"></TelerikButton> | ||
<TelerikButton OnClick="@MergePDF" Icon="file-ascx" Title="Merge PDF"></TelerikButton> | ||
<TelerikButton OnClick="@ExportDocx" Icon="file-word" Title="Export Docx"></TelerikButton> | ||
<TelerikButton OnClick="@ExportXlsx" Icon="file-excel" Title="Export Xlsx"></TelerikButton> | ||
<div class="k-form k-form-horizontal div-container"> | ||
<label>Zip Files Demo</label> | ||
<div class="k-form-field-wrap"> | ||
<TelerikUpload SaveUrl="@SaveUrl" | ||
AllowedExtensions="@AllowedExtensions" | ||
AutoUpload="false" | ||
MinFileSize="@MinFileSize" | ||
MaxFileSize="@MaxFileSize" | ||
Multiple="true" | ||
OnUpload="@UploadHandler"> | ||
</TelerikUpload> | ||
<div class="k-form-hint">Accepted files: <strong>DOCX, PDF, JPG and PNG</strong></div> | ||
<div calss="div-container"> | ||
<TelerikTextBox Width="200px" Value="@Password" Title="Password" ValueChanged="@PasswordChanged" PlaceHolder="Password for protect."></TelerikTextBox> | ||
<TelerikButton OnClick="@ZipFiles" Icon="file-zip" Title="Zip all uploaded files."></TelerikButton> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="loader-container"> | ||
<TelerikLoader Class="loader-indicator" Type="@LoaderType.InfiniteSpinner" Size="@(ThemeConstants.Loader.Size.Large)" Visible="@IsLoad"></TelerikLoader> | ||
</div> | ||
|
||
@code { | ||
public bool IsLoad { get; set; } = false; | ||
public string Password { get; set; } | ||
public async Task PasswordChanged(string value) { | ||
Password = value; | ||
} | ||
public async Task ExportPDF() { | ||
IsLoad = true; | ||
var response = await _httpUtil.GetAsync("documentprocessing/exporttopdf"); | ||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
Save(fileData, "application/pdf", "Sample Document.pdf"); | ||
} | ||
|
||
public async Task MergePDF() { | ||
IsLoad = true; | ||
var response = await _httpUtil.GetAsync("documentprocessing/mergepdf"); | ||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
Save(fileData, "application/pdf", "Merge Sample Document.pdf"); | ||
} | ||
public async Task ExportDocx() { | ||
IsLoad = true; | ||
var response = await _httpUtil.GetAsync("documentprocessing/exporttodocx"); | ||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
Save(fileData, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Sample Document.docx"); | ||
} | ||
public async Task ExportXlsx() { | ||
IsLoad = true; | ||
var response = await _httpUtil.GetAsync("documentprocessing/exporttoxlsx"); | ||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
Save(fileData, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Sample Document.xlsx"); | ||
|
||
} | ||
public string SaveUrl => "documentprocessing/uploadfiles"; | ||
public List<string> AllowedExtensions { get; set; } = new List<string>() { ".docx", ".pdf", ".jpg", ".png" }; | ||
public int MinFileSize { get; set; } = 1024; | ||
public int MaxFileSize { get; set; } = 4 * 1024 * 1024; | ||
public async Task UploadHandler(UploadEventArgs e) { | ||
e.RequestHeaders = new Dictionary<string, object>(); | ||
await _httpUtil.RefreshToken(e.RequestHeaders); | ||
} | ||
public async Task ZipFiles() { | ||
IsLoad = true; | ||
var response = await _httpUtil.GetAsync($"documentprocessing/zipfiles?password={Password}"); | ||
var fileData = await response.Content.ReadAsByteArrayAsync(); | ||
Save(fileData, "application/x-zip-compressed", "ZipDemo.zip"); | ||
} | ||
public void Save(byte[] byteData, string mimeType, string fileName) { | ||
if (byteData == null) { | ||
return; | ||
} | ||
var fileBase64=Convert.ToBase64String(byteData); | ||
JsRuntime.InvokeVoidAsync("saveFile", fileBase64, mimeType, fileName); | ||
IsLoad = false; | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.