From 522785c8bc1c1c60009ab2847f2408ab34b35246 Mon Sep 17 00:00:00 2001
From: doom4ster <doom4ster@gmail.com>
Date: 星期二, 12 九月 2017 15:46:51 +0800
Subject: [PATCH] CB_IMGPSScan.cab ver2.0.1.39  修正補掃 下非入庫 不分組 刪除問題

---
 CB_IMGPSScanImp.dcu |    0 
 CB_IMGPSScan.ocx    |    0 
 CB_IMGPSScan.dproj  |    4 +-
 CB_IMGPSScan.res    |    0 
 CB_IMGPSScanImp.pas |   97 ++++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 87 insertions(+), 14 deletions(-)

diff --git a/CB_IMGPSScan.dproj b/CB_IMGPSScan.dproj
index 3cfee56..7621c70 100644
--- a/CB_IMGPSScan.dproj
+++ b/CB_IMGPSScan.dproj
@@ -95,7 +95,7 @@
 						<VersionInfo Name="MajorVer">2</VersionInfo>
 						<VersionInfo Name="MinorVer">0</VersionInfo>
 						<VersionInfo Name="Release">1</VersionInfo>
-						<VersionInfo Name="Build">38</VersionInfo>
+						<VersionInfo Name="Build">39</VersionInfo>
 						<VersionInfo Name="Debug">False</VersionInfo>
 						<VersionInfo Name="PreRelease">False</VersionInfo>
 						<VersionInfo Name="Special">False</VersionInfo>
@@ -107,7 +107,7 @@
 					<VersionInfoKeys>
 						<VersionInfoKeys Name="CompanyName"/>
 						<VersionInfoKeys Name="FileDescription"/>
-						<VersionInfoKeys Name="FileVersion">2.0.1.38</VersionInfoKeys>
+						<VersionInfoKeys Name="FileVersion">2.0.1.39</VersionInfoKeys>
 						<VersionInfoKeys Name="InternalName"/>
 						<VersionInfoKeys Name="LegalCopyright"/>
 						<VersionInfoKeys Name="LegalTrademarks"/>
diff --git a/CB_IMGPSScan.ocx b/CB_IMGPSScan.ocx
index c0c67fc..83c4516 100644
--- a/CB_IMGPSScan.ocx
+++ b/CB_IMGPSScan.ocx
Binary files differ
diff --git a/CB_IMGPSScan.res b/CB_IMGPSScan.res
index 52cbdec..18364b8 100644
--- a/CB_IMGPSScan.res
+++ b/CB_IMGPSScan.res
Binary files differ
diff --git a/CB_IMGPSScanImp.dcu b/CB_IMGPSScanImp.dcu
index 665f5b5..015ca7e 100644
--- a/CB_IMGPSScanImp.dcu
+++ b/CB_IMGPSScanImp.dcu
Binary files differ
diff --git a/CB_IMGPSScanImp.pas b/CB_IMGPSScanImp.pas
index 8f64685..6ba47b2 100644
--- a/CB_IMGPSScanImp.pas
+++ b/CB_IMGPSScanImp.pas
@@ -840,7 +840,8 @@
     function ISExistImg(const filename:string):boolean;  //20170809 確認是否存在原有影像
     procedure _DelTreeForExistImg(ASourceDir:String);   //2017 刪除前確認 有舊影像嗎
     function DocNoIsExistImg(DocNopath: String): boolean; //2017 刪除前確認 有舊影像嗎
-    function CheckCaseAttach_OK: Boolean;     //2017 確認是否有未歸類文件
+    function CheckCaseAttach_OK: Boolean;
+    function DeleteDocNoFileForESCAN(Path, DocNo: String): Boolean;     //2017 確認是否有未歸類文件
   protected
     { Protected declarations }
     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
@@ -2489,8 +2490,16 @@
     If Messagedlg(Format(_Msg('文件(%s)是否刪除?'),[DocNo2DocName(NowCaseno,NowDocNo)]),mtconfirmation,[mbyes,mbcancel],0) = mrcancel then Exit;
     ClearView(1);
     Application.ProcessMessages;
