コード例 #1
0
ファイル: ConnectionLib.cs プロジェクト: monkeyglasses/mdws
        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);
        }
コード例 #2
0
ファイル: ConnectionPool.cs プロジェクト: marcsommer/mdo
        void growPool()
        {
            //Console.WriteLine("Connection pool at min size {0} - growing by {1}", this.PoolSource.MinPoolSize, this.PoolSource.PoolExpansionSize);
            int growSize = this.PoolSource.PoolExpansionSize;

            if (this.TotalResources + growSize > this.PoolSource.MaxPoolSize) // if the growth would expand the pool above the max pool size, only grow by the amount allowed
            {
                growSize = this.PoolSource.MaxPoolSize - this.TotalResources;
            }
            for (int i = 0; i < growSize; i++)
            {
                ConnectionThread a = new ConnectionThread();
                a.Connection = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(((ConnectionPoolSource)this.PoolSource).CxnSource.Protocol))
                               .getConnection(((ConnectionPoolSource)this.PoolSource).CxnSource);
                Thread t = new Thread(new ParameterizedThreadStart(connect));
                a.Thread = t;
                t.Start(a);
                _startedCxns.Add(a);
            }
        }
コード例 #3
0
        public DataSourceArray connectToLoginSite(string sitecode)
        {
            // TODO - FIX!!! This is very ugly - here so that SOAP and REST services can both be stateful or stateless
            if (!Convert.ToBoolean(_mySession.MdwsConfiguration.AllConfigs[MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][MdwsConfigConstants.CONNECTION_POOLING]))
            {
                return(new gov.va.medora.mdws.ConnectionLib(_mySession).connectToLoginSite(sitecode));
            }

            DataSourceArray result = new DataSourceArray();

            try
            {
                MdwsUtils.checkNullArgs(MdwsUtils.getArgsDictionary(System.Reflection.MethodInfo.GetCurrentMethod().GetParameters(), new List <object>()
                {
                    sitecode
                }));
                MdwsUtils.checkSiteTable(_mySession, sitecode);
                MdwsUtils.checkConnections(_mySession, sitecode);

                Site               site    = _mySession.SiteTable.getSite(sitecode);
                DataSource         src     = site.getDataSourceByModality("HIS");
                AbstractDaoFactory factory = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol));

                // REST
                SessionMgr.getInstance().setConnection(_mySession, sitecode);
                // END REST
                result = new DataSourceArray(src);

                result.items[0].welcomeMessage = "TODO - implement cached connection messages in pool";
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            finally
            {
                //RestSessionMgr.getInstance().returnConnections(_mySession);
            }
            return(result);
        }
コード例 #4
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>";
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: Order.cs プロジェクト: monkeyglasses/mdo-cxn-pool
        internal static IOrdersDao getDao(AbstractConnection cxn)
        {
            AbstractDaoFactory f = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(cxn.DataSource.Protocol));

            return(f.getOrdersDao(cxn));
        }
コード例 #7
0
ファイル: ConnectionPoolTest.cs プロジェクト: marcsommer/mdo
        public void testIsAlive()
        {
            VistaPoolConnection cxn = (VistaPoolConnection)AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant("PVISTA")).getConnection(_localSource.CxnSource);

            cxn.connect();
            login(cxn);

            cxn.setTimeout(new TimeSpan(0, 0, 1)); // set this low - one second - so the test can run quickly

            Assert.IsTrue(cxn.isAlive());

            System.Threading.Thread.Sleep(500); // sleep for less than timeout     \
            //                                                                      \
            cxn.heartbeat();
            Assert.IsTrue(cxn.isAlive());

            System.Threading.Thread.Sleep(500); // sleep for less than timeout     --  These three add up to more than timeout

            cxn.heartbeat();
            Assert.IsTrue(cxn.isAlive());
            //                                                                      /
            System.Threading.Thread.Sleep(500); // sleep for less than timeout     /

            cxn.heartbeat();
            Assert.IsTrue(cxn.isAlive());


            System.Threading.Thread.Sleep(1100);// sleep for more than timeout

            Assert.IsFalse(cxn.isAlive());

            Assert.IsFalse(cxn.IsConnected);

            try
            {
                new VistaPatientDao(cxn).match("m1234");
                Assert.Fail("Uh-oh! Previous line should have thrown exception!");
            }
            catch (Exception)
            {
                // cool!
            }
        }