desarrollosconsejeria/adtos-server/1.7-0/adtos/clestadocentro.pas @ 23a384b9
23a384b9 | Elisa | {
|
|
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 clestadocentro;
|
|||
{$mode objfpc}{$H+}
|
|||
interface
|
|||
uses
|
|||
Classes, SysUtils, IdTCPClient,IdSSLOpenSSL,globales;
|
|||
type
|
|||
ThrEstadoCentro = class(TThread)
|
|||
private
|
|||
{ Private declarations }
|
|||
fIPAulas:array of String;
|
|||
fIdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
|
|||
fcliente:TIdTCPClient;
|
|||
fNumeroEquipos:integer;
|
|||
fDatosEquipos:array of ansistring;
|
|||
procedure refrescarDatosCentro;
|
|||
protected
|
|||
procedure Execute; override;
|
|||
public
|
|||
constructor Create(ipsaulas:Array of String);
|
|||
end;
|
|||
implementation
|
|||
uses inicio;
|
|||
constructor ThrEstadoCentro.Create(ipsaulas:Array of String);
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
inherited Create(true);
|
|||
fNumeroEquipos:=Length(ipsaulas);
|
|||
//writeln('El número de aulas es ', fNumeroEquipos);
|
|||
SetLength(fIPAulas,fNumeroEquipos);
|
|||
for i:=0 to fNumeroEquipos-1 do
|
|||
fIPAulas[i]:=ipsaulas[i];
|
|||
FreeOnTerminate:=true;
|
|||
end;
|
|||
procedure ThrEstadoCentro.Execute;
|
|||
var
|
|||
i:integer;
|
|||
equipos:string;
|
|||
ipsError:Array of String;
|
|||
orden:string;
|
|||
size:Integer;
|
|||
begin
|
|||
//writeln('Estoy dentro de ThrEstadoCentro.Execu de centro hallando equipo aula');
|
|||
SetLength(fDatosEquipos,fNumeroEquipos);
|
|||
SetLength(ipsError,fNumeroEquipos);
|
|||
try
|
|||
orden:= 'hallarProcesosActivos equipos_aula X' ;
|
|||
//writeln(orden);
|
|||
fIdSSLIOHandlerSocketOpenSSL:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
|||
fIdSSLIOHandlerSocketOpenSSL.Port:= 37999;
|
|||
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode:=sslmClient;
|
|||
fIdSSLIOHandlerSocketOpenSSL.SSLOptions.Method:=sslvSSLv3;
|
|||
fcliente:=TidTcpClient.create(nil);
|
|||
fcliente.IOHandler:=fIdSSLIOHandlerSocketOpenSSL;
|
|||
fcliente.ConnectTimeout:=200;
|
|||
fcliente.port:=37999;
|
|||
for i:=0 to fNumeroEquipos-1 do
|
|||
begin
|
|||
try
|
|||
fDatosEquipos[i]:='';
|
|||
equipos:='';
|
|||
if trim(fIPAulas[i])='' then
|
|||
begin
|
|||
fDatosEquipos[i]:='';
|
|||
continue;
|
|||
end;
|
|||
// writeln( ' esta es la ip el equipo ', fIPAulas[i]);
|
|||
fcliente.Host:=fIPAulas[i];
|
|||
fcliente.connect;
|
|||
fcliente.GetResponse(200);
|
|||
fcliente.SendCmd(orden,305);
|
|||
size:= fcliente.IOHandler.ReadLongInt(true);
|
|||
equipos:=fcliente.IOHandler.ReadString(size);
|
|||
fDatosEquipos[i]:=Trim(equipos);
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
except
|
|||
begin
|
|||
//writeln( ' Error al conectar con el equipo ', fIPAulas[i]);
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
Sleep(1000);
|
|||
//writeln('He llegado hasta aquí____________________xx_____________________');
|
|||
for i:=0 to fNumeroEquipos-1 do
|
|||
begin
|
|||
try
|
|||
equipos:='';
|
|||
if (trim(fIPAulas[i])='') or (Trim (fDatosEquipos[i]) <>'') then continue;
|
|||
// writeln(' esta es la ip del equipo que parecía desconectado equipo ', fIPAulas[i]);
|
|||
fcliente.Host:=fIPAulas[i];
|
|||
fcliente.connect;
|
|||
fcliente.GetResponse(200);
|
|||
fcliente.SendCmd(orden,305);
|
|||
size:= fcliente.IOHandler.ReadLongInt(true);
|
|||
equipos:=fcliente.IOHandler.ReadString(size);
|
|||
fDatosEquipos[i]:=Trim(equipos);
|
|||
// writeln( ' y este su valor correcto ', fDatosEquipos[i]);
|
|||
// writeln(' fDatosEquipos[j]----> ',fDatosEquipos[j]);
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
except
|
|||
begin
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
finally
|
|||
if fcliente.Connected then fcliente.Disconnect;
|
|||
fcliente.free;
|
|||
fIdSSLIOHandlerSocketOpenSSL.Free;
|
|||
//writeln('antes de sincronice');
|
|||
synchronize(@refrescarDatosCentro);
|
|||
//writeln('Y he pasado el sincronize');
|
|||
//writeln('Despues de sincronice');
|
|||
end;
|
|||
end;
|
|||
procedure ThrEstadoCentro.refrescarDatosCentro;
|
|||
begin
|
|||
try
|
|||
//writeln('Refrescadno Datos centro');
|
|||
frmMain.RefrescarDatosCentro(fDatosEquipos);
|
|||
except
|
|||
writeln('clestadocentro. refrescarDatos cemtro. Error al hallar equipos centro ');
|
|||
end;
|
|||
end;
|
|||
end.
|