|
@@ -1,95 +0,0 @@
|
|
|
-using System.Threading.Tasks;
|
|
|
-using System.Collections.Generic;
|
|
|
-using WingInterfaceLibrary.DTO.ServerInfo;
|
|
|
-using WingServerCommon.Interfaces.Cache;
|
|
|
-using System;
|
|
|
-using System.Linq;
|
|
|
-
|
|
|
-namespace WingCloudServer.InteractionCenter
|
|
|
-{
|
|
|
- interface IVinnoServerManager : IBaseCacheManager<ServerInformation>
|
|
|
- {
|
|
|
- /// <summary>
|
|
|
- /// Get All ServerInfos
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- IList<ServerInformation> GetAllServerInfos();
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Get ServerInfos with specified client id
|
|
|
- /// </summary>
|
|
|
- /// <param name="clientId">User code, admin code or device code</param>
|
|
|
- /// <returns></returns>
|
|
|
- IList<ServerInformation> GetServerInfos(string code);
|
|
|
-
|
|
|
- // <summary>
|
|
|
- /// Get tokens with specified client ids
|
|
|
- /// </summary>
|
|
|
- /// <param name="clientId">User code, admin code or device code</param>
|
|
|
- /// <returns></returns>
|
|
|
- IList<ServerInformation> GetServerInfosByCodes(List<string> codes);
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// The ServerInfo info update event
|
|
|
- /// </summary>
|
|
|
- event EventHandler<IList<ServerInformation>> ServerInfoUpdate;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Internal Server token, just used in server session module
|
|
|
- /// </summary>
|
|
|
- internal class ServerInformation : ServerInfoDTO, ICacheObject
|
|
|
- {
|
|
|
- public ServerInformation()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //
|
|
|
- // 摘要:
|
|
|
- // The token string value
|
|
|
- public string Code { get; set; }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- internal class VinnoServerManager : CacheManager<ServerInformation>, IVinnoServerManager
|
|
|
- {
|
|
|
- private bool _isWatching = true;
|
|
|
- public event EventHandler<IList<ServerInformation>> ServerInfoUpdate;
|
|
|
-
|
|
|
- public VinnoServerManager(Func<string, ServerInformation> loadCacheFromDbWithId, Func<IList<string>, IList<ServerInformation>> loadCachesFromDbWithIds) : base(loadCacheFromDbWithId, loadCachesFromDbWithIds)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Get tokens with specified client id
|
|
|
- /// </summary>
|
|
|
- /// <param name="clientId">User code, admin code or device code</param>
|
|
|
- /// <returns></returns>
|
|
|
- public IList<ServerInformation> GetServerInfos(string code)
|
|
|
- {
|
|
|
- return Where(x => x.Code == code)?.ToList() ?? new List<ServerInformation>();
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Get tokens with specified client ids
|
|
|
- /// </summary>
|
|
|
- /// <param name="clientId">User code, admin code or device code</param>
|
|
|
- /// <returns></returns>
|
|
|
- public IList<ServerInformation> GetServerInfosByCodes(List<string> codes)
|
|
|
- {
|
|
|
- return Where(x => codes.Contains(x.Code))?.ToList() ?? new List<ServerInformation>();
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// Get tokens with specified client id
|
|
|
- /// </summary>
|
|
|
- /// <param name="clientId">User code, admin code or device code</param>
|
|
|
- /// <returns></returns>
|
|
|
- public IList<ServerInformation> GetAllServerInfos()
|
|
|
- {
|
|
|
- return Where(x => !string.IsNullOrEmpty(x.Name) && !string.IsNullOrEmpty(x.Host))?.ToList() ?? new List<ServerInformation>();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|