using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
|
namespace HH.WCS.Mobox3.YNJuXing.util
|
{
|
public class Settings
|
{
|
|
|
public static string HostToAgvServerUrl { get; set; }
|
public static string HASeverUrl { get; set; }
|
public static string AppKey { get; set; }
|
public static string AppSecret { get; set; }
|
public static string MoboxSeverUrl { get; set; }
|
public static string SqlServer { get; set; }
|
public static string SqlServer1 { get; set; }
|
public static List<deviceInfo> deviceInfos { get; set; } = new List<deviceInfo>();
|
public static List<Tasktype> Tasktypes { get; set; } = new List<Tasktype>();
|
|
|
public static int port { get; set; }
|
public static string WHCode { get; set; }
|
public static string FacCode { get; set; }
|
|
|
|
#region 越南巨星三期
|
public static string LiKUAreaNo { get; set; }
|
public static string LiKUAreaNo2 { get; set; }
|
public static string clientKey1 { get; set; }
|
public static string clientKey2 { get; set; }
|
public static string GLclientKey1 { get; set; }
|
public static string GLclientKey2 { get; set; }
|
public static string JXCODE { get; set; }
|
public static string GLCODE { get; set; }
|
public static string JWCODE { get; set; }
|
public static List<string> DuiDuoHeight { get; set; } = new List<string>();
|
public static List<string> ContrlBitList { get; set; } = new List<string>();
|
public static List<DuiDuoCodeModel> DuiDuoCodes = new List<DuiDuoCodeModel>();
|
public static List<InOutLocationModel> InOutLocations = new List<InOutLocationModel>();
|
public static List<ExtendParamSettingModel> ExtendParamSettings = new List<ExtendParamSettingModel>();
|
#endregion
|
|
public static void Init()
|
{
|
LogHelper.Info("加载配置文件信息 开始");
|
try
|
{
|
var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/config/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);
|
#region 越南巨星三期
|
if (keyValue.Name == "LiKUAreaNo")
|
{
|
LiKUAreaNo = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "LiKUAreaNo2")
|
{
|
LiKUAreaNo2 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "clientKey1")
|
{
|
clientKey1 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "clientKey2")
|
{
|
clientKey2 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "GLclientKey1")
|
{
|
GLclientKey1 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "GLclientKey2")
|
{
|
GLclientKey2 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "JXCODE")
|
{
|
JXCODE = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "GLCODE")
|
{
|
GLCODE = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "JWCODE")
|
{
|
JWCODE = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "DuiDuoHeight")
|
{
|
DuiDuoHeight = JsonConvert.DeserializeObject<List<string>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "ContrlBitList")
|
{
|
ContrlBitList = JsonConvert.DeserializeObject<List<string>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "DuiDuoCode")
|
{
|
DuiDuoCodes = JsonConvert.DeserializeObject<List<DuiDuoCodeModel>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "InOutLocation")
|
{
|
InOutLocations = JsonConvert.DeserializeObject<List<InOutLocationModel>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "ExtendParamSetting")
|
{
|
ExtendParamSettings = JsonConvert.DeserializeObject<List<ExtendParamSettingModel>>(keyValue.Value.ToString());
|
}
|
#endregion
|
if (keyValue.Name == "HostToAgvServerUrl")
|
{
|
HostToAgvServerUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "Tasktype")
|
{
|
Tasktypes = JsonConvert.DeserializeObject<List<Tasktype>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "HASeverUrl")
|
{
|
HASeverUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "AppKey")
|
{
|
AppKey = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "AppSecret")
|
{
|
AppSecret = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "MoboxSeverUrl")
|
{
|
MoboxSeverUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "SqlServer")
|
{
|
SqlServer = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "SqlServer1")
|
{
|
SqlServer1 = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "WHCode")
|
{
|
WHCode = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "FacCode")
|
{
|
FacCode = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "ApiPort")
|
{
|
port = int.Parse(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "DeviceInfo")
|
{
|
deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString());
|
}
|
}
|
}
|
}
|
LogHelper.Info("加载配置文件信息 完成");
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
|
}
|
|
}
|
|
public class ExtendParamSettingModel
|
{
|
/// <summary>
|
/// 扩展参数编号-唯一
|
/// </summary>
|
public string ExtendNo { get; set; }
|
/// <summary>
|
/// 扩展参数标识名
|
/// </summary>
|
public string ExtendName { get; set; }
|
/// <summary>
|
/// 扩展参数值
|
/// </summary>
|
public string ExtendParam { get; set; }
|
/// <summary>
|
/// 是否启用
|
/// </summary>
|
public string Enable { get; set; }
|
}
|
|
public class InOutLocationModel
|
{
|
public string Location { get; set; }
|
public string Code { get; set; }
|
}
|
|
public class DuiDuoCodeModel
|
{
|
public string roadway { get; set; }
|
public string code { get; set; }
|
}
|
|
|
public class Tasktype
|
{
|
public string StartArea { get; set; }
|
public string EndArea { get; set; }
|
public string TaskType { get; set; }
|
}
|
|
|
|
public class deviceInfo
|
{
|
public string address { get; set; }
|
public string deviceName { get; set; }
|
public string[] deviceNo { get; set; }
|
public string[] TN_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; }
|
}
|
|
}
|
}
|