;
begin
sTemp:=FindName(''SERVER'',''SERVERNAME'');
I:=WinExec(PChar(sTemp),SW_SHOW);
if I<31 then
begin
Ret:=Application.MessageBox(''Start NotesServer Error!'',''Error!'',MB_OK);
Exit;
end;
end;
〈2〉procedure TSrvForm.StopServer(); //停止运行应用程序
Var
I,Ret :Integer;
sTemp :string;
begin
sTemp:=FindName(''SERVER'',''SERVERNAME'')+'' -quit'';
I:=WinExec(PChar(sTemp),0);
if I<31 then
begin
Ret:=Application.MessageBox(''Stop NotesServer Error!'',''Error!'',MB_OK);
Exit;
end;
end;
〈3〉procedure TSrvForm.BackupData(); //启动数据备份程序
Var
sConent,sResourePath,sResoureFile,SDestPath :String;
sTemp,sDate,sConst,sDir :string;
I,J :Integer;
begin
sDate:=FormatDateTime(''yyyymmdd'',Date());
SDestPath:=FindName(''DESTINATION'',''PATHNAME'');
sTemp:=SDestPath+sDate;
sConst:=sTemp;//Don''t change this variable.
sConent:=''.\mkdir1.bat ''+sTemp;
I:=WinExec(PChar(sConent),0); //Create data store path
if I<31 then
begin
Application.MessageBox(''Mkdir Error!'',''Error!'',MB_OK);
Exit;
end;
//Copy all direstories and files
J:=1;
while 1=1 do
begin
sResourePath:=FindName(''DIRECTORYS'',''DIR''+IntToStr(J));
J:=J+1;
if sResourePath =''N'' then break;
//create same name directory
sDir:=sConst+FindLastDir(sResourePath);
I:=WinExec(PChar(''.\mkdir1.bat ''+sDir),0); //Create data store path
if I<31 then
begin
Application.MessageBox(''Mkdir Error!'',''Error!'',MB_OK);
Exit;
end;
//create end
sConent:=''.\xcopy1.bat ''+sResourePath+'' ''+ sDir;
I:=WinExec(PChar(sConent),0);
if I<31 then
begin
Application.MessageBox(''Copy Error!'',''Error!'',MB_OK);
Exit;
end;
end;
//Copy all files
J:=1;
while 1=1 do
begin
sResoureFile:=FindName(''FILES'',''FILE''+IntToStr(J));
J:=J+1;
if sResoureFile =''N'' then break;
sConent:=''.\copy1.bat ''+ sResoureFile +'' ''+ sConst;
I:=WinExec(PChar(sConent),0);
if I<31 then
begin
Application.MessageBox(''Copy Error!'',''Error!'',MB_OK);
Exit;
end;
end;
end;
(4) TIMER定时备份程序, 取当前时间,根据规则生成一格式为‘YYYYMMDD’的字符串,作为备份的子目录,用以表示备份数据的日期。从备份日志文件中查找是否已经备份,若已经备份退出程序,无备份则创建备份的子目录。如果是备份为静态备份,停止运行应用程序,若为动态备份,不停止应用程序的运行,进行数据的备份,并根据实际的备份时间进行延时。备份完毕,记录备份日志。程序如下:
procedure TSrvForm.Timer1Timer(Sender: TObject); //定时程序调用
Var
f: TextFile;
sTemp,sDate,sBegin:string;
iPos:Integer;
begin
sDate:=FormatDateTime(''yyyymmdd'',Now());
sBegin:=''[''+FormatDateTime(''hhnnss'',Now())+'']'';
//backup or not
AssignFile(f,''record.txt'');
Reset(f);
iPos:=0;
while NOT EOF(f) do
begin
Readln(f,sTemp);
iPos:=Pos(sDate,sTemp);
if iPos>0 then break;
end;
CloseFile(f);
if iPos>0 then exit;//Already backup
Label2.Visible:=True;
if (DayOfWeek(Date())=ipWeek) and ( FormatDateTime(''hhnnss'',Now())>spTime) then
begin
StopSrv();
Sleep(lpSleep1);//wait for lpSleep1/1000/60 minutes
BackupData();
Sleep(lpSleep2);//wait for lpSleep2/1000/60 minutes
StartSrv();
end
else
begin
if (DayOfWeek