doom4ster
2017-04-21 a4ae7e18f2dfff21a802682a4d800cb6cbcdd21c
CB_IMGPSScanImp.pas
@@ -650,6 +650,7 @@
    Procedure CreateIn_WH(CaseID:String);  //產生In_WH.dat
    Function CreateDocNo_Info(CaseID:String):String; //產生保管袋文件 DocNo[tab]份數[tab]總頁數[tab]是否異動[換行]DocNo[tab]份數[tab]總頁數[tab]是否異動
    Function CreateCustDocNo_Info(CaseID:String):String; //產生自訂文件 DocName[tab]份數[tab]總頁數[tab]是否異動[#13#10]DocName[tab]份數[tab]總頁數[tab]是否異動
    //Function CreateCustDocNo_Info(path,CaseID:String):String; overload
    Function CreateAttach_Info(CaseID:String):String; //產生是否有Attach Y:有 N:沒有
    Function CreateDocnoFrom_Info(CaseID:String):String; //產生被引進的保管袋文件資訊  Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
    Function CreateCustDocNoFrom_Info(CaseID:String):String; //產生被引進的自定文件資訊  Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
@@ -825,6 +826,7 @@
    function GetCurrentVersionNo: String;
    procedure initParameter;
    procedure LastInitFormidListCreate(path:string);
    function checkFormCodeIsCustom(path,formcode:string):boolean;
  protected
    { Protected declarations }
    procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
@@ -2145,7 +2147,7 @@
    Showmessage(_msg('資訊尚未下載完成,請稍候或重新進入'));
    Exit;
  end;
  if (FMode = 'RSCAN') or (FMode = 'ESCAN') then
  if (FMode = 'RSCAN') or (FMode = 'ESCAN') or (FMode = 'DSCAN') then
  begin
    if NewTreeNode.Count > 0 then
    begin
@@ -2508,10 +2510,36 @@
procedure TCB_IMGPSScanX.PM103Click(Sender: TObject);
begin
  if TreeView1.Selected = nil then Exit;
  {if Treeview1.Selected = NewTreeNode then
  begin
    ShowMessage('AAAAA');
  end;
  if Treeview1.Selected = MyTreeNode1 then
  begin
    ShowMessage('BBBBB');
  end;
  if Treeview1.Selected = MyTreeNode2 then
  begin
    ShowMessage('CCCCC');
  end;
  if Treeview1.Selected = MyTreeNode3 then
  begin
    ShowMessage('DDDDD');
  end;
  }
  if (Treeview1.Selected = NewTreeNode) {or (Treeview1.Selected = MyTreeNode1)} then
  begin
//ShowMessage('NewScanBtnClick');
    NewScanBtnClick(self)
  end
  Else
  begin
//ShowMessage('AddScanBtnclick');
    AddScanBtnclick(self);
  end;
end;
procedure TCB_IMGPSScanX.PM104Click(Sender: TObject);
@@ -3611,30 +3639,38 @@
  //Showmessage(CreateDocnoFrom_Info(NowCaseno));
  //Showmessage(self.CreateCustDocNoFrom_Info(NowCaseno));
        initkscan;
   showmessage('FUrl='+FUrl+#10#13+
   'FCaseID='+FCaseID+#10#13+
   'FMode='+FMode+#10#13+
   'FModeName='+FModeName+#10#13+
   'FWork_no='+FWork_no+#10#13+
   'FUserID='+FUserID+#10#13+
   'FUserName='+FUserName+#10#13+
   'FUserUnit='+FUserUnit+#10#13+
   'FData='+FData+#10#13+
   'FVerify='+FVerify+#10#13+
   'FReWrite='+FReWrite+#10#13+
   'FLanguage='+FLanguage+#10#13+
   'FLoanDoc_Value='+FLoanDoc_Value+#10#13+
   'FLoanDoc_Enable='+FLoanDoc_Enable+#10#13+
   'FUseProxy='+FUseProxy+#10#13+
   'FC_DocNoList='+FC_DocNoList+#10#13+
   'FC_DocNameList='+FC_DocNameList+#10#13+
   'FFixFileList='+FFixFileList+#10#13+
   'FIs_In_Wh='+FIs_In_Wh+#10#13+
   'FOldCaseInfo='+FOldCaseInfo+#10#13+
   'FPrintyn='+FPrintyn+#10#13+
   'FIs_OldCase='+FIs_OldCase+#10#13+
   'FCustDocYN='+FCustDocYN);
  ShowMessage('FImgDPI='+IntToStr(FImgDPI)+#10#13+
    'FScanColor='+    IntToStr(FScanColor)+#10#13+
    'FFileSizeLimit='+  IntToStr(FFileSizeLimit)  +#10#13+
    'FCaseNoLength='+ IntToStr(FCaseNoLength)   +#10#13+
    'FImgDelete='+    FImgDelete+#10#13+
    'FIsExternal='+    FIsExternal+#10#13+
    'FCheck_main_form='+    FCheck_main_form);
   showmessage('FUrl='+FUrl);
   showmessage('FCaseID='+FCaseID);
   showmessage('FMode='+FMode);
   showmessage('FModeName='+FModeName);
   showmessage('FWork_no='+FWork_no);
   showmessage('FUserID='+FUserID);
   showmessage('FUserName='+FUserName);
   showmessage('FUserUnit='+FUserUnit);
   showmessage('FData='+FData);
   showmessage('FVerify='+FVerify);
   showmessage('FReWrite='+FReWrite);
   showmessage('FLanguage='+FLanguage);
   showmessage('FLoanDoc_Value='+FLoanDoc_Value);
   showmessage('FLoanDoc_Enable='+FLoanDoc_Enable);
   showmessage('FUseProxy='+FUseProxy);
   showmessage('FC_DocNoList='+FC_DocNoList);
   showmessage('FC_DocNameList='+FC_DocNameList);
   showmessage('FFixFileList='+FFixFileList);
   showmessage('FIs_In_Wh='+FIs_In_Wh);
   showmessage('FOldCaseInfo='+FOldCaseInfo);
   showmessage('FPrintyn='+FPrintyn);
   showmessage('FIs_OldCase='+FIs_OldCase);
   showmessage('FCustDocYN='+FCustDocYN);
