101 lines
3.9 KiB
C#
101 lines
3.9 KiB
C#
using CapMachine.Model;
|
|
|
|
namespace CapMachine.Wpf.Models
|
|
{
|
|
/// <summary>
|
|
/// 种子数据
|
|
/// </summary>
|
|
public class SeekData
|
|
{
|
|
public SeekData(IFreeSql freeSql)
|
|
{
|
|
FreeSql = freeSql;
|
|
|
|
LoadChartTabGroupData();
|
|
LoadConfigChartYAxisData();
|
|
LoadUserData();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 加载Tab数据
|
|
/// </summary>
|
|
public void LoadChartTabGroupData()
|
|
{
|
|
var FindChartTabGroupData = FreeSql.Select<ChartTabGroup>().ToList();
|
|
|
|
if (FindChartTabGroupData!.Count() == 0)
|
|
{
|
|
var ListChartTabGroup = new List<ChartTabGroup>()
|
|
{
|
|
new ChartTabGroup(){ Index=0,IsEnable=true,Machine="M1",Name="工况1"},
|
|
new ChartTabGroup(){ Index=1,IsEnable=true,Machine="M1",Name="工况2"},
|
|
new ChartTabGroup(){ Index=2,IsEnable=true,Machine="M1",Name="工况3"},
|
|
new ChartTabGroup(){ Index=3,IsEnable=true,Machine="M1",Name="工况4"},
|
|
new ChartTabGroup(){ Index=4,IsEnable=true,Machine="M1",Name="工况5"},
|
|
};
|
|
FreeSql.Insert<ChartTabGroup>(ListChartTabGroup).ExecuteAffrows();
|
|
}
|
|
|
|
var FindHistoryChartTabGroup = FreeSql.Select<HistoryChartTabGroup>().ToList();
|
|
|
|
if (FindHistoryChartTabGroup!.Count() == 0)
|
|
{
|
|
var ListChartTabGroup = new List<HistoryChartTabGroup>()
|
|
{
|
|
new HistoryChartTabGroup(){ Index=0,IsEnable=true,Machine="History",Name="工况1"},
|
|
new HistoryChartTabGroup(){ Index=1,IsEnable=true,Machine="History",Name="工况2"},
|
|
new HistoryChartTabGroup(){ Index=2,IsEnable=true,Machine="History",Name="工况3"},
|
|
new HistoryChartTabGroup(){ Index=3,IsEnable=true,Machine="History",Name="工况4"},
|
|
new HistoryChartTabGroup(){ Index=4,IsEnable=true,Machine="History",Name="工况5"},
|
|
};
|
|
FreeSql.Insert<HistoryChartTabGroup>(ListChartTabGroup).ExecuteAffrows();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载Y轴的数据
|
|
/// </summary>
|
|
public void LoadConfigChartYAxisData()
|
|
{
|
|
var FindConfigChartYAxis = FreeSql.Select<ConfigChartYAxis>().ToList();
|
|
|
|
if (FindConfigChartYAxis!.Count() == 0)
|
|
{
|
|
var ListConfigChartYAxis = new List<ConfigChartYAxis>()
|
|
{
|
|
new ConfigChartYAxis(){ Index=0,Min=0,Max=100,Name="温度",Unit="℃"},
|
|
new ConfigChartYAxis(){ Index=1,Min=0,Max=100,Name="湿度",Unit="%"},
|
|
new ConfigChartYAxis(){ Index=2,Min=0,Max=8000,Name="转速",Unit="rpm"},
|
|
new ConfigChartYAxis(){ Index=3,Min=0,Max=100,Name="电压",Unit="V"},
|
|
new ConfigChartYAxis(){ Index=4,Min=0,Max=100,Name="电流",Unit="A"},
|
|
new ConfigChartYAxis(){ Index=5,Min=0,Max=5,Name="压力",Unit="MpaA"},
|
|
new ConfigChartYAxis(){ Index=6,Min=0,Max=5,Name="流量",Unit="L/min"},
|
|
new ConfigChartYAxis(){ Index=7,Min=0,Max=5,Name="功率",Unit="W"},
|
|
};
|
|
FreeSql.Insert<ConfigChartYAxis>(ListConfigChartYAxis).ExecuteAffrows();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载Y轴的数据
|
|
/// </summary>
|
|
public void LoadUserData()
|
|
{
|
|
var FindUser = FreeSql.Select<User>().ToList();
|
|
|
|
if (FindUser!.Count() == 0)
|
|
{
|
|
var ListUser = new List<User>()
|
|
{
|
|
new User(){ Name="admin",Password="123",Level="管理员",IsEnable=true},
|
|
};
|
|
FreeSql.Insert<User>(ListUser).ExecuteAffrows();
|
|
}
|
|
|
|
}
|
|
public IFreeSql FreeSql { get; }
|
|
}
|
|
}
|