From b012fccf647c4d253174e5dfcdea4d15335c3436 Mon Sep 17 00:00:00 2001
From: doom4ster <doom4ster@gmail.com>
Date: 星期三, 19 九月 2018 16:24:23 +0800
Subject: [PATCH] 66板

---
 CB_IMGPSScanImp.dcu |    0 
 ErrList.dcu         |    0 
 CB_IMGPSScan.ocx    |    0 
 ErrList.pas         |   13 +++
 CB_IMGPSScan.dproj  |    4 
 CB_IMGPSScan.res    |    0 
 CB_IMGPSScanImp.pas |  135 +++++++++++++++++++++++++++++++++++++++++---
 ErrList.dfm         |    4 +
 8 files changed, 142 insertions(+), 14 deletions(-)

diff --git a/CB_IMGPSScan.dproj b/CB_IMGPSScan.dproj
index 8d3855d..57200b6 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">65</VersionInfo>
+						<VersionInfo Name="Build">66</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.65</VersionInfoKeys>
+						<VersionInfoKeys Name="FileVersion">2.0.1.66</VersionInfoKeys>
 						<VersionInfoKeys Name="InternalName"/>
 						<VersionInfoKeys Name="LegalCopyright"/>
 						<VersionInfoKeys Name="LegalTrademarks"/>
diff --git a/CB_IMGPSScan.ocx b/CB_IMGPSScan.ocx
index feb454d..cbe22c1 100644
--- a/CB_IMGPSScan.ocx
+++ b/CB_IMGPSScan.ocx
Binary files differ
diff --git a/CB_IMGPSScan.res b/CB_IMGPSScan.res
index 9e5878a..158a503 100644
--- a/CB_IMGPSScan.res
+++ b/CB_IMGPSScan.res
Binary files differ
diff --git a/CB_IMGPSScanImp.dcu b/CB_IMGPSScanImp.dcu
index 7041623..e5e4e90 100644
--- a/CB_IMGPSScanImp.dcu
+++ b/CB_IMGPSScanImp.dcu
Binary files differ
diff --git a/CB_IMGPSScanImp.pas b/CB_IMGPSScanImp.pas
index 49bb35a..ca8c548 100644
--- a/CB_IMGPSScanImp.pas
+++ b/CB_IMGPSScanImp.pas
@@ -853,6 +853,8 @@
     function CheckRequiredColumnValues(workno,caseno:String) :Boolean;  //20171003  此大類下此案是否檢核必填
     function logTimeString :String;
     procedure ReduceLogFile ;
+    function FindLastestDocDirForPage(CaseID, DocNo, formid: String): String;
+    function OMRErrini2ListForLog(CaseID: String):String;
   protected
     { Protected declarations }
     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
@@ -2029,6 +2031,7 @@
   if TreeView1.Selected.Parent = MyTreeNode1 then
     PreNode2Name:= GetNode2Name(MyTreeNode2);
   ShowText := _Msg('文件歸類中,請稍候');
+LogFile1.LogToFile(logTimeString+'縮圖  歸類開始');
   DataLoading(True,True);
   GoAtt := False;
   if (MytreeNode2 <> nil) and (Pos('Attach',MyTreeNode2.Text)>0) then
@@ -2090,6 +2093,7 @@
 
 //ShowMessage('DocNoNeedDiv(DocNo)='+BoolToStr(DocNoNeedDiv(DocNo),true));
 //ShowMessage('DocDir='+DocDir);
+
           if DocNoNeedDiv(DocNo) then   //要分份數
           begin
             if ((FormCode2Page(FormID) = '01') and (GetDocDir_Page(NowCaseno,DocDir)>0)) or (DocDir = '') then
@@ -2126,6 +2130,7 @@
               DocDir:=DocNo2DocNoDir(ImageSavePath+NowCaseno+'\',DocNo);
             SetDocNoList('A',-1,NowCaseno,DocDir);
           end; }
