{ ==============================================================================
|
方法名稱:ReNameContext
|
引用相依:SaveToFile
|
方法描述:在指定路徑下執行影像清單的更名同步。遍歷 ContextList,比對舊檔名後更新
|
為新檔名,同步更新 Context.dat 及對應的文件編號清單(Context_DocNo.dat
|
)。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.ReNameContext(Path,OldName,NewName:String);
|
var
|
i : Integer;
|
begin
|
for i := 0 to ContextList.Count - 1 do
|
begin
|
if OldName = ContextList.Strings[i] then
|
begin
|
ContextList.Strings[i] := NewName;
|
ContextList.SaveToFile(Path+'Context.dat');
|
Context_DocnoList.Strings[i] := FormCode2DocNo(FileName2FormCode(NewName));
|
Context_DocnoList.SaveToFile(Path+'Context_DocNo.dat');
|
Break;
|
end;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteImageFile
|
引用相依:DeleteImageFile, FileExists, LoadFromFile, SaveToFile
|
方法描述:刪除指定的影像檔案。執行實體刪除後,自動計算文件目錄,並呼叫 SetContext
|
List 從 Context 清單中移除對應的影像記錄。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.DeleteImageFile(Path,FileName,CaseID:String); // 刪除檔案 (無法得到DocDir用)
|
var
|
i : Integer;
|
FileList:TStringlist;
|
DocDir : String;
|
begin
|
|
|
DeleteFile(Path+FileName);
|
DocDir := Path2DocDir(Path,CaseID);
|
//ShowMessage('DocDir='+DocDir);
|
SetContextList('D',-1,CaseID,DocDir,FileName);
|
{FileList:=TStringlist.Create;
|
try
|
if FileExists(Path+'Context.dat') then
|
FileList.LoadFromFile(Path+'Context.dat');
|
for i := 0 to FileList.Count - 1 do
|
begin
|
if FileName = FileList.Strings[i] then
|
begin
|
FileList.Delete(i);
|
FileList.SaveToFile(Path+'Context.dat');
|
Break;
|
end;
|
end;
|
if FileList.Count = 0 then
|
DeleteFile(Path+'Context.dat');
|
finally
|
FileList.Free;
|
end;}
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteFormCodeFile
|
引用相依:FileExists, LoadFromFile, DeleteImageFile, ReSortFileName, SaveToFil
|
e
|
方法描述:刪除案件中指定 FormID 的所有文件。讀取 Context.dat 並遍歷,若 FormID
|
匹配則執行刪除(在 ESCAN 模式下會檢查是否非當次掃瞄以保護舊圖)。刪除後
|
執行檔案序號重新排序。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.DeleteFormCodeFile(CaseID,DocDir,FormID:String); //刪除指定FormID文件
|
var
|
i: Integer;
|
FileList : TStringlist;
|
begin
|
FileList := TStringlist.Create;
|
try
|
FileList.Clear;
|
if FileExists(ImageSavePath+CaseID+'\'+DocDir+'\Context.dat') then
|
FileList.LoadFromFile(ImageSavePath+CaseID+'\'+DocDir+'\Context.dat');
|
|
for i := FileList.Count - 1 downto 0 do
|
begin
|
if FileName2FormCode(FileList.Strings[i]) = FormID then
|
begin
|
if (FMode = 'ESCAN') and (FModeName<>_Msg('異動件')) then
|
begin
|
if ISExistImg(ImageSavePath+CaseID+'\'+DocDir+'\'+FileList.Strings[i]) then
|
begin
|
//ShowMessage('有圖為非當次掃瞄,不可刪除');
|
Break;
|
end;
|
end;
|
//ShowMessage(FileList.Strings[i]);
|
DeleteImageFile(ImageSavePath+CaseID+'\'+DocDir+'\',FileList.Strings[i],CaseID);
|
end;
|
end;
|
finally
|
FileList.Free;
|
end;
|
ReSortFileName(ImageSavePath+CaseID+'\'+DocDir+'\');
|
{for i := ContextList.Count - 1 downto 0 do
|
begin
|
FName := ContextList.Strings[i];
|
if FormID = 'Err' then //刪未註冊文件
|
begin
|
If not FormIDExists(FileName2FormCode(FName),False,0) Then
|
begin
|
DeleteFile(Path+FName);
|
ContextList.Delete(i);
|
end;
|
end
|
Else
|
begin
|
If FormID = FileName2FormCode(FName) then
|
begin
|
DeleteFile(Path+FName);
|
ContextList.Delete(i);
|
end;
|
end;
|
end;
|
ContextList.SaveToFile(Path+'Context.dat');
|
ReSortFileName(Path); }
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteDocNoFile
|
引用相依:DeleteDocNoFile, SaveToFile, ReSortFileName, LoadFromFile, FileExist
|
s
|
方法描述:刪除指定的文件編號(DocNo)影像。遍歷 ContextList,比對文件編號後執行實
|
體刪除與清單移除(含 Context 與 Context_DocNo)。處理完成後執行檔案重新
|
排序並重新載入清單。
|
============================================================================== }
|
Function TCB_IMGPSScanX.DeleteDocNoFile(Path,DocNo:String):Boolean; //刪除指定DocNo文件
|
var
|
i: Integer;
|
FName : String;
|
begin
|
Result := False;
|
for i := ContextList.Count - 1 downto 0 do
|
begin
|
FName := ContextList.Strings[i];
|
If DocNo = FormCode2DocNo(FileName2FormCode(FName)) then
|
begin
|
DeleteFile(Path+FName);
|
ContextList.Delete(i);
|
Context_DocnoList.Delete(i);
|
Result := True; //有刪到指定文件
|
end;
|
end;
|
ContextList.SaveToFile(Path+'Context.dat');
|
Context_DocnoList.SaveToFile(Path+'Context_DocNo.dat');
|
ReSortFileName(Path);
|
ContextList.LoadFromFile(Path+'Context.dat');
|
Context_DocnoList.LoadFromFile(Path+'Context_DocNo.dat');
|
if FileExists(Path+'CustomDocNo.dat') then
|
Cust_DocNoList.LoadFromFile(Path+'CustomDocNo.dat');
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteDocNoFileForESCAN
|
引用相依:DeleteDocNoFile, SaveToFile, LoadFromFile, _DelTree
|
方法描述:在補件模式 (ESCAN) 下刪除屬於特定文件類型 (DocNo) 的影像。方法會從索
|
引清單 (ContextList) 的末尾開始向前遍歷,識別符合目標文件編號或附件名
|
稱的圖檔。若該檔案並非預先存在的(ISExistImg 返回 False),則執行實體刪
|
除並從索引清單中移除。若整個文件目錄因此清空,則會進一步移除該目錄並從
|
文件清單中刪除紀錄。
|
============================================================================== }
|
Function TCB_IMGPSScanX.DeleteDocNoFileForESCAN(Path,DocNo:String):Boolean; //刪除指定DocNo文件
|
var
|
i,j,k: Integer;
|
FName : String;
|
ST1,ST2,ST3:TStringList;
|
|
begin
|
|
Result := False;
|
//ShowMessage(DocNo);
|
for i := ContextList.Count - 1 downto 0 do
|
begin
|
FName := ContextList.Strings[i];
|
If (DocNo = FormCode2DocNo(FileName2FormCode(FName))) or (DocNo=AttName) then
|
begin
|
if not ISExistImg(Path+'\'+FName) then
|
begin
|
DeleteFile(Path+'\'+FName);
|
ContextList.Delete(i);
|
end;
|
Result := True; //有刪到指定文件
|
end;
|
end;
|
ContextList.SaveToFile(Path+'\Context.dat');
|
ContextList.LoadFromFile(Path+'\Context.dat');
|
|
if ContextList.Count=0 then
|
begin
|
_DelTree(Path);
|
SetDocNoList('D',-1,NowCaseNo,NowDocDir,'');
|
end;
|
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteShowFile
|
引用相依:DeleteShowFile
|
方法描述:刪除當前顯示清單(NowShowFileList)中的影像檔案並更新索引。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.DeleteShowFile(Path:String); //刪除顯示中的影像
|
var
|
i : Integer;
|
DelFile : String;
|
begin
|
for i := 0 to NowShowFileList.Count - 1 do
|
begin
|
DelFile := NowShowFileList.Strings[i];
|
DeleteFile(Path+DelFile);
|
SetContextList('D',-1,NowCaseno,NowDocNo,DelFile);
|
end;
|
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:DeleteCustomDocDir
|
引用相依:
|
方法描述:從 CustomDocNo.ini 中刪除指定的自定義文件區段。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.DeleteCustomDocDir(Path,DocNo:String); //刪除自定文件DocNo
|
var
|
ini : Tinifile;
|
begin
|
ini := Tinifile.Create(Path+'CustomDocNo.ini');
|
try
|
ini.EraseSection(DocNo);
|
finally
|
ini.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ReSortFileName
|
引用相依:ReSortFileName, FileExists, LoadFromFile, RenameFile, SaveToFile
|
方法描述:執行影像檔案名稱的重新排序與更名。讀取目錄下的 Context.dat,根據目前的
|
排列順序為每個檔案產生新的三位數序號前綴,並呼叫 ReNameFile 執行磁碟
|
更名,最後同步更新清單內容並儲存。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.ReSortFileName(Path:String); //檔名重新排序
|
var
|
i : Integer;
|
OldName,NewName : String;
|
Filelist : TStringlist;
|
begin
|
Filelist := TStringlist.Create;
|
try
|
if FileExists(Path+'Context.dat') then
|
begin
|
Filelist.LoadFromFile(Path+'Context.dat');
|
for i := 0 to Filelist.Count - 1 do
|
begin
|
OldName := Filelist.Strings[i];
|
//NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
|
NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
|
//ShowMessage(OldName+#10#13+NewName);
|
ReNameFile(Path+OldName,Path+NewName);
|
Filelist.Strings[i] := NewName;
|
end;
|
Filelist.SaveToFile(Path+'Context.dat');
|
ContextList.LoadFromFile(Path+'Context.dat');
|
end;
|
finally
|
Filelist.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ReSortFileName_New
|
引用相依:ReSortFileName, FileExists, LoadFromFile, RenameFile, SaveToFile
|
方法描述:與 ReSortFileName 類似,執行影像檔案名稱的重新排序,但採用從清單末尾向
|
前遍歷的方式執行更名與儲存。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.ReSortFileName_New(Path:String); //檔名重新排序
|
var
|
i : Integer;
|
OldName,NewName : String;
|
Filelist : TStringlist;
|
begin
|
Filelist := TStringlist.Create;
|
try
|
if FileExists(Path+'Context.dat') then
|
begin
|
Filelist.LoadFromFile(Path+'Context.dat');
|
for i := Filelist.Count - 1 downto 0 do
|
begin
|
OldName := Filelist.Strings[i];
|
//NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
|
NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
|
ReNameFile(Path+OldName,Path+NewName);
|
Filelist.Strings[i] := NewName;
|
end;
|
Filelist.SaveToFile(Path+'Context.dat');
|
ContextList.LoadFromFile(Path+'Context.dat');
|
end;
|
finally
|
Filelist.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ReSortFileName2Scanlist
|
引用相依:ReSortFileName, FileExists, LoadFromFile, RenameFile, SaveToFile
|
方法描述:針對 scanlist.dat 檔案內的影像路徑進行序號重排。讀取清單後,依序為檔案
|
名稱加上新的序號前綴並存回。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.ReSortFileName2Scanlist(Path:String); //檔名重新排序給Scanlist.dat
|
var
|
i : Integer;
|
OldName,NewName : String;
|
S : TStringlist;
|
begin
|
S := TStringlist.Create;
|
try
|
if FileExists(Path+'scanlist.dat') then
|
S.LoadFromFile(Path+'scanlist.dat');
|
for i := 0 to S.Count - 1 do
|
begin
|
OldName := S.Strings[i];
|
//NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
|
NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
|
//ReNameFile(Path+OldName,Path+NewName);
|
S.Strings[i] := NewName;
|
end;
|
S.SaveToFile(Path+'scanlist.dat');
|
finally
|
S.Free;
|
end;
|
end;
|