Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-02-2017
Avatar de noshy
noshy noshy is offline
Miembro
 
Registrado: jul 2003
Posts: 139
Poder: 21
noshy Va por buen camino
Me van a preguntar del codigo, lo agrego por las dudas.

Lo subo en un archivo adjunto ya que posee mas 50.000 caracteres y el mensaje me permite 30.000.
Archivos Adjuntos
Tipo de Archivo: rar codigo.rar (7,0 KB, 16 visitas)
__________________
\_--> NoShY <--_/
Responder Con Cita
  #2  
Antiguo 07-02-2017
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Hola noshy, te confieso que no he mirado el código.

Lo que te puedo recomendar es que agregues logs a tú aplicación. La idea es ir llevando el registro de lo que va pasando. Asi podes ir acercándote cada vez más al lugar el donde ocurre la excepción y bajo qué contexto.

Tenés habilitado el reporte de Eureka log? Genera un archivo con la traza y mucha más información muy útil
Responder Con Cita
  #3  
Antiguo 07-02-2017
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.490
Poder: 21
MAXIUM Va camino a la fama
No he revisado el código aún pero mis preguntas son
- ¿Es una aplicación o un servicio?
- ¿Se inicia solo o hay que iniciarlo? Si es lo primero ¿que sucede si se resetea el Servidor y a los minutos u horas, se bloquea la pantalla (no confundir con el protector de pantalla) como suele suceder en estos sistemas?
- ¿Que sucede si se pierde la conexión?
Responder Con Cita
  #4  
Antiguo 07-02-2017
bitbow bitbow is offline
Miembro
 
Registrado: jul 2006
Posts: 366
Poder: 18
bitbow Va camino a la fama
Otra pregunta importante seria
¿Usas componentes externos? alguna dll que pudiera estar presentando un error y que no dependa en si de tu aplicacion.

Saludos.
__________________
¡Ni como ayudarte Niño!!
bitbow
Responder Con Cita
  #5  
Antiguo 07-02-2017
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Poder: 30
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Yo te pediría, para empezar, que mostraras el primer mensaje de error que te sale (el de la ventana que está hasta atrás). ¿Es igual al resto?
Responder Con Cita
  #6  
Antiguo 07-02-2017
Avatar de noshy
noshy noshy is offline
Miembro
 
Registrado: jul 2003
Posts: 139
Poder: 21
noshy Va por buen camino
Cita:
Empezado por AgustinOrtu Ver Mensaje
Hola noshy, te confieso que no he mirado el código.

Lo que te puedo recomendar es que agregues logs a tú aplicación. La idea es ir llevando el registro de lo que va pasando. Asi podes ir acercándote cada vez más al lugar el donde ocurre la excepción y bajo qué contexto.

Tenés habilitado el reporte de Eureka log? Genera un archivo con la traza y mucha más información muy útil
Hola, gracias por responder, si lo tengo habilitado y no encuentra ningun tipo de error, es mas el codigo lo tengo en su totalidad con try / except y tampoco me toma la exception.
Tambien habilite para que chequeara los threads, ya que cada lectura del socket lo realiza en un thread diferente.

Cita:
Empezado por MAXIUM Ver Mensaje
No he revisado el código aún pero mis preguntas son
- ¿Es una aplicación o un servicio?
- ¿Se inicia solo o hay que iniciarlo? Si es lo primero ¿que sucede si se resetea el Servidor y a los minutos u horas, se bloquea la pantalla (no confundir con el protector de pantalla) como suele suceder en estos sistemas?
- ¿Que sucede si se pierde la conexión?
Hola, gracias por responder, si, por ahora es una aplicacion, hay que iniciarlo manualmente, tengo personal las 24 hs, asi que si se corta la conexion o se resetea el servidor, siempre hay gente para levantar todo.

Cita:
Empezado por bitbow Ver Mensaje
Otra pregunta importante seria
¿Usas componentes externos? alguna dll que pudiera estar presentando un error y que no dependa en si de tu aplicacion.

Saludos.
Hola, gracias por responder, no uso nada externo, tengo una conexion ADO a la base de tatos y el componente indy para el socket.
Creo y destruyo Query's en cada sentencia SQL.



