|
{
|
|
Adtos 1.0 Software de gestión de Aulas Tecnológicas
|
|
|
|
Programación: Manuel Narváez Martínez <mnarvaez007@gmail.com>
|
|
Diseño gráfico: Ana María Zamora Moreno
|
|
Desarrollado con Lazarus 0.9.26
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
}
|
|
unit cldatosAula;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils,IdSSLOpenSSL, IdTCPClient;
|
|
|
|
type
|
|
ThrDatosAula = class(TThread)
|
|
private
|
|
{ Private declarations }
|
|
fIPAulas:array of String;
|
|
fcliente,fclienteError:TIdTCPClient;
|
|
fIdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
|
|
fIdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL ;
|
|
fNumeroEquipos:integer;
|
|
fDatosEquipos:array of String;
|
|
procedure refrescarDatosAula;
|
|
protected
|
|
procedure Execute; override;
|
|
public
|
|
constructor Create(ipsaulas:Array of String);
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses inicio;
|
|
constructor ThrDatosAula.Create(ipsaulas:Array of String);
|
|
var
|
|
i:integer;
|
|
begin
|
|
inherited Create(true);
|
|
fNumeroEquipos:=Length(ipsaulas);
|
|
SetLength(fIPAulas,fNumeroEquipos);
|
|
for i:=0 to fNumeroEquipos-1 do
|
|
fIPAulas[i]:=ipsaulas[i];
|
|
FreeOnTerminate:=true;
|
|
end;
|
|
|
|
procedure ThrDatosAula.Execute;
|
|
var j,i:integer;
|
|
ipequipo:string;
|
|
ipsError:Array of String;
|
|
ke:integer;
|
|
begin
|
|
|
|
SetLength(fDatosEquipos,fNumeroEquipos);
|
|
SetLength(ipsError,fNumeroEquipos);
|
|
j:=0;
|
|
ke:=0;
|
|
try
|
|
fIdSSLIOHandlerSocketOpenSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
|
fIdSSLIOHandlerSocketOpenSSL.Port:= 37999;
|
|
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode:=sslmClient;
|
|
fIdSSLIOHandlerSocketOpenSSL.Destination:=':'+inttostr(37999);
|
|
fcliente:=TIdTCPClient.create(nil);
|
|
fcliente.IOHandler:=fIdSSLIOHandlerSocketOpenSSL;
|
|
|
|
fIdSSLIOHandlerSocketOpenSSL1:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
|
fIdSSLIOHandlerSocketOpenSSL1.Port:= 37999;
|
|
fIdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode:=sslmClient;
|
|
fIdSSLIOHandlerSocketOpenSSL1.Destination:=':'+inttostr(37999);
|
|
fclienteError:=TIdTCPClient.create(nil);
|
|
fclienteError.IOHandler:=fIdSSLIOHandlerSocketOpenSSL1;
|
|
|
|
fcliente.ConnectTimeout:=200;
|
|
fclienteError.ConnectTimeout:=200;
|
|
fclienteError.port:=37999;
|
|
fcliente.port:=37999;
|
|
for i:=0 to fNumeroEquipos-1 do
|
|
begin
|
|
ipequipo:= fIPAulas[i];
|
|
|
|
if ipequipo='' then continue;
|
|
fcliente.Host:=ipequipo;
|
|
|
|
try
|
|
fcliente.connect;
|
|
fcliente.GetResponse(200);
|
|
fcliente.SendCmd('datosEquipo',317);
|
|
fDatosEquipos[j]:= trim(fcliente.LastCmdResult.text.text);
|
|
inc(j);
|
|
if fcliente.Connected then fcliente.Disconnect;
|
|
except
|
|
begin
|
|
ipsError[ke]:=ipequipo;
|
|
inc(ke);
|
|
if fcliente.Connected then fcliente.Disconnect;
|
|
end;
|
|
end;
|
|
end;
|
|
SetLength(ipsError,ke);
|
|
for i:=0 to High(ipsError) do
|
|
begin
|
|
ipequipo:= ipsError[i];
|
|
fclienteError.Host:=ipequipo;
|
|
try
|
|
fclienteError.connect;
|
|
fclienteError.GetResponse(200);
|
|
fclienteError.SendCmd('datosEquipo',317);
|
|
fDatosEquipos[j]:= trim(fclienteError.LastCmdResult.text.text);
|
|
inc(j);
|
|
if fclienteError.Connected then fclienteError.Disconnect;
|
|
except
|
|
begin
|
|
if fclienteError.Connected then fclienteError.Disconnect;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
finally
|
|
SetLength(fDatosEquipos,j);
|
|
fcliente.free;
|
|
fclienteError.free;
|
|
fIdSSLIOHandlerSocketOpenSSL.Free;
|
|
fIdSSLIOHandlerSocketOpenSSL1.Free;
|
|
////writeln('Error al hallar equipos aula');
|
|
synchronize(@refrescarDatosAula)
|
|
end;
|
|
end;
|
|
|
|
procedure ThrDatosAula.refrescarDatosAula;
|
|
begin
|
|
try
|
|
//writeln('Refrescando aula');
|
|
|
|
except
|
|
////writeln('Error al hallar equipos aula');
|
|
end;
|
|
end;
|
|
end.
|
|
|