BMX version bumped to 2.3.

New dll
BMXNetConnectInfo: Event polling from RPMS/VISTA is now async. BMX Writer lock removed.
BMXNetLib: 
1. Application context changes are now suppressed. Developer must make sure that his/her application has all the needed BMX methods. This was done for performance enhancement as application context changes are very expensive in network time.
2. Locks are implemented at the TransmitRPC with a very simple Lock(this) which works very well.
RPMSDb: See #1 for BMXNetLib. All context changes are now suppressed.
This commit is contained in:
sam 2011-01-26 10:45:02 +00:00
parent 37366be3d9
commit dbd2742358
6 changed files with 163 additions and 87 deletions

View File

@ -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)]

View File

@ -11,7 +11,7 @@
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>BMXNet22</AssemblyName>
<AssemblyName>BMXNet23</AssemblyName>
<AssemblyOriginatorKeyFile>wv.key.snk</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
@ -28,7 +28,7 @@
</UpgradeBackupLocation>
<SignAssembly>false</SignAssembly>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>

View File

@ -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");
}
}
/// <summary>
/// Callback for Async operation to get events from RPMS/VISTA server
/// </summary>
/// <param name="itfAR"></param>
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

View File

@ -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)

View File

@ -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;
}

Binary file not shown.