-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroups.cs
More file actions
163 lines (141 loc) · 4.09 KB
/
Copy pathGroups.cs
File metadata and controls
163 lines (141 loc) · 4.09 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Net;
using System.Xml;
namespace IconCMO
{
public class GroupMember
{
private IconAuth auth;
private string httpRequest;
private XmlDocument xmlDoc;
private IconFilter filter;
private IconSort sort;
private Collection<GroupCategoryEntry> entries;
public GroupMember(IconAuth _auth, IconFilter _filter, IconSort _sort)
{
auth = _auth;
filter = _filter;
sort = _sort;
entries = null;
}
public GroupMember(IconAuth _auth) : this(_auth, null, null)
{
}
public void GetEntries()
{
xmlDoc = new XmlDocument();
entries = new Collection<GroupCategoryEntry>();
// Form the http request
httpRequest = HttpRequestHandler.BuildRequest("<Module>groups</Module>" +
"<Section>member</Section>",
filter,
auth,
sort);
// Send the request
HttpWebResponse response = HttpRequestHandler.SendRequest(httpRequest);
// Load the response into an XML document
xmlDoc.Load(new StreamReader(response.GetResponseStream()));
// Extract the security token from the response
HttpRequestHandler.GetSession(xmlDoc, ref auth);
// Load the directory index entries
LoadMemberEntries();
}
public Collection<GroupCategoryEntry> Entries
{
get { return entries; }
}
private void LoadMemberEntries()
{
// Get the memberindex nodes
XmlNodeList nodes = xmlDoc.SelectNodes("/iconresponse/member");
foreach (XmlNode node in nodes)
{
// Create a group category entry and add to the collection
GroupCategoryEntry entry = new GroupCategoryEntry();
XmlNode wrkNode = node.SelectSingleNode("id");
entry.Id = wrkNode.InnerText;
wrkNode = node.SelectSingleNode("category");
entry.Category = wrkNode.InnerText;
// Now load the groups in this category
XmlNodeList groupList = node.SelectNodes("groups");
foreach (XmlNode groupNode in groupList)
{
GroupEntry groupEntry = new GroupEntry();
wrkNode = groupNode.SelectSingleNode("id");
groupEntry.Id = wrkNode.InnerText;
wrkNode = groupNode.SelectSingleNode("name");
groupEntry.Name = wrkNode.InnerText;
wrkNode = groupNode.SelectSingleNode("description");
groupEntry.Description = wrkNode.InnerText;
// Get the members in the group
XmlNodeList memberList = groupNode.SelectNodes("members");
if (memberList.Count > 0)
{
foreach (XmlNode memberNode in memberList)
{
if (memberNode.ChildNodes.Count > 0 )
{
GroupMemberEntry memberEntry = new GroupMemberEntry();
wrkNode = memberNode.SelectSingleNode("id");
memberEntry.Id = wrkNode.InnerText;
wrkNode = memberNode.SelectSingleNode("first_name");
memberEntry.FirstName = wrkNode.InnerText;
wrkNode = memberNode.SelectSingleNode("last_name");
memberEntry.LastName = wrkNode.InnerText;
groupEntry.Members.Add(memberEntry);
}
}
}
entry.Groups.Add(groupEntry);
}
entries.Add(entry);
}
}
public IconAuth Auth
{
get { return auth; }
set { auth = value; }
}
}
public class GroupCategoryEntry
{
public string Id { get; set; }
public string Category { get; set; }
public Collection<GroupEntry> Groups { get; set; }
public GroupCategoryEntry()
{
Id = string.Empty;
Category = string.Empty;
Groups = new Collection<GroupEntry>();
}
}
public class GroupEntry
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Collection<GroupMemberEntry> Members { get; set; }
public GroupEntry()
{
Id = string.Empty;
Name = string.Empty;
Description = string.Empty;
Members = new Collection<GroupMemberEntry>();
}
}
public class GroupMemberEntry
{
public string Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public GroupMemberEntry()
{
Id = string.Empty;
FirstName = string.Empty;
LastName = string.Empty;
}
}
}