18 using erminas.SmartAPI.Exceptions;
19 using erminas.SmartAPI.Utils;
21 namespace erminas.SmartAPI.CMS.ServerManagement
26 string EMailAdress {
get;
set; }
27 new string Name {
get;
set; }
30 public static class GroupFactory
32 public static IGroup CreateFromGuid(
ISession session, Guid guid)
34 return new Group(session, guid);
38 internal class Group : PartialRedDotObject, IGroup
40 private string _email;
42 internal Group(ISession session, XmlElement xmlElement) : base(session, xmlElement)
47 internal Group(ISession session, Guid guid) : base(session, guid)
53 const string SAVE_GROUP =
54 @"<ADMINISTRATION><GROUP action=""save"" guid=""{0}"" name=""{1}"" email=""{2}""/></ADMINISTRATION>";
56 var xmlDoc = Session.ExecuteRQL(SAVE_GROUP.SecureRQLFormat(
this, Name, EMailAdress));
57 if (!xmlDoc.InnerText.Contains(Guid.ToRQLString()))
59 throw new SmartAPIException(Session.ServerLogin,
string.Format(
"Could not save group {0}",
this));
65 const string DELETE_GROUP =
@"<ADMINISTRATION><GROUP action=""delete"" guid=""{0}""/></ADMINISTRATION>";
66 var xmlDoc = Session.ExecuteRQL(DELETE_GROUP.RQLFormat(
this));
67 if (!xmlDoc.IsContainingOk())
69 throw new SmartAPIException(Session.ServerLogin,
string.Format(
"Could not delete group {0}",
this));
73 public string EMailAdress
75 get {
return LazyLoad(ref _email); }
78 EnsureInitialization();
83 public new string Name
85 get {
return base.Name; }
88 EnsureInitialization();
93 protected override void LoadWholeObject()
98 protected override XmlElement RetrieveWholeObject()
100 const string LOAD_GROUP =
@"<ADMINISTRATION><GROUP action=""load"" guid=""{0}""/></ADMINISTRATION>";
101 return Session.ExecuteRQL(LOAD_GROUP.RQLFormat(
this)).GetSingleElement(
"GROUP");
104 private void LoadXml()
106 _email = _xmlElement.GetAttributeValue(
"email");