PARAMETERS adresar, jmeno_souboru_html


****************************************************************************
*
* 2014-0611 vynechaji se radky z GETu s peti ".. OK"
*
****************************************************************************




vysledek = " v.2014-0611 " + m.adresar + m.crlf
adresar = adresar + IIF(RIGHT(m.adresar, 1)="\", "", "\")
pocet_adresaru = adir(seznamadresaru, m.adresar + "*.*", "D")
IF pocet_adresaru > 0
    CREATE TABLE (m.pri_path + "ftp_kontrola") (adr c(11), soubor C(55), prikaz C(7), radek C(252), barva C(55))
    for ii = 1 to m.pocet_adresaru
       if left(seznamadresaru(ii, 1), 1) # "." .and. "D" $ seznamadresaru(ii, 5)
           vysledek = vysledek + chr(9) + PADR(lowe(seznamadresaru(ii, 1)) + " ", 33, ".")
           DO ftp_kontrolor1 WITH adresar, lowe(seznamadresaru(ii, 1))
       endif
    endfor
    DO dobarvi
    DO generuj_html WITH m.adresar + IIF(EMPTY(jmeno_souboru_html), "kontrola_prenosu.htm", jmeno_souboru_html)

ENDIF 

**** **** **** **** **** **** **** **** **** **** **** **** 
PROCEDURE ftp_kontrolor1
PARAMETERS cesta1, cesta2
pocetsouboru = adir(seznamsouboru, m.cesta1 + m.cesta2 + "\*.txt")
vysledek = vysledek + STR(m.pocetsouboru, 4) + m.crlf
if pocetsouboru > 0
    for iiiii = 1 to pocetsouboru
        jmeno_souboru = lower(m.cesta1 + m.cesta2 + "\" + seznamsouboru(iiiii, 1))
        obsahsouboru = FILETOSTR( jmeno_souboru)
        posledni = RAT("  Connect", m.obsahsouboru)
        IF "kontrola_prenosu" $ jmeno_souboru
            posledni = -999
        ENDIF 
        IF m.posledni > 0
           obsahsouboru = SUBSTR(m.obsahsouboru, m.posledni - 3)
           STRTOFILE(m.obsahsouboru, jmeno_souboru)
           fh = FOPEN(jmeno_souboru)
           IF fh > 0
               DO WHILE ! FEOF(fh)
                   txt = ALLTRIM(FGETS(fh))
                   DO CASE 
                   CASE EMPTY(m.txt) .or. (repli("=", 55) $ m.txt)
                       * nic
                   CASE  (LEFT(m.txt, 2) = "//") .or. (LEFT(m.txt, 7) = "IGNORED")
                       * nic
                   CASE  "... " $ m.txt .and. " OK" $ m.txt
                       * nic
                   CASE AT(".. OK", m.txt, 5) > 0
                       * nic
                   OTHERWISE
                       APPEND BLANK 
                       REPLACE soubor WITH m.cesta2 + " : " + UPPER(JUSTFNAME(m.jmeno_souboru)), radek WITH m.txt, prikaz WITH m.txt
                   ENDCASE 
               ENDDO 
               FCLOSE(fh)
               IF .not. (" Disconnect" $ m.obsahsouboru)
                   APPEND BLANK 
                   REPLACE soubor WITH m.cesta2 + " : " + UPPER(JUSTFNAME(m.jmeno_souboru)), radek WITH "<center>= = &nbsp; P R E N O S &nbsp; N E N I &nbsp; D O K O N C E N &nbsp; = =</center>", prikaz WITH "[2B#R]"
               ENDIF 
           ENDIF 
        ENDIF 
    ENDFOR
ENDIF 


**** **** **** **** **** **** **** **** **** **** **** **** 
PROCEDURE dobarvi
REPLACE for LEFT(prikaz,3) = "EXE"                     prikaz WITH "EXEC",    barva WITH '<font size="1" color = "#005500">'
REPLACE for LEFT(prikaz,3) = "GET"                     prikaz WITH "GET",     barva WITH '<font size="1" color = "#000055">'
REPLACE for LEFT(prikaz,3) = "LOA"                     prikaz WITH "LOAD",    barva WITH '<font size="1" color = "#000055">'
REPLACE for LEFT(prikaz,4) = "SEND"                    prikaz WITH "SEND",    barva WITH '<font size="1" color = "#000055">'
REPLACE for "= " $ radek .and. ("Disconnect" $ radek)   prikaz WITH "DISCONN", barva WITH '<center><font size="2" color = "#444444"><B>'
REPLACE FOR                                            prikaz  =   "DISCONN"  radek WITH STRTRAN(radek, "====", "=")
REPLACE FOR "= " $ radek .and. (" Connect"    $ radek) prikaz WITH "CONNECT", radek WITH STRTRAN(STRTRAN(radek, "Connected to", ""), "=", "")
REPLACE FOR                                            prikaz  =   "CONNECT"  radek WITH STRTRAN(radek, "Connected", "")
REPLACE FOR                                            prikaz  =   "CONNECT"  radek WITH STRTRAN(radek, "Connect", "")

SCAN FOR "[" $ prikaz .and. "]" $ prikaz
        m.barva = '<font size="' + SUBSTR(prikaz,2,1) + '"'
        IF "#" $ prikaz
             barva_info = SUBSTR(prikaz, AT("#", prikaz))
             DO CASE 
             CASE "r" $ barva_info
                 barva = m.barva + ' color = "#990000">'
             CASE "R" $ barva_info
                 barva = m.barva + ' color = "#FF0000">'
             CASE "g" $ barva_info
                 barva = m.barva + ' color = "#008800">'
             CASE "G" $ barva_info
                 barva = m.barva + ' color = "#00CC00">'
             CASE "b" $ barva_info
                 barva = m.barva + ' color = "#000088">'
             CASE "B" $ barva_info
                 barva = m.barva + ' color = "#0000CC">'
             CASE "k" $ barva_info
                 barva = m.barva + ' color = "#999999">'
             CASE "K" $ barva_info
                 barva = m.barva + ' color = "#000000">'
             OTHERWISE 
                 barva = m.barva + '>'
             ENDCASE 
             IF "B" $ LEFT(prikaz, AT("#", prikaz))    && bold
                 barva = m.barva + '<B>'
             ENDIF 
             IF "T" $ LEFT(prikaz, AT("#", prikaz))    && teletype
                 barva = m.barva + '<TT>'
             ENDIF 
        ELSE 
             barva = m.barva + '>'
             IF "B" $ prikaz    && bold
                 barva = m.barva + '<B>'
             ENDIF 
             IF "T" $ prikaz    && teletype
                 barva = m.barva + '<TT>'
             ENDIF 
        ENDIF 
        REPLACE prikaz WITH "", radek WITH SUBSTR(radek, AT("]", radek)+1), barva WITH m.barva
ENDSCAN

REPLACE for .not. INLIST(prikaz, "GET", "LOAD", "SEND", "EXEC", "CONNECT", "DISCONN") prikaz WITH ""
DELETE FOR EMPTY(prikaz) .and. BETWEEN(VAL(LEFT(radek,2)),0,24) .and. SUBSTR(radek,3,1) = ":" .and. BETWEEN(VAL(SUBSTR(radek,4,2)),0,59)    && jen casova informace

REPLACE FOR EMPTY(prikaz) .and. "....." $ radek barva WITH '<font size="2" color = "#FF0000">'
REPLACE FOR EMPTY(prikaz) .and. EMPTY(barva) barva WITH '<font size="2" color = "#000000">'

SCAN FOR .f.
        IF INLIST(prikaz, "GET", "LOAD", "SEND") .and. (.not. EOF())
            SKIP 
            IF .not. EMPTY(prikaz)
                SKIP -1
                REPLACE radek WITH "SMAZAT"
            ELSE
                SKIP -1
            ENDIF 
        ENDIF 
ENDSCAN 
DELETE FOR radek = "SMAZAT"
 

**** **** **** **** **** **** **** **** **** **** **** **** 
PROCEDURE generuj_html
PARAMETERS jmeno_souboru
fh_report = FCREATE( m.jmeno_souboru)
FPUTS(fh_report, '<HTML><HEAD><TITLE> Report ' + ttoc(datetime()) + '</TITLE></HEAD>')
FPUTS(fh_report, '<BODY bgcolor="#ffffff"  text="#000000">' )
stary_soubor = "@(*#&%$^%"

SCAN
    DO CASE 
    CASE (soubor # m.stary_soubor) .or. (prikaz = "CONNECT")
        stary_soubor = soubor
        _verze = SUBST(radek, AT("v.20", radek))
        IF EMPTY(m._verze)
            _verze = SUBST(radek, AT(" 200", radek)+1)
        ENDIF 
        radek =  LEFT (radek, AT("v.20", radek)-1)
            
        FPUTS(fh_report, '<br><center>' + repli("=",44) + '<font size="1" color = "#000000"> <b> &nbsp; &nbsp; ' + ttoc(datetime()) + ' &nbsp;</b> &nbsp;</font>' + repli("=",44) + '</center>' + m.crlf )
        FPUTS(fh_report, '<center><font size="4" color = "#000000"><b>' + soubor + ' </b></font> &nbsp; &nbsp; ' + m.crlf )
        FPUTS(fh_report, '<font size="3" color = "#000000"> ' + ALLTRIM(m.radek) + '</font><img width=11 height=1 src="space.gif">' + m.crlf)

        DO formatuj_spusteni
        DO formatuj_verzi

    OTHERWISE 
       FPUTS(fh_report, '<br>' + IIF(EMPTY(prikaz), ' <img width=11 height=5 src="space.gif"> &nbsp; ', '') + ALLTRIM(barva) + ALLTRIM(radek) + IIF("<TT>" $ barva, "</TT>", "") + IIF("<B>" $ barva, "</B>", "") + '</font>' + IIF("<center>" $ barva, "</center>", "") + m.crlf)
    ENDCASE 
ENDSCAN 
    
FPUTS(fh_report, '</BODY></HTML>' )
FCLOSE(fh_report)


**** **** **** **** **** **** **** **** **** **** **** **** 
PROCEDURE formatuj_spusteni
spusteno = MAX(AT(".201", m.radek), AT(".202", m.radek))
IF m.spusteno > 5
   rok = VAL(SUBSTR(radek, m.spusteno+1,4))
   kousek_radku = STRTRAN(LEFT(m.radek, m.spusteno-1), "/", ".")
   DO CASE 
   CASE SUBSTR(m.kousek_radku, m.spusteno-3,1) = "."    && mesic z datum spusteni
        mesic = VAL(SUBSTR(kousek_radku, m.spusteno-2,2))
        kousek_radku = LEFT(m.kousek_radku, m.spusteno-4)
   CASE SUBSTR(m.kousek_radku, m.spusteno-2,1) = "."    && mesic z datum spusteni
        mesic = VAL(SUBSTR(kousek_radku, m.spusteno-1,1))
        kousek_radku = LEFT(m.kousek_radku, m.spusteno-3)
   OTHERWISE 
        mesic = 0
   ENDCASE 
   den = VAL(RIGHT(kousek_radku, 2))
   IF m.mesic > 12
        _pom = m.mesic
        mesic = m.den
        den = m._pom
   ENDIF 

   TRY 
        nespusteno = DATE() - DATE(m.rok, m.mesic, m.den)
   CATCH
        nespusteno = 0
   ENDTRY 
        
   DO CASE 
   CASE m.nespusteno > 55
        FPUTS(fh_report, '<font size="2" color = "#CC0000"><b>' + ' NEBYLO SPUSTENO ' + TRANSFORM(m.nespusteno, "999 DNI ") + '</b></font><img width=11 height=1 src="space.gif">' + m.crlf)
        cislo_radku = RECNO()
        REPLACE WHILE soubor = m.stary_soubor .and. prikaz # "DISCONN" barva WITH '<font size="1" color = "#999999">'    && zobrazi se sede
        GO (m.cislo_radku)
   CASE m.nespusteno > 11
        FPUTS(fh_report, '<font size="3" color = "#FF0000"><b>' + ' NEBYLO SPUSTENO ' + TRANSFORM(m.nespusteno, "999 DNI ") + '</b></font><img width=11 height=1 src="space.gif">' + m.crlf)
   CASE m.nespusteno > 6
        FPUTS(fh_report, '<font size="3" color = "#FF0000">'    + ' NEBYLO SPUSTENO ' + TRANSFORM(m.nespusteno, "999 DNI ") +     '</font><img width=11 height=1 src="space.gif">' + m.crlf)
   CASE m.nespusteno > 3
        FPUTS(fh_report, '<font size="2" color = "#CC0000"><b>' + ' NEBYLO SPUSTENO ' + TRANSFORM(m.nespusteno, "999 DNI ") + '</b></font><img width=11 height=1 src="space.gif">' + m.crlf)
   ENDCASE 
ENDIF 

**** **** **** **** **** **** **** **** **** **** **** **** 
PROCEDURE formatuj_verzi
_verze = LEFT (_verze, AT(" ", _verze))

DO CASE 
CASE ("200" $ _verze) .or. ("v.2010" $ _verze) .or. ("v.2011" $ _verze) .or. ("v.2012" $ _verze) .or. ("v.2013" $ _verze)
   FPUTS(fh_report, '<font size="4" color = "#FF0000"><b>(' + ALLTRIM(_verze) + ')</b></font></center>' + m.crlf)
CASE (_verze < "v.2014-03-00")
   FPUTS(fh_report, '<font size="2" color = "#DD0000"><b>(' + ALLTRIM(_verze) + ')</b></font></center>' + m.crlf)
OTHERWISE 
   FPUTS(fh_report, '<font size="2" color = "#000000">(' + ALLTRIM(_verze) + ')</font></center>' + m.crlf)
ENDCASE 
