-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogonColumn.cs
More file actions
142 lines (113 loc) · 4.48 KB
/
LogonColumn.cs
File metadata and controls
142 lines (113 loc) · 4.48 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
/*
Copyright (C) 2016 Marko Graf
*/
using System;
namespace KeeSAPLogon
{
public sealed class LogonColumn : IComparable
{
private string m_SAPID;
private string m_SAPClient;
private string m_SAPLanguage;
private string m_SAPTransaction;
//---------------------------------------------------------------------------------------------------
// Class Constructors
//---------------------------------------------------------------------------------------------------
public LogonColumn(string ID, string Client, string Language, string Transaction)
{
m_SAPID = ID;
m_SAPClient = Client;
m_SAPLanguage = Language;
m_SAPTransaction = Transaction;
}
//---------------------------------------------------------------------------------------------------
// Public Methods
//---------------------------------------------------------------------------------------------------
public string SAPID
{
get { return ReturnValidValue(m_SAPID); }
}
public string SAPClient
{
get { return ReturnValidValue(m_SAPClient); }
}
public string SAPLanguage
{
get { return ReturnValidValue(m_SAPLanguage); }
}
public string SAPTransaction
{
get { return ReturnValidValue(m_SAPTransaction); }
}
public bool HasSAPID()
{
return (!String.IsNullOrEmpty(this.SAPID));
}
public bool HasSAPClient()
{
return (!String.IsNullOrEmpty(this.SAPClient));
}
public bool HasSAPLanguage()
{
return (!String.IsNullOrEmpty(this.SAPLanguage));
}
public bool HasSAPTransaction()
{
return (!String.IsNullOrEmpty(this.SAPTransaction));
}
public bool IsValid()
{
return (this.HasSAPID() && this.HasSAPClient());
}
public void ExtendWithDefaults(string Language, string Transaction)
{
if (!HasSAPLanguage()) m_SAPLanguage = Language;
if (!HasSAPTransaction()) m_SAPTransaction = Transaction;
}
//---------------------------------------------------------------------------------------------------
// Interface Implementation: IComparable
//---------------------------------------------------------------------------------------------------
#region IComparable implementation
public int CompareTo(object obj)
{
if (obj == null) return 1;
LogonColumn otherLC = obj as LogonColumn;
if (otherLC != null)
{
if (this.SAPID.CompareTo(otherLC.SAPID) < 0) return -1;
if (this.SAPID.CompareTo(otherLC.SAPID) > 0) return 1;
if (this.SAPID.CompareTo(otherLC.SAPID) == 0)
{
if (this.SAPClient.CompareTo(otherLC.SAPClient) < 0) return -1;
if (this.SAPClient.CompareTo(otherLC.SAPClient) > 0) return 1;
if (this.SAPClient.CompareTo(otherLC.SAPClient) == 0)
{
if (this.SAPLanguage.CompareTo(otherLC.SAPLanguage) < 0) return -1;
if (this.SAPLanguage.CompareTo(otherLC.SAPLanguage) > 0) return 1;
if (this.SAPLanguage.CompareTo(otherLC.SAPLanguage) == 0)
{
return (this.SAPTransaction.CompareTo(otherLC.SAPTransaction));
}
}
}
}
else
{
throw new ArgumentException("Object is not an object of type " + this.ToString());
}
return 1;
}
#endregion
//---------------------------------------------------------------------------------------------------
// Private Static Methods
//---------------------------------------------------------------------------------------------------
private static string ReturnValidValue(string value)
{
if (!String.IsNullOrEmpty(value))
{
return value;
}
return String.Empty;
}
}
}