public string[] ddrGetsEntry(string siteId, string vistaFile, string iens, string flds, string flags)
        {
            AbstractConnection cxn = null;

            try
            {
                logging.Log.LOG(String.Format("DDR GETS ENTRY: {0}, {1}, {2}, {3}", siteId, vistaFile, iens, flds));
                cxn = (AbstractConnection)ConnectionPools.getInstance().checkOutAlive(siteId);

                DdrGetsEntry ddr = new DdrGetsEntry(cxn);
                ddr.File   = vistaFile;
                ddr.Iens   = iens;
                ddr.Fields = flds;
                ddr.Flags  = flags;

                String[] result = null;
                result = ddr.execute();
                return(result);
            }
            catch (UnauthorizedAccessException uae)
            {
                logging.Log.LOG("Connection not properly authenticated: " + uae.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw uae;
            }
            catch (System.Net.Sockets.SocketException se)
            {
                logging.Log.LOG("Socket error: " + se.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw se;
            }
            catch (gov.va.medora.mdo.exceptions.ConnectionException ce)
            {
                logging.Log.LOG("Cxn error: " + ce.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw ce;
            }
            catch (Exception exc)
            {
                logging.Log.LOG("DDR GETS ENTRY Exception: " + exc.Message);
                throw exc;
            }
            finally
            {
                try
                {
                    ConnectionPools.getInstance().checkIn(cxn);
                }
                catch (Exception) { }
            }
        }
        public string getVariableValueQuery(string siteId, string arg)
        {
            AbstractConnection cxn = null;

            try
            {
                logging.Log.LOG(String.Format("GVV: {0}, {1}", siteId, arg));
                cxn = (AbstractConnection)ConnectionPools.getInstance().checkOutAlive(siteId);

                VistaToolsDao dao    = new VistaToolsDao(cxn);
                String        result = null;

                result = dao.getVariableValue(arg);
                return(result);
            }
            catch (UnauthorizedAccessException uae)
            {
                logging.Log.LOG("Connection not properly authenticated: " + uae.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw uae;
            }
            catch (System.Net.Sockets.SocketException se)
            {
                logging.Log.LOG("Socket error: " + se.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw se;
            }
            catch (gov.va.medora.mdo.exceptions.ConnectionException ce)
            {
                logging.Log.LOG("Cxn error: " + ce.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw ce;
            }
            catch (Exception exc)
            {
                logging.Log.LOG("GVV Exception: " + exc.Message);
                throw exc;
            }
            finally
            {
                try
                {
                    ConnectionPools.getInstance().checkIn(cxn);
                }
                catch (Exception) { }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Signal the pool to shutdown. An attempt will be made to wait for as many connections as possible for return to the pool
        /// before disconnecting each of the connections. Sets SHUTDOWN_FLAG so pool no longer tries to continue to run
        /// </summary>
        public override void shutdown()
        {
            if (SHUTDOWN_FLAG == 1)
            {
                return;
            }
            SHUTDOWN_FLAG = 1;

            AbstractConnection current = null;

            while (_pooledCxns.TryTake(out current, 1000))
            {
                current.disconnect();
            }
        }
        //internal SqlConnection openCxn()
        //{
        //    //string cxnString = "server=" + _server +
        //    //    ";uid=" + _uid + ";pwd=" + _pwd + ";database=" + _dbName;
        //    SqlConnection cxn = new SqlConnection(_connectionString);
        //    cxn.Open();
        //    return cxn;
        //}

        public void addRecord(AbstractCredentials creds, string encryptionKey)
        {
            string sql = buildAddRecordStatement(creds, encryptionKey);

            _cxn.connect();
            SqlCommand myCmd = new SqlCommand(sql, ((UserValidationConnection)_cxn).SqlConnection);
            int        rows  = -1;

            try
            {
                rows = myCmd.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                if (e.Number != 2627) // duplicate key exception code. i.e. primary key violations are ok
                {
                    throw;
                }
            }
            finally
            {
                _cxn.disconnect();
            }
        }
Beispiel #5
0
        protected void TestVistaSettingsClick(object sender, EventArgs e)
        {
            int port = 0;

            if (String.IsNullOrEmpty(textboxVistaIp.Text) || String.IsNullOrEmpty(textboxVistaPort.Text) ||
                !Int32.TryParse(textboxVistaPort.Text, out port))
            {
                labelMessage.Text = "Invalid Vista connection parameters. Please be sure to enter a valid IP address and port number";
                return;
            }

            DataSource testSrc = new DataSource();

            testSrc.Provider = textboxVistaIp.Text;
            testSrc.Modality = "HIS";
            testSrc.Port     = port;
            testSrc.Protocol = "VISTA";
            testSrc.SiteId   = new SiteId("900", "Test"); // this site id doesn't matter - it's just there because a site ID is expected by the code below

            string welcomeMsg = "";

            try
            {
                AbstractDaoFactory factory = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(testSrc.Protocol));
                AbstractConnection cxn     = factory.getConnection(testSrc);
                cxn.connect();
                welcomeMsg = cxn.getWelcomeMessage();
                cxn.disconnect();
            }
            catch (Exception exc)
            {
                labelMessage.Text = "Unable to connect to that datasource. Please check your test system and try again." +
                                    "This might help figure out why:</p><p>" + exc.ToString() + "</p>";
                return;
            }

            labelMessage.Text = "<p>You rock. Connection successfully established. You should put this site in your VhaSites.xml " +
                                "file is you'd like it to be available later on via MDWS.</p><p>" + welcomeMsg + "</p>";
        }
Beispiel #6
0
        public TextArray ddrListerPlus(
            string sitecode,
            string file,
            string iens,
            string fields,
            string flags,
            string maxrex,
            string from,
            string part,
            string xref,
            string screen,
            string identifier)
        {
            AbstractConnection cxn = null;

            try
            {
                cxn = (AbstractConnection)ConnectionPools.getInstance().checkOutAlive(sitecode);
                DdrLister ddr = new DdrLister(cxn)
                {
                    File   = file,
                    Iens   = iens,
                    Fields = fields,
                    Flags  = flags,
                    Max    = maxrex,
                    From   = from,
                    Part   = part,
                    Xref   = String.IsNullOrEmpty(xref) ? "#" : xref,
                    Screen = screen,
                    Id     = identifier
                };
                return(new TextArray(ddr.execute()));
                //VistaRpcQuery ddrResult = ddr.execute();
                //return new DdrRpcResult(ddrResult);
            }
            catch (System.Net.Sockets.SocketException se)
            {
                try
                {
                    cxn.disconnect();
                }
                catch (Exception) { }
                return(new TextArray()
                {
                    fault = new FaultTO(se)
                });
                //return new DdrRpcResult() { fault = new FaultTO(se) };
            }
            catch (Exception exc)
            {
                return(new TextArray()
                {
                    fault = new FaultTO(exc)
                });
                //return new DdrRpcResult() { fault = new FaultTO(exc) };
            }
            finally
            {
                if (cxn != null)
                {
                    ConnectionPools.getInstance().checkIn(cxn);
                }
            }
        }
 public void tearDown()
 {
     _cxn.disconnect();
 }
        public string[] ddrLister(string siteId, string vistaFile, string iens, string fields, string flags, string maxRex, string from, string part, string xref, string screen, string identifier)
        {
            AbstractConnection cxn = null;

            try
            {
                logging.Log.logDDR(String.Format("DDR LISTER: Site {0}, File {1}, IENS {2}, Fields {3}, Flags {7}, From {4}, Screen {5}, Identifier {6}", siteId, vistaFile, iens, fields, from, screen, identifier, flags));
                cxn = (AbstractConnection)ConnectionPools.getInstance().checkOutAlive(siteId);

                DdrLister ddr = new DdrLister(cxn);
                ddr.File   = vistaFile;
                ddr.Iens   = iens;
                ddr.Fields = fields;
                ddr.Flags  = flags;
                if (String.Equals(flags, "I") && !String.IsNullOrEmpty(identifier))
                {
                    ddr.Options = "WID"; // this is how we get identifier part for unpacked query results
                }
                if (String.IsNullOrEmpty(xref))
                {
                    ddr.Xref = "#";
                }
                else
                {
                    ddr.Xref = xref;
                }
                ddr.Max    = maxRex;
                ddr.From   = from;
                ddr.Part   = part;
                ddr.Screen = screen;
                ddr.Id     = identifier;

                String[] result = null;
                result = ddr.execute();
                return(result);
            }
            catch (UnauthorizedAccessException uae)
            {
                logging.Log.LOG("Connection not properly authenticated: " + uae.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw uae;
            }
            catch (System.Net.Sockets.SocketException se)
            {
                logging.Log.LOG("Socket error: " + se.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw se;
            }
            catch (gov.va.medora.mdo.exceptions.ConnectionException ce)
            {
                logging.Log.LOG("Cxn error: " + ce.Message);
                cxn.disconnect(); // will cause cxn pool to discard
                throw ce;
            }
            catch (Exception exc)
            {
                logging.Log.LOG("DDR LISTER Exception: " + exc.Message);
                throw exc;
            }
            finally
            {
                try
                {
                    ConnectionPools.getInstance().checkIn(cxn);
                }
                catch (Exception) { }
            }
        }
Beispiel #9
0
        /// <summary>
        /// patientVisit
        /// This method is used by MHV and will probably be used by other PHR apps.
        /// </summary>
        /// <param name="pwd">Client app's BSE security phrase</param>
        /// <param name="homeSitecode">Station number</param>
        /// <param name="mpiPid">ICN</param>
        /// <param name="multiSite">Set to false for now</param>
        /// <returns>SiteArray: Nothing really in it though, except error messages</returns>
        public SiteArray patientVisit(string pwd, string homeSitecode, string mpiPid, bool multiSite)
        {
            SiteArray result = new SiteArray();

            //Make sure we have all the args we need
            if (mySession == null || mySession.SiteTable == null)
            {
                result.fault = new FaultTO("No session has been started");
            }
            else if (String.IsNullOrEmpty(homeSitecode))
            {
                result.fault = new FaultTO("No homeSitecode");
            }
            else if (mySession.SiteTable.getSite(homeSitecode) == null)
            {
                result.fault = new FaultTO("No site " + homeSitecode + " in the site table");
            }
            else if (mySession.ConnectionSet != null &&
                     mySession.ConnectionSet.Count > 0 &&
                     mySession.ConnectionSet.HasConnection(homeSitecode))
            {
                result.fault = new FaultTO("Site " + homeSitecode + " already connected");
            }
            else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0)
            {
                result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?");
            }
            else if (mpiPid == "")
            {
                result.fault = new FaultTO("No MPI PID");
            }
            if (result.fault != null)
            {
                return(result);
            }

            Site homeSite = mySession.SiteTable.getSite(homeSitecode);

            mySession.Credentials = getAdministrativeCredentials(homeSite);

            mySession.Credentials.SecurityPhrase = pwd;

            string context = MdwsConstants.MDWS_CONTEXT;

            if (mySession.DefaultVisitMethod == MdwsConstants.NON_BSE_CREDENTIALS)
            {
                context = MdwsConstants.CPRS_CONTEXT;
            }
            mySession.PrimaryPermission = new MenuOption(context);

            try
            {
                mySession.User = doTheVisit(homeSitecode, mySession.Credentials, mySession.PrimaryPermission);

                PatientApi patientApi = new PatientApi();
                string     localPid   = patientApi.getLocalPid(myCxn, mpiPid);
                if (localPid == "")
                {
                    myCxn.disconnect();
                    result.fault = new FaultTO("No such patient at this site");
                    return(result);
                }
                mySession.Patient = patientApi.select(myCxn, localPid);
                addMyCxn2CxnSet();
            }
            catch (Exception e)
            {
                myCxn.disconnect();
                result.fault = new FaultTO(e.Message);
                return(result);
            }
            return(result);
        }