85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Egw.Window.Data;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace WebAedificaConfigurator
|
|
{
|
|
public partial class WebAedificaMaker
|
|
{
|
|
string m_FilePath = "";
|
|
string m_sSvg = "";
|
|
|
|
[Parameter]
|
|
public EventCallback<Dictionary<string, string>> EC_OnSave { get; set; }
|
|
|
|
[Parameter]
|
|
public string CssSvg { get; set; } = "responsive-svg";
|
|
|
|
[Parameter]
|
|
public string LiveSVG
|
|
{
|
|
get => m_sSvg;
|
|
set => m_sSvg = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Salvattagio dizionario contenente il file
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task DoSave()
|
|
{
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
Args.Add("FilePath", m_FilePath);
|
|
Args.Add("Mode", 1.ToString());
|
|
await EC_OnSave.InvokeAsync(Args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esegue lettura file + invio richiesta specifica
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <returns></returns>
|
|
|
|
private async Task UploadFile(InputFileChangeEventArgs e)
|
|
{
|
|
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
|
|
// leggo il contenuto del PRIMO (singolo) file
|
|
IBrowserFile file = e.File;
|
|
// limite file size (al momento 10 MB)
|
|
var maxAllowedSize = 10* 1024 * 1024;
|
|
|
|
using var stream = file.OpenReadStream(maxAllowedSize);
|
|
using var reader = new StreamReader(stream);
|
|
string rawContent = await reader.ReadToEndAsync();
|
|
// parametri richiesta
|
|
Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}");
|
|
Args.Add("Btl", rawContent);
|
|
await EC_OnSave.InvokeAsync(Args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Componente SVG da mostrare
|
|
/// </summary>
|
|
protected MarkupString outSvg
|
|
{
|
|
get
|
|
{
|
|
// aggiunta gestione classe svg per posizionamento con costraints
|
|
var newSvg = LiveSVG.Replace("<svg", $"<svg class=\"{CssSvg}\"");
|
|
return (MarkupString)newSvg;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|