17 using System.Collections.Generic;
20 using erminas.SmartAPI.Utils;
21 using erminas.SmartAPI.Utils.CachedCollections;
23 namespace erminas.SmartAPI.CMS.ServerManagement
25 internal class ApplicationServers : RDList<IApplicationServer>, IApplicationServers
27 private readonly Lazy<IApplicationServer> _currentApplicationServer;
28 private readonly Session _session;
30 public ApplicationServers(Session session,
Caching caching) : base(caching)
33 RetrieveFunc = GetApplicationServers;
34 _currentApplicationServer =
new Lazy<IApplicationServer>(GetCurrentApplicationServer);
37 public IApplicationServer Current
39 get {
return _currentApplicationServer.Value; }
42 public ISession Session
44 get {
return _session; }
47 private List<IApplicationServer> GetApplicationServers()
49 const string LIST_APPLICATION_SERVERS =
50 @"<ADMINISTRATION><EDITORIALSERVERS action=""list""/></ADMINISTRATION>";
51 XmlDocument xmlDoc = _session.ExecuteRQL(LIST_APPLICATION_SERVERS);
53 XmlNodeList editorialServers = xmlDoc.GetElementsByTagName(
"EDITORIALSERVER");
54 return (from XmlElement curServer in editorialServers
57 new ApplicationServer(_session, curServer.GetGuid())
59 Name = curServer.GetName(),
60 IpAddress = curServer.GetAttributeValue(
"ip")
64 private IApplicationServer GetCurrentApplicationServer()
66 const string LOAD_APPLICATIONSERVER =
67 @"<ADMINISTRATION><EDITORIALSERVER action=""check""/></ADMINISTRATION>";
68 XmlDocument reply = _session.ExecuteRQL(LOAD_APPLICATIONSERVER, RQL.IODataFormat.Plain);
69 return new ApplicationServer(_session, reply.GetSingleElement(
"EDITORIALSERVER").GetGuid(
"serverguid"));