source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.Test/TestUser.cs@ 1222

Last change on this file since 1222 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IndianHealthService.BMXNet.WinForm.Configuration;
5using IndianHealthService.BMXNet.WinForm;
6
7namespace IndianHealthService.BMXNet.Tests
8{
9 public class TestUser
10 {
11 public static String ReadAppConfig(String parentName, String aName, String aDefaultValue)
12 {
13 String hit = System.Configuration.ConfigurationManager.AppSettings[parentName + "." + aName];
14
15 return (hit == null || (hit.Length == 0)) ? aDefaultValue : hit;
16 }
17
18 public static bool ReadAppConfig(String parentName, String aName, bool defaultValue)
19 {
20 return "True".Equals(ReadAppConfig(parentName, aName,defaultValue.ToString()), StringComparison.InvariantCultureIgnoreCase);
21 }
22
23 public static int ReadAppConfig(String parentName, String aName, int anInt)
24 {
25 String hit = ReadAppConfig(parentName, aName, "");
26 if (hit.Length == 0)
27 return anInt;
28
29 int result = -1;
30 int.TryParse(hit, out result);
31 return result;
32 }
33
34 public static TestUser ReadFromAppConfig(String aName)
35 {
36 TestUser user = new TestUser();
37 RpmsConnectionSpec connection = new RpmsConnectionSpec();
38
39 connection.Server = ReadAppConfig("Default", "rpmsHost", "");
40 connection.Port = ReadAppConfig("Default", "bmxPort", 0);
41 connection.NameSpace = ReadAppConfig("Default", "namespace", "");
42 connection.UseWindowsAuthentication = ReadAppConfig("Default", "useWinAuth", false);
43
44 connection.Server = ReadAppConfig(aName, "rpmsHost", connection.Server);
45 connection.Port = ReadAppConfig(aName, "bmxPort", connection.Port);
46 connection.NameSpace = ReadAppConfig(aName, "namespace", connection.NameSpace);
47 connection.UseWindowsAuthentication = ReadAppConfig(aName, "useWinAuth", connection.UseWindowsAuthentication);
48
49 user.ConnectionSpec = connection;
50 user.AccessCode = ReadAppConfig(aName, "accessCode", ReadAppConfig("Default", "accessCode", ""));
51 user.VerifyCode = ReadAppConfig(aName, "verifyCode", ReadAppConfig("Default", "verifyCode", ""));
52
53 return user;
54 }
55
56 private String _name = null;
57
58 public String Name
59 {
60 get { return _name; }
61 set { _name = value; }
62 }
63
64 private RpmsConnectionSpec _connectionSpec = null;
65
66 public RpmsConnectionSpec ConnectionSpec
67 {
68 get { return _connectionSpec; }
69 set { _connectionSpec = value; }
70 }
71 private String _accessCode = null;
72
73 public String AccessCode
74 {
75 get { return _accessCode; }
76 set { _accessCode = value; }
77 }
78 private String _verifyCode = null;
79
80 public String VerifyCode
81 {
82 get { return _verifyCode; }
83 set { _verifyCode = value; }
84 }
85
86 public bool Login(LoginProcess aProcess)
87 {
88 return aProcess.AttemptAccessVerifyLogin(this.ConnectionSpec, this.AccessCode, this.VerifyCode);
89 }
90 }
91}
Note: See TracBrowser for help on using the repository browser.