diff --git a/cs/bmx_0200scr/BMX2/BMXNet/AssemblyInfo.cs b/cs/bmx_0200scr/BMX2/BMXNet/AssemblyInfo.cs index 3d6f97e..efedc0f 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/AssemblyInfo.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/AssemblyInfo.cs @@ -27,7 +27,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.2.0.*")] +[assembly: AssemblyVersion("2.3.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the @@ -57,5 +57,5 @@ using System.Runtime.InteropServices; //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile("")] //[assembly: AssemblyKeyName("")] -[assembly: AssemblyFileVersionAttribute("2.2.0.0")] +[assembly: AssemblyFileVersionAttribute("2.3.0.0")] [assembly: ComVisibleAttribute(false)] diff --git a/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj b/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj index da5a386..4ac7b24 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj +++ b/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj @@ -11,7 +11,7 @@ - BMXNet22 + BMXNet23 wv.key.snk JScript Grid @@ -28,7 +28,7 @@ false 3.5 - v3.5 + v4.0 publish\ true Disk diff --git a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs index 11cdd69..f4476fb 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs @@ -12,6 +12,7 @@ using System.Text; using System.Security.Cryptography; using System.Timers; using System.Threading; +using System.Runtime.Remoting.Messaging; namespace IndianHealthService.BMXNet @@ -227,7 +228,7 @@ namespace IndianHealthService.BMXNet { try { - this.bmxNetLib.BMXRWL.AcquireWriterLock(5); + //this.bmxNetLib.BMXRWL.AcquireWriterLock(5); try { this.m_timerEvent.Enabled = false; @@ -264,15 +265,21 @@ namespace IndianHealthService.BMXNet this.CreateHandle(); } RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(RPMSDataTable); - dtEvents = (DataTable) this.Invoke(rdtd, new object[] {"BMX EVENT POLL", "BMXNetEvents"}); - } + + //SMH - 3100110 - BMX EVENT POLL happens in the foreground. It blocks the main thread + //until it is done. So I changed it to async so that there would be no jerking + //on this thread while it's taking place. + //dtEvents = (DataTable) this.Invoke(rdtd, new object[] {"BMX EVENT POLL", "BMXNetEvents"}); + + rdtd.BeginInvoke("BMX EVENT POLL", "BMXNetEvents", new AsyncCallback(BMXNetEventsCallback), null); + } catch (Exception ex) { string sMsg = ex.Message; this.m_timerEvent.Enabled = true; return; } - + /* try { if (dtEvents.Rows.Count == 0) @@ -285,6 +292,7 @@ namespace IndianHealthService.BMXNet { Debug.Write("upper Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n"); } + try { //If events exist, raise BMXNetEvent @@ -304,23 +312,70 @@ namespace IndianHealthService.BMXNet { Debug.Write("lower Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n"); } + */ } catch(Exception ex) { Debug.Write("Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n"); } - finally - { - this.bmxNetLib.BMXRWL.ReleaseWriterLock(); - this.m_timerEvent.Enabled = true; - } - } + finally + { + //this.bmxNetLib.BMXRWL.ReleaseWriterLock(); + //this.m_timerEvent.Enabled = true; + } + + } catch { Debug.Write(" OnEventTimer failed to obtain lock.\n"); } } + + /// + /// Callback for Async operation to get events from RPMS/VISTA server + /// + /// + void BMXNetEventsCallback(IAsyncResult itfAR) + { + //Define datatable we will receive results at. + DataTable dtEvents; + //Get Result + AsyncResult ar = (AsyncResult)itfAR; + //Get Original Delegate + RPMSDataTableDelegate rdtd = (RPMSDataTableDelegate)ar.AsyncDelegate; + + //Complete the call of the delegate. We may lose connection so try catch + try + { + dtEvents = rdtd.EndInvoke(itfAR); + } + catch (Exception ex) + { + throw new BMXNetException("Lost connection to Server", ex); + } + + BMXNetEventArgs args = new BMXNetEventArgs(); + + //Fire off BMXNetEvent to interested subscribers + if (dtEvents.Rows.Count != 0) + { + foreach (DataRow dr in dtEvents.Rows) + { + args.BMXEvent = dr["EVENT"].ToString(); + args.BMXParam = dr["PARAM"].ToString(); + if (BMXNetEvent != null) + { + BMXNetEvent(this, args); + } + } + } + + //re-enable the timer so it can check again for events + + this.m_timerEvent.Enabled = true; + } + #endregion BMXNetEvent #region Fields diff --git a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs index 2189ec9..dc56d15 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs @@ -1026,15 +1026,17 @@ namespace IndianHealthService.BMXNet { try { - string sContext = this.AppContext; - this.AppContext = "BMXRPC"; + /* 3110109 -- smh Commented out for performance issues. + /*string sContext = this.AppContext; + this.AppContext = "BMXRPC";*/ Variable = Variable.Replace("^","~"); string sRet = "0"; bool bRet = false; string sParam = Variable + "^" + Increment + "^" + TimeOut; sRet = TransmitRPC("BMX LOCK", sParam); bRet = (sRet == "1")?true:false; - this.AppContext = sContext; + /* 3110109 -- smh Commented out for performance issues. + /*this.AppContext = sContext;*/ return bRet; } catch (Exception ex) @@ -1076,66 +1078,74 @@ namespace IndianHealthService.BMXNet public string TransmitRPC(string sRPC, string sParam, int nLockTimeOut) { - try - { - try - { - if (m_bConnected == false) - { - throw new BMXNetException("BMXNetLib.TransmitRPC failed because BMXNetLib is not connected to RPMS."); - } - Debug.Assert(m_cDUZ != ""); - Debug.Assert(m_pCommSocket != null); + lock (this) // This method CANNOT be executed simultaneously! + { + try + { + try + { + if (m_bConnected == false) + { + throw new BMXNetException("BMXNetLib.TransmitRPC failed because BMXNetLib is not connected to RPMS."); + } + Debug.Assert(m_cDUZ != ""); + Debug.Assert(m_pCommSocket != null); - string sOldAppContext = ""; - if (sRPC.StartsWith("BMX")&&(this.m_cAppContext != "BMXRPC")) - { - sOldAppContext = this.m_cAppContext; - this.AppContext = "BMXRPC"; - } - string sMult = ""; - string sSend = ADEBLDMsg(m_cHDR, sRPC, sParam, ref sMult); - SendString(m_pCommSocket, sSend, sMult); -#if TRACE - DateTime sendTime = DateTime.Now; - Debug.Write("TransmitRPC Sent: " + sSend.Replace((char) 30, (char) 10) + "\n"); -#endif - string strResult = ReceiveString(m_pCommSocket); + string sOldAppContext = ""; + /* 3110109 -- smh Commented out for performance issues. + if (sRPC.StartsWith("BMX")&&(this.m_cAppContext != "BMXRPC")) + { + sOldAppContext = this.m_cAppContext; + this.AppContext = "BMXRPC"; + } + */ + string sMult = ""; + string sSend = ADEBLDMsg(m_cHDR, sRPC, sParam, ref sMult); + SendString(m_pCommSocket, sSend, sMult); #if TRACE - DateTime receiveTime = DateTime.Now; - Debug.Write("TransmitRPC Received: " + strResult.Replace((char) 30, (char) 10) + "\n"); - TimeSpan executionTime = receiveTime - sendTime; - Debug.Write("Execution Time: " + executionTime.TotalMilliseconds + " ms.\n"); - Debug.Write("-------------------------------------------------------\n"); + DateTime sendTime = DateTime.Now; + int threadid = Thread.CurrentThread.ManagedThreadId; + Debug.Write("TransmitRPC Sent: (T:" + threadid + ")" + sSend.Replace((char)30, (char)10) + "\n"); #endif - if (sOldAppContext != "") + string strResult = ReceiveString(m_pCommSocket); +#if TRACE + DateTime receiveTime = DateTime.Now; + Debug.Write("TransmitRPC Received: (T:" + threadid + ")" + strResult.Replace((char)30, (char)10) + "\n"); + TimeSpan executionTime = receiveTime - sendTime; + Debug.Write("Execution Time: " + executionTime.TotalMilliseconds + " ms.\n"); + Debug.Write("-------------------------------------------------------\n"); +#endif + /* /* 3110109 -- smh Commented out for performance issues. + * if (sOldAppContext != "") { this.AppContext = sOldAppContext; } - return strResult; - } - catch (Exception ex) - { - if (ex.Message == "Unable to write data to the transport connection.") - { - m_bConnected = false; - } - throw ex; - } - finally - { - } - } - catch (ApplicationException aex) - { - // The writer lock request timed out. - Debug.Write("TransmitRPC writer lock request timed out.\n"); - throw aex; - } - catch (Exception OuterEx) - { - throw OuterEx; - } + */ + return strResult; + } + catch (Exception ex) + { + if (ex.Message == "Unable to write data to the transport connection.") + { + m_bConnected = false; + } + throw ex; + } + finally + { + } + } + catch (ApplicationException aex) + { + // The writer lock request timed out. + Debug.Write("TransmitRPC writer lock request timed out.\n"); + throw aex; + } + catch (Exception OuterEx) + { + throw OuterEx; + } + } } public string TransmitRPC(string sRPC, string sParam) diff --git a/cs/bmx_0200scr/BMX2/BMXNet/RPMSDb.cs b/cs/bmx_0200scr/BMX2/BMXNet/RPMSDb.cs index 8b40e26..5f85463 100644 --- a/cs/bmx_0200scr/BMX2/BMXNet/RPMSDb.cs +++ b/cs/bmx_0200scr/BMX2/BMXNet/RPMSDb.cs @@ -86,22 +86,27 @@ namespace IndianHealthService.BMXNet private void _executeUpdate(out RPMSDbResultSet resultset) { string sRPC; - string sOldContext = m_rpx.AppContext; - if (m_rpx.AppContext != "BMXRPC") - { - m_rpx.AppContext = "BMXRPC"; - } + /* /* 3110109 -- smh Commented out for performance + string sOldContext = m_rpx.AppContext; + + if (m_rpx.AppContext != "BMXRPC") + { + m_rpx.AppContext = "BMXRPC"; + } + */ sRPC = "BMX UPDATE"; int nStart = 7; m_sCmd = m_sCmd.Substring(nStart); string sResult = m_rpx.TransmitRPC( sRPC, m_sCmd); - - if (sOldContext != m_rpx.AppContext) - { - m_rpx.AppContext = sOldContext; - } + + /* /* 3110109 -- smh Commented out for performance + if (sOldContext != m_rpx.AppContext) + { + m_rpx.AppContext = sOldContext; + } + */ resultset = new RPMSDbResultSet(); resultset.recordsAffected = 1; //Make this the return value of the call @@ -112,13 +117,17 @@ namespace IndianHealthService.BMXNet //Make rpx call string sRPC; string sParam; - string sOldContext = m_rpx.AppContext; - if (m_sQueryType == "SELECT") + /* /* 3110109 -- smh Commented out for performance issues. + string sOldContext = m_rpx.AppContext; + */ + if (m_sQueryType == "SELECT") { - if (m_rpx.AppContext != "BMXRPC") - { - m_rpx.AppContext = "BMXRPC"; - } + /*/* 3110109 -- smh Commented out for performance issues. + if (m_rpx.AppContext != "BMXRPC") + { + m_rpx.AppContext = "BMXRPC"; + } + */ sRPC = "BMX SQL"; sParam = m_sCmd; } @@ -130,10 +139,12 @@ namespace IndianHealthService.BMXNet string sResult = m_rpx.TransmitRPC( sRPC, sParam); + /* if (sOldContext != m_rpx.AppContext) { m_rpx.AppContext = sOldContext; } + */ return sResult; } diff --git a/cs/bmx_0200scr/BMX2/BMXNet/bin/Release/BMXNet23.dll b/cs/bmx_0200scr/BMX2/BMXNet/bin/Release/BMXNet23.dll new file mode 100644 index 0000000..37330c9 Binary files /dev/null and b/cs/bmx_0200scr/BMX2/BMXNet/bin/Release/BMXNet23.dll differ