{ ==============================================================================
|
方法名稱:CreateCaseNeedData
|
引用相依:FileExists, LoadFromFile, SaveToFile
|
方法描述:掃描案件目錄下的 Context.dat 影像清單,自動推導並產生該案件所需的 Doc
|
Dir.dat、CaseDocNo.dat 及份數清單,用於修復或重建案件結構。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.CreateCaseNeedData(Path:String);
|
var
|
FileList,DocNoList,CaseDocNoList,CaseDocNo_CopiesList : TStringlist;
|
i,n : Integer;
|
Docno : String;
|
Exists : Boolean;
|
begin
|
FileList := TStringlist.Create;
|
DocNoList := TStringlist.Create;
|
CaseDocNoList := TStringlist.Create;
|
CaseDocNo_CopiesList := TStringlist.Create;
|
try
|
if FileExists(Path+'Context.dat') then
|
begin
|
FileList.LoadFromFile(Path+'Context.dat');
|
for i := 0 to FileList.Count - 1 do
|
begin
|
Docno := FormCode2DocNo(FileName2FormCode(FileList.Strings[i]));
|
//ShowMessage('Docno='+Docno);
|
DocNoList.Add(DocNo);
|
Exists := False;
|
for n := 0 to CaseDocNoList.Count - 1 do
|
begin
|
if Docno = CaseDocNoList.Strings[n] then
|
Exists := True;
|
end;
|
if not Exists then
|
begin
|
CaseDocNoList.Add(DocNo);
|
CaseDocNo_CopiesList.Add('1');
|
end;
|
end;
|
//ShowMessage('CreateCaseNeedData DocNoList='+DocNoList.Text);
|
DocNoList.SaveToFile(Path+'DocDir.dat');
|
CaseDocNoList.SaveToFile(Path+'CaseDocNo.dat');
|
CaseDocNo_CopiesList.SaveToFile(Path+'CaseDocNo_Copies.dat')
|
end;
|
|
finally
|
FileList.Free;
|
DocNoList.Free;
|
CaseDocNoList.Free;
|
CaseDocNo_CopiesList.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:Case2upload
|
引用相依:DirectoryExists, _DelTree, Str2Dir, CopyFile, FileExists, LoadFromFi
|
le, SaveToFile
|
方法描述:準備案件上傳用的資料夾結構。將分散在各文件子目錄下的影像檔案複製到單
|
一的 Upload 目錄下並重新編號檔名,同時產生彙整後的索引檔與附件。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.Case2upload(CaseID:String);
|
var
|
i,n:Integer;
|
OldPath,NewPath,DocDir : String;
|
OldFile,NewFile,AttFile : String;
|
DocNoList,FileList:TStringlist;
|
iFileList,iFile_DocNoList :TStringlist;
|
iDocDirList : TStringlist;
|
iAttFileList : TStringlist;
|
begin
|
DocNoList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
iFileList := TStringlist.Create;
|
iFile_DocNoList := TStringlist.Create;
|
iDocDirList := TStringlist.Create;
|
iAttFileList := TStringlist.Create;
|
try
|
OldPath := ImageSavePath+CaseID+'\';
|
NewPath := ImageSavePath+CaseID+'\Upload\';
|
if DirectoryExists(NewPath) then
|
_DelTree(NewPath);
|
str2dir(NewPath);
|
CopyFile(PWideChar(OldPath+'CaseDocNo.dat'),PWideChar(NewPath+'CaseDocNo.dat'),False);
|
CopyFile(PWideChar(OldPath+'CaseDocNo_Copies.dat'),PWideChar(NewPath+'CaseDocNo_Copies.dat'),False);
|
CopyFile(PWideChar(OldPath+'CustomDocNo.ini'),PWideChar(NewPath+'CustomDocNo.ini'),False);
|
CopyFile(PWideChar(OldPath+'CaseIndex.dat'),PWideChar(NewPath+'CaseIndex.dat'),False);
|
CopyFile(PWideChar(OldPath+'In_Wh.dat'),PWideChar(NewPath+'In_Wh.dat'),False);
|
CopyFile(PWideChar(OldPath+'UseCase.ini'),PWideChar(NewPath+'UseCase.ini'),False);
|
|
if FileExists(OldPath+'CaseDocNo.dat') then
|
begin
|
DocNoList.LoadFromFile(OldPath+'CaseDocNo.dat');
|
end
|
else
|
begin
|
DocNoList.SaveToFile(OldPath+'CaseDocNo.dat');
|
CopyFile(PWideChar(OldPath+'CaseDocNo.dat'),PWideChar(NewPath+'CaseDocNo.dat'),False);
|
end;
|
|
for i := 0 to DocNoList.Count-1 do
|
begin
|
DocDir := DocNoList.Strings[i];
|
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
|
|
FileList.Clear;
|
if FileExists(OldPath+'Context.dat') then
|
begin
|
FileList.LoadFromFile(OldPath+'Context.dat');
|
for n := 0 to FileList.Count - 1 do
|
begin
|
OldFile := FileList.Strings[n];
|
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
|
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
|
iFileList.Add(NewFile);
|
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
|
iDocDirList.Add(DocDir);
|
end;
|
end;
|
end;
|
if DirectoryExists(ImageSavePath+CaseID+'\Attach') then
|
begin
|
DocDir := 'Attach';
|
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
|
|
FileList.Clear;
|
if FileExists(OldPath+'Context.dat') then
|
begin
|
FileList.LoadFromFile(OldPath+'Context.dat');
|
for n := 0 to FileList.Count - 1 do
|
begin
|
OldFile := FileList.Strings[n];
|
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
|
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
|
iFileList.Add(NewFile);
|
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
|
iDocDirList.Add(DocDir);
|
end;
|
end;
|
end;
|
|
if DirectoryExists(ImageSavePath+CaseID+'\S_Attach') then
|
begin
|
DocDir := 'S_Attach';
|
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
|
|
FileList.Clear;
|
if FileExists(OldPath+'Context.dat') then
|
begin
|
FileList.LoadFromFile(OldPath+'Context.dat');
|
for n := 0 to FileList.Count - 1 do
|
begin
|
OldFile := FileList.Strings[n];
|
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
|
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
|
iFileList.Add(NewFile);
|
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
|
iDocDirList.Add(DocDir);
|
end;
|
end;
|
end;
|
OldPath := ImageSavePath+CaseID+'\';
|
if FileExists(OldPath+'AttContext.dat') then
|
begin
|
iAttFileList.LoadFromFile(OldPath+'AttContext.dat');
|
for n := 0 to iAttFileList.Count - 1 do
|
begin
|
AttFile := iAttFileList.Strings[n];
|
CopyFile(PWideChar(OldPath+AttFile),PWideChar(NewPath+AttFile),False);
|
end;
|
iAttFileList.SaveToFile(NewPath+'AttContext.dat');
|
end;
|
|
|
iFileList.SaveToFile(NewPath+'Context.dat');
|
iFile_DocNoList.SaveToFile(NewPath+'Context_DocNo.dat');
|
iDocDirList.SaveToFile(NewPath+'DocDir.dat');
|
|
finally
|
iFileList.Free;
|
iAttFileList.Free;
|
iFile_DocNoList.Free;
|
DocNoList.Free;
|
FileList.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:Download2Case
|
引用相依:FileExists, CopyFile, LoadFromFile, DirectoryExists, SaveToFile
|
方法描述:將下載或匯入的案件結構還原回本系統的多層級目錄結構。包含建立文件子目
|
錄、檔案複製並重新編號、以及重建各類索引與份數設定檔。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.Download2Case(SoDir,DeDir:String);
|
var
|
i,n : Integer;
|
DocDir:String;
|
OldFile,NewFile,AttFile:String;
|
DocNoList,FileList : TStringlist;
|
iFileList,iFile_DocDirList :TStringlist;
|
iAttFileList :TStringlist;
|
AA,AA2,AA3,AA4:Boolean;
|
begin
|
|
if (not FileExists(SoDir+'CaseDocNo.dat')) or (not FileExists(SoDir+'DocDir.dat')) then //截畫面會沒這些檔
|
begin
|
//ShowMessage('產生必要的文字檔');
|
CreateCaseNeedData(SoDir); //產生必要的文字檔
|
end;
|
|
AA:=CopyFile(PWideChar(SoDir+'CaseDocNo.dat'),PWideChar(DeDir+'CaseDocNo.dat'),False);
|
AA2:=CopyFile(PWideChar(SoDir+'CaseDocNo_Copies.dat'),PWideChar(DeDir+'CaseDocNo_Copies.dat'),False);
|
AA3:=CopyFile(PWideChar(SoDir+'CustomDocNo.ini'),PWideChar(DeDir+'CustomDocNo.ini'),False);
|
AA4:=CopyFile(PWideChar(SoDir+'UseCase.ini'),PWideChar(DeDir+'UseCase.ini'),False);
|
//ShowMessage(BoolToStr(AA)+#10#13+BoolToStr(AA2)+#10#13+BoolToStr(AA3)+#10#13+BoolToStr(AA4));
|
if FileExists(SoDir+'DocDir.dat') then //20170222 新加
|
begin
|
CopyFile(PWideChar(SoDir+'DocDir.dat'),PWideChar(DeDir+'DocDir.dat'),False);
|
end;
|
|
|
DocNoList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
iFileList := TStringlist.Create;
|
iFile_DocDirList := TStringlist.Create;
|
iAttFileList := TStringlist.Create;
|
try
|
//if Not FileExists(SoDir+'Context.dat') then Exit;
|
//iFileList.LoadFromFile(SoDir+'Context.dat');
|
//if iFileList.Count = 0 then Exit;
|
if FileExists(SoDir+'Context.dat') then
|
iFileList.LoadFromFile(SoDir+'Context.dat');
|
if FileExists(SoDir+'DocDir.dat') then
|
iFile_DocDirList.LoadFromFile(SoDir+'DocDir.dat');
|
if iFileList.Count <> iFile_DocDirList.Count then
|
begin
|
for i := 0 to iFileList.Count - 1 do
|
begin
|
if i > iFile_DocDirList.Count -1 then
|
begin
|
iFile_DocDirList.Add(FormCode2DocNo(FileName2FormCode(iFileList.Strings[i])));
|
end;
|
end;
|
end;
|
if FileExists(SoDir+'CaseDocNo.dat') then
|
DocNoList.LoadFromFile(SoDir+'CaseDocNo.dat');
|
if FileExists(DeDir+'CaseDocNo_Copies.dat') then
|
CaseDocNo_CopiesList.LoadFromFile(DeDir+'CaseDocNo_Copies.dat');
|
{for i := 0 to DocNoList.Count - 1 do
|
begin
|
DocDir := DocNoList.Strings[i];
|
MkDir(DeDir+DocDir);
|
end;}
|
//ShowMessage('DocNoList='+DocNoList.Text);
|
|
for i := DocNoList.Count - 1 downto 0 do
|
begin
|
DocDir := DocNoList.Strings[i];
|
if not DirectoryExists(DeDir+DocDir) then
|
begin
|
MkDir(DeDir+DocDir);
|
if not FileExists(DeDir+DocDir+'\Context.dat') then
|
StringtoFile('',DeDir+DocDir+'\Context.dat');
|
end
|
else
|
begin
|
//ShowMessage('GGG');
|
DocNoList.Delete(i);
|
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
|
if i <= CaseDocNo_CopiesList.Count-1 then
|
begin
|
//ShowMessage('KKKK');
|
CaseDocNo_CopiesList.Delete(i);
|
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
|
end;
|
end;
|
end;
|
//20170221 先註解起來 因為他在補充掃瞄時好像會有顯示的問題
|
|
for i := 0 to iFileList.Count - 1 do
|
begin
|
OldFile := iFileList.Strings[i];
|
DocDir := iFile_DocDirList.Strings[i];
|
if (DocDir = 'Attach') or (DocDir = 'S_Attach') then
|
begin
|
if not DirectoryExists(DeDir+DocDir) then
|
MkDir(DeDir+DocDir);
|
end;
|
|
FileList.Clear;
|
if FileExists(DeDir+DocDir+'\Context.dat') then
|
begin
|
FileList.LoadFromFile(DeDir+DocDir+'\Context.dat');
|
end;
|
NewFile := Add_Zoo(FileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
|
CopyFile(PWideChar(SoDir+OldFile),PWideChar(DeDir+DocDir+'\'+NewFile),False);
|
FileList.Add(NewFile);
|
FileList.SaveToFile(DeDir+DocDir+'\Context.dat');
|
end;
|
|
for i := DocNoList.Count -1 downto 0 do
|
begin
|
if (DocNoList.Strings[i] = 'Attach') or (DocNoList.Strings[i] = 'S_Attach') then
|
begin
|
DocNoList.Delete(i);
|
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
|
end;
|
end;
|
|
{if (DocNoList.Count > 0) and ((DocNoList.Strings[DocNoList.Count-1] = 'Attach') or (DocNoList.Strings[DocNoList.Count-1] = 'S_Attach')) then
|
begin
|
DocNoList.Delete(DocNoList.Count-1);
|
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
|
end; }
|
CaseDocNo_CopiesList.Clear;
|
|
if FileExists(DeDir+'CaseDocNo_Copies.dat') then
|
CaseDocNo_CopiesList.LoadFromFile(DeDir+'CaseDocNo_Copies.dat');
|
if DocNoList.Count > CaseDocNo_CopiesList.Count then
|
begin
|
for i := 0 to DocNoList.Count - 1 do
|
begin
|
if i > CaseDocNo_CopiesList.Count-1 then
|
begin
|
CaseDocNo_CopiesList.Add('1');
|
//CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
|
end;
|
end;
|
end;
|
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
|
{if (not FileExists(DeDir+'CaseDocNo_Copies.dat') then
|
begin
|
CaseDocNo_CopiesList.Free;
|
for i := 0 to DocNoList.Count - 1 do
|
begin
|
CaseDocNo_CopiesList.Add('1');
|
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
|
end;
|
end;}
|
if FileExists(SoDir+'AttContext.dat') then
|
begin
|
iAttFileList.LoadFromFile(SoDir+'AttContext.dat');
|
for i := 0 to iAttFileList.Count - 1 do
|
begin
|
AttFile := iAttFileList.Strings[i];
|
CopyFile(PWideChar(SoDir+AttFile),PWideChar(DeDir+AttFile),False);
|
end;
|
iAttFileList.SaveToFile(DeDir+'AttContext.dat');
|
end;
|
|
|
if FMode='ESCAN' then
|
begin
|
InitExistImgList(DeDir);
|
end;
|
|
|
finally
|
iFileList.Free;
|
FileList.Free;
|
DocNoList.Free;
|
iFile_DocDirList.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:GetCaseFormID
|
引用相依:LoadFromFile
|
方法描述:從案件目錄的 Context.dat 檔案中搜尋並回傳該案件的主表單代碼(FormID)。
|
程序會遍歷影像清單,提取各檔案的表單代碼,並排除特定的分案頁代碼,直到
|
找到符合條件的主表單代碼為止。
|
============================================================================== }
|
Function TCB_IMGPSScanX.GetCaseFormID(Path:String):String; //取案件的主FormID
|
var i,n : Integer;
|
FileFormID : String;
|
begin
|
Result := '';
|
ContextList.LoadFromFile(Path+'Context.dat');
|
for I := 0 to ContextList.Count - 1 do
|
begin
|
FileFormID := FileName2FormCode(ContextList.Strings[i]);
|
|
if DivPageFormIDList.IndexOf(FileFormID)<>-1 then //20170509 跳過分案頁的formid
|
begin
|
Continue;
|
end;
|
if FindDivFormCode(FileFormID) then
|
begin
|
Result := FileFormID;
|
Break;
|
end;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateFormID_FormName
|
引用相依:SaveToFile
|
方法描述:遍歷 ContextList,提取每個檔案的表單代號與名稱並格式化為「代號_名稱」,
|
最後存成 FormCode_Name.dat 供上傳使用。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.CreateFormID_FormName(Path,CaseID:String); //產生FormID_FormName.dat
|
var i : Integer;
|
S : TStringlist;
|
FormID : String;
|
FormName : String;
|
begin
|
S := TStringlist.Create;
|
try
|
for I := 0 to ContextList.Count - 1 do
|
begin
|
FormID := FileName2FormCode(ContextList.Strings[i]);
|
FormName := FormCode2FormName(CaseID,FormID);
|
S.Add(FormID+'_'+FormName);
|
end;
|
S.SaveToFile(Path + 'FormCode_Name.dat',TEnCoding.UTF8);
|
finally
|
S.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateDocNo_DocName
|
引用相依:SaveToFile
|
方法描述:產生包含文件代號與名稱的對應檔 DocNo_Name.dat。首先執行案件內文件去重
|
,接著遍歷 CaseDocNoList 取得對應名稱,針對不需分組的文件會在名稱前加
|
上星號標記,最後將結果以 UTF-8 編碼儲存。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.CreateDocNo_DocName(Path,CaseID:String); //產生DocNo_DocName.dat
|
var
|
i : Integer;
|
S : TStringlist;
|
Doc_Name : String;
|
begin
|
S := TStringlist.Create;
|
try
|
DistinctDocNoinCase(Path);
|
for i := 0 to CaseDocNoList.Count - 1 do
|
begin
|
Doc_Name := CaseDocNoList.Strings[i]+'_'+DocNo2DocName(CaseID,CaseDocNoList.Strings[i]);
|
if not DocnoNeedGroup(CaseDocNoList.Strings[i]) Then //不用分組的加*號給智豪
|
Doc_Name := '*'+Doc_Name;
|
S.Add(Doc_Name);
|
end;
|
S.SaveToFile(Path+'DocNo_Name.dat',TEnCoding.UTF8);
|
finally
|
S.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateIn_WH
|
引用相依:FileExists, LoadFromFile, SaveToFile
|
方法描述:產生在席文件清單檔 In_Wh.dat。讀取案件的文件目錄清單後,比對全域的在席
|
文件清單(IN_WH_DocNoList),若文件代號匹配或屬於特定系統目錄(ZZZZZ),則
|
將其加入清單並儲存,用於標記需留存實體的文件。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.CreateIn_WH(CaseID:String); //產生In_WH.dat
|
var
|
i,n : Integer;
|
DocDirList,In_WH_List : TStringlist;
|
iDocNo : String;
|
begin
|
DocDirList := TStringlist.Create;
|
In_WH_List := TStringlist.Create;
|
try
|
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
|
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
|
for i := 0 to DocDirList.Count - 1 do
|
begin
|
iDocNo := DocNoDir2DocNo(DocDirList.Strings[i]);
|
for n := 0 to IN_WH_DocNoList.Count - 1 do
|
begin
|
if (iDocNo = IN_WH_DocNoList.Strings[n]) or (Copy(iDocNo,1,5)='ZZZZZ') then
|
begin
|
In_WH_List.Add(DocDirList.Strings[i]);
|
Break;
|
end;
|
end;
|
end;
|
In_WH_List.SaveToFile(ImageSavePath+CaseID+'\In_Wh.dat');
|
|
finally
|
DocDirList.Free;
|
In_WH_List.Free;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateDocNo_Info
|
引用相依:FileExists, LoadFromFile
|
方法描述:產生案件內標準文件(非自訂)的彙總資訊字串。方法讀取 CaseDocNo.dat,針對
|
每個非 'ZZZZZ' 開頭的文件編號,計算其在案件中的總份數、累計總頁數,並檢
|
查編輯狀態(異動旗標)。結果以「編號[Tab]份數[Tab]頁數[Tab]狀態」的格式逐
|
行組成,作為案件上傳時與伺服器比對資料完整性的核心依據。
|
============================================================================== }
|
Function TCB_IMGPSScanX.CreateDocNo_Info(CaseID:String):String; //產生 DocNo[tab]份數[tab]總頁數[tab]是否異動[換行]DocNo[tab]份數[tab]總頁數[tab]是否異動
|
var
|
i,n : Integer;
|
DocDirList,DocDir_CopiesList,FileList,C_DocNoList : TStringlist;
|
DocNo,iDocDir,iDocNo,iEdit:String;
|
icopys,ipages : integer;
|
S,S1 : TStringlist;
|
Str : String;
|
begin
|
DocDirList := TStringlist.Create;
|
DocDir_CopiesList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
C_DocNoList := TStringlist.Create;
|
try
|
Str := '';
|
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
|
|
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
|
|
if DocDirList.Count =0 then exit;//20170222 新加
|
|
|
DocDir_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
|
while DocDirList.Count > 0 do
|
begin
|
iDocDir := DocDirList.Strings[0];
|
DocNo := DocNoDir2DocNo(iDocDir);
|
if Copy(iDocDir,1,5) <> 'ZZZZZ' then //不為自定文件
|
begin
|
//icopys := 1;
|
icopys := GetDocNoCount(CaseID,DocNo);
|
ipages := GetDocDir_Page(CaseID,iDocDir);
|
iEdit := GetDocNoEdit(CaseID,DocNo,'');
|
for i := DocDirList.Count - 1 downto 1 do
|
begin
|
iDocDir := DocDirList.Strings[i];
|
iDocNo := DocNoDir2DocNo(iDocDir);
|
if iDocNo = DocNo then
|
begin
|
//inc(icopys);
|
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
|
DocDirList.Delete(i);
|
end;
|
end;
|
if str = '' then
|
Str := Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocNo,iCopys,iPages,iEdit])
|
else
|
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocNo,iCopys,iPages,iEdit]);
|
end;
|
DocDirList.Delete(0);
|
end;
|
|
|
finally
|
DocDirList.Free;
|
DocDir_CopiesList.Free;
|
FileList.Free;
|
C_DocNoList.Free;
|
end;
|
Result := Str;
|
|
{S := TStringlist.Create;
|
S1 := TStringlist.Create;
|
try
|
S.LoadFromFile(Path+'Context.dat');
|
S1.LoadFromFile(Path+'Context_DocNo.dat');
|
for i := 0 to CaseDocNoList.Count - 1 do
|
begin
|
iDocNo := CaseDocNoList.Strings[i];
|
iCopys := GetDocNo_Count(Path,iDocNo);
|
iPages := GetDocNo_Page(Path,iDocNo);
|
if str = '' then
|
Str := Format('%s,%d,%d',[iDocNo,iCopys,iPages])
|
else
|
Str := Str+';'+ Format('%s,%d,%d',[iDocNo,iCopys,iPages]);
|
end;
|
Result := Str;
|
|
finally
|
S.Free;
|
S1.Free;
|
end; }
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateCustDocNo_Info
|
引用相依:FileExists, LoadFromFile
|
方法描述:產生案件內自訂文件的彙總資訊字串。方法專門處理代碼開頭為 'ZZZZZ' 的文
|
件目錄,透過 GetCustomDocName 取得使用者定義的文件名稱,並彙整其總份數
|
、總頁數與編輯異動狀態。最終格式與標準文件一致,但首位欄位改為顯示自訂
|
名稱,確保自訂類別的文件也能正確被伺服器識別與儲存。
|
============================================================================== }
|
Function TCB_IMGPSScanX.CreateCustDocNo_Info(CaseID:String):String; //產生自訂文件 DocName[tab]份數[tab]總頁數[tab]是否異動[#13#10]DocName[tab]份數[tab]總頁數[tab]是否異動
|
var
|
i,n : Integer;
|
DocDirList,FileList : TStringlist;
|
DocNo,DocName,iDocDir,iDocNo,iEdit:String;
|
icopys,ipages : integer;
|
S,S1 : TStringlist;
|
Str : String;
|
begin
|
DocDirList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
try
|
Str := '';
|
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
|
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
|
//ShowMessage(DocDirList.Text);
|
while DocDirList.Count > 0 do
|
begin
|
iDocDir := DocDirList.Strings[0];
|
DocNo := DocNoDir2DocNo(iDocDir);
|
if Copy(iDocDir,1,5) = 'ZZZZZ' then //是自定文件
|
begin
|
//icopys := 1;
|
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
|
icopys := GetDocNoCount(CaseID,DocNo);
|
ipages := GetDocDir_Page(CaseID,iDocDir);
|
iEdit := GetDocNoEdit(CaseID,DocNo,DocName);
|
for i := DocDirList.Count - 1 downto 1 do
|
begin
|
iDocDir := DocDirList.Strings[i];
|
iDocNo := DocNoDir2DocNo(iDocDir);
|
if iDocNo = DocNo then
|
begin
|
//inc(icopys);
|
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
|
DocDirList.Delete(i);
|
end;
|
end;
|
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
|
if str = '' then
|
Str := Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocName,iCopys,iPages,iEdit])
|
else
|
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocName,iCopys,iPages,iEdit]);
|
end;
|
DocDirList.Delete(0);
|
end;
|
finally
|
DocDirList.Free;
|
FileList.Free;
|
end;
|
Result := Str;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateDocnoFrom_Info
|
引用相依:FileExists, LoadFromFile
|
方法描述:產生被引進的保管袋文件詳細資訊字串。程序遍歷案件的文件目錄,排除自定義
|
文件後,取得各文件的份數、總頁數、異動狀態及來源案件編號(UseCase)。若同
|
一文件來自多個目錄,則會累加數據,最後產出以 Tab 分隔的文件資訊清單。
|
============================================================================== }
|
Function TCB_IMGPSScanX.CreateDocnoFrom_Info(CaseID:String):String; //產生被引進的保管袋文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
|
var
|
i,n : Integer;
|
DocDirList,DocDir_CopiesList,FileList : TStringlist;
|
DocNo,iDocDir,iDocNo,iEdit:String;
|
FromCaseID : string;
|
icopys,ipages : integer;
|
S,S1 : TStringlist;
|
Str : String;
|
begin
|
DocDirList := TStringlist.Create;
|
DocDir_CopiesList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
try
|
Str := '';
|
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
|
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
|
|
if DocDirList.Count=0 then exit;//20170222 新加
|
|
|
DocDir_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
|
while DocDirList.Count > 0 do
|
begin
|
iDocDir := DocDirList.Strings[0];
|
DocNo := DocNoDir2DocNo(iDocDir);
|
if (Copy(iDocDir,1,5) <> 'ZZZZZ') then //不為自定文件
|
begin
|
//icopys := 1;
|
//icopys := GetDocNoCount(CaseID,DocNo);
|
icopys := GetDocDirCopies(CaseID,iDocDir);
|
ipages := GetDocDir_Page(CaseID,iDocDir);
|
iEdit := GetDocNoEdit(CaseID,DocNo,'');
|
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
|
if FromCaseID <> '' then
|
begin
|
for i := DocDirList.Count - 1 downto 1 do
|
begin
|
iDocDir := DocDirList.Strings[i];
|
iDocNo := DocNoDir2DocNo(iDocDir);
|
if (iDocNo = DocNo) and (GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir)<>'') then
|
begin
|
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
|
//inc(icopys);
|
icopys := icopys + GetDocDirCopies(CaseID,iDocDir);
|
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
|
DocDirList.Delete(i);
|
end;
|
end;
|
if str = '' then
|
Str := Format('%s'+#9+'%d'+#9+'%s',[DocNo,iCopys,FromCaseID])
|
else
|
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%s',[DocNo,iCopys,FromCaseID]);
|
end;
|
end;
|
DocDirList.Delete(0);
|
end;
|
finally
|
DocDirList.Free;
|
DocDir_CopiesList.Free;
|
FileList.Free;
|
end;
|
Result := Str;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateCustDocNoFrom_Info
|
引用相依:FileExists, LoadFromFile
|
方法描述:產出自定義文件的引進資訊字串。專門處理前綴為 "ZZZZZ" 的目錄,提取自定
|
義文件名稱、份數及來源案件。與保管袋文件類似,會執行重複合併並統計總頁
|
數,最後產出格式化的資訊字串。
|
============================================================================== }
|
Function TCB_IMGPSScanX.CreateCustDocNoFrom_Info(CaseID:String):String; //產生被引進的自定文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
|
var
|
i,n : Integer;
|
DocDirList,FileList : TStringlist;
|
DocNo,DocName,iDocDir,iDocNo,iEdit:String;
|
FromCaseID : string;
|
icopys,ipages : integer;
|
S,S1 : TStringlist;
|
Str : String;
|
begin
|
DocDirList := TStringlist.Create;
|
FileList := TStringlist.Create;
|
try
|
Str := '';
|
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
|
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
|
while DocDirList.Count > 0 do
|
begin
|
iDocDir := DocDirList.Strings[0];
|
DocNo := DocNoDir2DocNo(iDocDir);
|
if Copy(iDocDir,1,5) = 'ZZZZZ' then //是自定文件
|
begin
|
//icopys := 1;
|
//icopys := GetDocNoCount(CaseID,DocNo);
|
icopys := GetDocDirCopies(CaseID,iDocDir);
|
ipages := GetDocDir_Page(CaseID,iDocDir);
|
iEdit := GetDocNoEdit(CaseID,DocNo,DocName);
|
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
|
if FromCaseID <> '' then
|
begin
|
for i := DocDirList.Count - 1 downto 1 do
|
begin
|
iDocDir := DocDirList.Strings[i];
|
iDocNo := DocNoDir2DocNo(iDocDir);
|
if (iDocNo = DocNo) and (GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir)<>'') then
|
begin
|
FromCaseID := GetUseCase('F',DisplayPath,iDocDir);
|
//inc(icopys);
|
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
|
DocDirList.Delete(i);
|
end;
|
end;
|
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
|
if str = '' then
|
Str := Format('%s'+#9+'%d'+#9+'%s',[DocName,iCopys,FromCaseID])
|
else
|
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%s',[DocName,iCopys,FromCaseID]);
|
end;
|
end;
|
DocDirList.Delete(0);
|
end;
|
finally
|
DocDirList.Free;
|
FileList.Free;
|
end;
|
Result := Str;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:CreateAttach_Info
|
引用相依:
|
方法描述:判斷案件是否存在附加電子檔。透過檢查附加檔案目錄的總頁數是否大於 0,回
|
傳 "Y" 或 "N"。
|
============================================================================== }
|
Function TCB_IMGPSScanX.CreateAttach_Info(CaseID:String):String; //產生是否有Attach Y:有 N:沒有
|
begin
|
Result := 'N';
|
if GetDocDir_Page(CaseID,AttName) > 0 Then
|
Result := 'Y';
|
end;
|