using System;
|
using System.Collections.Generic;
|
using HH.WCS.Mobox3.Template.Entity.Dto;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
|
namespace HH.WCS.Mobox3.Template.Util.Helper
|
{
|
public class Settings
|
{
|
public static string HostToAgvServerUrl { get; set; }
|
public static string HASeverUrl { get; set; }
|
public static string SqlServer { get; set; }
|
public static string WMSBaseUrl { get; set; }
|
public static string FourWayCarBaseUrl { get; set; }
|
public static int port { get; set; }
|
|
/// <summary>
|
/// 输送线线体配置
|
/// </summary>
|
public static List<ConveyorlinesInfoDto> ConveyorlinesInfos { 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 == "FourWayCarBaseUrl")
|
{
|
FourWayCarBaseUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "WMSBaseUrl")
|
{
|
WMSBaseUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "HASeverUrl") {
|
HASeverUrl = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "SqlServer") {
|
SqlServer = keyValue.Value.ToString();
|
}
|
if (keyValue.Name == "ApiPort") {
|
port = int.Parse(keyValue.Value.ToString());
|
}
|
if (keyValue.Name == "ConveyorlinesInfos") {
|
ConveyorlinesInfos = JsonConvert.DeserializeObject<List<ConveyorlinesInfoDto>>(keyValue.Value.ToString());
|
}
|
}
|
}
|
}
|
LogHelper.Info("加载配置文件信息 完成");
|
}
|
catch (Exception ex) {
|
LogHelper.Error("加载配置文件失败!" + ex.Message, ex);
|
}
|
|
}
|
}
|
}
|