Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1.  
  2. void __fastcall TFMain::ICMPReply(TComponent *ASender,
  3.       const TReplyStatus &AReplyStatus)
  4. {
  5.  AnsiString sTime, result[5];
  6. try
  7.  
  8. {
  9.      if(AReplyStatus.MsRoundTripTime == 0)
  10.      {
  11.           sTime = "<1";
  12.      }
  13.      else
  14.      {
  15.           sTime = "=";
  16.      }
  17.  
  18.      result[0] = IntToStr(AReplyStatus.BytesReceived);
  19.      result[1] = AReplyStatus.FromIpAddress;
  20.      result[2] = IntToStr((int)AReplyStatus.SequenceId);
  21.      result[3] = IntToStr((int)AReplyStatus.TimeToLive);
  22.      result[4] = sTime;
  23.      result[5] = IntToStr(AReplyStatus.MsRoundTripTime);
  24.   }
  25.   catch (...)
  26.   { StatusBar1->Panels->Items[3]->Text = "Сервер недоступний";
  27.    ServerGo=false;
  28.   }
  29.    if (result[0]=="0")
  30.    {StatusBar1->Panels->Items[3]->Text = "Сервер недоступний";
  31.    ServerGo=false;
  32.    }
  33.    else
  34.    {StatusBar1->Panels->Items[3]->Text = "Сервер доступний";
  35.    ServerGo=true;
  36.    }
  37. }
  38. //************************************************************************
  39. void __fastcall TFMain::OpenServerExecute(TObject *Sender)
  40. {
  41. //Авторизація користувача в системі
  42.      try
  43.      {
  44.      FMain->ICMP->OnReply = FMain->ICMPReply;
  45.      FMain->ICMP->ReceiveTimeout = 1000;
  46.    
  47.           FMain->ICMP->Host = FMain->DB.server;
  48.                FMain->ICMP->Ping();
  49.                Application->ProcessMessages();
  50.                // Sleep(1000);
  51.      }
  52.    //  __finally
  53.    catch (...) { }
  54.      {
  55.  
  56. if ( (FMain->ServerGo==true) && (FMain->user.user_id.Length()>1))
  57.  {
  58.  
  59.   if (!DMServer->OraDB->Connected)
  60.   { DMServer->OraDB->Server=FMain->DB.server+":2121:MACS";
  61.     DMServer->OraDB->Username=FMain->user.user_id;
  62.     DMServer->OraDB->Password=FMain->user.pw;
  63.     DMServer->OraDB->LoginPrompt=false;
  64.     try
  65.                 {
  66.                 DMServer->OraDB->Connect();
  67.                 }
  68.                 catch (...)
  69.                 {  }
  70.  
  71.  }
  72.  }
  73.  }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement