|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
using Blazor.Models;
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
using ChoETL;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using System.Reflection.Metadata;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Pages;
|
|
|
|
|
public partial class Chapters
|
|
|
|
@ -58,4 +61,29 @@ public partial class Chapters
|
|
|
|
|
chapters = new List<ChaptersModel>(response); // an actual data for the current page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void Export()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
HttpResponseMessage response = await Http.GetAsync("https://trusting-panini.87-106-126-109.plesk.page/api/chapters");
|
|
|
|
|
var json = await response.Content.ReadAsStringAsync();
|
|
|
|
|
using (var jsonFile = ChoJSONReader.LoadText(json))
|
|
|
|
|
{
|
|
|
|
|
using (var csvFile = new ChoCSVWriter(sb).WithFirstLineHeader())
|
|
|
|
|
{
|
|
|
|
|
csvFile.Write(json);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string path = @"C:\temp\file"; // path to file
|
|
|
|
|
using (FileStream fs = File.Create(path))
|
|
|
|
|
{
|
|
|
|
|
// writing data in string
|
|
|
|
|
byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString());
|
|
|
|
|
fs.Write(info, 0, info.Length);
|
|
|
|
|
|
|
|
|
|
// writing data in bytes already
|
|
|
|
|
byte[] data = new byte[] { 0x0 };
|
|
|
|
|
fs.Write(data, 0, data.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|