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

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

BMX v2.2

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