end;
procedure TCB_IMGPSScanX.Button4Click(Sender: TObject);
@@ -3648,8 +3684,8 @@
  str:='';
  for I := 1 to 11 do // 看 OMRErrInfo 的內容
  begin
  str:=str+BoolToStr(OMRErrInfo[i].Display)+','
          +BoolToStr(OMRErrInfo[i].Ignore)+','+OMRErrInfo[i].Info+','
  str:=str+BoolToStr(OMRErrInfo[i].Display,true)+','
          +BoolToStr(OMRErrInfo[i].Ignore,true)+','+OMRErrInfo[i].Info+','
          +OMRErrInfo[i].Mode+#10#13;
  end;
  ShowMessage('OMRErrInfo='+str);
@@ -4020,7 +4056,8 @@
          Str2Dir(ScanPath);
          ScanDocDir := FindLastestDocDir(ScanCaseno,DocNo);
          if DocNoNeedDiv(DocNo) then   //要分份數
          if DocNoNeedDiv(DocNo)then   //要分份數
          begin
            //Showmessage(DocNo+#13+FormCode2Page(FormID)+#13+inttostr(GetDocDir_Page(ScanCaseno,ScanDocDir))+#13+ScanDocDir);
            if ((FormCode2Page(FormID) = '01') and (GetDocDir_Page(ScanCaseno,ScanDocDir)>0))  or (ScanDocDir = '') then
@@ -4096,12 +4133,16 @@
          FormID := NowGuideFormID;
        DocNo := FormCode2DocNo(FormID);
        ScanDocDir := FindLastestDocDir(ScanCaseno,DocNo);
        if DocNoNeedDiv(DocNo) then   //要分份數
