-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUser.cs
More file actions
120 lines (108 loc) · 3.71 KB
/
User.cs
File metadata and controls
120 lines (108 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Collections.Generic;
using System.Xml;
namespace RustyLogic.RedDotNet
{
public class User : RedDotObject
{
public static readonly string DefaultUserLanguage = "ENG";
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Email
{
get
{
if (_name != "Unknown User")
{
return XmlNode.Attributes.GetNamedItem("email").Value;
}
else return null;
}
}
public string FullName
{
get
{
return XmlNode.Attributes.GetNamedItem("fullname").Value;
}
}
public DirectoryService DirectoryService
{
get
{
// account system guid is null for internal users or 200 for admin
string accountSystemGuid = XmlNode.Attributes.GetNamedItem("accountsystemguid").Value;
if (accountSystemGuid == null || accountSystemGuid == "00000000000000000000000000000200")
{
return null;
}
return new DirectoryService(new Guid(XmlNode.Attributes.GetNamedItem("accountsystemguid").Value));
}
set
{
string rqlStatement =
"<IODATA>" +
"<ADMINISTRATION>" +
"<USER action=\"save\" guid=\"" + GuidString + "\" accountsystemguid=\"" + value.GuidString + "\"/>" +
"</ADMINISTRATION>" +
"</IODATA>";
Session.Execute(rqlStatement, Session.Info.LoginGuid);
}
}
private void Save(string attributeName, string attributeValue)
{
string rqlStatement =
"<IODATA>" +
"<USER action=\"save\" guid=\"" + GuidString + "\" " +
attributeName + "=\"" + attributeValue + "\"/>" +
"</IODATA>";
Session.Execute(rqlStatement, Session.Info.LoginGuid);
}
protected User(XmlNode xmlNode) : base(xmlNode) { }
internal User(Guid guid) : base(guid) { }
protected override void LoadBasics(XmlNode xmlNode)
{
if (xmlNode.OuterXml.Length != 0)
{
_name = xmlNode.Attributes.GetNamedItem("name").Value;
}
else
{
// We have an 'Unknown User'
_name = "Unknown User";
}
}
protected override XmlNode LoadXml()
{
string rqlStatement =
"<IODATA>" +
"<ADMINISTRATION>" +
"<USER action=\"load\" guid=\"" + GuidString + "\"/>" +
"</ADMINISTRATION>" +
"</IODATA>";
xmlDoc.LoadXml(Session.Execute(rqlStatement));
return xmlDoc.GetElementsByTagName("USER")[0];
}
public static List<User> List()
{
List<User> users = new List<User>();
string rqlStatement =
"<IODATA>" +
"<ADMINISTRATION>" +
"<USERS action=\"list\"/>" +
"</ADMINISTRATION>" +
"</IODATA>";
xmlDoc.LoadXml(Session.Execute(rqlStatement, Session.Info.LoginGuid));
XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("USER");
foreach (XmlNode xmlNode in xmlNodes)
{
users.Add(new User(xmlNode));
}
return users;
}
}
}