forked from huysentruitw/SapNwRfc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSapConnectionParameters.cs
328 lines (277 loc) · 10.3 KB
/
SapConnectionParameters.cs
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace SapNwRfc
{
/// <summary>
/// Represents the SAP connection parameters for passing settings to the <see cref="SapConnection"/> class.
/// </summary>
public class SapConnectionParameters
{
/// <summary>
/// Gets or sets the Application Server Host parameter.
/// </summary>
[SapName("ASHOST")]
public string AppServerHost { get; set; }
/// <summary>
/// Gets or sets the SNC Library Path parameter.
/// </summary>
[SapName("SNC_LIB")]
public string SncLibraryPath { get; set; }
/// <summary>
/// Gets or sets the SNC QOP parameter.
/// </summary>
[SapName("SNC_QOP")]
public string SncQop { get; set; }
/// <summary>
/// Gets or sets the Trace parameter.
/// </summary>
[SapName("TRACE")]
public string Trace { get; set; }
/// <summary>
/// Gets or sets the SAP Router parameter.
/// </summary>
[SapName("SAPROUTER")]
public string SapRouter { get; set; }
/// <summary>
/// Gets or sets the No Compression parameter.
/// </summary>
[SapName("NO_COMPRESSION")]
public string NoCompression { get; set; }
/// <summary>
/// Gets or sets the On Character Conversion Error parameter.
/// </summary>
[SapName("ON_CCE")]
public string OnCharacterConversionError { get; set; }
/// <summary>
/// Gets or sets the Character Fault Indicator Token parameter.
/// </summary>
[SapName("CFIT")]
public string CharacterFaultIndicatorToken { get; set; }
/// <summary>
/// Gets or sets the Maximum Pool Size parameter.
/// </summary>
[SapName("MAX_POOL_SIZE")]
public string MaxPoolSize { get; set; }
/// <summary>
/// Gets or sets the Pool Size parameter.
/// </summary>
[SapName("POOL_SIZE")]
public string PoolSize { get; set; }
/// <summary>
/// Gets or sets the SNC Partner Names parameter.
/// </summary>
[SapName("SNC_PARTNER_NAMES")]
public string SncPartnerNames { get; set; }
/// <summary>
/// Gets or sets the Idle Timeout parameter.
/// </summary>
[SapName("IDLE_TIMEOUT")]
public string IdleTimeout { get; set; }
/// <summary>
/// Gets or sets the Maximum Pool Wait Time parameter.
/// </summary>
[SapName("MAX_POOL_WAIT_TIME")]
public string MaxPoolWaitTime { get; set; }
/// <summary>
/// Gets or sets the Registration Count parameter.
/// </summary>
[SapName("REG_COUNT")]
public string RegistrationCount { get; set; }
/// <summary>
/// Gets or sets the Password Change Enforced parameter.
/// </summary>
[SapName("PASSWORD_CHANGE_ENFORCED")]
public string PasswordChangeEnforced { get; set; }
/// <summary>
/// Gets or sets the Name parameter.
/// </summary>
[SapName("NAME")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the Repository Destination parameter.
/// </summary>
[SapName("REPOSITORY_DESTINATION")]
public string RepositoryDestination { get; set; }
/// <summary>
/// Gets or sets the Repository User parameter.
/// </summary>
[SapName("REPOSITORY_USER")]
public string RepositoryUser { get; set; }
/// <summary>
/// Gets or sets the Repository Password parameter.
/// </summary>
[SapName("REPOSITORY_PASSWD")]
public string RepositoryPassword { get; set; }
/// <summary>
/// Gets or sets the Repository SNC My Name parameter.
/// </summary>
[SapName("REPOSITORY_SNC_MYNAME")]
public string RepositorySncMyName { get; set; }
/// <summary>
/// Gets or sets the Reporitory X509 Certificate parameter.
/// </summary>
[SapName("REPOSITORY_X509CERT")]
public string RepositoryX509Certificate { get; set; }
/// <summary>
/// Gets or sets the Idle Check Time parameter.
/// </summary>
[SapName("IDLE_CHECK_TIME")]
public string IdleCheckTime { get; set; }
/// <summary>
/// Gets or sets the SNC My Name parameter.
/// </summary>
[SapName("SNC_MYNAME")]
public string SncMyName { get; set; }
/// <summary>
/// Gets or sets the SNC Partner Name parameter.
/// </summary>
[SapName("SNC_PARTNERNAME")]
public string SncPartnerName { get; set; }
/// <summary>
/// Gets or sets the Program Id parameter.
/// </summary>
[SapName("PROGRAM_ID")]
public string ProgramId { get; set; }
/// <summary>
/// Gets or sets the App Server Service parameter.
/// </summary>
[SapName("ASSERV")]
public string AppServerService { get; set; }
/// <summary>
/// Gets or sets the Message Server Host parameter.
/// </summary>
[SapName("MSHOST")]
public string MessageServerHost { get; set; }
/// <summary>
/// Gets or sets the Message Server Service parameter.
/// </summary>
[SapName("MSSERV")]
public string MessageServerService { get; set; }
/// <summary>
/// Gets or sets the R/3 Name parameter.
/// </summary>
[SapName("R3NAME")]
public string R3Name { get; set; }
/// <summary>
/// Gets or sets the Logon Group parameter.
/// </summary>
[SapName("GROUP")]
public string LogonGroup { get; set; }
/// <summary>
/// Gets or sets the Gateway Host parameter.
/// </summary>
[SapName("GWHOST")]
public string GatewayHost { get; set; }
/// <summary>
/// Gets or sets the Gateway Service parameter.
/// </summary>
[SapName("GWSERV")]
public string GatewayService { get; set; }
/// <summary>
/// Gets or sets the System Number parameter.
/// </summary>
[SapName("SYSNR")]
public string SystemNumber { get; set; }
/// <summary>
/// Gets or sets the User parameter.
/// </summary>
[SapName("USER")]
public string User { get; set; }
/// <summary>
/// Gets or sets the Alias User parameter.
/// </summary>
[SapName("ALIAS_USER")]
public string AliasUser { get; set; }
/// <summary>
/// Gets or sets the SNC Mode parameter.
/// </summary>
[SapName("SNC_MODE")]
public string SncMode { get; set; }
/// <summary>
/// Gets or sets the Client parameter.
/// </summary>
[SapName("CLIENT")]
public string Client { get; set; }
/// <summary>
/// Gets or sets the Password parameter.
/// </summary>
[SapName("PASSWD")]
public string Password { get; set; }
/// <summary>
/// Gets or sets the Codepage parameter.
/// </summary>
[SapName("CODEPAGE")]
public string Codepage { get; set; }
/// <summary>
/// Gets or sets the Partner Char Size parameter.
/// </summary>
[SapName("PCS")]
public string PartnerCharSize { get; set; }
/// <summary>
/// Gets or sets the System ID parameter.
/// </summary>
[SapName("SYSID")]
public string SystemId { get; set; }
/// <summary>
/// Gets or sets the Systems ID parameter.
/// </summary>
[SapName("SYS_IDS")]
public string SystemIds { get; set; }
/// <summary>
/// Gets or sets the X509 Certificate parameter.
/// </summary>
[SapName("X509CERT")]
public string X509Certificate { get; set; }
/// <summary>
/// Gets or sets the SAP SSO2 Ticket parameter.
/// </summary>
[SapName("MYSAPSSO2")]
public string SapSso2Ticket { get; set; }
/// <summary>
/// Gets or sets the Use SAP GUI parameter.
/// </summary>
[SapName("USE_SAPGUI")]
public string UseSapGui { get; set; }
/// <summary>
/// Gets or sets the ABAP Debug parameter.
/// </summary>
[SapName("ABAP_DEBUG")]
public string AbapDebug { get; set; }
/// <summary>
/// Gets or sets the Logon Check parameter.
/// </summary>
[SapName("LCHECK")]
public string LogonCheck { get; set; }
/// <summary>
/// Gets or sets the Language parameter.
/// </summary>
[SapName("LANG")]
public string Language { get; set; }
/// <summary>
/// Parses a connection string into a <see cref="SapConnectionParameters"/> object.
/// </summary>
/// <param name="connectionString">The connection string.</param>
/// <returns>The <see cref="SapConnectionParameters"/> instance.</returns>
public static SapConnectionParameters Parse(string connectionString)
{
if (string.IsNullOrEmpty(connectionString))
throw new ArgumentException("Value cannot be null or empty", nameof(connectionString));
IReadOnlyDictionary<string, string> parts = connectionString
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
.Select(entry => Regex.Match(entry, @"^\s*(?<key>\S+)\s*=\s*(?<value>\S+)\s*$"))
.Where(match => match.Success)
.ToDictionary(match => match.Groups["key"].Value, match => match.Groups["value"].Value);
return typeof(SapConnectionParameters)
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Aggregate(new SapConnectionParameters(), (parameters, propertyInfo) =>
{
if (parts.ContainsKey(propertyInfo.Name) && propertyInfo.CanWrite)
propertyInfo.SetValue(parameters, parts[propertyInfo.Name]);
return parameters;
});
}
}
}