代码拉取完成,页面将自动刷新
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, Psock, NMFtp,inifiles;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
NMFTP1:TNMFTP;
TheDate:TDate;
Current_Scheme_Values:Array[0..17] Of String;
procedure GetCurrentScheme(name: String);
procedure DelOldFile;
procedure FTPBackFile;
public
{ Public declarations }
end;
const
iniFileName:String='oraback.ini';
SCHEME_VALUES:Array[0..17] Of String=
('NAME','PARFILE','RUNTIME','RUNDATE','CYCLE','USERNAME','PASSWORD','SERVER','ARCDIR','ISZIP','SAVECYCLE','LEVELAST'
,'FTP_HOST','FTP_USE','FTP_PASS','FTP_PORT','FTP_DMP','FTP_RAR'
);
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
SCH:String;
begin
if ParamCount<2 Then
begin
Application.Terminate;
exit;
end;
TheDate:=StrToDate(ParamStr(1));
SCH:=ParamStr(2);
GetCurrentScheme(SCH);
FTPBackFile;
DelOldFile;
Application.Terminate;
end;
procedure TForm1.FTPBackFile;
var s,SCH,dmpname,rarname:string;
begin
if Current_Scheme_Values[12]='' then exit;
if (Current_Scheme_Values[16]<>'1') or (Current_Scheme_Values[17]<>'1') then exit;
NMFTP1:=TNMFTP.Create(self);
NMFTP1.Host:=Current_Scheme_Values[12];
NMFTP1.UserID:=Current_Scheme_Values[13];
NMFTP1.Password:=Current_Scheme_Values[14];
NMFTP1.Port:=StrToInt(Current_Scheme_Values[15]);
try
NMFTP1.Disconnect;
except end;
try
NMFTP1.connect;
except
exit;
end;
SCH:=Current_Scheme_Values[1];
if SCH='ȱʡ' then
SCH:=''
else
SCH:='_'+SCH;
S:=FormatDateTime('YYYY-MM-DD',TheDate);
dmpname:=Current_Scheme_Values[5]+'\EXP_'+Current_Scheme_Values[5]+'_'+S+SCH+'.dmp';
rarname:=Current_Scheme_Values[8]+'\'+Current_Scheme_Values[5]+'\EXP_'+Current_Scheme_Values[5]+'_'+S+SCH+'.rar';
try
if Current_Scheme_Values[16]='1' then
begin
NMFTP1.Upload(dmpname,dmpname);
end;
if Current_Scheme_Values[17]='1' then
begin
NMFTP1.Upload(rarname,rarname);
end;
finally
NMFTP1.Disconnect;
end;
end;
procedure TForm1.DelOldFile;
var
dmpname,rarname,S,SCH:String;
D1,D2:TDate;
I,DayCount:INTEGER;
HasLeve:boolean;
SaveCycle:Integer;
IsZip,LeveLast:Boolean;
ArcDir,UserName:String;
begin
SaveCycle:=StrToInt(Current_Scheme_Values[4]);
IsZip:=Current_Scheme_Values[9]='1';
ArcDir:=Current_Scheme_Values[8];
UserName:=Current_Scheme_Values[5];
LeveLast:=true;
if ParamCount>=7 then
LeveLast:=ParamStr(7)='1';
case SaveCycle of
1: //ÿ
begin
D1:=StrToDate(FormatDateTime('YYYY-MM',IncMonth(TheDate,-1))+'-01');
D2:=IncMonth(D1,1)-1;
end;
2: //ÿ
begin
D1:=(TheDate-DayOfWeek(TheDate)+2)-7;
D2:=D1+7;
end;
else begin
Application.Terminate;
exit;
end;
end;
DayCount:=round(D2-D1);
HasLeve:=false;
SCH:=Current_Scheme_Values[1];
if SCH='ȱʡ' then
SCH:=''
else
SCH:='_'+SCH;
for I := 0 to DayCount-1 do
begin
S:=FormatDateTime('YYYY-MM-DD',D2-I);
dmpname:=UserName+'\EXP_'+UserName+'_'+S+SCH+'.dmp';
rarname:=ArcDir+'\'+UserName+'\EXP_'+UserName+'_'+S+SCH+'.rar';
if FileExists(dmpname) then
begin
if LeveLast and not HasLeve then
begin
HasLeve:=true;
continue;
end;
DeleteFile(dmpname);
if IsZip and FileExists(rarname) then
DeleteFile(rarname);
end;
end;
end;
procedure TForm1.GetCurrentScheme(name:String);
var ini: TIniFile;
i:Integer;
begin
ini:=TIniFile.Create(iniFileName);
for i := 0 to length(SCHEME_VALUES)-1 do
begin
Current_Scheme_Values[i]:=ini.ReadString(name,SCHEME_VALUES[i],'');
end;
ini.Destroy;
If Current_Scheme_Values[3]='' Then
Current_Scheme_Values[3]:=DateToStr(date);
If Current_Scheme_Values[4]='' Then
Current_Scheme_Values[4]:='0';
If Current_Scheme_Values[2]='' Then
Current_Scheme_Values[2]:='00:00:00';
If Current_Scheme_Values[9]='' Then
Current_Scheme_Values[9]:='1';
If Current_Scheme_Values[10]='' Then
Current_Scheme_Values[10]:='0';
If Current_Scheme_Values[11]='' Then
Current_Scheme_Values[11]:='1';
If Current_Scheme_Values[16]='' Then
Current_Scheme_Values[16]:='1';
If Current_Scheme_Values[17]='' Then
Current_Scheme_Values[17]:='1';
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。