You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
using Microsoft.Win32;
|
|
using Newtonsoft.Json;
|
|
using MODELING_DEF_DES_MI_VI.Interfaces;
|
|
using MODELING_DEF_DES_MI_VI.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
|
|
namespace MODELING_DEF_DES_MI_VI.Controllers
|
|
{
|
|
public class ReportGenerator : BaseSaveLoadController
|
|
{
|
|
public string AddOther(string fileName)
|
|
{
|
|
return
|
|
".\\results\\"
|
|
+ fileName + "_"
|
|
+ DateTime.Now.ToString("yyyyMMdd_HHmmss")
|
|
+ ".mdl";
|
|
}
|
|
|
|
public override DataType Load<DataType>()
|
|
{
|
|
try
|
|
{
|
|
var dialog = new OpenFileDialog();
|
|
if (dialog.ShowDialog() != true)
|
|
return default(DataType);
|
|
var data = File.ReadAllText(dialog.FileName);
|
|
var output = JsonConvert.DeserializeObject<DataType>(data);
|
|
return output;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
return default(DataType);
|
|
}
|
|
}
|
|
|
|
public override void Save<DataType>(DataType data, string fileName)
|
|
{
|
|
var output = JsonConvert.SerializeObject(data);
|
|
try
|
|
{
|
|
if (!Directory.Exists(".\\results\\")) Directory.CreateDirectory(".\\results\\");
|
|
File.WriteAllText(fileName, output);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|