1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341:
| unit main;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellApi, ubZipUtils, ubFILESUtils;
type TForm1 = class(TForm) Label1: TLabel; Button1: TButton; Label2: TLabel; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); private public x:string; error:string;
end;
var Form1: TForm1;
implementation
{$R *.DFM}
PROCEDURE TForm1.Button1Click(Sender: TObject);
VAR sl_commandos, sl_dat, sl_currLns: TStringList;
VAR i, j, l, posi, m, n, o: Integer;
VAR currLn, ID, id_zs, Kommando, kommando_zs, StartTime, st_zs, EndTime, et_zs, NR, nr_zs: STRING;
VAR StartZeit, EndZeit, endevorlaeufer, Laufzeit: TDateTime;
VAR result: TextFile;
VAR temp, s1, s2, s3, hilf, punkt, noData, RunTime, endtime_vorlaeufer, id_vorlaeufer: String;
VAR anz_dat, anz_lns, anz_kommandos: Integer;
VAR exit: Boolean;
BEGIN punkt:='.'; exit:=True; TRY sl_commandos:=TStringList.Create; sl_commandos.LoadFromFile('C:\D-Dateien\commandos.txt');
TRY sl_dat:=TStringList.Create; fGetfiles(sl_dat,'C:\D-Dateien','*.zip', true,false);
anz_dat:=sl_dat.count-1;
AssignFile(result, 'C:\D-Dateien\Auswertung\results_runtime-'+DateTimeToStr(Date)+'.xls');
IF FileExists('C:\D-Dateien\Auswertung\results_runtime-'+DateTimeToStr(Date)+'.xls') = True THEN BEGIN Rewrite(result); writeln(result, 'VSTKNR,Kommando,ID,Startzeit,Endzeit,Laufzeit'); END ELSE BEGIN Rewrite(result); writeln(result, 'VSTKNR,Kommando,ID,Startzeit,Endzeit,Laufzeit'); END;
FOR i:=0 TO anz_dat DO BEGIN fbUnZipSingleFile('*.d1', sl_dat[i], 'C:\D-Dateien\d1-dateien\', x, error);
TRY sl_currLns:=TStringList.Create; sl_currLns.LoadFromFile('C:\D-Dateien\d1-dateien\' + ChangeFileExt(ExtractFileName(sl_dat[i]), '.d1'));
anz_lns:=sl_currLns.count-1;
anz_kommandos:=sl_commandos.count-1;
Application.ProcessMessages; nr_zs:=ExtractFileName(sl_dat[i]); hilf:=Copy(nr_zs, 0, 9); IF pos(punkt, Copy(hilf,9,1)) > 0 THEN BEGIN nr_zs:=Copy(hilf, 0, 8); temp:=Copy(nr_zs, 0, 3); hilf:=temp+'--'; temp:=Copy(nr_zs, 4, 4); hilf:=hilf+temp+'-'; temp:=Copy(nr_zs, 8, 1); NR:=hilf+temp; END ELSE IF pos(punkt, Copy(hilf,8,1)) > 0 THEN BEGIN nr_zs:=Copy(hilf, 0, 7); temp:=Copy(nr_zs, 0, 3); hilf:=temp+'--'; temp:=Copy(nr_zs, 4, 3); hilf:=hilf+temp+'--'; temp:=Copy(nr_zs, 7, 1); NR:=hilf+temp; END ELSE BEGIN nr_zs:=Copy(hilf, 0, 6); temp:=Copy(nr_zs, 0, 3); hilf:=temp+'--'; temp:=Copy(nr_zs, 4, 2); hilf:=hilf+temp+'---'; temp:=Copy(nr_zs, 6, 1); NR:=hilf+temp; END;
FOR l:=0 TO anz_kommandos DO BEGIN FOR j:=0 TO anz_lns DO BEGIN Application.ProcessMessages; IF pos(sl_commandos[l], sl_currLns[j]) > 0 THEN BEGIN currLn:= Copy(sl_currLns[j],0,Length(sl_commandos[l]));
kommando_zs:=currLn; IF(kommando_zs = Kommando) = False THEN BEGIN Kommando:=kommando_zs; exit:=False;
currLn:= Copy(sl_currLns[j-3],55,18); IF (currLn = st_zs) = False THEN BEGIN st_zs:=currLn; StartTime:=st_zs;
temp:=copy(StartTime,7,2); s1:=temp+'.'; temp:=copy(StartTime,4,2); s1:=s1+temp+'.'; temp:=copy(StartTime,1,2); s1:=s1+temp+' '; temp:=copy(StartTime,10,9); s1:=s1+temp; StartZeit:=StrToDateTime(s1);
temp:='';
end; END;
currLn:= Copy(sl_currLns[j-2],0,4); IF(currLn = id_zs) = False THEN BEGIN id_zs:=currLn; ID:=id_zs; END;
END;
try
if exit=False Then begin if pos('END JOB '+ID, sl_currLns[j]) > 0 then begin for m:=j downto 0 do begin if pos(ID, copy(sl_currLns[m],0,4)) > 0 then begin EndTime:=Copy(sl_currLns[m-1],55,18);
temp:=copy(EndTime,7,2); s2:=temp+'.'; temp:=copy(EndTime,4,2); s2:=s2+temp+'.'; temp:=copy(EndTime,1,2); s2:=s2+temp+' '; temp:=copy(EndTime,10,9); s2:=s2+temp; EndZeit:=StrToDateTime(s2); temp:='';
break; end; end;
for n:=j downto 0 do begin if pos('END JOB ', sl_currLns[n]) > 0 then begin id_vorlaeufer:=copy(sl_currLns[n],9,4);
for o:=n downto 0 do begin if pos(id_vorlaeufer, copy(sl_currLns[o],0,4)) > 0 then begin endtime_vorlaeufer:=copy(sl_currLns[o-1],55,18);
temp:=copy(endtime_vorlaeufer,7,2); s3:=temp+'.'; temp:=copy(endtime_vorlaeufer,4,2); s3:=s3+temp+'.'; temp:=copy(endtime_vorlaeufer,1,2); s3:=s3+temp+' '; temp:=copy(endtime_vorlaeufer,10,9); s3:=s3+temp; endevorlaeufer:=StrToDateTime(s3); temp:='';
exit:=True; end; end; if exit=True then begin break; end; end else begin if pos('END TEXT JOB '+ID, sl_currLns[n]) > 0 then
for o:=n downto 0 do begin if pos(ID, copy(sl_currLns[o],0,4)) > 0 then begin endtime_vorlaeufer:=copy(sl_currLns[o-1],55,18); temp:=copy(endtime_vorlaeufer,7,2); s3:=temp+'.'; temp:=copy(endtime_vorlaeufer,4,2); s3:=s3+temp+'.'; temp:=copy(endtime_vorlaeufer,1,2); s3:=s3+temp+' '; temp:=copy(endtime_vorlaeufer,10,9); s3:=s3+temp; endevorlaeufer:=StrToDateTime(s3); temp:='';
exit:=True; end; end; if exit=True then begin break; end; end; end; end;
end;
except on EConvertError do RunTime:=' FEHLER!!!'; end;
if RunTime <> ' FEHLER!!!' then begin if EndZeit <> 0 then begin RunTime:=FormatDateTime('hh:nn:ss', EndZeit-endevorlaeufer); StartTime:=DateTimeToStr(StartZeit); EndTime:=DateTimeToStr(EndZeit); end; end; END;
IF Kommando = sl_commandos[l] THEN BEGIN Write(result, NR+','); Write(result, Kommando+','); Write(result, ID+','); Write(result, StartTime+','); Write(result, EndTime+','); WriteLn(result, RunTime); noData:=''; RunTime:='';
END; END;
FINALLY freeandnil(sl_currLns); END;
END;
CloseFile(result);
FINALLY freeandnil(sl_dat); END;
FINALLY freeandnil(sl_commandos); END;
END; |