1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
|
unit AdminServerInfo;
interface
uses
gnugettext, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, AdditionalClasses, Buttons, PNGImage,
InstanceSections, AuxFuncs, myx_public_interface,
ApplicationDataModule, MySQLConnection, MyxError, TntExtCtrls,
TntStdCtrls;
type
TAdminServerInfoForm = class(TInstanceSectionForm)
ServerInfoPnl: TTntPanel;
LogoImg: TTntImage;
RightBGImg: TTntImage;
ConnectionGBox: TTntGroupBox;
UserLbl: TTntLabel;
HostLbl: TTntLabel;
ClientInfoGBox: TTntGroupBox;
ClientVersionCaptionLbl: TTntLabel;
ClientHardwareCaptionLbl: TTntLabel;
ClientOSCaptionLbl: TTntLabel;
ClientNetworkNameCaptionLbl: TTntLabel;
UserCaptionLbl: TTntLabel;
HostCaptionLbl: TTntLabel;
PortCaptionLbl: TTntLabel;
PortLbl: TTntLabel;
InstanceCaptionLbl: TTntLabel;
InstanceNameLbl: TTntLabel;
ClientNetworkNameLbl: TTntLabel;
ClientOSLbl: TTntLabel;
ClientHardwareLabel: TTntLabel;
ClientVersionLbl: TTntLabel;
ClientIPCaptionLabel: TTntLabel;
ClientIPLbl: TTntLabel;
ServiceStatusImg: TTntImage;
Label5: TTntLabel;
ServerStatusLbl: TTntLabel;
ServerInfoGBox: TTntGroupBox;
ServerVersionCaptionLbl: TTntLabel;
ServerHardwareCaptionLbl: TTntLabel;
ServerOSCaptionLbl: TTntLabel;
ServerNetworkNameCaptionLbl: TTntLabel;
ServerNetworkNameLbl: TTntLabel;
ServerOSLbl: TTntLabel;
ServerHardwareLbl: TTntLabel;
ServerVersionLbl: TTntLabel;
ServerIPCaptionLbl: TTntLabel;
ServerIPLbl: TTntLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ServerStatusLblMouseEnter(Sender: TObject);
procedure ServerStatusLblMouseLeave(Sender: TObject);
procedure ServerStatusLblClick(Sender: TObject);
procedure ServerInfoPnlResize(Sender: TObject);
procedure SetServerInfos(Sender: TObject);
procedure SetClientInfos(Sender: TObject);
procedure FetchInfos(Sender: TObject);
procedure GetInfos;
procedure ClearInfos;
function GetFormContentAsText: WideString; override;
procedure ConnectionLost(var Message: TMessage); message WM_CONNECTION_LOST;
procedure ConnectionEstablished(var Message: TMessage); message WM_CONNECTION_ESTABLISHED;
private
FRightBGPNGImg,
FMySQLLogoPNGImg: TPNGObject;
FServiceStatusRunningPNGImg,
FServiceStatusUnknownPNGImg: TPNGObject;
FMaschineInfo: PMYX_MACHINE_INFO;
end;
const
CaptionTextWidth = 25;
var
AdminServerInfoForm: TAdminServerInfoForm;
//----------------------------------------------------------------------------------------------------------------------
implementation
{$R *.dfm}
uses
Main, PNGTools;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.FormCreate(Sender: TObject);
begin
InitForm(self);
RightBGImg.Width := RightBGImg.Width;
DockedPanel := ServerInfoPnl;
FRightBGPNGImg := LoadPNGImageFromResource('dockpnl_bg', RightBGImg);
FMySQLLogoPNGImg := LoadPNGImageFromResource('mysql_logo', LogoImg);
FServiceStatusRunningPNGImg := LoadPNGImageFromResource('service_status_running');
FServiceStatusUnknownPNGImg := LoadPNGImageFromResource('service_status_unknown');
ServiceStatusImg.Picture.Graphic := FServiceStatusRunningPNGImg;
GetInfos;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.FormDestroy(Sender: TObject);
begin
FRightBGPNGImg.Free;
FMySQLLogoPNGImg.Free;
FServiceStatusRunningPNGImg.Free;
FServiceStatusUnknownPNGImg.Free;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ServerStatusLblMouseEnter(Sender: TObject);
begin
ServerStatusLbl.Font.Style := [fsBold, fsUnderline];
ServerStatusLbl.Font.Color := clBlue;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ServerStatusLblMouseLeave(Sender: TObject);
begin
ServerStatusLbl.Font.Style := [fsBold];
ServerStatusLbl.Font.Color := clBlack;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ServerStatusLblClick(Sender: TObject);
begin
if(Owner is TMainForm)then
begin
TMainForm(Owner).SectionControls.AdminTreeView.Selected := TMainForm(Owner).SectionControls.AdminTreeView.Items[1];
end;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ServerInfoPnlResize(Sender: TObject);
begin
LogoImg.Left := ServerInfoPnl.Width - 636 + 484;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.SetServerInfos(Sender: TObject);
begin
ServerVersionLbl.Caption := FMaschineInfo.version;
ServerNetworkNameLbl.Caption := FMaschineInfo.network_name;
ServerIPLbl.Caption := FMaschineInfo.IP;
ServerOSLbl.Caption := FMaschineInfo.OS;
ServerHardwareLbl.Caption := FMaschineInfo.hardware;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.SetClientInfos(Sender: TObject);
begin
ClientVersionLbl.Caption := FMaschineInfo.version;
if FMaschineInfo.network_name <> '' then
ClientNetworkNameLbl.Caption := FMaschineInfo.network_name
else
begin
if FMaschineInfo.IP = '127.0.0.1' then
ClientNetworkNameLbl.Caption := _('localhost')
else
ClientNetworkNameLbl.Caption := _('unknown');
end;
ClientIPLbl.Caption := FMaschineInfo.IP;
ClientOSLbl.Caption := FMaschineInfo.OS;
ClientHardwareLabel.Caption := FMaschineInfo.hardware;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.FetchInfos(Sender: TObject);
var
PMySQL: Pointer;
begin
PMySQL := myx_mysql_init;
try
if myx_connect_to_instance(MySQLConn.UserConnection.get_record_pointer, PMySQL) <> 0 then
raise EMyxSQLError.Create(_('Cannot clone MySQL connection.'), myx_mysql_errno(PMySQL), myx_mysql_error(PMySQL));
// Display client infos
FMaschineInfo := myx_get_client_info(PMySQL);
TFetchDataThread(Sender).ExecuteSynchronized(SetClientInfos);
myx_free_pc_info(FMaschineInfo);
// Display server infos
FMaschineInfo := myx_get_server_info(MySQLConn.UserConnection.get_record_pointer, PMySQL);
TFetchDataThread(Sender).ExecuteSynchronized(SetServerInfos);
myx_free_pc_info(FMaschineInfo);
finally
myx_mysql_close(PMySQL);
end;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.GetInfos;
var
NewHeight: integer;
begin
// Start Thread fetching data
MySQLConn.FetchData(dkStatusVars, FetchInfos, nil, nil, _('Fetching Server Status ...'), True);
// Display connection Infos
UserLbl.Caption := MySQLConn.UserConnection.username;
HostLbl.Caption := MySQLConn.UserConnection.hostname;
PortLbl.Caption := IntToStr(MySQLConn.UserConnection.port);
InstanceNameLbl.Caption := '';
//Hide unknown fields
NewHeight := 105;
if(InstanceNameLbl.Caption='-')or
(InstanceNameLbl.Caption='')then
begin
InstanceCaptionLbl.Hide;
InstanceNameLbl.Hide;
NewHeight := NewHeight-18;
end;
ConnectionGBox.Height := NewHeight;
ServerInfoGBox.Top := ConnectionGBox.Top+ConnectionGBox.Height+9;
NewHeight := 127;
if(ServerOSLbl.Caption='-')then
begin
ServerOSCaptionLbl.Hide;
ServerOSLbl.Hide;
NewHeight := NewHeight-18;
end;
if(ServerHardwareLbl.Caption='-')then
begin
ServerHardwareCaptionLbl.Hide;
ServerHardwareLbl.Hide;
NewHeight := NewHeight-18;
end;
ServerInfoGBox.Height := NewHeight;
ClientInfoGBox.Top := ServerInfoGBox.Top+ServerInfoGBox.Height+9;
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ClearInfos;
begin
UserLbl.Caption := '-';
HostLbl.Caption := '-';
PortLbl.Caption := '-';
InstanceNameLbl.Caption := '-';
ServerVersionLbl.Caption := '-';
ServerNetworkNameLbl.Caption := '-';
ServerIPLbl.Caption := '-';
ServerOSLbl.Caption := '-';
ServerHardwareLbl.Caption := '-';
ClientVersionLbl.Caption := '-';
ClientNetworkNameLbl.Caption := '-';
ClientIPLbl.Caption := '-';
ClientOSLbl.Caption := '-';
ClientHardwareLabel.Caption := '-';
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ConnectionLost(var Message: TMessage);
begin
ClearInfos;
ServerStatusLbl.Caption := _('Disconnected from Server.');
ServiceStatusImg.Picture.Assign(FServiceStatusUnknownPNGImg);
end;
//----------------------------------------------------------------------------------------------------------------------
procedure TAdminServerInfoForm.ConnectionEstablished(var Message: TMessage);
begin
GetInfos;
ServerStatusLbl.Caption := _('MySQL Server is running.');
ServiceStatusImg.Picture.Assign(FServiceStatusRunningPNGImg);
end;
//----------------------------------------------------------------------------------------------------------------------
function TAdminServerInfoForm.GetFormContentAsText: WideString;
var
S: WideString;
begin
S := _('MySQL Server Information')+#13#10+
StringOfChar('-', 80)+#13#10+
ConnectionGBox.Caption+#13#10+
' '+StringAlignLeft(UserCaptionLbl.Caption, CaptionTextWidth)+
UserLbl.Caption+#13#10+
' '+StringAlignLeft(HostCaptionLbl.Caption, CaptionTextWidth)+
HostLbl.Caption+#13#10+
' '+StringAlignLeft(PortCaptionLbl.Caption, CaptionTextWidth)+
PortLbl.Caption+#13#10;
if(InstanceCaptionLbl.Visible)then
S := S+' '+StringAlignLeft(InstanceCaptionLbl.Caption, CaptionTextWidth)+
InstanceNameLbl.Caption+#13#10;
S := S+StringOfChar('-', 80)+#13#10+
ServerInfoGBox.Caption+#13#10+
' '+StringAlignLeft(ServerVersionCaptionLbl.Caption, CaptionTextWidth)+
ServerVersionLbl.Caption+#13#10+
' '+StringAlignLeft(ServerNetworkNameCaptionLbl.Caption, CaptionTextWidth)+
ServerNetworkNameLbl.Caption+#13#10+
' '+StringAlignLeft(ServerIPCaptionLbl.Caption, CaptionTextWidth)+
ServerIPLbl.Caption+#13#10;
if(ServerOSLbl.Visible)then
S := S+' '+StringAlignLeft(ServerOSCaptionLbl.Caption, CaptionTextWidth)+ServerOSLbl.Caption+#13#10;
if(ServerHardwareLbl.Visible)then
S := S+' '+StringAlignLeft(ServerHardwareCaptionLbl.Caption, CaptionTextWidth)+ServerHardwareLbl.Caption+#13#10;
S := S+StringOfChar('-', 80)+#13#10+
ClientInfoGBox.Caption+#13#10+
' '+StringAlignLeft(ClientVersionCaptionLbl.Caption, CaptionTextWidth)+
ClientVersionLbl.Caption+#13#10+
' '+StringAlignLeft(ClientNetworkNameCaptionLbl.Caption, CaptionTextWidth)+
ClientNetworkNameLbl.Caption+#13#10+
' '+StringAlignLeft(ClientIPCaptionLabel.Caption, CaptionTextWidth)+
ClientIPLbl.Caption+#13#10+
' '+StringAlignLeft(ClientOSCaptionLbl.Caption, CaptionTextWidth)+
ClientOSLbl.Caption+#13#10+
' '+StringAlignLeft(ClientHardwareCaptionLbl.Caption, CaptionTextWidth)+
ClientHardwareLabel.Caption+#13#10;
Result := S;
end;
//----------------------------------------------------------------------------------------------------------------------
end.
|