47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using IDIS.Model;
|
|
using IDIS.Models;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace IDIS.YL106.Model;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main()
|
|
{
|
|
var list = new List<IDIS_Model>
|
|
{
|
|
new Data_Oder(),
|
|
new Object_Equipment(),
|
|
new Object_Material(),
|
|
new Object_Product(),
|
|
new Procedure_Assembly(),
|
|
new Procedure_Transport()
|
|
};
|
|
|
|
var currentDirectory = Environment.CurrentDirectory;
|
|
#if DEBUG
|
|
currentDirectory = new DirectoryInfo(currentDirectory).Parent!.Parent!.Parent?.FullName!;
|
|
#endif
|
|
currentDirectory = Path.Combine(currentDirectory, "Samples");
|
|
|
|
Console.WriteLine("生成的样本将保存于: " + currentDirectory);
|
|
|
|
new DirectoryInfo(currentDirectory).Create();
|
|
foreach (var x in list)
|
|
{
|
|
var templatePath = Path.Combine(currentDirectory, $"{x.GetType().Name}_Template.json");
|
|
var registerPath = Path.Combine(currentDirectory, $"{x.GetType().Name}_Register.json");
|
|
var registerData = new IDIS_Register_Data
|
|
{
|
|
Handle = $"88.123.99/{DateTime.Now.Ticks}",
|
|
TemplateVersion = "Template-1.0.0",
|
|
Value = x.AsValueInfo()
|
|
};
|
|
File.WriteAllText(templatePath,JsonConvert.SerializeObject(x.AsTemplate(),Formatting.Indented));
|
|
File.WriteAllText(registerPath,JsonConvert.SerializeObject(registerData,Formatting.Indented));
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine($"生成了{x.GetType().Name}的样本,模板保存于\n{templatePath},注册数据保存于\n{registerPath}");
|
|
}
|
|
}
|
|
} |