CB_IMGPSScanImp.pas
@@ -14,7 +14,7 @@
  ExtCtrls, ComCtrls, Menus, StdCtrls, Gauges, EnImgScr, PJMenuSpeedButtons,
  Buttons, ImgList, SBSimpleSSL, SBHTTPSClient, SBWinCertStorage, SBX509,
  SBCustomCertStorage, SBUtils,mpsBarco,BarcodesFinder,HTTPApp,ErrList,
  Xmltool,inifiles,printers;
  Xmltool,inifiles,printers,IdHashMessageDigest, idHash;
var
  Ch_WriteNote : Boolean;
@@ -835,6 +835,8 @@
    function ISDivPageFormID(FormID: String): Boolean;
    function GetSampleInf: Boolean;
    procedure InitExistImgList(casepath:String);
    function LoadFileGetMD5(const filename:string):string; //20170809 取的檔案的MD5
    function ISExistImg(const filename:string):boolean; //20170809 確認是否存在原有影像
  protected
    { Protected declarations }
    procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
@@ -1213,9 +1215,9 @@
  ST1:=TStringList.Create;
  ST2:=TStringList.Create;
  ST3:=TStringList.Create;
  ST4:=TStringList.Create;
//FImgDelete:='Y';
  if FileExists(casepath+'CaseDocNo.dat') then
  {if FileExists(casepath+'CaseDocNo.dat') then
  begin
    ST1.LoadFromFile(casepath+'CaseDocNo.dat');
    for I := 0 to ST1.Count - 1 do
@@ -1244,6 +1246,12 @@
    begin
      ExistImgList.Add(casepath+'Attach\'+ST3.Strings[i])
    end;
  end; }
  ExistImgList.Clear;
  ST1.LoadFromFile(casepath+'Download\Context.dat');
  for I := 0 to ST1.Count - 1 do
  begin
    ExistImgList.Add(LoadFileGetMD5(casepath+'Download\'+ST1.Strings[i])) ;
  end;
  ST1.Free;
@@ -5852,14 +5860,11 @@
    begin
      str1:=Copy(ST1.Strings[i],1,Pos('_',St1.Strings[i])-1);
      ST2.Add(str1);
      if ST2.IndexOf(str1) = -1 then
      begin
        must_formidStr:= must_formidStr+str1+'@#,';
      end;
      must_formidStr:= must_formidStr+str1+'@#,';
    end;
  end;
  must_formidStr:=Copy(must_formidStr,1,Length(must_formidStr)-3) ;
//ShowMessage('must_formidStr='+must_formidStr);
//ShowMessage('AST2='+ST2.Text);
  for I := 0 to LastInitFormidList.Count - 1 do
  begin
@@ -8423,6 +8428,30 @@
  ST1.Free;
end;
function TCB_IMGPSScanX.LoadFileGetMD5(const filename: string): string;
var
  Stream: TFileStream;
  //Buffer: array[0..1023] of AnsiChar;
  Buffer: array[0..1023] of AnsiChar;
  TempStr: string;
  i: Integer;
  idmd5:TIdHashMessageDigest5;  //import IdHashMessageDigest, idHash
begin
  idmd5 := TIdHashMessageDigest5.Create;
  try
    Stream := TFileStream.Create(filename, fmOpenRead);
    Stream.Read(Buffer[0], SizeOf(Buffer));
    result := idmd5.HashStreamAsHex(Stream) ;
  finally
    idmd5.Free;
    Stream.Free;
  end;
end;
procedure TCB_IMGPSScanX.LoadImgFile;  //載入新件及替換件
Var
  i,v,v1,m : Integer;
@@ -9936,6 +9965,18 @@
  end;
end;
function TCB_IMGPSScanX.ISExistImg(const filename: string): boolean;
begin
  if ExistImgList.IndexOf(LoadFileGetMD5(filename))<>-1 then
  begin
    Result:=True;
  end
  else
  begin
    Result:=False;
  end;
end;
Function TCB_IMGPSScanX.CaseDelete_Enable(CaseID:String):Boolean;  //案件可否被刪除
var
  i : Integer;