query() public method

public query ( MdoQuery vq, AbstractPermission context = null ) : object
vq MdoQuery
context AbstractPermission
return object
Beispiel #1
0
        public string getProcedureReport(string noteId)
        {
            MdoQuery request  = buildGetClinicalProcedureReportQuery(_cxn.Pid, noteId);
            string   response = (string)_cxn.query(request);

            return(response);
        }
Beispiel #2
0
        internal IList <Problem> getProblems(String status, String pid)
        {
            MdoQuery request  = buildGetProblemsRequest(status, pid);
            String   response = (String)_cxn.query(request);

            return(toProblems(response));
        }
Beispiel #3
0
        public String getParameterValue(String arg)
        {
            MdoQuery request  = buildGetParameterValueRequest(arg);
            String   response = (String)_cxn.query(request);

            return(response);
        }
Beispiel #4
0
        public void connect()
        {
            cxn.IsConnected = false;

            if (dataSource == null)
            {
                throw new ArgumentNullException("No data source");
            }
            string hostname = dataSource.Provider;

            if (hostname == null || hostname == "")
            {
                throw new ArgumentNullException("No provider (hostname)");
            }

            //Start my listener - make sure we use an IPV4 address as IPV6 address listeners are incompatible with this algorithm
            IPHostEntry hostEntry = Dns.GetHostEntry("localhost");

            IPAddress[] myIPs = ((IPHostEntry)Dns.GetHostEntry(hostEntry.HostName)).AddressList;
            IPAddress   myIP  = null;

            foreach (IPAddress ip in myIPs)
            {
                if (ip != null && ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    myIP = ip;
                    break;
                }
            }
            if (myIP == null)
            {
                throw new Exception("Unable to obtain a local IPV4 address for the connection listener");
            }
            IPEndPoint myEndPoint = new IPEndPoint(myIP, 0);
            MdoSocket  listener   = new MdoSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            listener.Bind(myEndPoint);
            int myPort = ((IPEndPoint)listener.LocalEndPoint).Port;

            listener.Listen(2);

            //Build the request message
            string request = "TCPconnect^" + myIP.ToString() + '^' + myPort + '^' + hostEntry.HostName;

            request = "{XWB}" + StringUtils.strPack(request, 5);

            //Config my client socket and connnect to VistA
            IPAddress vistaIP = null;

            try
            {
                vistaIP = ((IPAddress[])Dns.GetHostAddresses(hostname))[0]; // GetHostAddresses takes a hostname or IP - cool!
            }
            catch (SocketException se)
            {
                throw new ConnectionException("No route to host " + hostname, se);
            }

            IPEndPoint vistaEndPoint = new IPEndPoint(vistaIP, cxn.port);

            cxn.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            cxn.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, cxn.ConnectTimeout);
            try
            {
                cxn.socket.Connect(vistaEndPoint);
            }
            catch (SocketException se)
            {
                throw new ConnectionException("No VistA listener at " + hostname + ", port " + cxn.port, se);
            }
            if (!cxn.socket.Connected)
            {
                listener.Close();
                throw new ConnectionException("Unable to connect to " + hostname + ", port " + cxn.port);
            }

            string reply = "";

            try
            {
                reply = (string)cxn.query(request);
            }
            catch (SocketException se)
            {
                throw new ConnectionException("No VistA listener at " + vistaIP, se);
            }
            if (reply != "accept")
            {
                listener.Close(cxn.ConnectTimeout);
                cxn.socket.Close();
                throw new ConnectionException("Unaccepted by " + hostname);
            }

            //Do the hookup
            cxn.socket.Close();
            cxn.socket = listener.Accept(LISTENER_TIMEOUT); // use MdoSocket timeout arg so listener doesn't turn in to a server in the event Vista fails to call back
            listener.Close();

            cxn.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, cxn.ReadTimeout);

            // Fix up the return stuff for successful connection
            cxn.WelcomeMessage = cxn.getWelcomeMessage();
            cxn.IsConnected    = true;
        }
        public void connect()
        {
            cxn.IsConnected = false;

            if (dataSource == null)
            {
                throw new ArgumentNullException("No data source");
            }
            string hostname = dataSource.Provider;

            if (String.IsNullOrEmpty(hostname))
            {
                throw new ArgumentNullException("No provider (hostname)");
            }

            //Who am I?
            IPHostEntry hostEntry = Dns.GetHostEntry("localhost");
            IPAddress   myIP      = (IPAddress)Dns.GetHostEntry(hostEntry.HostName).AddressList[0];

            //Config my client socket and connnect to VistA
            IPAddress vistaIP = null;

            if (!IPAddress.TryParse(hostname, out vistaIP)) // see if hostname is actually IP address (will get stuck in vistaIP, if so) - if not, get IP address from hostname
            {
                try
                {
                    vistaIP = (IPAddress)Dns.GetHostEntry(hostname).AddressList[0];
                }
                catch (SocketException se)
                {
                    throw new ConnectionException("No route to host " + hostname, se);
                }
            }
            IPEndPoint vistaEndPoint = new IPEndPoint(vistaIP, cxn.port);

            cxn.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            cxn.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, cxn.ConnectTimeout);
            try
            {
                cxn.socket.Connect(vistaEndPoint);
            }
            catch (SocketException se)
            {
                throw new ConnectionException("No VistA listener at " + hostname + ", port " + cxn.port, se);
            }
            if (!cxn.socket.Connected)
            {
                throw new ConnectionException("Unable to connect to " + hostname + ", port " + cxn.port);
            }

            //Build the request message
            int    COUNT_WIDTH = 3;
            string request     = "[XWB]10" + COUNT_WIDTH.ToString() + "04\nTCPConnect50" +
                                 StringUtils.strPack(myIP.ToString(), COUNT_WIDTH) +
                                 "f0" + StringUtils.strPack(Convert.ToString(0), COUNT_WIDTH) + "f0" +
                                 StringUtils.strPack(hostEntry.HostName, COUNT_WIDTH) + "f\x0004";

            string reply = "";

            try
            {
                reply = (string)cxn.query(request);
            }
            catch (SocketException se)
            {
                throw new ConnectionException("No VistA listener at " + hostname + ", port " + cxn.port, se);
            }
            if (reply != "accept")
            {
                cxn.socket.Close();
                throw new Exception("Unaccepted by " + hostname);
            }

            cxn.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, cxn.ReadTimeout);

            request = "[XWB]11302\x00010\rXUS INTRO MSG54f\x0004";
            reply   = (string)cxn.query(request);

            cxn.IsConnected = true;
        }