Git Repository Public Repository

CPE_learningsite

URLs

Copy to Clipboard

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
using System;
using System.Xml;

namespace CPE.App.Web.Connect {

	/// <summary>
	/// Represents a principal-info object returned from Connect.
	/// </summary>
	public class PrincipalInfo {
		
		/// <summary>
		/// The ID of the account the principal belongs to.
		/// </summary>
		public int AccountId { get; private set; }

		/// <summary>
		/// The date the account was disabled. If the account is active, then the value will be null.
		/// </summary>
		public DateTime? Disabled { get; private set; }

		/// <summary>
		/// The ID of the principal.
		/// </summary>
		public int PrincipalId { get; private set; }

		/// <summary>
		/// The principal’s login ID on Connect Enterprise. Can be the same as an e-mail address.
		/// </summary>
		public string Login { get; private set; }

		/// <summary>
		/// For a user, the e-mail address.
		/// </summary>
		public string Email { get; private set; }

		/// <summary>
		/// For a user, the full name, concatenated from their first and last name fields.
		/// </summary>
		public string Name { get; private set; }

		/// <summary>
		/// For a user, the first name.
		/// </summary>
		public string FirstName { get; private set; }

		/// <summary>
		/// For a user, the last name.
		/// </summary>
		public string LastName { get; private set; }


	    public string DisplayName
	    {
	        get
	        {
	            return string.Format("{0} {1}", FirstName, LastName).Trim();
	        }
	    }

		/// <summary>
		/// Initializes the object by parsing the values from the XmlDocument.
		/// </summary>
		/// <param name="document">The XmlDocument returned from Connect for this object.</param>
		public PrincipalInfo(XmlNode document) {

			// Find main node
			XmlNode principal = document.SelectSingleNode("/results/principal");

			// Parse values	
			AccountId = int.Parse(principal.Attributes["account-id"].Value);
			PrincipalId = int.Parse(principal.Attributes["principal-id"].Value);
			Login = principal.SelectSingleNode("login").InnerText;
			Name = principal.SelectSingleNode("name").InnerText;
            try
            {
                FirstName = principal.SelectSingleNode("first-name").InnerText;
            }
            catch
            {
                FirstName = "";
            }
            try
            {
                LastName = principal.SelectSingleNode("last-name").InnerText;
            }
            catch
            {
                LastName = "";
            }
		    Email = principal.SelectSingleNode("email").InnerText;

			if(principal.Attributes["disabled"].Value != string.Empty)
				Disabled = DateTime.Parse(principal.Attributes["disabled"].Value);
		}
	}
}

Commits for CPE_learningsiteCPE/CPE.App/CPE.App.Web/Connect/PrincipalInfo.cs

Diff revisions: vs.
Revision Author Commited Message
4cd176 ... v.shishlov Fri 27 Aug, 2021 14:33:17 +0000

initial commit