+LogFile1.LogToFile(logTimeString+'縮圖  FormID='+FormID);
           if Not DirectoryExists(ImageSavePath+NowCaseno+'\'+DocDir) then
             Mkdir(ImageSavePath+NowCaseno+'\'+DocDir);
           ContextList.Clear;
@@ -2196,6 +2201,7 @@
   end;
   if CustomDocNo = '' then Exit;
   DocDir := CustomDocNo;
+LogFile1.LogToFile(logTimeString+'縮圖 歸類自訂文件 DocDir='+DocDir);
   SavePath := ImageSavePath+NowCaseNo+'\'+DocDir+'\';
   Str2Dir(SavePath);
   SetDocNoList('A',-1,NowCaseNo,DocDir,'1');
@@ -2287,7 +2293,7 @@
 //          Exit;
 //        end;
 //      end;
-
+LogFile1.LogToFile(logTimeString+'縮圖刪除 iISB.FileName='+iISB.FileName);
       DeleteImageFile(ExtractFilePath(iISB.FileName),ExtractFileName(iISB.FileName),NowCaseNo);
     end;
   end;
@@ -2325,6 +2331,7 @@
     Showmessage(_msg('資訊尚未下載完成,請稍候或重新進入'));
     Exit;
   end;
+LogFile1.LogToFile(logTimeString+'掃瞄開始');
   if (FMode = 'RSCAN') or (FMode = 'ESCAN') or (FMode = 'DSCAN') then
   begin
     if NewTreeNode.Count > 0 then
@@ -2354,6 +2361,7 @@
     ContextList.Clear;
     Try
       StatrTwainScan;
+LogFile1.LogToFile(logTimeString+'掃瞄結束');
     Except
       Panel1.Enabled := True;
       Panel2.Enabled := True;
@@ -2514,9 +2522,10 @@
   P,v,v1,v2,ln,i : Integer;
   iDocDir,iDocNo : String;
 begin
+LogFile1.LogToFile(logTimeString+'Tree 按下刪除');
   if TreeView1.Selected = NewTreeNode then  //全刪  //新掃描件
   begin
-
+LogFile1.LogToFile(logTimeString+'Tree 全部刪除');
     If Messagedlg(_Msg('是否刪除所有案件?'),mtconfirmation,[mbyes,mbcancel],0) = mrcancel then Exit;
     clearView(1);
     Application.ProcessMessages;
@@ -2531,7 +2540,7 @@
   end
   Else if TreeView1.Selected = MyTreeNode1 then       //案件編號
   begin
-
+LogFile1.LogToFile(logTimeString+'Tree 案件編號刪除 NowCaseno='+NowCaseno);
     If Messagedlg(Format(_Msg('編號(%s)是否刪除?'),[NowCaseno]),mtconfirmation,[mbyes,mbcancel],0) = mrcancel then Exit;
     clearView(1);
     Application.ProcessMessages;
@@ -2577,6 +2586,7 @@
     ClearView(1);
     Application.ProcessMessages;
 //ShowMessage(NowDocDir);
+LogFile1.LogToFile(logTimeString+'Tree 文件層號刪除 NowDocDir='+NowDocDir);
     if (Length(NowDocDir)=8) or (NowDocDir=AttName) then
     begin
 //ShowMessage('DeleteDocNoFileForESCAN');
@@ -2601,7 +2611,7 @@
   Else if TreeView1.Selected = MyTreeNode3 then       //FormID層
   begin
     If Messagedlg(Format(_Msg('文件(%s)是否刪除?'),[NowFormName]),mtconfirmation,[mbyes,mbcancel],0) = mrcancel then Exit;
-
+LogFile1.LogToFile(logTimeString+'Tree FormID層號刪除 NowFormCode='+NowFormCode);
     DeleteFormCodeFile(NowCaseNo,NowDocDir,NowFormCode);
     SetRecordEditedDocDir('A',NowCaseNo,NowDocDir);
     DrawDocItem2(MytreeNode1,NowCaseno);
@@ -2620,7 +2630,6 @@
   Result:=False;
   ST:=TStringList.Create;
   ST.loadFromfile(DocNopath+'\Context.dat');
-//ShowMessage(ST.Text);
   for I := 0 to ST.Count - 1 do
   begin
     if ISExistImg(DocNopath+ST.Strings[i]) then
@@ -2711,11 +2720,13 @@
   if (Treeview1.Selected = NewTreeNode) {or (Treeview1.Selected = MyTreeNode1)} then
   begin
 //ShowMessage('NewScanBtnClick');
+LogFile1.LogToFile(logTimeString+'Tree NewScanBtnClick');
     NewScanBtnClick(self)
   end
   Else
   begin
 //ShowMessage('AddScanBtnclick');
+LogFile1.LogToFile(logTimeString+'Tree AddScanBtnclick');
     AddScanBtnclick(self);
   end;
 end;
@@ -2745,6 +2756,7 @@
     ISB := TImageScrollBox.Create(self);
 try
     ShowText := _Msg('檔案加入中,請稍候');
+LogFile1.LogToFile(logTimeString+'檔案加入中開始');
     DataLoading(True, True);
     If TreeView1.Selected = Nil Then
       Exit;
@@ -2880,11 +2892,19 @@
 
           DocNo := FormCode2DocNo(FormID);
           DocDir := FindLastestDocDir(CaseID, DocNo);
+          if (FMode='ESCAN') and (FModeName='補件掃描') then
+          begin
+            DocDir := FindLastestDocDirForPage(CaseID, DocNo,FormID);
+//ShowMessage('DocDir='+DocDir);
+          end;
+
           If DocNoNeedDiv(DocNo) Then // 要分份數
           Begin
             If ((FormCode2Page(FormID) = '01') And
               (GetDocDir_Page(CaseID, DocDir) > 0)) Or (DocDir = '') Then
-              DocDir := DocNo2DocNoDir(ImageSavePath + CaseID + '\', DocNo);
+              begin
+                DocDir := DocNo2DocNoDir(ImageSavePath + CaseID + '\', DocNo);
+              end;
           End
           Else // 不分份數
           Begin
@@ -3192,6 +3212,7 @@
 begin
   DocListForm := TDocListForm.Create(self);
   try
+LogFile1.LogToFile(logTimeString+'Tree 歸類開始');
     InitialLanguage(DocListForm); //載入多國語言
     DocListForm.CheckBox1.Visible:=True;
     for i := 1 to FORM_INF_List.Count - 1 do
@@ -3217,6 +3238,7 @@
       begin
         //歸類到自訂文件
         NewFormID:=DocListForm.Edit1.Text;
+
         if Trim(DocListForm.Edit1.Text)='' then
         begin
           Showmessage('未輸入文件名稱');
@@ -3239,6 +3261,7 @@
         end;
         CustomDocNo := GetNewCustomDocNo(DisplayPath,NewFormID);
 //ShowMessage('CustomDocNo='+CustomDocNo);
+LogFile1.LogToFile(logTimeString+'Tree 歸類到自訂文件 CustomDocNo='+CustomDocNo);
         ShowText := _Msg('歸類中,請稍侯');
         DataLoading(True,True);
         FormIDReplace(NowCaseNo,NowDocDir,NowFormCode,CustomDocNo+'010101A');
@@ -3259,6 +3282,7 @@
         ShowText := _Msg('歸類中,請稍侯');
         DataLoading(True,True);
 //ShowMessage('NowDocDir='+NowDocDir);
+LogFile1.LogToFile(logTimeString+'Tree 歸類到既有文件 NewFormID='+NewFormID);
         FormIDReplace(NowCaseNo,NowDocDir,NowFormCode,NewFormID);
 
       end;
@@ -4429,7 +4453,7 @@
       iGraphic.JpegQuality:=FJpgCompression;
     end;
 
-
+//ShowMessage('WTF');
     while not iGraphic.IsEmpty do
     begin
       //Application.ProcessMessages;
@@ -4458,7 +4482,6 @@
           iGraphic.Compression:=tcJPEG;
           iGraphic.JpegQuality:=FJpgCompression;
         end;
-
         PageEnd;
         IF PEFileName <> '' Then
         begin
@@ -4628,7 +4651,9 @@
           Str2Dir(ScanPath);
 
           ScanDocDir := FindLastestDocDir(ScanCaseno,DocNo);
+//ShowMessage('AA ScanDocDir='+ScanDocDir);
 
+//ShowMessage('BB ScanDocDir='+ScanDocDir);
           if DocNoNeedDiv(DocNo)then   //要分份數
           begin
             //Showmessage(DocNo+#13+FormCode2Page(FormID)+#13+inttostr(GetDocDir_Page(ScanCaseno,ScanDocDir))+#13+ScanDocDir);
@@ -4704,7 +4729,12 @@
           FormID := NowGuideFormID;
         DocNo := FormCode2DocNo(FormID);
         ScanDocDir := FindLastestDocDir(ScanCaseno,DocNo);
-//ShowMessage('ScanDocDir='+ScanDocDir);
+
+        if (FMode='ESCAN') and (FModeName='補件掃描') then    //20180207 加入的特殊邏輯
+        begin
+          ScanDocDir := FindLastestDocDirForPage(ScanCaseno, DocNo,FormID);
+        end;
+
         if (DocNoNeedDiv(DocNo)) then   //要分份數
         begin
           if TreeView1.Selected = MyTreeNode1 then   //20170421 掃瞄插頁時選則在案號上才要分份數 選在FormID上就不分份數
@@ -8513,12 +8543,14 @@
 begin
   ShowText := _Msg('處理檢核失敗中,請稍候');
   DataLoading(True,True);
+LogFile1.LogToFile(logTimeString+'處理檢核失敗中開始');
   ErrlistForm := TErrlistForm.Create(Self);
   RejectCase := False;
   S := TStringlist.Create;
   try
     InitialLanguage(ErrlistForm);
     Application.ProcessMessages;
+    ErrlistForm.LogFile1.LogFile:=LogFile1.LogFile;
     ErrlistForm.DeleteBt.Caption := ErrlistForm.DeleteBt.Caption+'(&D)';
     ErrlistForm.iniPath := ImageSavePath + NowCaseNo+'\upload\';
     OMRErrini2List(NowCaseno,ErrlistForm);
@@ -9900,6 +9932,48 @@
   FileList.Free;
   end;
 end;
+
+Function TCB_IMGPSScanX.FindLastestDocDirForPage(CaseID,DocNo,formid:String):String; //找出最新的DocDir  20180207  排除隱藏的資料夾
+var
+  i,j:integer;
+  DocNoList,FileList : TStringlist;
+  Imglist: TStringlist;
+  DirIsHide:Boolean;
+begin
+  Result := '';
+  DocNoList := TStringlist.Create;
+  FileList := TStringlist.Create;
+  imglist := TStringlist.Create;
+  try
+  if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
+    DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
+
+  for i := DocNoList.Count-1 downto 0 do
+  begin
+    if Copy(DocNoList.Strings[i],1,length(DocNo)) = DocNo then
+    begin
+//ShowMessage(ImageSavePath+CaseID+'\'+DocNoList.Strings[i]);
+      if not DocNoIsExistImg(ImageSavePath+CaseID+'\'+DocNoList.Strings[i]+'\') then
+      begin
+//ShowMessage('DDDDD');
+        Result := '';
+        Break;
+      end
+      else
+      begin
+        Result := DocNoList.Strings[i];
+        Break;
+      end;
+    end;
+  end;
+  finally
+    DocNoList.Free;
+    FileList.Free;
+    imglist.Free;
+  end;
+
+end;
+
 
 Procedure TCB_IMGPSScanX.Create_Cust_DocDir(CaseID:String); //產生外面傳入的文件代號及自定文件
 var
@@ -12391,6 +12465,44 @@
   end;
 end;
 
+function TCB_IMGPSScanX.OMRErrini2ListForLog(CaseID: String): String;
+var
+  ini : Tinifile;
+  Errcount : Integer;
+  Del : Boolean;
+  i,j : Integer;
+  ST,CaseList:TStringList;
+
+begin
+  Result:='';
+  //CaseList.dat
+  ST:=TStringList.Create;
+  CaseList:=TStringList.Create;
+  CaseList.LoadFromFile(ImageSavePath+'CaseList.dat');
+  for I := 0 to CaseList.Count - 1 do
+  begin
+    ini := Tinifile.Create(ImageSavePath + CaseList.Strings[i]+'\upload\Checkerr.ini');
+    try
+      Errcount := ini.ReadInteger('OMRCount','Count',0);
+
+      for j := 1 to ErrCount do
+      begin
+        Del := ini.ReadBool(inttostr(j),'Del',False); //是否被移除了
+        if Not Del then
+        begin
+          ST.Add(ini.ReadString(inttostr(j),'Reason','')) ;
+        end;
+      end;
+    finally
+    ini.Free;
+    end;
+  end;
+  Result:=ST.Text;
+  ST.Free;
+  CaseList.Free;
+end;
+
+
 Function TCB_IMGPSScanX.DownLanguage:Boolean;  //下載多國語言檔
 begin
   Result := True;     // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
@@ -14670,6 +14782,7 @@
     Showmessage(_msg('資訊尚未下載完成,請稍候或重新進入'));
     Exit;
   end;
+LogFile1.LogToFile(logTimeString+'按下上傳');
   ClearView(1);
   CaseHelpBtn.Visible := False;
   DisplayPath := '';
@@ -14801,8 +14914,10 @@
   if ReCasecount > 0 then
     TransMsg := TransMsg + #13#10 + Format(_Msg('無法上傳件【%d】件'),[ReCasecount]);
   if CheckErrCount > 0 then
+  begin
     TransMsg := TransMsg + #13#10 + Format(_Msg('檢核失敗件【%d】件,請先點選「案件編號」,再點選「問號」查看錯誤原因'),[CheckErrCount]);
-
+LogFile1.LogToFile(logTimeString+'檢核失敗原因:'+OMRErrini2ListForLog(''));
+  end;
 
   if (FMode = 'DSCAN') and (SuccessCount = 1)  then
   begin
diff --git a/ErrList.dcu b/ErrList.dcu
index 5e9d4ab..e84e480 100644
--- a/ErrList.dcu
+++ b/ErrList.dcu
Binary files differ
diff --git a/ErrList.dfm b/ErrList.dfm
index cdae027..acd09ed 100644
--- a/ErrList.dfm
+++ b/ErrList.dfm
@@ -405,4 +405,8 @@
     Left = 504
     Top = 136
   end
+  object LogFile1: TLogFile
+    Left = 352
+    Top = 120
+  end
 end
diff --git a/ErrList.pas b/ErrList.pas
index a7ef3c0..ed4543d 100644
--- a/ErrList.pas
+++ b/ErrList.pas
@@ -5,7 +5,8 @@
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, OleCtrls, Menus, StdCtrls, Buttons, ComCtrls, ExtCtrls,inifiles,
-  iisUnit,iis_ImageProcess, EnImgScr,mpsBarco,BarcodesFinder, EnMisc, EnDiGrph;
+  iisUnit,iis_ImageProcess, EnImgScr,mpsBarco,BarcodesFinder, EnMisc, EnDiGrph,
+  LogFile;
 
 type
   TErrlistForm = class(TForm)
@@ -39,6 +40,7 @@
     ImageScrollBox2: TImageScrollBox;
     ImageScrollBox3: TImageScrollBox;
     Button1: TButton;
+    LogFile1: TLogFile;
     procedure ExitBtClick(Sender: TObject);
     procedure ImmediateBtClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -103,7 +105,8 @@
     Procedure ShowRelaOMRErr(Relaidx:Integer); //�e���W�q�X���YOMR�ˮ֥���
     Procedure GetOMRErrini(Index:String); //���ˮ֥���ini
     Procedure InitialData;
-    procedure ImageScrollBox1NewGraphic(const Graphic: TDibGraphic);  //��_����������A
+    procedure ImageScrollBox1NewGraphic(const Graphic: TDibGraphic);
+    function logTimeString: String;  //��_����������A
   public
     { Public declarations }
     iniPath : String;
@@ -348,6 +351,12 @@
 procedure TErrlistForm.ImmediateBtClick(Sender: TObject);
 begin
   ModalResult := mrOK;
+  LogFile1.LogToFile(logTimeString+'�ߧY�e��');
+end;
+
+function TErrlistForm.logTimeString: String;
+begin
+Result:=FormatDateTime('yyyymmdd hh:mm:ss',now)+'  ';
 end;
 
 procedure TErrlistForm.RelaNextBtClick(Sender: TObject);

--
Gitblit v1.8.0