-
-    _DelTree(ImageSavePath+NowCaseno+'\'+NowDocDir);
+//ShowMessage(NowDocDir);
+    if (Length(NowDocDir)=8) or (NowDocDir=AttName) then
+    begin
+//ShowMessage('DeleteDocNoFileForESCAN');
+      DeleteDocNoFileForESCAN(ImageSavePath+NowCaseno+'\'+NowDocDir,NowDocDir);
+    end
+    else
+    begin
+      _DelTree(ImageSavePath+NowCaseno+'\'+NowDocDir);
+    end;
     SetUseCase('D',ImageSavePath+NowCaseno+'\',NowDocDir,'','');
     SetDocNoList('D',-1,NowCaseNo,NowDocDir,'');
     if (Copy(NowDocNo,1,5)='ZZZZZ') then   //20140703 刪除自定文件時要刪ini檔資料
@@ -2505,7 +2514,6 @@
   Else if TreeView1.Selected = MyTreeNode3 then       //FormID層
   begin
     If Messagedlg(Format(_Msg('文件(%s)是否刪除?'),[NowFormName]),mtconfirmation,[mbyes,mbcancel],0) = mrcancel then Exit;
-
 
     DeleteFormCodeFile(NowCaseNo,NowDocDir,NowFormCode);
     SetRecordEditedDocDir('A',NowCaseNo,NowDocDir);
@@ -2804,8 +2812,10 @@
       begin
         DrawDocItem2(MytreeNode1,CaseID); //長出文件名稱的樹並傳回是否有申請書的影像
         page := GetCasePage(ImageSavePath,CaseID);
+//ShowMessage('page='+IntToStr(page));
         MytreeNode1.Text := Format(_Msg('%s-%d頁'),[CaseID,page]);
       end;
+//ShowMessage('AAAA');
       NewTreeNodeRefresh;
       Application.ProcessMessages;
       DataLoading(False,False);
@@ -3304,6 +3314,9 @@
     begin
       PM101.Visible:=false;
     end;
+
+    if FMode='ESCAN' then
+      PM101.Visible:=false;
 
     if FModeName='異動件' then
     begin
@@ -5512,10 +5525,11 @@
         begin
           if ISExistImg(ImageSavePath+CaseID+'\'+DocDir+'\'+FileList.Strings[i]) then
           begin
-            ShowMessage('有圖為非當次掃瞄,不可刪除');
-            Exit;
+            //ShowMessage('有圖為非當次掃瞄,不可刪除');
+            Break;
           end;
         end;
+//ShowMessage(FileList.Strings[i]);
         DeleteImageFile(ImageSavePath+CaseID+'\'+DocDir+'\',FileList.Strings[i],CaseID);
       end;
     end;
@@ -5571,6 +5585,34 @@
   Context_DocnoList.LoadFromFile(Path+'Context_DocNo.dat');
   if FileExists(Path+'CustomDocNo.dat') then
     Cust_DocNoList.LoadFromFile(Path+'CustomDocNo.dat');
+end;
+
+Function TCB_IMGPSScanX.DeleteDocNoFileForESCAN(Path,DocNo:String):Boolean;  //刪除指定DocNo文件
+var
+  i,j,k: Integer;
+  FName : String;
+  ST1,ST2,ST3:TStringList;
+
+begin
+ 
+  Result := False;
+
+  for i := ContextList.Count - 1 downto 0 do
+  begin
+    FName := ContextList.Strings[i];
+    If DocNo = FormCode2DocNo(FileName2FormCode(FName)) 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');
+
 end;
 
 Procedure TCB_IMGPSScanX.DeleteShowFile(Path:String); //刪除顯示中的影像
@@ -6708,7 +6750,8 @@
             if Index <> -1 then
             begin
               //SetRecordEditedDocDir('D',CaseNo,CaseDocNoList.Strings[Index]);  //20140624 修改刪除文件時也記一筆異動,刪掉會無法通知前端網頁有異動
-              SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[Index]);
+              SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[Index]);  //20170912 要刪除  不然我寫不下去
+
               CaseDocNoList.Delete(Index);
               CaseDocNo_CopiesList.Delete(Index);
 
@@ -6720,7 +6763,7 @@
                 if DocDir = CaseDocNoList.Strings[i] then
                 begin
                   //SetRecordEditedDocDir('D',CaseNo,CaseDocNoList.Strings[i]);  //20140624 修改刪除文件時也記一筆異動,刪掉會無法通知前端網頁有異動
-                  SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[i]);
+                  SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[i]);  //20170912 要刪除  不然我寫不下去
                   CaseDocNoList.Delete(i);
                   CaseDocNo_CopiesList.Delete(i);
                   Break;
@@ -7207,8 +7250,8 @@
 
 Function TCB_IMGPSScanX.GetCase_PageCount(var CaseCount,PageCount:Integer):Boolean; //取出案件的數量及頁數
 var
-  i,n: Integer;
-  CaseList,DocList,FileList : TStringlist;
+  i,n,k: Integer;
+  CaseList,DocList,FileList,ST1 : TStringlist;
 begin
   Result := False;
   CaseCount := 0;
@@ -7216,19 +7259,23 @@
   CaseList := TStringlist.Create;
   DocList := TStringlist.Create;
   FileList := TStringlist.Create;
+  ST1:= TStringlist.Create;
   try
     ImageSavePath := ImagePath;
     CaseList.Clear;
     if FileExists(ImageSavePath + 'CaseList.dat') then
       CaseList.LoadFromFile(ImageSavePath + 'CaseList.dat');
     CaseCount :=  CaseCount+CaseList.Count;
+//ShowMessage('ImageSavePath='+ImageSavePath+#10#13+'CaseList.Count='+IntToStr(CaseList.Count));
     for i := 0 to CaseList.Count - 1 do
     begin
       DocList.Clear;
       If FileExists(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat') Then
         DocList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat');
+//ShowMessage('DocList='+DocList.Text);
       for n := 0 to DocList.Count - 1 do
       begin
+//ShowMessage(DocList.Strings[n]+','+BoolToStr(DocNoAppear(DocNoDir2DocNo(DocList.Strings[n])),true));
         if not DocNoAppear(DocNoDir2DocNo(DocList.Strings[n])) then Continue;
         FileList.Clear;
         If FileExists(ImageSavePath+CaseList.Strings[i]+'\'+DocList.Strings[n]+'\Context.dat') Then
@@ -7240,14 +7287,40 @@
       If FileExists(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat') Then
           FileList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat');
       //Showmessage(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat');
-      //Showmessage(FileList.Text);
+//Showmessage('FileList='+FileList.Text);
       PageCount := PageCount+FileList.Count;
-      //Showmessage(inttostr(PageCount));
+//Showmessage('PageCount='+inttostr(PageCount));
+      if (FWH_category='N') and (FIs_In_Wh='Y') then  //20170912 針對非入庫並當次掃描做頁數計算
+      begin
+        if FileExists(ImageSavePath+NowCaseno+'\EditedDocDir.dat') then
+        begin
+          ST1.LoadFromFile(ImageSavePath+NowCaseno+'\EditedDocDir.dat');
+          for n := 0 to ST1.Count - 1 do
+          begin
+//ShowMessage(ST1.Strings[n]+','+BoolToStr(DocNoIs_In_WH(DocNoDir2DocNo(ST1.Strings[n])),true));
+            if not DocNoIs_In_WH(DocNoDir2DocNo(ST1.Strings[n])) then
+            begin
+
+              FileList.Clear;
+              if FileExists(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\Context.dat') then
+              begin
+                FileList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\Context.dat');
+                for k := 0 to FileList.Count - 1 do
+                begin
+                  if not ISExistImg(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\'+FileList.Strings[k]) then
+                    PageCount := PageCount+1;
+                end;
+              end;
+            end;
+          end;
+        end;
+      end;
     end;
   Finally
   CaseList.Free;
   DocList.Free;
   FileList.Free;
+  ST1.Free
   end;
   Result := True;
 end;

--
Gitblit v1.8.0