静态数据

zw
smartwyy 6 months ago
parent f1353af778
commit 6b60d2c6d8

@ -138,6 +138,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
Connected = false;
if (AutoReConnect)
{
Thread.Sleep(5000);
Connect();
}
}
@ -147,6 +148,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
Log.Error("connect cloud error", e);
if (AutoReConnect)
{
Thread.Sleep(5000);
Connect();
}
}

@ -28,6 +28,7 @@ public class CloudClientMgr
CloudClient.AutoReConnect = true;
CloudClient.InitHandler();
CloudClient.Connect();
// Task.Run(() => CloudClient.Connect());
}
}

@ -40,7 +40,15 @@ public class StaticStationInfo
public static int CloudServerPort
{
get => int.Parse(Resolve(StationParamConst.CloudServerPort));
get
{
string port = Resolve(StationParamConst.CloudServerPort);
if (string.IsNullOrWhiteSpace(port))
{
return 33000;
}
return int.Parse(port);
}
set => Set(StationParamConst.CloudServerPort, value);
}
@ -93,7 +101,7 @@ public class StaticStationInfo
return s;
}
return "33000";
return "";
}
private static void Set(string key, object value)

@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Collections.Concurrent;
using System.ComponentModel;
using Autofac;
using Common.Enum;
using Entity.Base;
@ -19,6 +20,7 @@ namespace Service.System
[Scope("SingleInstance")]
public class SysConfigService : BaseServices<SysConfig>
{
private static readonly ConcurrentDictionary<string, string> Dictionary = new ConcurrentDictionary<string, string>();
private readonly SysConfigMgr _sysConfigMgr;
private readonly SysConfigRepository _sysConfigRep;
@ -168,6 +170,11 @@ namespace Service.System
throw new InvalidParameterException("配置数据key格式错误");
}
if (Dictionary.TryGetValue(key, out string? value))
{
return value;
}
SysConfig sysConfig = _sysConfigRep.QueryByClause(i => i.GroupCode == keys[0] && i.Code == keys[1]);
if (sysConfig == null)
{
@ -190,6 +197,10 @@ namespace Service.System
throw new InvalidParameterException("配置数据key格式错误");
}
string newValue = Convert.ToString(value);
Dictionary.AddOrUpdate(key, newValue, (s, s1) => newValue);
SysConfig sysConfig = _sysConfigRep.QueryByClause(i => i.GroupCode == keys[0] && i.Code == keys[1]);
if (sysConfig == null)
{
@ -197,14 +208,14 @@ namespace Service.System
{
GroupCode = keys[0],
Code = keys[1],
Value = value.ToString(),
Value = newValue,
SysFlag = YesNoEnum.N,
Name = key
});
}
else
{
sysConfig.Value = value.ToString();
sysConfig.Value = newValue;
_sysConfigRep.Update(sysConfig);
}

@ -1,8 +1,8 @@

using Entity.Base;
using Entity.Base;
using Entity.DbModel.System.SysBaseObject;
using Entity.Dto.Req;
using Microsoft.AspNetCore.Mvc;
using Service.Init;
using Service.System;
namespace WebStarter.Controllers.System
@ -72,5 +72,20 @@ namespace WebStarter.Controllers.System
{
await _sysConfigService.BatchDeleteConfig(input);
}
[HttpGet]
[Route("/api/sysConfig/GetStationNo")]
public string GetStationNo()
{
return StaticStationInfo.StationName;
}
[HttpGet]
[Route("/api/sysConfig/SetStationNo/{stationNo}")]
public bool SetStationNo(string stationNo)
{
StaticStationInfo.StationName = stationNo;
return true;
}
}
}

@ -1,19 +1,11 @@
{
"Version": 1,
"Hash": "FS59OvTZ9B6lpwaxIjb4jYpPMI2uWVuvwpvRJoWtEFc=",
"Hash": "7euZr+Skxn+CPwHhQ3H6LZuur9IzJqC+CYg6oY75X7A=",
"Source": "WebStarter",
"BasePath": "_content/WebStarter",
"Mode": "Default",
"ManifestType": "Build",
"ReferencedProjectsConfiguration": [],
"DiscoveryPatterns": [
{
"Name": "WebStarter\\wwwroot",
"Source": "WebStarter",
"ContentRoot": "D:\\Desktop\\huannengMain\\WebStarter\\wwwroot\\",
"BasePath": "_content/WebStarter",
"Pattern": "**"
}
],
"DiscoveryPatterns": [],
"Assets": []
}
Loading…
Cancel
Save