Changeset 1180 for BMXNET_RPMS_dotNET_UTILITIES-BMX
- Timestamp:
- May 11, 2011, 9:17:45 AM (14 years ago)
- Location:
- BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/BMXNetSessionConnection.cs
r1146 r1180 441 441 public abstract int ReceiveTimeout { get; set; } 442 442 public abstract int SendTimeout { get; set; } 443 public abstract Encoding ConnectionEncoding { get; set; } 443 444 444 445 … … 469 470 // The writer lock request timed out. 470 471 //TODO: Remark: to writer lock for Transmit RPC 471 Debug.Write("TransmitRPC writer lock request timed out.\n"); 472 //SMH: Wrong error message. We do have an exception, but nothing to do with a lock. 473 //Debug.Write("TransmitRPC writer lock request timed out.\n"); 474 Debug.Write("Exception: " + exception.Message); 472 475 throw exception; 473 476 } -
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/Net/BMXNetSessionSocketConnection.cs
r1146 r1180 24 24 public static int DefaultReceiveTimeout = 40000; 25 25 26 26 27 private int _sendTimeout = 0; 27 28 … … 63 64 } 64 65 66 public override Encoding ConnectionEncoding // Default Encoding determined by Windows; typically a Windows Code Page 67 { 68 get; 69 set; 70 } 71 72 65 73 public BMXNetSessionSocketConnection(BMXNetBroker aBroker):base(aBroker) 66 74 { … … 70 78 m_sWISH = ""; 71 79 m_cHDR = ADEBHDR(m_sWKID,m_sWINH,m_sPRCH,m_sWISH); 80 81 ConnectionEncoding = Encoding.Default; 72 82 73 83 } … … 218 228 } 219 229 220 221 222 223 230 bool m_bLogging = false; 224 231 … … 239 246 { 240 247 String cMSG = ADEBLDMsg(m_cHDR, "BMX CONNECT STATUS", ""); 241 248 #if DEBUG 249 _watch = new Stopwatch(); 250 _watch.Start(); 251 #endif 242 252 this.SendString(this.Socket, cMSG); 243 253 String strReceive = ReceiveString(this.Socket); 254 #if DEBUG 255 _watch.Stop(); 256 257 Debug.WriteLine("Time: " + _watch.ElapsedMilliseconds + " ms"); 258 Debug.WriteLine("---"); 259 _watch = null; 260 #endif 261 244 262 String port = BMXNetBroker.Piece(strReceive, "|", 1); 245 263 String message = BMXNetBroker.Piece(strReceive, "|", 2); … … 275 293 } 276 294 277 295 Stopwatch _watch = new Stopwatch(); 296 278 297 protected override String SendReceiveString(string cSendString, string cMult) 279 298 { 280 299 #if DEBUG 281 Stopwatch_watch = new Stopwatch();300 _watch = new Stopwatch(); 282 301 _watch.Start(); 283 Debug.WriteLine("Sending (T:" + Thread.CurrentThread.ManagedThreadId + "): " + cSendString);284 302 #endif 285 303 this.SendString(this.m_pCommSocket, cSendString, cMult); 304 Debug.WriteLine("Time After Send: " + _watch.ElapsedMilliseconds + " ms"); 286 305 string _received = this.ReceiveString(this.m_pCommSocket); 287 306 #if DEBUG 288 Debug.WriteLine("Received(T:" + Thread.CurrentThread.ManagedThreadId + "): " + _received.Replace((char) 30, (char) 10)); 307 _watch.Stop(); 308 289 309 Debug.WriteLine("Time: " + _watch.ElapsedMilliseconds + " ms"); 290 310 Debug.WriteLine("---"); … … 303 323 protected virtual void SendString(TcpClient tcpClient, string cSendString, string cMult) 304 324 { 325 #if DEBUG 326 Debug.WriteLine("Sending (T:" + Thread.CurrentThread.ManagedThreadId + "): " + cSendString); 327 #endif 305 328 String encodedString = this.EncodeSendString(cSendString, cMult); 306 329 307 330 NetworkStream ns = tcpClient.GetStream(); 308 331 ns.WriteTimeout = this.SendTimeout; 309 byte[] sendBytes = Encoding.ASCII.GetBytes(encodedString);332 byte[] sendBytes = ConnectionEncoding.GetBytes(encodedString); 310 333 ns.Write(sendBytes,0,sendBytes.Length); 311 334 if (this.m_bLogging == true) … … 319 342 private string ReceiveString(TcpClient tcpClient) 320 343 { 321 NetworkStream ns = tcpClient.GetStream(); 344 #if DEBUG 345 Debug.WriteLine("Time At Start of Receive: " + _watch.ElapsedMilliseconds + " ms"); 346 #endif 347 348 NetworkStream ns = tcpClient.GetStream(); 349 ns.ReadTimeout = this.ReceiveTimeout; //Timeout; throw exception automatically if we time out. 350 351 MemoryStream mStream = new MemoryStream(1500); // Auto expanding memory storage for what we receive 352 int numberOfBytesRead = 0; 353 bool bFinished = false; // Have we found the End of Transmission (ASCII 4) yet? 354 355 // Main Read Loop 356 while (!bFinished) //while we are not done 357 { 358 byte[] bReadBuffer = new byte[1500]; //buffer size = MTU. Message MUST be smaller. 359 numberOfBytesRead = ns.Read(bReadBuffer, 0, bReadBuffer.Length); //read data 360 bFinished = FindChar(bReadBuffer, (char)4) > -1; //look for the EOT (ASCII 4) character 361 if (!bFinished) mStream.Write(bReadBuffer, 0, numberOfBytesRead); //if we are not done, put the whole stream in 362 else mStream.Write(bReadBuffer, 0, numberOfBytesRead - 1); //otherwise, number of bytes minus the $C(4) at the end 363 } 364 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 393 394 String decodedReceiveString = this.DecodeReceiveString(sReadBuffer); 395 396 if (this.m_bLogging) 397 { 398 Log("Received: " + decodedReceiveString, this.m_LogWriter); 399 } 400 #if DEBUG 401 Debug.WriteLine("Time At End of Receive: " + _watch.ElapsedMilliseconds + " ms"); 402 Debug.WriteLine("Received(T:" + Thread.CurrentThread.ManagedThreadId + "): " + decodedReceiveString.Replace((char)30, (char)10)); 403 #endif 404 return decodedReceiveString; 405 406 407 /* OLD CODE 408 NetworkStream ns = tcpClient.GetStream(); 322 409 ns.ReadTimeout = this.ReceiveTimeout; 323 410 … … 409 496 Log("Received: " + decodedReceiveString, this.m_LogWriter); 410 497 } 498 #if DEBUG 499 Debug.WriteLine("Time At End of Receive: " + _watch.ElapsedMilliseconds + " ms"); 500 #endif 411 501 return decodedReceiveString; 412 502 */ 413 503 } 414 504 … … 422 512 //Build AV Call 423 513 cMSG = ADEBLDMsg(m_cHDR, "BMX AV CODE", winIdentity.Name); 514 #if DEBUG 515 _watch = new Stopwatch(); 516 _watch.Start(); 517 #endif 424 518 SendString(this.Socket, cMSG); 425 426 519 strReceive = ReceiveString(this.Socket); 520 #if DEBUG 521 _watch.Stop(); 522 523 Debug.WriteLine("Time: " + _watch.ElapsedMilliseconds + " ms"); 524 Debug.WriteLine("---"); 525 _watch = null; 526 #endif 527 427 528 sTest = strReceive.Substring(0,3); 428 529 … … 453 554 454 555 cMSG = ADEBLDMsg(m_cHDR, "XUS AV CODE", encryptedAccessVerifyCode); 556 #if DEBUG 557 _watch = new Stopwatch(); 558 _watch.Start(); 559 #endif 455 560 SendString(this.Socket, cMSG); 456 457 561 strReceive = ReceiveString(this.Socket); 562 #if DEBUG 563 _watch.Stop(); 564 565 Debug.WriteLine("Time: " + _watch.ElapsedMilliseconds + " ms"); 566 Debug.WriteLine("---"); 567 _watch = null; 568 #endif 458 569 459 570 if (strReceive.StartsWith("M ERROR=")) … … 519 630 throw new BMXNetException("BMXNetBroker is not connected to RPMS"); 520 631 } 521 632 #if DEBUG 633 _watch = new Stopwatch(); 634 _watch.Start(); 635 #endif 522 636 this.SendString(this.Socket, ADEBLDMsg(m_cHDR, "BMXGetFac", aDuz)); 523 637 return this.ReceiveString(this.Socket); 638 #if DEBUG 639 _watch = new Stopwatch(); 640 _watch.Start(); 641 #endif 642 524 643 } 525 644 catch (BMXNetException bmxEx) -
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/RemoteSession.cs
r1146 r1180 47 47 /// </example> 48 48 String AppContext { get; set; } 49 50 Encoding ConnectionEncoding { get; set; } 49 51 50 52 #endregion … … 680 682 /// <param name="aString">The command to be examined</param> 681 683 /// <returns>True if it complied, otherwise false</returns> 682 bool IsBmxAdoCommand(String aString); 684 bool IsBmxAdoCommand(String aString); 685 686 /// <summary> 687 /// Locks a Name on the Mumps Database 688 /// </summary> 689 /// <param name="g/lvnToLock">Global or Local Name to Lock</param> 690 /// <param name="addOrSubstract">+ or - to increment or decrement the lock</param> 691 /// <returns>true for success; false for failure</returns> 692 bool Lock(string lvnToLock, string addOrSubstract); 693 683 694 #endregion 684 695 -
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/Sevices/BMXNetRemoteSession.cs
r1146 r1180 1 1 using System; 2 2 using System.Data; 3 using System.Text; 3 4 using System.Windows.Forms; 4 5 using IndianHealthService.BMXNet.Model; … … 76 77 } 77 78 79 public Encoding ConnectionEncoding 80 { 81 get 82 { 83 return SessionConnection.ConnectionEncoding; 84 } 85 set 86 { 87 SessionConnection.ConnectionEncoding = value; 88 } 89 } 90 78 91 public bool IsEventPollingEnabled 79 92 { … … 509 522 } 510 523 524 //smh: THIS IS WRONG. If you pass the data set, why make a new dataset... 511 525 public DataTable TableFromSQL(string sql, DataSet aDataSet, string aTableName) 512 526 { 513 return this.TableFromSQL(sql, new DataSet(), this.DefaultTableName, this.AppContext);527 return this.TableFromSQL(sql, aDataSet, aTableName, this.AppContext); 514 528 } 515 529 … … 1070 1084 } 1071 1085 } 1086 1087 public bool Lock(string lvnToLock, string addOrSubstract) 1088 { 1089 return SessionConnection.Lock(lvnToLock, addOrSubstract); 1090 } 1072 1091 } 1073 1092 } -
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/Sevices/BMXNetSessionConnectionOverAnotherSessionConnection.cs
r1146 r1180 35 35 } 36 36 37 public override Encoding ConnectionEncoding 38 { 39 get; 40 set; 41 } 42 37 43 public override void Close() 38 44 { -
BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet/bmxnet.xml
r1146 r1180 1051 1051 <param name="aString">The command to be examined</param> 1052 1052 <returns>True if it complied, otherwise false</returns> 1053 </member> 1054 <member name="M:IndianHealthService.BMXNet.RemoteSession.Lock(System.String,System.String)"> 1055 <summary> 1056 Locks a Name on the Mumps Database 1057 </summary> 1058 <param name="g/lvnToLock">Global or Local Name to Lock</param> 1059 <param name="addOrSubstract">+ or - to increment or decrement the lock</param> 1060 <returns>true for success; false for failure</returns> 1053 1061 </member> 1054 1062 <member name="M:IndianHealthService.BMXNet.RemoteSession.Close">
Note:
See TracChangeset
for help on using the changeset viewer.