falta que se actualize numProducto y los infomes
This commit is contained in:
42
Controladora/ControladoraInformes.cs
Normal file
42
Controladora/ControladoraInformes.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Informes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Controladora
|
||||
{
|
||||
public class ControladoraInformes : Singleton<ControladoraInformes>
|
||||
{
|
||||
const string configpath = "settings.json";
|
||||
|
||||
public void GuardarConfig(ConfigEmail config)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configpath, json);
|
||||
|
||||
}
|
||||
catch (IOException ex) { throw; }
|
||||
}
|
||||
|
||||
public ConfigEmail RecuperarConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(configpath))
|
||||
{
|
||||
string json = JsonSerializer.Serialize(new ConfigEmail { EmailAddr = "", EmailPass = "", EmailTarget = new List<String>() }, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configpath, json);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) { throw; }
|
||||
|
||||
string jsonString = File.ReadAllText(configpath);
|
||||
return JsonSerializer.Deserialize<ConfigEmail>(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user