Proyecto

General

Perfil

Descargar (5,17 KB) Estadísticas
| Rama: | Revisión:
54e95a47 Elisa
{
Adtos 1.0 Software de gestión de Aulas Tecnológicas
23a384b9 Elisa
54e95a47 Elisa
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
23a384b9 Elisa
Classes, SysUtils,IdSSLOpenSSL, IdTCPClient;
54e95a47 Elisa
type
ThrDatosAula = class(TThread)
private
{ Private declarations }
fIPAulas:array of String;
fcliente,fclienteError:TIdTCPClient;
23a384b9 Elisa
fIdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
fIdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL ;
54e95a47 Elisa
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
23a384b9 Elisa
fIdSSLIOHandlerSocketOpenSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
fIdSSLIOHandlerSocketOpenSSL.Port:= 37999;
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode:=sslmClient;
fIdSSLIOHandlerSocketOpenSSL.Destination:=':'+inttostr(37999);
54e95a47 Elisa
fcliente:=TIdTCPClient.create(nil);
23a384b9 Elisa
fcliente.IOHandler:=fIdSSLIOHandlerSocketOpenSSL;

fIdSSLIOHandlerSocketOpenSSL1:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
fIdSSLIOHandlerSocketOpenSSL1.Port:= 37999;
fIdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode:=sslmClient;
fIdSSLIOHandlerSocketOpenSSL1.Destination:=':'+inttostr(37999);
54e95a47 Elisa
fclienteError:=TIdTCPClient.create(nil);
23a384b9 Elisa
fclienteError.IOHandler:=fIdSSLIOHandlerSocketOpenSSL1;

54e95a47 Elisa
fcliente.ConnectTimeout:=200;
fclienteError.ConnectTimeout:=200;
23a384b9 Elisa
fclienteError.port:=37999;
fcliente.port:=37999;
54e95a47 Elisa
for i:=0 to fNumeroEquipos-1 do
begin
ipequipo:= fIPAulas[i];
23a384b9 Elisa
54e95a47 Elisa
if ipequipo='' then continue;
fcliente.Host:=ipequipo;
23a384b9 Elisa
54e95a47 Elisa
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);
23a384b9 Elisa
inc(j);
54e95a47 Elisa
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;
23a384b9 Elisa
fIdSSLIOHandlerSocketOpenSSL.Free;
fIdSSLIOHandlerSocketOpenSSL1.Free;
////writeln('Error al hallar equipos aula');
54e95a47 Elisa
synchronize(@refrescarDatosAula)
end;
end;

procedure ThrDatosAula.refrescarDatosAula;
begin
try
23a384b9 Elisa
//writeln('Refrescando aula');

54e95a47 Elisa
except
23a384b9 Elisa
////writeln('Error al hallar equipos aula');
54e95a47 Elisa
end;
end;
end.