using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
|
namespace HH.WCS.Mobox3.pinggao.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 WCSSeverUrl { get; set; }
|
public static string SapUrl { 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<transportInfo> transportInfos { get; set; } = new List<transportInfo>();
|
public static List<connectArea> connectAreas { get; set; } = new List<connectArea>();
|
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 AREACode { get; set; }
|
public static string FacCode { get; set; }
|
|
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);
|
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 == "WCSSeverUrl")
|
{
|
WCSSeverUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "SapUrl")
|
{
|
SapUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "AreaCode")
|
{
|
AREACode = 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());
|
}
|
if (keyValue.Name == "TransportInfo")
|
{
|
transportInfos = JsonConvert.DeserializeObject<List<transportInfo>>(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "ConnectArea")
|
{
|
connectAreas = JsonConvert.DeserializeObject<List<connectArea>>(keyValue.Value.ToString());
|
}
|
}
|
}
|
}
|
LogHelper.Info("加载配置文件信息 完成");
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
|
}
|
|
}
|
|
public class Tasktype
|
{
|
public string StartArea { get; set; }
|
public string EndArea { get; set; }
|
public string TaskType { get; set; }
|
}
|
|
|
public class connectArea
|
{
|
/// <summary>
|
/// 产线号
|
/// </summary>
|
public string deviceName { get; set; }
|
/// <summary>
|
/// 货位属性 空/满
|
/// </summary>
|
public string locAttribute { get; set; }
|
/// <summary>
|
/// 连接库区
|
/// </summary>
|
public string[] connectAreaList { get; set; }
|
public int enable { get; set; }
|
}
|
|
|
public class transportInfo
|
{
|
/// <summary>
|
/// 起点库区
|
/// </summary>
|
public string startArea { get; set; }
|
/// <summary>
|
/// 起点库区密集
|
/// </summary>
|
public string startAreaRowLock { get; set; }
|
/// <summary>
|
/// 起点货位属性
|
/// </summary>
|
public string startLocAttribute { get; set; }
|
/// <summary>
|
/// 按创建时间出
|
/// </summary>
|
public string startLocCreatTime { get; set; }
|
/// <summary>
|
/// 终点库区
|
/// </summary>
|
public string endArea { get; set; }
|
/// <summary>
|
/// 终点库区密集
|
/// </summary>
|
public string endAreaRowLock { get; set; }
|
/// <summary>
|
/// 终点货位属性
|
/// </summary>
|
public string endLocAttribute { get; set; }
|
public int 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; }
|
/// <summary>
|
/// 可口可乐项目 1:注塑机
|
/// </summary>
|
public int deviceType { get; set; }
|
public int enable { get; set; }
|
}
|
public class TableName
|
{
|
public string name { get; set; }
|
public string code { get; set; }
|
}
|
|
}
|
}
|