添加项目文件。
This commit is contained in:
25
XKRS.Common.Model/Helper/AttributeHelper.cs
Normal file
25
XKRS.Common.Model/Helper/AttributeHelper.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static XKRS.Common.Model.Helper.EnumHelper;
|
||||
|
||||
namespace XKRS.Common.Model.Helper
|
||||
{
|
||||
public class AttributeHelper:Attribute
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class ProcessAttribute : Attribute
|
||||
{
|
||||
public string ProcessCode { get; set; }
|
||||
public DeviceAttributeType AttrType { get; set; }
|
||||
public ProcessAttribute(string stationCode,DeviceAttributeType attrType)
|
||||
{
|
||||
ProcessCode = stationCode;
|
||||
AttrType = attrType;
|
||||
}
|
||||
}
|
||||
}
|
22
XKRS.Common.Model/Helper/EnumHelper.cs
Normal file
22
XKRS.Common.Model/Helper/EnumHelper.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XKRS.Common.Model.Helper
|
||||
{
|
||||
public static class EnumHelper
|
||||
{
|
||||
public enum DeviceState
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Flags]//将枚举视为位域
|
||||
public enum DeviceAttributeType
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
92
XKRS.Common.Model/Helper/SettingHelper.cs
Normal file
92
XKRS.Common.Model/Helper/SettingHelper.cs
Normal file
@ -0,0 +1,92 @@
|
||||
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; } = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user