From 1807a861b1b5f54ff5cbe249caf24f9b68ebd18e Mon Sep 17 00:00:00 2001
From: doom4ster <doom4ster@gmail.com>
Date: 星期四, 30 十一月 2017 15:02:41 +0800
Subject: [PATCH] CB_IMGPSScan.cab ver2.0.1.56  加上上傳大小限制   和  jpg 轉 tif 檔案大小縮減

---
 CB_IMGPSScanImp.dcu |    0 
 CB_IMGPSScan.ocx    |    0 
 CB_IMGPSScanImp.pas |   47 ++++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/CB_IMGPSScan.ocx b/CB_IMGPSScan.ocx
index 1657750..ad72674 100644
--- a/CB_IMGPSScan.ocx
+++ b/CB_IMGPSScan.ocx
Binary files differ
diff --git a/CB_IMGPSScanImp.dcu b/CB_IMGPSScanImp.dcu
index ad2b7eb..e0f221c 100644
--- a/CB_IMGPSScanImp.dcu
+++ b/CB_IMGPSScanImp.dcu
Binary files differ
diff --git a/CB_IMGPSScanImp.pas b/CB_IMGPSScanImp.pas
index d26cb2e..515f04e 100644
--- a/CB_IMGPSScanImp.pas
+++ b/CB_IMGPSScanImp.pas
@@ -564,6 +564,7 @@
     NowDivPageFormID:String;
 
     FirstDocDir : String;
+    FMaxUploadSize:String;// 上傳zip大小限制
 
     Draging : Boolean;
 
@@ -2734,6 +2735,8 @@
       iGraphic_sec := TTiffGraphic.Create;
 
       iGraphic_First.Assign(ISB.Graphic);
+      //ShowMessage(IntToStr(iGraphic_First.Palette.palNumEntries)); //彩色 會為0  黑白 為2
+
       MpsGetBarcode(ISB.Graphic, MpsBarcodeinf); //判斷A3 有用FormID 所以要先辨條碼
       //有必要的話先把影像轉正 再開始切圖
       If CheckNeedCrop(iGraphic_First) Then
@@ -2840,6 +2843,12 @@
               Break;
             End;
           End;
+
+          if iGraphic.Palette.palNumEntries = 0 then  //20171130 彩色 會為0  黑白 為2
+          begin
+            iGraphic.Compression:=tcJPEG;
+            iGraphic.JpegQuality:=70;
+          end;
 
           If LowerCase(ExtractFileExt(SavePath + SaveFilename)) = '.tif' Then
           Begin
@@ -4039,10 +4048,10 @@
   //CreateFormID_FormName(DisplayPath);  //產生FormID_FormName.dat
   //CreateDocNo_DocName(DisplayPath); //產生DocNo_Name.dat
   //Showmessage(CreateDocNo_Info(DisplayPath));  //產生 Docno,份數,頁數;Docno,份數,頁數 的回傳字串
-  lb1.Caption:='AAAAAAAAAAA';
+  //lb1.Caption:='AAAAAAAAAAA';
   //Showmessage(CreateDocnoFrom_Info(NowCaseno));
   //Showmessage(self.CreateCustDocNoFrom_Info(NowCaseno));
-
+  ShowMessage('FMaxUploadSize='+FMaxUploadSize);
         initkscan;
 	showmessage('FUrl='+FUrl+#10#13+
 	'FCaseID='+FCaseID+#10#13+
@@ -5142,6 +5151,11 @@
     begin
       PARA_CONTENT := GetSQLData(WORK_INF_List,'PARA_CONTENT',i);
       DivPageFormIDList.CommaText := PARA_CONTENT;
+    end
+    Else if UpperCase(GetSQLData(WORK_INF_List,'PARA_NO',i)) = 'MAX_UPLOAD_SIZE' Then     //取得 上傳大小的限制(MB)
+    begin
+      PARA_CONTENT := GetSQLData(WORK_INF_List,'PARA_CONTENT',i);
+      FMaxUploadSize := PARA_CONTENT;
     end;
   end;
   ScanDuplex := Def_ScanDuplex;
@@ -6114,6 +6128,8 @@
   casepath:String;
   filesizeInt:integer;
   case_page:string;
+  Fname:String;
+  FileRec:TSearchrec;
 begin
   Result := True;
   TransName := CaseID;
@@ -6177,7 +6193,7 @@
 
   for I := 0 to ST1.Count - 1 do
   begin
-    if (Pos('_',St1.Strings[i])<>1) and (Pos('_',St1.Strings[i])<>-11) then
+    if (Pos('_',St1.Strings[i])<>1) and (Pos('_',St1.Strings[i])<>-1) then
     begin
       str1:=Copy(ST1.Strings[i],1,Pos('_',St1.Strings[i])-1);
       ST2.Add(str1);
@@ -6231,6 +6247,27 @@
   if HaveMask then
     ZipMaskFile(Path,MaskPath,Path,'MaskImg.zip');  //有遮罩設定的才產生
   /////壓檔////
+
+  ///檢查上傳的zip大小////
+   FName :=Path+ 'Img.zip';
+
+    FindFirst(FName, faAnyfile, FileRec);
+
+    //FMaxUploadSize
+//ShowMessage(IntToStr(FileRec.Size));
+//Result:=False;
+//exit;
+    If FileRec.Size > StrtoInt(FMaxUploadSize) * 1048576 Then // 檢查檔案大小
+    Begin
+      ShowMessage(Format('%.3f', [FileRec.Size / 1048576]) +
+        ' MB,超過上傳限制大小 '+FMaxUploadSize+' MB');
+      FindClose(FileRec);
+      Result := False;
+      Exit;
+    End;
+    FindClose(FileRec);
+  ///檢查上傳的zip大小////
+//ShowMessage('last_add_formidstr='+last_add_formidstr);
   ////上傳/////
   SendData:='data='+HTTPEncode(UTF8Encode(FData))
   +'&verify='+FVerify
@@ -8941,7 +8978,7 @@
   ST1.LoadFromFile(path+'FormCode_Name.dat');
   for I := 0 to ST1.Count - 1 do
   begin
-    if (Pos('_',St1.Strings[i])<>1) and (Pos('_',St1.Strings[i])<>-11) then
+    if (Pos('_',St1.Strings[i])<>1) and (Pos('_',St1.Strings[i])<>-1) then
     begin
       str1:=Copy(ST1.Strings[i],1,Pos('_',St1.Strings[i])-1);
       LastInitFormidList.Add(str1);
@@ -14011,7 +14048,7 @@
   PageLVclear := True;
   InitialOk := False;
 
-
+  FMaxUploadSize:='10';
   //FMode := 'DSCAN' ;
   //FIs_In_Wh := 'Y';
   if FIs_In_Wh = 'Y' then

--
Gitblit v1.8.0