using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace HH.WCS.JingyuNongfu.util
|
{
|
public class Settings
|
{
|
public static string HostToAgvServerUrl { get; set; }
|
public static string OITcpSeverUrl { get; set; }
|
public static string SqlServer { get; set; }
|
public static string Time { get; set; }
|
public static List<deviceInfo> deviceInfos { get; set; }
|
public static List<zoneInfo> ppZones { get; set; }
|
public static List<zoneInfo1> cpZones { get; set; }
|
public static List<taskTypePri> taskTypePris { get; set; }
|
|
public static List<ThirdPartyUrlModel> GetThirdPartyUrlList { get; set; }
|
|
public static List<HttpApiVerifyModel> GetHttpApiVerifyList { get; set; }
|
public static List<transport> Gettransport { get; set; }
|
public static string FactoryCode { get; set; }
|
|
public static string FactoryName { get; set; }
|
|
public static string ProjectName { get; set; }
|
public static string OneSign { get; set; }
|
public static void Init()
|
{
|
LogHelper.Info("加载配置文件信息 开始");
|
try
|
{
|
var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/config/config.json";
|
//var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "config.json";
|
using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
|
{
|
using (JsonTextReader reader = new JsonTextReader(file))
|
{
|
JObject o = (JObject)JToken.ReadFrom(reader);
|
foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties())
|
{
|
Console.WriteLine(keyValue.Name);
|
if (keyValue.Name == "TableName")
|
{
|
var list = JsonConvert.DeserializeObject<List<TableName>>(keyValue.Value.ToString());
|
list.ForEach(a => STAttribute.attributes.Add(a.name, a.code));
|
}
|
if (keyValue.Name == "HostToAgvServerUrl")
|
{
|
HostToAgvServerUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "Time")
|
{
|
Time = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "OITcpSeverUrl")
|
{
|
OITcpSeverUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "SqlServer")
|
{
|
SqlServer = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "DeviceInfo")
|
{
|
deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "DeviceInfo")
|
{
|
deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "PPZone")
|
{
|
ppZones = JsonConvert.DeserializeObject<List<zoneInfo>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "CPZone")
|
{
|
cpZones = JsonConvert.DeserializeObject<List<zoneInfo1>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "taskTypePri")
|
{
|
taskTypePris = JsonConvert.DeserializeObject<List<taskTypePri>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "GetThirdPartyUrlList")
|
{
|
GetThirdPartyUrlList = JsonConvert.DeserializeObject<List<ThirdPartyUrlModel>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "FactoryCode")
|
{
|
FactoryCode = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "FactoryName")
|
{
|
FactoryName = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "GetHttpApiVerifyList")
|
{
|
GetHttpApiVerifyList = JsonConvert.DeserializeObject<List<HttpApiVerifyModel>>(keyValue.Value.ToString());
|
} if (keyValue.Name == "transport")
|
{
|
Gettransport = JsonConvert.DeserializeObject<List<transport>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "ProjectName")
|
{
|
ProjectName = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "OneSign")
|
{
|
OneSign = keyValue.Value.ToString();
|
}
|
}
|
}
|
}
|
LogHelper.Info("加载配置文件信息 完成");
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
|
}
|
|
}
|
|
public class ThirdPartyUrlModel
|
{
|
/// <summary>
|
/// URL编号-唯一
|
/// </summary>
|
public string UrlNo { get; set; }
|
/// <summary>
|
/// URL标识名
|
/// </summary>
|
public string UrlName { get; set; }
|
/// <summary>
|
/// URL路径
|
/// </summary>
|
public string Url { get; set; }
|
/// <summary>
|
/// 是否启用
|
/// </summary>
|
public string Enable { get; set; }
|
}
|
public class deviceInfo
|
{
|
public string address { get; set; }
|
public string deviceName { get; set; }
|
public string[] deviceNo { get; set; }
|
public string[] location { get; set; }
|
|
public int deviceType { get; set; }
|
public int enable { get; set; }
|
}
|
public class TableName
|
{
|
public string name { get; set; }
|
public string code { get; set; }
|
}
|
|
public class zoneInfo
|
{
|
public string zone { get; set; }
|
public string deviceName { get; set; }
|
/// <summary>
|
/// </summary>
|
public int zoneType { get; set; }
|
public int[] rows { get; set; }
|
|
public string[] bits { get; set; }
|
|
}
|
public class zoneInfo1
|
{
|
public string deviceName { get; set; }
|
/// <summary>
|
/// 库区列表,按数组下标顺序选择
|
/// </summary>
|
public string[] zone { get; set; }
|
|
/// <summary>
|
///zoneType=0 成品下线区域(一条线可以下线去多个库区,库区优先级按数组顺序排列)
|
///zoneType=1 空双托上线区
|
///zoneType=2 空单托上线区
|
///zoneType=3 空托准备区-双托
|
/// </summary>
|
public int zoneType { get; set; }
|
}
|
|
public class HttpApiVerifyModel
|
{
|
/// <summary>
|
/// 验证编码
|
/// </summary>
|
public string VerifyNo { get; set; }
|
/// <summary>
|
/// 项目编码
|
/// </summary>
|
public string Project { get; set; }
|
/// <summary>
|
/// 扩展编码
|
/// </summary>
|
public string[] Extend { get; set; }
|
/// <summary>
|
/// 是否启用
|
/// </summary>
|
public string Enable { get; set; }
|
}
|
|
/// <summary>
|
/// 任务类型对应优先级
|
/// </summary>
|
public class taskTypePri
|
{
|
public string name { get; set; }
|
public int pri { get; set; }
|
}
|
public class transport
|
{
|
public string startloc { get; set; }
|
public string endloc { get; set; }
|
}
|
}
|
}
|