From 0756bf12d10cf1b7f78c571de0a9ad69cbaeb7ca Mon Sep 17 00:00:00 2001
From: curtis <curtis@i-mps.com>
Date: 星期一, 30 三月 2026 14:24:17 +0800
Subject: [PATCH] fix: 更新內部引用方法參照

---
 reassemble/transp/fileClient.pas |  161 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 161 insertions(+), 0 deletions(-)

diff --git a/reassemble/transp/fileClient.pas b/reassemble/transp/fileClient.pas
new file mode 100644
index 0000000..460ea8f
--- /dev/null
+++ b/reassemble/transp/fileClient.pas
@@ -0,0 +1,161 @@
+{ ==============================================================================
+  方法名稱:GetFtpinfo
+  引用相依:
+  方法描述:向伺服器請求案件上傳所需的 FTP 連線資訊。核心邏輯:
+            1. 發送包含案件編號與動作代碼的 HTTP POST 請求至後台 Servlet。
+            2. 解析伺服器回傳結果,若回傳 'nodata' 則維持 tsNone 模式;若回傳成功,
+            則根據標籤判斷是否啟用 FTP 模式 (tsFtp)。
+            3. 若為 FTP 模式,會進一步解析並呼叫 DecodeFtpInfo 對包含連線協定、IP、
+            Port、帳號及密碼的加密字串進行解密,並存入系統全域變數中。
+============================================================================== }
+Function TCB_IMGPSScanX.GetFtpinfo(CaseID,Action:String):Boolean;
+var
+  SendData : String;
+
+  Procedure DecodeFtpInfo(EncryStr:String);
+  var
+    FtpStr : String;
+    ftpinfoList : TStringlist;
+  begin
+    if EncryStr = '' then Exit;
+    ftpinfoList := TStringlist.Create;
+    try
+      FtpStr := En_DecryptionStr_Base64('D',EncryStr,MpsKey);
+      SplitString('!@!',FtpStr,ftpinfoList);
+      if ftpinfoList[0] = 'ftps' then
+        FFtpProtocol := fpftps
+      else if ftpinfoList[0] = 'ftp' then
+        FFtpProtocol := fpftp;
+      FFtpIP := ftpinfoList[1];
+      FFtpPort := strtoint(ftpinfoList[2]);
+      FFtpID := ftpinfoList[3];
+      FFtpPwd := ftpinfoList[4];
+
+    finally
+    ftpinfoList.Free;
+    end;
+  end;
+begin
+  Result := True;
+  SendData:='product='+FWork_no+'&case_no='+CaseID+'&department='+FUserUnit+'&action='+Action;
+  If not ProcessServlet_FormData(HTTPSClient,FURL+'service/imgpsc/IMGPSC02/ftps',SendData,FReWrite,Memo1,False) Then
+  begin
+    HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
+    Result := False;
+    Exit;
+  end;
+  IF (memo1.Lines.Strings[0] = '1') Then
+  begin
+    if memo1.Lines.Strings[1]='nodata' then   //nodata 為正常可繼續的判斷
+    begin
+      TransMode := tsNone;
+      Result := True;
+      Exit;
+    end
+    else
+    begin
+      HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
+      Result := False;
+      Exit;
+    end;
+  end
+  Else if Pos('<script type="text/javascript" src="scripts/CW00/login.js"></script>',Memo1.Lines.Text) > 0 then
+  begin
+    HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
+    Result := False;
+    Exit;
+  end
+  else if (memo1.Lines.Strings[0] <> '0') then//不認識的字串
+  begin
+    HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[0];
+    Result := False;
+    Exit;
+  end;
+  TransMode := tsHttp;
+  FFtpExtraPath := '';
+
+  if memo1.Lines.Strings[0] = '0' then
+  begin
+    if memo1.Lines.Strings[2] = 'Y' then   //要使用FTP
+      TransMode := tsFtp;
+    if memo1.Lines.Count > 3 then
+    begin
+      FFtpExtraPath := memo1.Lines.Strings[3];
+      DecodeFtpInfo(memo1.Lines.Strings[4]);
+    end;
+  end;
+end;
+
+
+{ ==============================================================================
+  方法名稱:SetFtpInfo
+  引用相依:IIS_Ftp, SetFtpInfo
+  方法描述:將 FTP 連線參數與事件回呼設定至 FTP 傳輸元件 (IIS_Ftp)。此方法會將先
+            前取得並解碼的連線資訊(如 FTP IP、帳號、密碼、路徑、連接埠)指派給 IIS_Ft
+            p 物件,並根據協定類型設定是否開啟 SSL/TLS 以及被動模式 (Passive)。此
+            外,也會關聯各項事件處理器(如 SSLError, CertificateValidate, TextData
+            Line 等),以監控傳輸過程中的通訊狀態。
+============================================================================== }
+Procedure TCB_IMGPSScanX.SetFtpInfo;     //餵入FTP資訊
+begin
+  IIS_Ftp.Display1 := Display1;
+  IIS_Ftp.FTPSClient1 := FTPSClient1;
+  IIS_Ftp.ElMemoryCertStorage := ElMemoryCertStorage;
+  IIS_Ftp.Display1 := Display1;
+  IIS_Ftp.Ftpip := FFtpIP;
+  IIS_Ftp.Ftpuserid := FFtpID;
+  IIS_Ftp.FtpPwd := FFtpPwd;
+  IIS_Ftp.FtpPath := FFtpRootPath;
+  IIS_Ftp.FtpPort := FFtpPort;
+  IIS_Ftp.FtpSSL := True;
+  IIS_Ftp.FtpPassive := True;
+  if FFtpProtocol = fpftp then
+     IIS_Ftp.FtpSSL := False;
+  IIS_Ftp.FtpEncryptDataChannel := true;
+  FTPSClient1.OnControlReceiveAsString := IIS_Ftp.EventHandlers.ControlReceiveAsString;
+  FTPSClient1.OnControlSendAsString := IIS_Ftp.EventHandlers.ControlSendAsString;
+  FTPSClient1.OnSSLError := IIS_Ftp.EventHandlers.SSLError;
+  FTPSClient1.OnCertificateValidate := IIS_Ftp.EventHandlers.CertificateValidate;
+  FTPSClient1.OnTextDataLine := IIS_Ftp.EventHandlers.TextDataLine;
+
+  {Showmessage(Format('Ftpip:%s'+#13
+              +'Ftpid:%s'+#13
+              +'Ftppwd:%s'+#13
+              +'Ftppath:%s'+#13
+              +'Ftpport:%s'+#13
+              ,[FFtpIP,FFtpid,FFtpPwd,Ftppath,inttostr(Ftpport)]));}
+end;
+
+
+{ ==============================================================================
+  方法名稱:FtpCaseComplete
+  引用相依:FtpCaseComplete, ProcessServlet_FormData
+  方法描述:通知後台伺服器 FTP 案件上傳已完成。方法會將包含案件狀態的上傳數據發送
+            至特定的 Servlet 介面。邏輯包含檢查 HTTP 通訊是否成功、解析伺服器回傳
+            的結果代碼,並處理可能的登入過期(Session Timeout)情況。若執行失敗,會將
+            錯誤原因記錄至 HttpErrStr,供後續 UI 顯示錯誤訊息。
+============================================================================== }
+Function TCB_IMGPSScanX.FtpCaseComplete(SendData:String):Boolean;
+begin
+  Result := True;
+  If not ProcessServlet_FormData(HTTPSClient,FURL+'service/imgpsc/IMGPSC02/caseupload',SendData,FReWrite,Memo1,False) Then
+  begin
+    HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
+    Result := False;
+    Exit;
+  end;
+  IF (memo1.Lines.Strings[0] = '1') or (memo1.Lines.Strings[0] <> '0') Then
+  begin
+    HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
+    Result := False;
+    Exit;
+  end
+  Else if Pos('<script type="text/javascript" src="scripts/CW00/login.js"></script>',Memo1.Lines.Text) > 0 then
+  begin
+    HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
+    Result := False;
+    Exit;
+  end;
+end;
+
+

--
Gitblit v1.8.0