|
@@ -19,6 +19,7 @@ namespace Sers.Gover.Base
|
|
{
|
|
{
|
|
[JsonProperty]
|
|
[JsonProperty]
|
|
ConcurrentDictionary<string, ApiStationData> apiStations;
|
|
ConcurrentDictionary<string, ApiStationData> apiStations;
|
|
|
|
+
|
|
GoverApiCenterService goverManage;
|
|
GoverApiCenterService goverManage;
|
|
public ApiStationMng()
|
|
public ApiStationMng()
|
|
{
|
|
{
|
|
@@ -111,12 +112,6 @@ namespace Sers.Gover.Base
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
ApiStationData ApiStation_Get(string route)
|
|
ApiStationData ApiStation_Get(string route)
|
|
{
|
|
{
|
|
@@ -147,6 +142,60 @@ namespace Sers.Gover.Base
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ #region ApiService
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 移除离线的ApiService
|
|
|
|
+ /// </summary>
|
|
|
|
+ public void ApiService_RemoveOffline()
|
|
|
|
+ {
|
|
|
|
+ List<ApiStationData> changedApiStationList;
|
|
|
|
+
|
|
|
|
+ lock (this)
|
|
|
|
+ {
|
|
|
|
+ var apiServiceItems = (from apiStation in apiStations.Values
|
|
|
|
+ from apiService in apiStation.apiServices.Values
|
|
|
|
+ where apiService.apiNodeCount==0
|
|
|
|
+ select (apiStation,apiService)).ToList();
|
|
|
|
+
|
|
|
|
+ foreach (var (apiStation, apiService) in apiServiceItems)
|
|
|
|
+ {
|
|
|
|
+ apiStation.ApiService_Remove(apiService.apiDesc.ServiceKeyGet());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ changedApiStationList = apiServiceItems.Select(m => m.apiStation).Distinct().ToList();
|
|
|
|
+
|
|
|
|
+ foreach (var apiStation in changedApiStationList)
|
|
|
|
+ {
|
|
|
|
+ if (apiStation.apiServiceCount == 0)
|
|
|
|
+ {
|
|
|
|
+ ApiStation_Remove(apiStation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #region 持久化对应ApiStation中的所有ApiDesc(异步执行)
|
|
|
|
+ Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ foreach (var apiStation in changedApiStationList)
|
|
|
|
+ {
|
|
|
|
+ Persistence_ApiDesc.ApiDesc_SaveApiStationToJsonFile(apiStation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ Logger.Error(ex);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
#region ApiNode
|
|
#region ApiNode
|
|
|
|
|
|
static bool Config_ApiRegistEvent_Print = (false != ConfigurationManager.Instance.GetByPath<bool?>("Sers.ServiceCenter.ApiRegistEvent_Print"));
|
|
static bool Config_ApiRegistEvent_Print = (false != ConfigurationManager.Instance.GetByPath<bool?>("Sers.ServiceCenter.ApiRegistEvent_Print"));
|
|
@@ -207,6 +256,10 @@ namespace Sers.Gover.Base
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
#region ServiceStation
|
|
#region ServiceStation
|
|
|
|
|
|
#region ServiceStation_Add
|
|
#region ServiceStation_Add
|