93 lines
2.6 KiB
C#
93 lines
2.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace XKRS.Common.Model.Helper
|
|||
|
{
|
|||
|
public static class SettingHelper
|
|||
|
{
|
|||
|
const string SETTINGFILE = "Setting.json";
|
|||
|
//声明一个SettingInfo类型的字段
|
|||
|
public static SettingInfo SettingInfo;
|
|||
|
public static string SettingPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SETTINGFILE);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 声明一个静态方法,获取选择的布局
|
|||
|
/// </summary>
|
|||
|
/// <returns>返回当前布局</returns>
|
|||
|
public static string GetSelectLayout()
|
|||
|
{
|
|||
|
return SettingInfo.CurrLayout;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 获取生产代码,
|
|||
|
/// </summary>
|
|||
|
/// <returns>字符串类型的集合</returns>
|
|||
|
public static List<string> GetProductionCodes()
|
|||
|
{
|
|||
|
if (SettingInfo.ProductionCodes.Count == 0)
|
|||
|
{
|
|||
|
SettingInfo.ProductionCodes.Add("Default");
|
|||
|
}
|
|||
|
if (!string.IsNullOrWhiteSpace(SettingInfo.DefaultProduction))
|
|||
|
{
|
|||
|
if (SettingInfo.ProductionCodes.Contains(SettingInfo.DefaultProduction))
|
|||
|
{
|
|||
|
SettingInfo.ProductionCodes.Remove(SettingInfo.DefaultProduction);
|
|||
|
SettingInfo.ProductionCodes.Insert(0, SettingInfo.DefaultProduction);
|
|||
|
}
|
|||
|
}
|
|||
|
return SettingInfo.ProductionCodes;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取过程代码
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<string> GetProcessCodes()
|
|||
|
{
|
|||
|
if (!string.IsNullOrWhiteSpace(SettingInfo.DefaultProcess))
|
|||
|
{
|
|||
|
if (SettingInfo.ProcessCodes.Contains(SettingInfo.DefaultProcess))
|
|||
|
{
|
|||
|
SettingInfo.ProcessCodes.Remove(SettingInfo.DefaultProcess);
|
|||
|
SettingInfo.ProcessCodes.Insert(0, SettingInfo.DefaultProcess);
|
|||
|
}
|
|||
|
}
|
|||
|
return SettingInfo.ProcessCodes;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 设置信息类,声明自动属性
|
|||
|
/// </summary>
|
|||
|
public class SettingInfo
|
|||
|
{
|
|||
|
public List<string> ProcessCodes { get; set; } = new List<string>();
|
|||
|
public List<string> ProductionCodes { get; set; } = new List<string>();
|
|||
|
|
|||
|
public string DefaultProcess { get; set; }
|
|||
|
public string DefaultProduction { get; set; }
|
|||
|
public string CurrLayout { get; set; } = "";
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|