source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXCmdTester/bmxTesterForVista_0200.cs

Last change on this file was 1103, checked in by Sam Habiel, 14 years ago

Updated bmxTesterForVista to support RPMS. Compile using VISTA or RPMS flag

File size: 4.6 KB
Line 
1using System;
2using IndianHealthService.BMXNet;
3
4namespace SamsStuff.IHS.BMX
5{
6 class MyFirstApp
7 {
8 static void Main(string[] args)
9 {
10 if (args.Length < 4)
11 {
12 Console.WriteLine("Enter parameters as server port ac vc");
13 return;
14 }
15
16 BMXNetLib ConnectionManager = new BMXNetLib();
17 string ip = args[0];
18 int portno = int.Parse(args[1]);
19 string accessCode = args[2];
20 string verifyCode = args[3];
21 ConnectionManager.MServerPort = portno;
22 bool success = ConnectionManager.OpenConnection(ip, accessCode, verifyCode);
23 Console.WriteLine("Connected: " + success.ToString() + " DUZ: " + ConnectionManager.DUZ);
24 ConnectionManager.AppContext = "BMXRPC";
25 string result = ConnectionManager.TransmitRPC("BMX USER", ConnectionManager.DUZ);
26 Console.WriteLine("Simple RPC: User Name: " + result);
27
28 //string result =
29 ConnectionManager.AppContext = "OR CPRS GUI CHART";
30 result = ConnectionManager.TransmitRPC("ORWU NEWPERS","A^1");
31 Console.WriteLine("CPRS RPC with Parameters: ");
32 Console.WriteLine(result);
33 Console.WriteLine();
34 Console.WriteLine("SQL Statement");
35 //string cmd = "SELECT NAME,SEX,DATE_OF_BIRTH FROM PATIENT";
36 string cmd = "SELECT * FROM HOLIDAY";
37 RPMSDb dbTables = new RPMSDb(ConnectionManager);
38 RPMSDb.RPMSDbResultSet rs = new RPMSDb.RPMSDbResultSet();
39 dbTables.Execute(cmd, out rs);
40 for (int i = 0; i < rs.data.GetLength(0); i++)
41 {
42 Console.WriteLine();
43 for (int j = 0; j < rs.data.GetLength(1); j++)
44 {
45 if (rs.data[i, j] != null)
46 Console.Write(rs.data[i, j].ToString() + "\t");
47 }
48 }
49 Console.WriteLine();
50 Console.WriteLine("BMX Schema RPC");
51 ConnectionManager.AppContext = "BMXRPC";
52 BMXNetConnection conn = new BMXNetConnection(ConnectionManager);
53 BMXNetCommand cmd2 = (BMXNetCommand) conn.CreateCommand();
54 cmd2.CommandText = "BMX DEMO^S^10";
55 BMXNetDataAdapter da = new BMXNetDataAdapter();
56 da.SelectCommand = cmd2;
57 System.Data.DataSet ds = new System.Data.DataSet();
58 da.Fill(ds,"BMXNetTable1");
59 System.Data.DataTable dt = new System.Data.DataTable();
60 dt = ds.Tables["BMXNetTable1"];
61 System.Text.StringBuilder sb = new System.Text.StringBuilder();
62 for (int i = 0; i < dt.Rows.Count; i++)
63 {
64 for (int j = 0; j < dt.Columns.Count; j++)
65 {
66 sb.Append(dt.Rows[i][j]);
67 sb.Append("\t");
68 }
69 sb.Append("\n");
70 }
71 Console.WriteLine();
72 Console.Write(sb);
73 Console.WriteLine();
74 Console.WriteLine("More complicated SQL\n");
75 BMXNetCommand cmd3 = (BMXNetCommand)conn.CreateCommand();
76 cmd3.CommandText = String.Empty; // Default
77#if VISTA
78 cmd3.CommandText = @"SELECT PATIENT.NAME 'NAME', PATIENT.STATE 'STATE',
79 STATE.ABBREVIATION 'ABBR', PATIENT.AGE 'AGE' FROM PATIENT, STATE
80 WHERE INTERNAL[PATIENT.STATE] = STATE.BMXIEN MAXRECORDS:5";
81#elif RPMS
82 cmd3.CommandText = @"SELECT VA_PATIENT.NAME 'NAME', VA_PATIENT.STATE 'STATE',
83 STATE.ABBREVIATION 'ABBR', VA_PATIENT.AGE 'AGE' FROM VA_PATIENT, STATE
84 WHERE INTERNAL[VA_PATIENT.STATE] = STATE.BMXIEN MAXRECORDS:5";
85#endif
86 da.SelectCommand = cmd3;
87 da.Fill(ds, "BMXNetTable2");
88 System.Data.DataTable dt2 = new System.Data.DataTable();
89 dt2 = ds.Tables["BMXNetTable2"];
90 System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
91 for (int i = 0; i < dt2.Columns.Count; i++)
92 {
93 sb2.Append(dt2.Columns[i].ColumnName);
94 sb2.Append("\t");
95 }
96 sb2.Append("\n");
97 for (int i = 0; i < dt2.Rows.Count; i++)
98 {
99 for (int j = 0; j < dt2.Columns.Count; j++)
100 {
101 sb2.Append(dt2.Rows[i][j]);
102 sb2.Append("\t");
103 }
104 sb2.Append("\n");
105 }
106 Console.Write(sb2);
107 Console.ReadKey();
108 ConnectionManager.CloseConnection();
109 }
110 }
111}
Note: See TracBrowser for help on using the repository browser.