Ignore:
Timestamp:
May 26, 2011, 5:45:42 AM (14 years ago)
Author:
Sam Habiel
Message:

BMXNetEhrSessionConnection.cs implements ConnectionEncoding so that the project can compile.
BMXNetEhrSessionConnection.cs: ReceiveString TCP code refactored, AGAIN!

Updated dlls.

Location:
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.EHR/BMXNetEhrSessionConnection.cs

    r1146 r1193  
    2020            get { return 60000; }
    2121            set { }
     22        }
     23
     24        public override Encoding ConnectionEncoding
     25        {
     26            get
     27            {
     28                return System.Text.Encoding.Default;
     29            }
     30            set
     31            {
     32                ConnectionEncoding = value;
     33            }
    2234        }
    2335
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/LoginProcess.cs

    r1146 r1193  
    282282        public bool AttemptUserInputLogin(string aDialogTitle, int maxAttempts, bool enableConnectionManagement,IWin32Window aUiOwnerForPositioningDialog)
    283283        {
     284            //test sam
     285            //Framework.SocketBroker.Open(
     286            //Framework.SocketBroker.PrimaryRemoteSession.TransmitRPC("XUS INTRO TEXT","","XUS SIGNON");
     287            //test sam
     288
    284289            this.MaxAttempts = maxAttempts;
    285290            RpmsLoginView view = (RpmsLoginView)new RpmsLoginDialog();
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.WinForm/WinFramework.cs

    r1146 r1193  
    657657        public LoginProcess CreateLoginProcess()
    658658        {
     659            /*
     660            //sam test
     661            BMXNetSocketConnectionSpec spec = new BMXNetSocketConnectionSpec();
     662            spec.Server = this.ConnectionSettings.DefaultConnectionSpec.Server;
     663            spec.Port = this.ConnectionSettings.DefaultConnectionSpec.Port;
     664
     665            var broker = new BMXNetSocketBroker();
     666            broker.ConnectionSpec = spec;
     667            var initcxn = new BMXNetSessionSocketConnection(broker);
     668            initcxn.ConnectionSpec = spec;
     669            initcxn.OpenConnectionCommon();
     670            initcxn.IsConnected = true;
     671            string txt = initcxn.TransmitRPC("XUS INTRO TEXT", "");
     672            //end test
     673            */
    659674            return new LoginProcess(this);
    660675
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/Net/BMXNetSessionSocketConnection.cs

    r1180 r1193  
    1010using System.Threading;
    1111using System.Timers;
     12using System.Linq;
    1213
    1314namespace IndianHealthService.BMXNet.Net
     
    115116     Port = "All",
    116117     Transport = "All")]
    117                 protected virtual void OpenConnectionCommon()
     118        protected virtual void OpenConnectionCommon()
    118119                {
    119120                        try
     
    346347#endif
    347348
     349            /******************INIT*****************/
    348350            NetworkStream ns = tcpClient.GetStream();
    349351            ns.ReadTimeout = this.ReceiveTimeout; //Timeout; throw exception automatically if we time out.
    350352
     353            /*************SECURITY S-PACKET READ***********************/
     354            int secPackLen = ns.ReadByte();  //Read S-Pack Length Byte
     355            byte[] secPackContents = new byte[secPackLen];;
     356            if (secPackLen > 0)
     357            {
     358                ns.Read(secPackContents, 0, secPackLen);
     359            }
     360
     361            /****************ERROR S-PACKET READ******************/
     362            int errPackLen = ns.ReadByte(); //Read S-Pack Length Byte
     363            byte[] errPackConents = new byte[errPackLen];;
     364            if (errPackLen > 0)
     365            {
     366                ns.Read(errPackConents, 0, errPackLen);
     367            }
     368
     369            //If either one of these exists, then we have an error on the Mumps Database
     370            if (secPackLen > 0 || errPackLen > 0)
     371            {
     372                //We still have to read the Data to empty the tcp OS buffers even if we have security/errors in the DB
     373                while (ns.DataAvailable) ns.ReadByte() ;  //while loop to empty the buffer -- this is theoretically slow, but that's not important here
     374
     375                //Now decode them.
     376                string secString = ConnectionEncoding.GetString(secPackContents);
     377                string errString = ConnectionEncoding.GetString(errPackConents);
     378                throw new BMXNetException("Mumps Database Security/Error: " + secString + " | " + errString);
     379            }
     380
     381            /*****************DATA STREAM READ*******************/
     382            //Data stream from VISTA ends when we find the EOT (ASCII 4) character
    351383            MemoryStream mStream = new MemoryStream(1500); // Auto expanding memory storage for what we receive
    352             int numberOfBytesRead = 0; 
     384            int numberOfBytesRead = 0;
    353385            bool bFinished = false;  // Have we found the End of Transmission (ASCII 4) yet?
    354386
     
    362394                else mStream.Write(bReadBuffer, 0, numberOfBytesRead - 1);           //otherwise, number of bytes minus the $C(4) at the end
    363395            }
     396
     397            //At this point, we are done reading from the Network Stream. Now we have to decode the data.
    364398           
    365             //Read Security S-Packet
    366             mStream.Seek(0, SeekOrigin.Begin);
    367             int secLength = mStream.ReadByte();
    368             byte[] secBytes = new byte[secLength];
    369             if (secLength > 0)
    370             {
    371                 mStream.Read(secBytes, 0, secLength);
    372             }
    373 
    374             //Read Error S-Packet
    375             mStream.Seek(secLength + 1, SeekOrigin.Begin);
    376             int errLength = mStream.ReadByte();
    377             byte[] errBytes = new byte[errLength];
    378             if (errLength > 0)
    379             {
    380                 mStream.Read(errBytes, 0, errLength);
    381             }
    382 
    383             //If either one of these exists, then we have an error on the Mumps Database
    384             if (secLength > 0 || errLength > 0)
    385             {
    386                 string errString = ConnectionEncoding.GetString(secBytes);
    387                 string appString = ConnectionEncoding.GetString(errBytes);
    388                 throw new BMXNetException("Mumps Database Security/Error: " + errString + " | " + appString);
    389             }
    390 
    391             //No Errors. Decode the entire message starting from after the S packets above
    392             string sReadBuffer = ConnectionEncoding.GetString(mStream.ToArray(), secLength + errLength + 2, mStream.ToArray().Length - (secLength + errLength + 2)); //decode
     399            //Decode the entire message.
     400            string sReadBuffer = ConnectionEncoding.GetString(mStream.ToArray()); //decode
    393401
    394402            String decodedReceiveString = this.DecodeReceiveString(sReadBuffer);
     
    636644                this.SendString(this.Socket, ADEBLDMsg(m_cHDR, "BMXGetFac", aDuz));
    637645                return this.ReceiveString(this.Socket);
    638 #if DEBUG
    639                 _watch = new Stopwatch();
    640                 _watch.Start();
    641 #endif
    642 
    643646                        }
    644647                        catch (BMXNetException bmxEx)
Note: See TracChangeset for help on using the changeset viewer.