|
|
@ -13,6 +13,7 @@ using Blazored.Modal;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using Blazor.Components;
|
|
|
|
using Blazor.Components;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
|
|
|
|
using SuperConvert.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Pages.Questions;
|
|
|
|
namespace Blazor.Pages.Questions;
|
|
|
|
|
|
|
|
|
|
|
@ -110,15 +111,9 @@ public partial class Questions
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
HttpResponseMessage response = await Http.GetAsync(API.API_URL+"questionsExport/"+API.TOKEN);
|
|
|
|
HttpResponseMessage response = await Http.GetAsync(API.API_URL+"questionsExport/"+API.TOKEN);
|
|
|
|
var json = await response.Content.ReadAsStringAsync();
|
|
|
|
var json = await response.Content.ReadAsStringAsync();
|
|
|
|
using (var jsonFile = ChoJSONReader.LoadText(json))
|
|
|
|
byte[] csv = json.ToCsv(';');
|
|
|
|
{
|
|
|
|
string csvString = Encoding.Unicode.GetString(csv);
|
|
|
|
using (var csvFile = new ChoCSVWriter(sb).WithFirstLineHeader())
|
|
|
|
var sentFile = new MemoryStream(Encoding.Unicode.GetBytes(csvString));
|
|
|
|
{
|
|
|
|
|
|
|
|
csvFile.Write(jsonFile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sentFile = new MemoryStream(Encoding.Unicode.GetBytes(sb.ToString()));
|
|
|
|
|
|
|
|
using (var streamRef = new DotNetStreamReference(stream: sentFile))
|
|
|
|
using (var streamRef = new DotNetStreamReference(stream: sentFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await IJSRuntime.InvokeVoidAsync("downloadFileFromStream", "data.csv", streamRef);
|
|
|
|
await IJSRuntime.InvokeVoidAsync("downloadFileFromStream", "data.csv", streamRef);
|
|
|
@ -131,9 +126,10 @@ public partial class Questions
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await e.File.OpenReadStream().CopyToAsync(ms);
|
|
|
|
await e.File.OpenReadStream().CopyToAsync(ms);
|
|
|
|
var bytes = ms.ToArray();
|
|
|
|
var bytes = ms.ToArray();
|
|
|
|
string s = Encoding.UTF8.GetString(bytes);
|
|
|
|
string s = Encoding.Unicode.GetString(bytes);
|
|
|
|
|
|
|
|
|
|
|
|
s = s.Replace("\r\n", "\n");
|
|
|
|
s = s.Replace("\r\n", "\n");
|
|
|
|
|
|
|
|
s = s.Replace("\0", "");
|
|
|
|
var rows = s.Split('\n');
|
|
|
|
var rows = s.Split('\n');
|
|
|
|
rows = rows.Skip(1).ToArray();
|
|
|
|
rows = rows.Skip(1).ToArray();
|
|
|
|
|
|
|
|
|
|
|
|