Cita:
Empezado por Al González Ver Mensaje
Yo te pediría, para empezar, que mostraras el primer mensaje de error que te sale (el de la ventana que está hasta atrás). ¿Es igual al resto?
Hola, gracias por responder, Son todos iguales los mensajes y una curiosidad, tambien es la misma address 00000000000002C8 en todas las ejecuciones.



He limpiado un poco el codigo, sacando todos los try / except para ver si me salta el error en alguna linea y nada, me sigue saltando el mismo error.

He estado investigando un poco y me estoy tirando por el lado de que windows server 2008 R2 tenga un limite de conexiones TCP pero no he encontrado nada concreto y calculo yo que me deberia ingorar el resto de las conexiones y no tirarme el error que estoy teniendo (https://www.outsystems.com/forums/di...-web-requests/).

Algo muy curioso es que me levanta el uso de la memoria, al iniciar comienza con 10 mb y despues de toda la noche llego a 73 mb, revise de destruir todos los componentes creados pero sigue igual.

Editado:

Otro dato, tengo habilitado el evento OnException del componente Indy y tampoco me toma la exception por ahi, me larga el dialogo directamente.
__________________
\_--> NoShY <--_/
Responder Con Cita
  #7  
Antiguo 07-02-2017
Avatar de noshy
noshy noshy is offline
Miembro
 
Registrado: jul 2003
Posts: 139
Poder: 21
noshy Va por buen camino
Código Delphi [-]
procedure TFDespachoAutomatico.server2Execute(AContext: TIdContext);
var
  vDespDatoRec       : string;  //Guarda la Cadena Recibida
  vDespRespLogin     : Integer; //Resuesta del Login
  vDespJSONDato      : TlkJSONobject;
  vDespJSONRespuestaFinal : TlkJSONobject;
  vDespJSONRespuestaLogin : TlkJSONobject;
  vDespUsuario       : string;  //Usuario logueado
  vDespLoginVersion  : string;
  vDespAuxS          : string;  //Variable Auxiliar String
  vDespTipoDato      : Integer; //Tipo de dato solicitado
  vDespMovil         : Integer; //Movil que envia la posicion
  vDespIdViaje       : Integer;   //Id Viaje Datos
  vDespIdViajeEnUso  : Integer; //Id Viaje En Uso
  vDespDomicilio     : string;
  vDespObservaciones : string;
  vDespViajeLat      : string;
  vDespViajeLng      : string;
  vDespRespS         : string;
  vDespMsgError      : string;



        //Funcion IdViajeEnusoInt ----------------------------------------------
        function IdViajeEnusoInt(vIdViaje: Integer):Integer;
        var
          vQryVEU : TADOQuery;
        begin
          Result := 0;
          vQryVEU            := TADOQuery.Create(nil);
          vQryVEU.Connection := conDB1;
          try
            with vQryVEU do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select idViajeEnUso from AppViajes_DatoViajes with (NOLOCK) where ');
              SQL.Add('id = :vIdViaje ');
              Parameters.ParamByName('vIdViaje').Value := vIdViaje;
              Open;
            end;
            if vQryVEU.RecordCount > 0 then
              Result := vQryVEU['idViajeEnUso']
            else
              Result := 0;
          finally
            FreeAndNil(vQryVEU);
          end;
        end;
        //Fin Funcion IdViajeEnusoInt ------------------------------------------

        //Funcion GrabarLogint -------------------------------------------------
        procedure GrabarlogInt(vDato, vCarpeta : string);
        var
         F: TextFile;
         Nombre :string;
        begin
          try
            if not DirectoryExists(GetCurrentDir + '\Log') then
              CreateDir(GetCurrentDir + '\Log');

            if not DirectoryExists(GetCurrentDir + '\Log\' + vCarpeta) then
              CreateDir(GetCurrentDir + '\Log\' + vCarpeta);

            nombre:=GetCurrentDir + '\Log\' + vCarpeta + '\' + FormatDateTime('YYYYMMDD',Now) + '.log';

            AssignFile(F, nombre);

            if (FileExists(nombre)) then
              Append(F)
            else
              ReWrite(F);

            if vCarpeta = 'Despacho' then
              Writeln(F, vDato )
            else
              Writeln(F, '['+DateTimeToStr(Now)+'] '+ vDato );
          finally
            CloseFile(F);
          end;
        end;
        //Fin Funcion GrabarLogint ---------------------------------------------

        //Funcion LogInt -------------------------------------------------------
        procedure LogInt(vDespLog: string; vDespTipo: Integer);
        begin
          case vDespTipo of
           0: begin //Log Errores
                GrabarlogInt(vDespLog,'Errores');  //Log Errores
                //Mostramos el log
                mmoErrores.Lines.Add(DateTimeToStr(Now)+' - '+vDespLog);
                //Booramos el excedente de 100 lineas
                if mmoErrores.Lines.Count > 20 then
                begin
                   mmoErrores.Lines.Delete(0);
                   mmoErrores.Lines.Delete(0);
                end;
                SendMessage(mmoErrores.Handle, EM_SCROLL, SB_BOTTOM, 0);
              end;
           1: begin //Log Crudo
                GrabarlogInt(vDespLog,'Crudo');  //Log Crudo
                if chkLogCrudo.Checked then
                begin
                  //Mostramos el log
                  mmoLog.Lines.Add(DateTimeToStr(Now)+' - '+vDespLog);
                  //Booramos el excedente de 100 lineas
                  if mmoLog.Lines.Count > 20 then
                  begin
                     mmoLog.Lines.Delete(0);
                     mmoLog.Lines.Delete(0);
                  end;
                  SendMessage(mmoLog.Handle, EM_SCROLL, SB_BOTTOM, 0);
                end;
              end;
           2: begin //Log Viajes
                GrabarlogInt(vDespLog,'Viajes');  //Log Viajes
                if chkLogViaje.Checked then
                begin
                  //Mostramos el log
                  mmoLog.Lines.Add(DateTimeToStr(Now)+' - '+vDespLog);
                  //Booramos el excedente de 100 lineas
                  if mmoLog.Lines.Count > 20 then
                  begin
                     mmoLog.Lines.Delete(0);
                     mmoLog.Lines.Delete(0);
                  end;
                  SendMessage(mmoLog.Handle, EM_SCROLL, SB_BOTTOM, 0);
                end;
              end;
          end;
        end;
        //Fin Funcion LogInt ---------------------------------------------------

        //Funcion DatoViajesInt ------------------------------------------------
        function DatoViajesInt(vDespLeido : Boolean; vDespRespuesta, vDespId: Integer):Boolean;
        var
          vQryDato : TADOQuery;
        begin
          Result := True;
          vQryDato            := TADOQuery.Create(nil);
          vQryDato.Connection := conDB;
          try
            with vQryDato do
            begin
              Close;
              SQL.Clear;
              SQL.Add('update AppViajes_DatoViajes set leido = :vleido, respuesta = :vrespuesta ');
              if vDespRespuesta = 1 then
              begin
                SQL.Add(',TipoDato = 2 ');
              end;
              SQL.Add('where id = :vid ');
              Parameters.ParamByName('vleido').Value     := vDespLeido;
              Parameters.ParamByName('vrespuesta').Value := vDespRespuesta;
              Parameters.ParamByName('vid').Value        := vDespId;
              ExecSQL;
            end;
          finally
            FreeAndNil(vQryDato);
          end;
        end;
        //Fin Funcion DatoViajesInt ----------------------------------

        //Procedimiento GuardarPosicionInt -------------------------------
        procedure GuardarPosicionInt(vDespMovil, vDespEstado, vDespConConsulta: Integer; vDespLat, vDespLng: string; vDespFecha: TDateTime );
        var
          vCant : Integer;
          vQryGP  : TADOQuery;
        begin
          vQryGP := TADOQuery.Create(nil);
          vQryGP.Connection := conDB;
          try
            with vQryGP do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select count(*) as total from AppViajes_UltimaPosicion with (NOLOCK) where movil = :movil');
              Parameters.ParamByName('movil').Value := vDespMovil;
              Open;
            end;
            vCant := vQryGP['total'];
            if vCant > 0 then
            begin
              with vQryGP do
              begin
                Close;
                SQL.Clear;
                SQL.Add('update AppViajes_UltimaPosicion set lat = :lat, lng = :lng, fecha = :fecha, estado = :estado, conConsulta = :conConsulta');
                SQL.Add('where movil = :movil');
                Parameters.ParamByName('lat').Value         := vDespLat;
                Parameters.ParamByName('lng').Value         := vDespLng;
                Parameters.ParamByName('fecha').Value       := vDespFecha;
                Parameters.ParamByName('estado').Value      := vDespEstado;
                Parameters.ParamByName('conConsulta').Value := vDespConConsulta;
                Parameters.ParamByName('movil').Value       := vDespMovil;
                ExecSQL;
              end;
            end
            else
            begin
              with vQryGP do
              begin
                Close;
                SQL.Clear;
                SQL.Add('Insert into AppViajes_UltimaPosicion(movil, lat, lng, fecha, estado, conConsulta)');
                SQL.Add('Values(:movil, :lat, :lng, :fecha, :estado, :conConsulta)');
                Parameters.ParamByName('movil').Value       := vDespMovil;
                Parameters.ParamByName('lat').Value         := vDespLat;
                Parameters.ParamByName('lng').Value         := vDespLng;
                Parameters.ParamByName('fecha').Value       := vDespFecha;
                Parameters.ParamByName('estado').Value      := vDespEstado;
                Parameters.ParamByName('conConsulta').Value := vDespConConsulta;
                ExecSQL;
              end;
            end;
          finally
            FreeAndNil(vQryGP);
          end;
        end;
        //FIN Procedimiento GuardarPosicion --------------------------------------

        //Funcion PosicionInt --------------------------------------------------
        function PosicionInt(vDespCadena: string):Boolean;
        var
          vJSONPosicion : TlkJSONobject;
          vMovil : Integer;
          vLat, vLng : string;
          vEstado : Integer;
        begin
          vJSONPosicion := TlkJSON.ParseText(vDespCadena) as TlkJSONobject;
          Result := False;
          try
            vMovil  := StrToInt(vartostr(vJSONPosicion.Field['posicion'].Field['movil'].Value));
            vLat    := vartostr(vJSONPosicion.Field['posicion'].Field['lat'].Value);
            vLat := ReplaceStr(Trim(vLat), '.', ',');
            vLng    := vartostr(vJSONPosicion.Field['posicion'].Field['lng'].Value);
            vLng := ReplaceStr(Trim(vLng), '.', ',');
            vEstado := StrToInt(vartostr(vJSONPosicion.Field['posicion'].Field['estado'].Value));

            if vEstado = 0 then
              vEstado := 3;

            if vEstado = 1 then
              vEstado := 2;

            GuardarPosicionInt(vMovil, vEstado, 0, vLat, vLng, now );
            Result := True;
          finally
            FreeAndnil(vJSONPosicion);
          end;
        end;
        //Fin Funcion PosicionInt ----------------------------------------------

        //Funcion PendienteLatInt ----------------------------------------------
        function PendienteLatInt(vDespIdViajeEnuso: Integer):string;
        var
          vQryLat : TADOQuery;
        begin
          Result := '';
          vQryLat            := TADOQuery.Create(nil);
          vQryLat.Connection := conDB;
          try
            with vQryLat do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.Lat from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vDespIdViajeEnuso;
              Open;
            end;
            if vQryLat.RecordCount > 0 then
              Result := vQryLat['Lat']
            else
              Result := '';
          finally
            FreeAndNil(vQryLat);
          end;
        end;
        //Fin Funcion PendienteLatInt ------------------------------------------

        //funcion PendienteLngInt ----------------------------------------------
        function PendienteLngInt(vIdViajeEnuso: Integer):string;
        var
          vQryLng : TADOQuery;
        begin
          Result := '';
          vQryLng            := TADOQuery.Create(nil);
          vQryLng.Connection := conDB;
          try
            with vQryLng do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.Lng from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vIdViajeEnuso;
              Open;
            end;
            if vQryLng.RecordCount > 0 then
              Result := vQryLng['Lng']
            else
              Result := '';
          finally
            FreeAndNil(vQryLng);
          end;
        end;
        //Fin funcion PendienteLngInt ------------------------------------------

        //Funcion ArmarDomicilioInt --------------------------------------------
        function ArmarDomicilioInt(vDomIdViajeEnuso: Integer):string;
        var
          vQryCalle : TADOQuery;
          vDomicilioArmado : string;
          vPiso, vDpto : string;
        begin
          vDomicilioArmado := '';
          Result := '';
          try
            vQryCalle            := TADOQuery.Create(nil);
            vQryCalle.Connection := conDB;
            with vQryCalle do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.calle, p.altura, p.piso, p.dpto from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vDomIdViajeEnuso;
              Open;
            end;
            vDomicilioArmado := Trim(vQryCalle['calle']);
            vDomicilioArmado := vDomicilioArmado + ' ' + IntToStr(vQryCalle['altura']);

            try
              vPiso := Trim(vQryCalle['piso']);
              vDpto := Trim(vQryCalle['dpto']);
            except
              vPiso := '';
              vDpto := '';
            end;

            if vPiso.Length > 0 then
              vDomicilioArmado := vDomicilioArmado + ' Piso '+Trim(vQryCalle['piso']);

            if vDpto.Length > 0 then
              vDomicilioArmado := vDomicilioArmado + ' Dpto '+Trim(vQryCalle['dpto']);

            Result := vDomicilioArmado;

          finally
            FreeAndNil(vQryCalle);
          end;

        end;
        //Fin Funcion ArmarDomicilioInt ----------------------------------------

        //Funcion PendienteObservacionesInt ------------------------------------
        function PendienteObservacionesInt(vObsIdViajeEnuso: Integer):string;
        var
          vQryObservaciones : TADOQuery;
        begin
          Result := '';
          vQryObservaciones            := TADOQuery.Create(nil);
          vQryObservaciones.Connection := conDB;
          try
            with vQryObservaciones do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.observaciones from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vObsIdViajeEnuso;
              Open;
            end;
            if vQryObservaciones.RecordCount > 0 then
              Result := vQryObservaciones['observaciones']
            else
              Result := '';
          finally
            FreeAndNil(vQryObservaciones);
          end;
        end;


        //Funcion PendienteBarrioInt -------------------------------------------
        function PendienteBarrioInt(vBarrioIdViajeEnuso: Integer):string;
        var
          vQryBarrio : TADOQuery;
        begin
          Result := '';
          vQryBarrio            := TADOQuery.Create(nil);
          vQryBarrio.Connection := conDB;
          try
            with vQryBarrio do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.barrio from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vBarrioIdViajeEnuso;
              Open;
            end;
            while not vQryBarrio.Eof do
            begin
              Result := Trim(vQryBarrio['barrio']);
              vQryBarrio.Next;
            end;

          finally
            FreeAndNil(vQryBarrio);
          end;
        end;
        //Fin Funcion PendienteBarrioInt ---------------------------------------

        //Funcion PendienteInfoTmpInt ------------------------------------------
        function PendienteInfoTmpInt(vInfoIdViajeEnuso: Integer):string;
        var
          vQryInfoTmp : TADOQuery;
        begin
          Result := '-';
          vQryInfoTmp            := TADOQuery.Create(nil);
          vQryInfoTmp.Connection := conDB;
          try
            with vQryInfoTmp do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select p.infotmp from sat_viajespendientes p, AppViajes_ViajesEnUso u with (NOLOCK) where ');
              SQL.Add('p.id = u.idViajePendiente ');
              SQL.Add('and u.id = :vidviajeenuso ');
              Parameters.ParamByName('vidviajeenuso').Value := vInfoIdViajeEnuso;
              Open;
            end;
            try
              Result := Trim(vQryInfoTmp['infotmp'])
            except
              Result := '-';
            end;
          finally
            FreeAndNil(vQryInfoTmp);
          end;
        end;
        //Fin Funcion PendienteInfoTmpInt --------------------------------------

        //Funcion ControlInt ---------------------------------------------------
        function ControlInt(vDespControlMovil: Integer):string;
        var
          vDespQryControl  : TADOQuery;
          //vDespCadenaCtr   : string;
          vDespJSONControl : TlkJSONobject;
          vDespText, vObs  : string;
          vDespIdViaje     : Integer;
          vDespBarrio      : string;
        begin
          Result := '';
          vDespQryControl := TADOQuery.Create(nil);
          vDespQryControl.Connection := conDB1;
          vDespJSONControl  := TlkJSONobject.Create;
          try
            with vDespQryControl do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select id, movil, texto, idViajeEnUso ');
              SQL.Add('from AppViajes_DatoViajes with (NOLOCK) where ');
              SQL.Add('movil = :vctrmovil and ');
              SQL.Add('tipodato = 1 and leido = 0 ');  //que tipodato = 1 (proposicion) y no este leido
              Parameters.ParamByName('vctrmovil').Value := vDespControlMovil;
              Open;
            end;

            //SI tiene viaje asignado
            while not vDespQryControl.Eof do
            begin
              //vText    := LimpiarTexto(vQryViajes['texto']);
              vDespText    := vDespQryControl['texto'];
              vDespIdViaje := vDespQryControl['id'];

              vDespBarrio  := PendienteBarrioInt(vDespQryControl['idViajeEnUso']);
              if vDespBarrio.Length > 0 then
                vObs := 'Barrio: '+vDespBarrio
              else
                vObs := '';

              //vObs     :=  vObs +' '+  LimpiarTexto(PendienteInfoTmp(vQryViajes['idViajeEnUso']));
              vObs     :=  vObs +' '+  PendienteInfoTmpInt(vDespQryControl['idViajeEnUso']);

              vDespJSONControl.Add('domicilio', vDespText);  //Domicilio
              vDespJSONControl.Add('obs', vObs);             //Observaqciones
              vDespJSONControl.Add('idviaje', vDespIdViaje); //Id VIaje

              //Se marca el viaje como leido y se devuelve la cadena co el viaje
              if DatoViajesInt(True, 0,vDespQryControl['Id']) then //cambiamos el viaje a leido
              begin
                Result := TlkJSON.GenerateText(vDespJSONControl);
              end;

              vDespQryControl.Next;
            end;
          finally
            FreeAndNil(vDespQryControl);
            FreeAndnil(vDespJSONControl);
          end;
        end;
        //Fin Funcion ControlInt -----------------------------------------------

        //Funcion ControlQTAInt ------------------------------------------------
        function ControlQTAInt(vDespQTAMovil: Integer):string;
        var
          vDespQryViajesQTA    : TADOQuery;
          vDespJSONControlQTA : TlkJSONobject;
          //vDespCadena: string;
          vDespIdViaje: Integer;
        begin
          vDespQryViajesQTA := TADOQuery.Create(nil);
          vDespQryViajesQTA.Connection := conDB2;
          vDespJSONControlQTA  := TlkJSONobject.Create;
          try
            //CONTROL DE VIAJES QTA ------------------------------------------------------
            with vDespQryViajesQTA do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select id, movil, idViajeEnUso ');
              SQL.Add('from AppViajes_DatoViajes with (NOLOCK) where ');
              SQL.Add('tipodato = 3 and leido = 0 and ');  //que tipodato = 3 (CANCELADO) y no este leido
              SQL.Add('movil = :vvqtamovil ');
              Parameters.ParamByName('vvqtamovil').Value := vDespQTAMovil;
              Open;
            end;
            //SI tiene viaje asignado
            while not vDespQryViajesQTA.Eof do
            begin
              vDespIdViaje := vDespQryViajesQTA['id'];

              vDespJSONControlQTA.Add('estado', 'qta');  //estado
              vDespJSONControlQTA.Add('movil', IntToStr(vDespQTAMovil));  //movil
              vDespJSONControlQTA.Add('idviajeqta', vDespIdViaje); //Id VIaje

              if DatoViajesInt(True, 0,vDespQryViajesQTA['Id']) then //cambiamos el viaje a leido
              begin
                Result := TlkJSON.GenerateText(vDespJSONControlQTA);
              end;

              vDespQryViajesQTA.Next
            end;
          finally
            FreeAndNil(vDespQryViajesQTA);
            FreeAndnil(vDespJSONControlQTA);
          end;
        end;
        //Fin Funcion ControlQTAInt --------------------------------------------

        //Funcion LoginInt -----------------------------------------------------
        function LoginInt(vDespCadena: string):Integer;
        var
          vDespJSONLogin : TlkJSONobject;
          vDespUser, vDespPass: string;
          vDespQryLogin : TADOQuery;
        begin
          Result := 3; //Por defecto lo ponemos como error interno al resultado
          vDespQryLogin := TADOQuery.Create(nil);
          vDespQryLogin.Connection := conDB;

          vDespUser := '-';
          vDespPass := '-';
          //Creamos el objeto con el json enviado
          vDespJSONLogin := TlkJSON.ParseText(vDespCadena) as TlkJSONobject;
          try
            try
              vDespUser := vartostr(vDespJSONLogin.Field['login'].Field['user'].Value);
              vDespPass := vartostr(vDespJSONLogin.Field['login'].Field['pass'].Value);
            except
              Result := 3; //Error interno
              //Exit;
            end;

            //Validacion del usuario
            with vDespQryLogin do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select count(*) as total from AppViajes_Choferes with (NOLOCK) where usuario = :vusu and password = :vpass ');
              Parameters.ParamByName('vusu').Value  := vDespUser;
              Parameters.ParamByName('vpass').Value := vDespPass;
              Open;
            end;
            if vDespQryLogin['total'] > 0 then
            begin
              Result := 0; //Ingreso permitido
            end
            else
            begin
              Result := 1; //Ingreso denegado
            end;
          finally
            FreeAndNil(vDespQryLogin);
            FreeAndnil(vDespJSONLogin);
          end;
        end;
        //Fin Funcion LoginInt -------------------------------------------------

        //Funcion ValidarMovilQRXInt -------------------------------------------
        function ValidarMovilQRXInt(vMovilQRX: Integer):string;
        var
          vFecha     : TDateTime;
          //vOrigenQRX : string;
          qryQRX     : TADOQuery;
          vJSONQRX   : TlkJSONobject;
          s          : string;
          vResultado :  Boolean;
        begin
          qryQRX            := TADOQuery.Create(nil);
          qryQRX.Connection := conDB;
          vJSONQRX := TlkJSONobject.Create;
          try
            Result := '{}';
            vResultado := False; //QAP

            //Validamos si el movil se encuentra QRX
            with qryQRX do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select GETDATE() as fecha ');
              Open;
            end;
            vFecha := qryQRX['fecha']; //Obtenermos la fecha del server
            with qryQRX do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select nromovil,indefinido,fechafin from sat_movilesqrx with (NOLOCK) where nromovil = :vmov ');
              SQL.Add('and fechainicio <= GETDATE()  ');
              Parameters.ParamByName('vmov').Value := vMovilQRX;
              Open;
            end;
            while not qryQRX.Eof do
            begin
              if qryQRX['nromovil'] = vMovilQRX then
              begin
                if qryQRX['indefinido']= 's' then
                begin
                  vResultado := True; //QRX sin fecha de fin
                end
                else
                begin
                  if vFecha < qryQRX['fechafin'] then
                  begin
                    vResultado := True; //QRX dentro de la fecha de fin
                  end;
                end;
              end;
              qryQRX.Next;
            end;

            if vResultado then
              vJSONQRX.Add('estado', 'QRX')
            else
              vJSONQRX.Add('estado', 'QAP');
            //------------------------------------------------------
            s := TlkJSON.GenerateText(vJSONQRX);

            Result := s;
          finally
            FreeAndNil(qryQRX);
            FreeAndnil(vJSONQRX);
          end;
        end;
        //Fin Funcion ValidarMovilQRXInt ---------------------------------------

        //Funcion UsuarioMovilInt ----------------------------------------------
        function UsuarioMovilInt(vUsuario: string): Integer;
        var
          vQryMovil : TADOQuery;
        begin
          vQryMovil := TADOQuery.Create(nil);
          vQryMovil.Connection := conDB;
          try
            //Validacion del usuario
            with vQryMovil do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select movil from AppViajes_Choferes with (NOLOCK) where usuario = :vusu');
              Parameters.ParamByName('vusu').Value  := Trim(vUsuario);
              Open;
            end;
            try
              Result := vQryMovil['movil'];
            except
              Result := 0;
            end;
          finally
            FreeAndNil(vQryMovil);
          end;
        end;
        //Fin Funcion UsuarioMovilInt ------------------------------------------

        //Funcion ViajesInt ----------------------------------------------------
        function ViajesInt(vViajeMovil: Integer):String;
        var
          vJSONViajes : TlkJSONobject;
          vQryViajes  : TADOQuery;
          vCount      : integer;
          s : string;
          vTotal : integer;
          vTexto : string;
        begin
          Result := '';
          vQryViajes := TADOQuery.Create(nil);
          vQryViajes.Connection := conDB;
          vJSONViajes := TlkJSONobject.Create;
          try
            with vQryViajes do
            begin
              Close;
              SQL.Clear;
              SQL.Add('Select top 5 calle, altura, fechaenviado, estado from sat_viajesenviadostmp with (NOLOCK) where movil = :vmovil ');
              SQL.Add('order by fechaenviado desc ');
              Parameters.ParamByName('vmovil').Value := vViajeMovil;
              Open;
            end;

            try
              vTotal := vQryViajes.RecordCount;
            except
              vTotal := 0;
            end;
            //Log(IntToStr(vTotal)+' Viajes');

            vCount := 1;

            //Log('Reg: '+IntToStr(vQry.RecordCount));

            while not vQryViajes.Eof do
            begin
              //vJSONRes.Add('dv'+IntToStr(vCount), '['+DateToStr(vQry['fecha'])+'] $'+FloatToStrF(vQry['deuda'],ffFixed,14,2)+'-'+trim(vQry['detalle']) );
              vTexto := '['+DateTimeToStr(vQryViajes['fechaenviado'])+'] '+Trim(vQryViajes['calle'])+' '+IntToStr(vQryViajes['altura']);
              if vQryViajes['estado'] = 'QTA' then
                 vTexto := vTexto +' ['+vQryViajes['estado']+']';
              vJSONViajes.Add('viaje'+IntToStr(vCount), vTexto);
              /////
              vCount := vCount + 1;
              vQryViajes.Next;
            end;
            //El en ultimo registro colocamos el total de viajes----
            vJSONViajes.Add('total', IntToStr(vTotal));
            //------------------------------------------------------

            s := TlkJSON.GenerateText(vJSONViajes);

            Result := s;

          finally
            FreeAndNil(vQryViajes);
            FreeAndnil(vJSONViajes);
          end;
        end;
        //Fin Funcion ViajesInt ------------------------------------------------
__________________
\_--> NoShY <--_/
Responder Con Cita
  #8  
Antiguo 07-02-2017
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Poder: 30
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Cita:
Empezado por noshy Ver Mensaje
Son todos iguales los mensajes y una curiosidad, tambien es la misma address 00000000000002C8 en todas las ejecuciones.
Veo que es una aplicación de 64 bits (16 dígitos hexadecimales para las direcciones de memoria). ¿Te es posible compilar y ejecutar la aplicación en 32 bits? ¿Ocurrirá el mismo problema como aplicación de 32 bits?

Por otro lado, un AV con dirección de memoria muy baja es sintomático de intentar usar un objeto Nil; en el desplazamiento 2C8 de la instancia del objeto estaría el campo al que se desea acceder. Si es así, ese desplazamiento pareciera el de un objeto cuya clase posee cierto número de propiedades (particulares más heredadas). Digamos que objeto pequeño no es.

Cita:
Empezado por noshy Ver Mensaje
cada lectura del socket lo realiza en un thread diferente
¿Es posible que al momento de capturar esa imagen haya habido alrededor de 30 hilos activos? (Uno por cada ventana de error). Es casi seguro que esas ventanas de error en cascada surgen de algo que se está ejecutando en segundo plano. ¿Cuál es el código que programaste para esos hilos? Y ¿hay otros hilos para otras tareas?

Saludos.

Al González.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
no me detecta teclado numero Rofocale Varios 4 20-06-2011 23:00:14
BDS 2006 no detecta el IIS 7 en Win Vista ozrics Windows 0 17-06-2007 04:19:45
Software k detecta hardware Mrcl Debates 2 03-01-2007 22:07:58
la función SetSchemaInfo no detecta los índices amezeta32 Conexión con bases de datos 1 29-08-2006 22:51:53
¿Cua es el error que me detecta???? gandalf_27 C++ Builder 1 27-04-2006 19:57:44


La franja horaria es GMT +2. Ahora son las 10:16:16.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi