18 using erminas.SmartAPI.CMS.ServerManagement;
19 using erminas.SmartAPI.Utils;
21 namespace erminas.SmartAPI.CMS.Project
28 string DatabaseName {
get; }
38 string DescriptionInCurrentDisplayLanguage {
get; }
44 internal class DatabaseConnection : PartialRedDotProjectObject, IDatabaseConnection
46 private string _databaseName;
47 private DatabaseServer _databaseServer;
48 private string _description;
50 internal DatabaseConnection(IProject project, Guid guid) : base(project, guid)
54 internal DatabaseConnection(IProject project, XmlElement xmlElement) : base(project, xmlElement)
62 public string DatabaseName
64 get {
return LazyLoad(ref _databaseName); }
72 get {
return LazyLoad(ref _databaseServer); }
78 public string DescriptionInCurrentDisplayLanguage
80 get {
return LazyLoad(ref _description); }
83 protected override void LoadWholeObject()
88 protected override XmlElement RetrieveWholeObject()
90 const string LOAD_DATABASE_CONNECTION =
@"<DATABASE action=""load"" guid=""{0}""/>";
91 XmlDocument xmlDoc = Project.ExecuteRQL(String.Format(LOAD_DATABASE_CONNECTION, Guid.ToRQLString()),
93 XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName(
"DATABASE");
94 if (xmlNodes.Count != 1)
96 throw new ArgumentException(
"Could not find database connection with guid " + Guid.ToRQLString());
98 return (XmlElement) xmlNodes[0];
101 private void LoadXml()
103 InitIfPresent(ref _description,
"description", x => x);
104 InitIfPresent(ref _databaseServer,
"databaseserverguid",
105 x =>
new DatabaseServer(Project.Session, GuidConvert(x)));
106 InitIfPresent(ref _databaseName,
"databasename", x => x);