//ShowMessage('ScanDocDir='+ScanDocDir);
        if (DocNoNeedDiv(DocNo)) then   //要分份數
        begin
          if ((FormCode2Page(FormID) = '01') and (GetDocDir_Page(ScanCaseno,ScanDocDir)>0)) or (ScanDocDir = '') then
          if TreeView1.Selected = MyTreeNode1 then   //20170421 掃瞄插頁時選則在案號上才要分份數 選在FormID上就不分份數
          begin
            ScanInfo.ImageCount := 0;
            ScanDocDir := DocNo2DocNoDir(ImageSavePath + ScanCaseno+'\',DocNo);
            if ((FormCode2Page(FormID) = '01') and (GetDocDir_Page(ScanCaseno,ScanDocDir)>0)) or (ScanDocDir = '') then
            begin
              ScanInfo.ImageCount := 0;
              ScanDocDir := DocNo2DocNoDir(ImageSavePath + ScanCaseno+'\',DocNo);
            end;
          end;
        end
        Else        //不分份數
@@ -5282,20 +5323,21 @@
  S : TStringlist;
  FormCode,iPage : String;
begin
  Count := 1;
  Count := 0;
  S := TStringlist.Create;
  try
    S.LoadFromFile(ImageSavePath+CaseID+'\upload\Context.dat');
    for I := 0 to pages-1 do
    for I := 1 to pages do //從0到pages-1  改成 1到pages 20170316 這樣可以修改檢核的頁數問題
    begin
      iPage := Add_Zoo(i,2);
      for n := 0 to S.Count - 1 do
      begin
        FormCode := FileName2FormCode(S.Strings[n]);
        //Showmessage('1:'+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
//Showmessage('1:'+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
        if (version = FormCode2Version(FormCode)) and (DocNo = FormCode2DocNo(FormCode)) and (ipage = FormCode2Page(FormCode)) then
        begin
          //Showmessage(inttostr(Count+1));
//Showmessage(version+','+DocNo+',iPage='+iPage);
//Showmessage(inttostr(Count+1));
          Inc(Count);
          Break;   //找到了...離開
        end;
@@ -5474,6 +5516,7 @@
  must_formidStr :string;
  last_add_formidstr :string;
  casepath:String;
  filesizeInt:integer;
begin
  Result := True;
  TransName := CaseID;
@@ -5584,6 +5627,10 @@
  end;
  ///保留外部影像  end///////////////////////////////
  //file_size 計算  就先不做 20170316
  filesizeInt:=0;
  //////壓檔/////
  ZipMainFile(Path,Path,'Img.zip');
  if HaveMask then
@@ -5598,11 +5645,14 @@
  +'&doc_data='+HTTPEncode(UTF8Encode(Doc_Data))
  +'&doc_data1='+HTTPEncode(UTF8Encode(Doc_Data1))
  +'&attach='+AttachYN
  +'&file_size='+IntToStr(filesizeInt)
  +'&must_formid='+must_formidStr  //擁有的 formid
  +'&last_add_formid='+last_add_formidstr   //當次新加的 formid
  +'&in_doc1='+HTTPEncode(UTF8Encode(In_Doc1))
  +'&in_doc2='+HTTPEncode(UTF8Encode(In_Doc2));
//ShowMessage('SendData='+SendData);
//ShowMessage(FData+#10#13+Doc_Data);
//exit;
  if not upFile(HTTPSClient,FUrl,'service/imgpsc/IMGPSC02/caseupload',SendData,'file',Path+'Img.zip',FReWrite,Memo1,False) then
  begin
@@ -6442,6 +6492,27 @@
      Break;
    end;
  end;
end;
function TCB_IMGPSScanX.checkFormCodeIsCustom(path, formcode: string): boolean;
var
  i:integer;
  ini : Tmeminifile;
  str1:String;
begin
//ShowMessage(path);
  ini := Tmeminifile.Create(Path+'CustomDocNo.ini');
  str1:=ini.ReadString(Copy(formcode,1,8),'FormID','');
//ShowMessage('str1'+str1);
  if str1 = formcode then
  begin
    Result:=True;
  end
  else
  begin
    Result := False;
  end;
end;
Function TCB_IMGPSScanX.CheckCaseID_OK:Boolean;  //檢查是否有未配號的案件
@@ -10481,7 +10552,7 @@
          //20131203 yuu說不檢查這個,先拿掉   20170315 楷琳說未歸類要擋
          if FCheck_main_form='Y' then
          begin
            if (FMode <> 'SSCAN') and (Fmode <> 'ESCAN') then  //簽署章件會換主FormID,先跳過
            if (FMode <> 'SSCAN') then  //簽署章件會換主FormID,先跳過
            begin
              ErrStr:=_Msg('找不到分案文件');   //找不到主文件
              OMRErr2ini(CaseID,ErrStr,'','','','','','',False,False,True);
@@ -10586,10 +10657,12 @@
        end }
        /////未註冊文件/////
        //////停用文件//
        {Else} IF ModeNeedCheck(OMRErrInfo[9].Mode,FMode) and (not FormIDExists(FormCode,True,0)) then  //有停用的文件
        {Else} IF ModeNeedCheck(OMRErrInfo[9].Mode,FMode) and (not FormIDExists(FormCode,True,0)) and (not checkFormCodeIsCustom(ImageSavePath + CaseID+'\upload\',FormCode)) then  //有停用的文件
        begin
//ShowMessage('AAAA');
          ErrStr:=Format(OMRErrInfo[9].Info,[FormCode2FormName(CaseID,FormCode)]);   //有停用文件
          OMRErr2ini(CaseID,ErrStr,'','','','','','',False,OMRErrInfo[9].Ignore,OMRErrInfo[9].Display);
//ShowMessage('ErrStr='+ErrStr);
          if OMRErrInfo[9].Display then
            CaseOk := false;
        end;
@@ -12074,6 +12147,7 @@
    Str := '';
    if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
    DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
//ShowMessage(DocDirList.Text);
    while DocDirList.Count > 0 do
    begin
      iDocDir := DocDirList.Strings[0];
@@ -13094,6 +13168,7 @@
  ImagePath := ImagePath + 'Scantemp\';
  ScaniniPath :=ImagePath+FWork_No+'\'+FUserUnit +'\';
  ImagePath := ImagePath + FWork_No+'\'+FUserUnit+'\'+FMode+'\';
//ShowMessage('ImagePath='+ImagePath);
  ImageSavePath := ImagePath;
  str2dir(CheckXmlPath);
  str2dir(SitePath);
@@ -13306,7 +13381,7 @@
      s.Free;
      end;
    end;}
    if (FMode = 'NSCAN') then
    if (FMode = 'NSCAN') or (FMode = 'DSCAN')  then //20170406 待掃瞄也要問一下
    begin
      /////訊問是否可上傳/////
      CaseTrans := CaseAsk(CaseID);