16 using System.Collections.Generic;
19 using erminas.SmartAPI.Utils.CachedCollections;
21 namespace erminas.SmartAPI.CMS.ServerManagement
23 internal class ServerManager : IServerManager
25 private readonly Session _session;
27 internal ServerManager(Session session)
31 Groups =
new Groups(_session,
Caching.Enabled);
32 Projects =
new Projects(_session,
Caching.Enabled);
33 DatabaseServers =
new DatabaseServers(_session,
Caching.Enabled);
34 Users =
new Users(_session,
Caching.Enabled);
35 Modules =
new IndexedRDList<ModuleType, IModule>(GetModules, x => x.Type,
Caching.Enabled);
36 AsynchronousProcesses =
new RDList<IAsynchronousProcess>(GetAsynchronousProcesses,
Caching.Disabled);
37 ApplicationServers =
new ApplicationServers(_session,
Caching.Enabled);
40 public IApplicationServers ApplicationServers {
get;
private set; }
42 public IRDList<IAsynchronousProcess> AsynchronousProcesses {
get;
private set; }
43 public IDatabaseServers DatabaseServers {
get;
private set; }
44 public IGroups Groups {
get;
private set; }
45 public IIndexedRDList<ModuleType, IModule> Modules {
get;
private set; }
47 public IProjects Projects {
get;
private set; }
48 public IUsers Users {
get;
private set; }
50 private List<IAsynchronousProcess> GetAsynchronousProcesses()
52 const string LIST_PROCESSES =
@"<ADMINISTRATION><ASYNCQUEUE action=""list"" project=""""/></ADMINISTRATION>";
53 XmlDocument xmlDoc = _session.ExecuteRQL(LIST_PROCESSES);
54 return (from XmlElement curProcess in xmlDoc.GetElementsByTagName(
"ASYNCQUEUE")
55 select (IAsynchronousProcess) new AsynchronousProcess(_session, curProcess)).ToList();
58 private List<IModule> GetModules()
60 const string LIST_MODULES =
@"<ADMINISTRATION><MODULES action=""list"" /></ADMINISTRATION>";
61 XmlDocument xmlDoc = _session.ExecuteRQL(LIST_MODULES);
66 List<XmlElement> moduleElements = xmlDoc.GetElementsByTagName(
"MODULE").OfType<XmlElement>().ToList();
68 (from XmlElement curModule in moduleElements select (IModule)
new Module(_session, curModule)).ToList();
82 IRDList<IAsynchronousProcess> AsynchronousProcesses {
get; }
87 IIndexedRDList<ModuleType, IModule> Modules {
get; }