Esempio n. 1
0
        //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();
            }
        }
Esempio n. 2
0
        public DataSourceArray connectToLoginSite(string sitecode)
        {
            DataSourceArray result = new DataSourceArray();

            if (String.IsNullOrEmpty(sitecode))
            {
                result.fault = new FaultTO(NO_SITECODE);
            }
            else if (mySession.SiteTable == null)
            {
                result.fault = new FaultTO(NO_SITE_TABLE);
            }
            else if (mySession.SiteTable.getSite(sitecode) == null)
            {
                result.fault = new FaultTO(SITE_NOT_IN_SITE_TABLE);
            }
            else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0 && mySession.ConnectionSet.HasConnection(sitecode))
            {
                result.fault = new FaultTO(ALREADY_CONNECTED_TO_SITE);
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                Site               site    = mySession.SiteTable.getSite(sitecode);
                DataSource         src     = site.getDataSourceByModality("HIS");
                AbstractDaoFactory factory = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol));
                AbstractConnection c       = factory.getConnection(src);
                c.connect();
                result = new DataSourceArray(src);
                result.items[0].welcomeMessage = c.getWelcomeMessage();
                mySession.ConnectionSet.Add(c);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            return(result);
        }
Esempio n. 3
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>";
        }
Esempio n. 4
0
        public DataSourceTO connectSite(string sitecode)
        {
            DataSourceTO result = new DataSourceTO();

            if (String.IsNullOrEmpty(sitecode))
            {
                result.fault = new FaultTO(NO_SITECODE);
            }
            else if (mySession.SiteTable == null || mySession.SiteTable.getSite(sitecode) == null)
            {
                result.fault = new FaultTO(NO_SITE_TABLE);
            }
            else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0 && mySession.ConnectionSet.HasConnection(sitecode))
            {
                result.fault = new FaultTO(ALREADY_CONNECTED_TO_SITE);
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                Site               site       = (Site)mySession.SiteTable.Sites[sitecode];
                DataSource         dataSource = site.getDataSourceByModality("HIS");
                AbstractDaoFactory factory    = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(dataSource.Protocol));
                AbstractConnection c          = factory.getConnection(dataSource);
                c.connect();
                result = new DataSourceTO(dataSource);
                result.welcomeMessage = c.getWelcomeMessage();
                mySession.ConnectionSet.Add(c);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            return(result);
        }
Esempio n. 5
0
 public void setup()
 {
     _cxn = new MockConnection("1128", "VISTA");
     _dao = new VistaSchedulingDao(_cxn);
     _cxn.connect();
 }
Esempio n. 6
0
        internal void buildConnectionSetForGetClaimants()
        {
            Dictionary <string, AbstractConnection> cxns = new Dictionary <string, AbstractConnection>(3);

            //DataSource nptSrc = new DataSource();
            //nptSrc.Protocol = "NPT";
            //nptSrc.SiteId = new SiteId("NPT", "National Patient Table");
            //AbstractConnection nptCxn = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.NPT).getConnection(nptSrc);
            //try
            //{
            //    nptCxn.connect();
            //    cxns.Add("NPT", nptCxn);
            //}
            //catch (Exception ex)
            //{
            //}

            DataSource adrSrc = new DataSource();

            adrSrc.Protocol         = "ADR";
            adrSrc.SiteId           = new SiteId("ADR", "Administrative Data Repository");
            adrSrc.ConnectionString = gov.va.medora.mdo.dao.oracle.adr.AdrConstants.DEFAULT_CXN_STRING;
            AbstractConnection adrCxn = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.ADR).getConnection(adrSrc);

            try
            {
                adrCxn.connect();
                cxns.Add("ADR", adrCxn);
            }
            catch (Exception ex)
            {
            }

            DataSource vadirSrc = new DataSource();

            vadirSrc.Protocol         = "VADIR";
            vadirSrc.SiteId           = new SiteId("VADIR", "VA-DoD Information Repository");
            vadirSrc.ConnectionString = gov.va.medora.mdo.dao.oracle.vadir.VadirConstants.DEFAULT_CXN_STRING;
            AbstractConnection vadirCxn = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.VADIR).getConnection(vadirSrc);

            try
            {
                vadirCxn.connect();
                cxns.Add("VADIR", vadirCxn);
            }
            catch (Exception ex)
            {
            }

            DataSource vbacorpSrc = new DataSource();

            vbacorpSrc.Protocol         = "VBACORP";
            vbacorpSrc.SiteId           = new SiteId("VBACORP", "VBA Corp");
            vbacorpSrc.ConnectionString = gov.va.medora.mdo.dao.oracle.vbacorp.VbacorpConstants.DEFAULT_CXN_STRING;
            AbstractConnection vbacorpCxn = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.VBACORP).getConnection(vbacorpSrc);

            try
            {
                vbacorpCxn.connect();
                cxns.Add("VBACORP", vbacorpCxn);
            }
            catch (Exception ex)
            {
            }

            mySession.ConnectionSet = new ConnectionSet(cxns);
        }