function TCB_IMGPSScanX.Get_HelpFile: WideString;
begin
Result := WideString(HelpFile);
end;
procedure TCB_IMGPSScanX.Set_HelpFile(const Value: WideString);
begin
HelpFile := string(Value);
end;
function TCB_IMGPSScanX.DocNoIsExistImg(DocNopath:String):boolean;
var
i:integer;
ST:TStringList;
begin
Result:=False;
ST:=TStringList.Create;
if FileExists(DocNopath+'\Context.dat') then /////20190319 Hong 當有空的Docno目錄時會掛掉,增加這行
ST.loadFromfile(DocNopath+'\Context.dat');
for I := 0 to ST.Count - 1 do
begin
if ISExistImg(DocNopath+ST.Strings[i]) then
begin
Result:=False;
Exit;
Break;
end;
end;
Result:=True;
end;
procedure TCB_IMGPSScanX.HTTPSClientCertificateValidate(Sender: TObject;
X509Certificate: TElX509Certificate; var Validate: Boolean);
begin
Validate := True;
end;
procedure TCB_IMGPSScanX.HTTPSClientRedirection(Sender: TObject;
const OldURL: string; var NewURL: string; var AllowRedirection: Boolean);
begin
AllowRedirection := True;
end;
Function TCB_IMGPSScanX.GetServerDate : Boolean;
begin
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/servertimeforocx','',FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
ServerDate := memo1.Lines.Strings[1];
ServerTime := Copy(ServerDate,9,6);
ServerDate := Copy(ServerDate,1,8);
Balance := GetBalance(ServerTime); //Server 跟Local的時間差
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf1 : Boolean; //取系統設定資訊Mode1 DOC_INF
Var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT %s FROM DOC_INF WHERE WORK_NO = '%s' ORDER BY DOC_TYPE, DOC_NO, DOC_VERSION"
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'WORK_NO,DOC_NO,DOC_U_DESC,DOC_TYPE,DOC_VERSION,FORM_PAGES,START_DATE,STOP_DATE,IS_DOC_DIV,IS_IN_WH';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=1&col='+Doc_Inf_Colume+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=1&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,Doc_Inf_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf2 : Boolean; //取系統設定資訊Mode2 DM_FORM_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT %s FROM DM_FORM_INF
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'WORK_NO,MAIN_FORM_ID,DOC_VERSION,DEPE_FORM_ID,MUTEX_FORM_ID';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=2&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=2&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,DM_FORM_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf3 : Boolean; //取系統設定資訊mode3 FORM_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT distinct %s FROM FORM_INF T1 LEFT JOIN DOC_INF T2 ON T2.DOC_NO = T1.DOC_NO AND T1.DOC_VERSION = T2.DOC_VERSION AND T1.WORK_NO = T2.WORK_NO WHERE T2.IS_USE = 'Y' AND T2.WORK_NO = %s
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
//ColumeStr := 'T1.WORK_NO,T1.FORM_ID,T1.DOC_KIND,T1.DOC_NO,T1.DOC_VERSION,T1.FORM_NAME,T1.FORM_DESC,T1.DIVISION,T1.ANCHOR,T1.MAX_PAGE,T1.FORM_HEIGHT,T1.FORM_WIDTH,T1.MERGE_IMAGE,T1.CC_FORM_ID,T1.CC_MERGE_FORMID,T2.DOC_TYPE'; {T1.CC_FORM_ID,T1.CC_MERGE_FORMID,}
ColumeStr := 'T1.WORK_NO,T1.FORM_ID,T1.DOC_NO,T1.DOC_VERSION,T1.FORM_NAME,T1.FORM_DESC,T1.DIVISION,T1.ANCHOR,T1.MAX_PAGE,T1.FORM_HEIGHT,T1.FORM_WIDTH,T1.IS_PRINT,T2.DOC_TYPE'; {T1.CC_FORM_ID,T1.CC_MERGE_FORMID,}
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=3&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=3&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,FORM_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf4 : Boolean; //取系統設定資訊mode4 CHECK_RULE_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT %s FROM CHECK_RULE_INF WHERE CHECK_TYPE = 'S'
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'WORK_NO,CHECK_NO,CHECK_RULE_DESC,MESG_SHOW_TYPE,MESG_DISP_TYPE,CHECK_MESG,SCAN_MODE';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=4&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=4&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,CHECK_RULE_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
CheckRule2OMRErrInfo;
end;
Function TCB_IMGPSScanX.GetSetInf5 : Boolean; //取系統設定資訊mode5 MEMO_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT %s FROM MEMO_INF T1 LEFT JOIN MEMO_TYPE_INF T2 ON T2.MEMO_TYPE_NO = T1.MEMO_TYPE WHERE T1.MEMO_SOURCE = '01'
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'T1.WORK_NO,T1.MEMO_TYPE,T1.MEMO_CONTENT,T2.MEMO_TYPE_NAME';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=5&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=5&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,MEMO_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf6 : Boolean; //取系統設定資訊mode5 WORK_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT %s FROM WORK_INF
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'WORK_NO,PARA_NO,PARA_CONTENT';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=5&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=6&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,WORK_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.GetSetInf7 : Boolean; //取系統設定資訊mode5 LASTEST_FORM_INF
var
ColumeStr : String;
S : TStringlist;
EnCodeDateTime : String;
begin
//SELECT FORM_ID,DOC_NO,DOC_VERSION FROM FORM_INF WHERE (DOC_NO,DOC_VERSION) in (SELECT DOC_NO, MAX(DOC_VERSION) FROM FORM_INF GROUP BY DOC_NO) ORDER BY DOC_NO
Result := False; // http://192.168.0.101:8080/fbnp/servlet/CWC01?act=getservertime
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
ColumeStr := 'FORM_ID,DOC_NO';
//If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC02 ','checktime='+EnCodeDateTime+'&mode=5&col='+ColumeStr+'&workno='+FWork_No,FReWrite.Text,Memo1) Then
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC01/tables','checktime='+EnCodeDateTime+'&mode=7&col='+En_DecryptionStr_Base64('E',ColumeStr,Mpskey)+'&work_no='+FWork_No,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
IF memo1.Lines.Strings[0] = '1' Then
begin
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else IF memo1.Lines.Strings[0] = '0' Then
begin
S := TStringlist.Create;
S.Text := Memo1.Lines.Text;
SetSQLData(ColumeStr,S,LASTEST_FORM_INF_List);
S.Free;
Result := True;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Procedure TCB_IMGPSScanX.SetIn_WH_DocNo; //將要入庫的DocNo抽出來另存入list裡
var
i : Integer;
begin
for i := 1 to Doc_Inf_List.Count - 1 do
begin
if GetSQLData(Doc_Inf_List,'IS_IN_WH',i) = 'Y' then
IN_WH_DocNoList.Add(GetSQLData(Doc_Inf_List,'DOC_NO',i));
end;
{Showmessage(IN_WH_DocNoList.Text);
StringtoFile(IN_WH_DocNoList.Text,'D:\121.txt');}
end;
Function TCB_IMGPSScanX.DeleteDocNoFile(Path,DocNo:String):Boolean; //刪除指定DocNo文件
var
i: Integer;
FName : String;
begin
Result := False;
for i := ContextList.Count - 1 downto 0 do
begin
FName := ContextList.Strings[i];
If DocNo = FormCode2DocNo(FileName2FormCode(FName)) then
begin
DeleteFile(Path+FName);
ContextList.Delete(i);
Context_DocnoList.Delete(i);
Result := True; //有刪到指定文件
end;
end;
ContextList.SaveToFile(Path+'Context.dat');
Context_DocnoList.SaveToFile(Path+'Context_DocNo.dat');
ReSortFileName(Path);
ContextList.LoadFromFile(Path+'Context.dat');
Context_DocnoList.LoadFromFile(Path+'Context_DocNo.dat');
if FileExists(Path+'CustomDocNo.dat') then
Cust_DocNoList.LoadFromFile(Path+'CustomDocNo.dat');
end;
Procedure TCB_IMGPSScanX.DeleteShowFile(Path:String); //刪除顯示中的影像
var
i : Integer;
DelFile : String;
begin
for i := 0 to NowShowFileList.Count - 1 do
begin
DelFile := NowShowFileList.Strings[i];
DeleteFile(Path+DelFile);
SetContextList('D',-1,NowCaseno,NowDocNo,DelFile);
end;
end;
Function TCB_IMGPSScanX.GetDataDocNoPage(MainDocNo,MainVersion:String):Integer; //取記錄的文件_版本頁數
var
P : String;
begin
Result := 0;
If FindSQLData(Doc_Inf_List,'FORM_PAGES','DOC_NO,DOC_VERSION',MainDocNo+','+MainVersion,0,FindResult) Then
begin
P := GetFindResult('FORM_PAGES');
if P <> '' then
Result := strtoint(P)
else
Result := 0;
end;
end;
Function TCB_IMGPSScanX.CheckCaseDocNoPage(CaseID,DocNo,Version:String;Pages:Integer):Integer; //取案件裡的文件_版本頁數
var
i,n,Count : integer;
S, S2 : TStringlist;
FormCode,iPage : String;
docInt,tempInt:integer;
v,v2:integer;
begin
Count := 0;
docInt:=0;
tempInt:=0;
S := TStringlist.Create;
S2 := TStringlist.Create;
//ShowMessage('page='+IntToStr(Pages));
try
S.LoadFromFile(ImageSavePath+CaseID+'\upload\Context.dat');
S2.LoadFromFile(ImageSavePath+CaseID+'\upload\DocDir.dat'); //2017 1220 改成只承認第一份的
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
if (FWH_category='N') and (FIs_In_Wh='Y') then
begin
if ISExistImg(ImageSavePath+CaseID+'\upload\'+S.Strings[n]) then
begin
Continue;
end;
end;
if (Length(S2.Strings[n])>8) and (Pos(DocNo,S2.Strings[n])<>0) then //2017 1220 改成只承認第一份的
begin
//LogFile1.LogToFile(logTimeString+'有進'+docno+','+S2.Strings[n]+IntToStr(Pos(DocNo,S2.Strings[n])));
v:=Pos('(',S2.Strings[n]);
v2:=Pos(')',S2.Strings[n]);
tempInt:=StrToInt(Copy(S2.Strings[n],v+1,v2-v-1));
if docInt=0 then
begin
docInt:=tempInt;
end;
if docInt<>tempInt then
begin
//LogFile1.LogToFile(logTimeString+'docInt='+IntToStr(docInt)+',tempInt='+IntToStr(tempInt));
Result := Count;
Break;
end;
end;
FormCode := FileName2FormCode(S.Strings[n]);
//LogFile1.LogToFile(logTimeString+'S.Strings[n]='+S.Strings[n]);
//Showmessage('1:'+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
//LogFile1.LogToFile(logTimeString+'FormCode='+FormCode);
LogFile1.LogToFile(logTimeString+'CheckCaseDocNoPage caseno='+CaseID+','+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
//ShowMessage(DocNo+','+IntToStr(docInt)+','+IntToStr(tempInt));
//LogFile1.LogToFile(logTimeString+'FormCode='+FormCode);
if (version = FormCode2Version(FormCode)) and (DocNo = FormCode2DocNo(FormCode)) and (ipage = FormCode2Page(FormCode)) then
begin
LogFile1.LogToFile(logTimeString+'CheckCaseDocNoPage caseno='+CaseID+','+version+','+FormCode2Version(FormCode)+','+DocNo+','+FormCode2DocNo(FormCode)+','+iPage+','+FormCode2Page(FormCode));
//Showmessage(version+','+DocNo+',iPage='+iPage);
//Showmessage(inttostr(Count+1));
Inc(Count);
Break; //找到了...離開
end;
end;
end;
finally
S.Free;
S2.free;
end;
Result := Count;
end;
Function TCB_IMGPSScanX.TransCaseID(Path,CaseID:String;MainCase:Boolean):Boolean; //傳送案件
Var
i,n,v: Integer;
ZipFileList : TStringlist;
UpFormID:String;
pages : Integer;
TransName : String;
MaskPath : String;
HaveMask : Boolean;
S : String;
SendData:String;
Doc_Data,Doc_Data1 : String;
In_Doc1,In_Doc2 : String;
AttachYN : String; //是否有附件 Y:有 N:沒有
ST1,ST2,ST3:TStringList;
str1,str2:String;
must_formidStr :string;
last_add_formidstr :string;
ScanListStr:String;
casepath:String;
filesizeInt:integer;
case_page:string;
Fname:String;
FileRec:TSearchrec;
begin
Result := True;
TransName := CaseID;
MaskPath := Path+'MaskImg\';
if fileExists(Path+'Context.dat') then
begin
ContextList.LoadFromFile(Path+'Context.dat');
Context_DocnoList.LoadFromFile(Path+'Context_DocNo.dat');
end;
if FileExists(Path+'CustomDocNo.dat') then
Cust_DocNoList.LoadFromFile(Path+'CustomDocNo.dat');
Pages := ContextList.Count;
case_page:=IntToStr(pages);
if (FMode = 'NSCAN') or (FMode = 'ESCAN') or (FMode = 'ASCAN') or (FMode = 'DSCAN') or (FMode = 'SSCAN') or (FMode = 'MSCAN') or (FMode = 'RI_SCAN') or (FMode = 'RSCAN') then
begin
//Showmessage('1');
UpformID := GetCaseFormID(Path);
{if UpformID = '' then //20131213 yuu說不管主form
begin
Showmessage(_msg('取不到主FormID!!'));
Result := False;
DataLoading(False,False);
Exit;
end;}
end;
CaseResort2Scanlist(Path); //檔名照設定排序產生scanlist.dat
//CaseResort(Path); //檔名照設定排序
CreateFormID_FormName(Path,CaseID); //產生FormID_FormName.dat
CreateDocNo_DocName(Path,CaseID); //產生DocNo_Name.dat
Doc_Data := CreateDocNo_Info(CaseID); //產生保管袋文件 Docno,份數,頁數;Docno,份數,頁數 的回傳字串
Doc_Data1 := CreateCustDocNo_Info(CaseID); //產生自定文件 Docname,份數,頁數;Docno,份數,頁數 的回傳字串
In_Doc1 := CreateDocnoFrom_Info(CaseID); //產生被引進的保管袋文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
In_Doc2 := CreateCustDocNoFrom_Info(CaseID); //產生被引進的自定文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
AttachYN := CreateAttach_Info(CaseID); //是否還有附件 Y:有 N:沒有
ReadCaseIndex(Path);
//LoanDoc := 'Y';
//產生遮罩影像
// if FWork_No = 'CW' then
// HaveMask := Case2Mask(Path,MaskPath);
//產生遮罩影像
// S := S +#13+'5-->'+ Timetostr(now);
///////必要formid 20170315 start //////////////////////////////
must_formidStr:='';
last_add_formidstr:='';
ST1:=TStringList.Create;
ST1.LoadFromFile(path+'FormCode_Name.dat');
//ShowMessage(ST1.Text);
//ShowMessage(LastInitFormidList.Text);
ST2:=TStringList.Create;
ST3:=TStringlist.Create;
for I := 0 to ST1.Count - 1 do
begin
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);
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
if ST2.IndexOf(LastInitFormidList.Strings[i]) <> -1 then
begin
ST2.Delete(ST2.IndexOf(LastInitFormidList.Strings[i]));
end;
end;
//ShowMessage('BST2='+ST2.Text);
for I := 0 to ST2.Count - 1 do
begin
last_add_formidstr:=last_add_formidstr+ST2.Strings[i]+'@#,';
end;
last_add_formidstr:=Copy(last_add_formidstr,1,Length(last_add_formidstr)-3) ;
ST3.LoadFromFile(path+'scanlist.dat');
for I := 0 to ST3.Count - 1 do
begin
if ScanListStr = '' then
ScanListStr := FileName2FormCode(ST3.Strings[i])
else
ScanListStr := Format('%s,%s',[ScanListStr,FileName2FormCode(ST3.Strings[i])]);
end;
ST1.Free;
ST2.Free;
ST3.Free;
//ShowMessage('last_add_formidstr='+last_add_formidstr);
///////必要formid 20170315 end //////////////////////////
///保留外部影像 start///////////////////////////////
casepath:= Copy(Path,1,pos('Upload',path)-1);
//ShowMessage('casepath='+casepath);
//FIsExternal:='Y';
if (FMode='ESCAN') and (FIsExternal='Y') then
begin
if FileExists(casepath+'Download\FirstImg.zip') then
begin
CopyFile(PWChar(casepath+'Download\FirstImg.zip'),PWChar(path+'FirstImg.zip'),false);
end
else
begin
CopyFile(PWChar(casepath+'Download\'+CaseID+'.zip'),PWChar(path+'FirstImg.zip'),false);
end;
end;
///保留外部影像 end///////////////////////////////
//file_size 計算 就先不做 20170316
filesizeInt:=0;
//////壓檔/////
ZipMainFile(Path,Path,'Img.zip');
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; //目前上傳檔案大小為xxMB,已超過50MB,無法上傳 %.3f ,[FileRec.Size / 1048576]
If FileRec.Size > StrtoInt(FMaxUploadSize) * 1048576 Then // 檢查檔案大小
Begin
ShowMessage(Format(_Msg('%s目前上傳檔案大小為%.3fMB,已超過%sMB,無法上傳'),[caseid,FileRec.Size / 1048576,FMaxUploadSize]));
//ShowMessage(Format('%s目前上傳檔案大小為%.3fMB,已超過'+FMaxUploadSize+'MB,無法上傳',[caseid,FileRec.Size / 1048576]) );
FindClose(FileRec);
Result := False;
Exit;
End;
FindClose(FileRec);
///檢查上傳的zip大小////
//ShowMessage('last_add_formidstr='+last_add_formidstr);
if not GetftpInfo(CaseID,'upload') then //取案件上傳方式
begin
//Showmessage(_Msg()Inttostr(HttpError.HttpErrorCode)+' '+HttpError.HttpReason+'.');
DownFileErrStr := _Msg('取案件上傳資訊失敗!!')+HttpErrStr;
Result := False;
Exit;
end;
SendData:='data='+HTTPEncode(UTF8Encode(FData))
+'&verify='+FVerify
+'&form_id='+UpformID
+'&loan_doc='+Case_loandoc
+'&case_no='+TransName
+'&doc_data='+HTTPEncode(UTF8Encode(Doc_Data))
+'&doc_data1='+HTTPEncode(UTF8Encode(Doc_Data1))
+'&attach='+AttachYN
+'&case_page='+case_page
+'&file_size='+IntToStr(filesizeInt)
+'&must_formid='+must_formidStr //擁有的 formid
+'&last_add_formid='+last_add_formidstr //當次新加的 formid
+'&form_code='+ScanListStr //scanlist.dat 表單代號
+'&ftp_image_path='+FFtpExtraPath //加傳FTP目錄 HTTP上傳時會是空白
+'&in_doc1='+HTTPEncode(UTF8Encode(In_Doc1))
+'&in_doc2='+HTTPEncode(UTF8Encode(In_Doc2));
case TransMode of
tsHttp :
begin
////上傳/////
ShowText := CaseID+_Msg('資料上傳中(Http),請稍候');
DataLoading(True,True);
if not upFile(HTTPSClient,FUrl,'service/imgpsc/IMGPSC02/caseupload',SendData,'file',Path+'Img.zip',FReWrite,Memo1,False) then
begin
Showmessage(Inttostr(HttpError.HttpErrorCode)+' '+HttpError.HttpReason+'.');
Result := False;
Exit;
end;
if memo1.Lines.Strings[0] = '1' then
begin
Showmessage(Format(_Msg('')+_Msg(''),[CaseID])+memo1.Lines.Strings[1]+'。');
Result := False;
Exit;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
Showmessage(Format(_Msg('')+_Msg('')+_Msg('閒置過久或被登出,請重新登入'),[CaseID]));
Result := False;
Exit;
end;
////上傳////
end;
tsFtp :
begin
ShowText := CaseID+_Msg('資料上傳中(Ftp),請稍候');
DataLoading(True,True);
SetFtpInfo;
try
if not IIS_Ftp.FtpsConnect then
begin
Showmessage(Format('無法連上Ftp主機,錯誤原因:%s',[FtpErrReason]));
Result := False;
Exit;
end;
if not IIS_Ftp.FtpsToMain(FFtpExtraPath,CaseID+'.zip',Path+'Img.zip',display1) then
begin
Showmessage(Format(_msg('上傳案件(%s)時,發生錯誤,錯誤原因:%s'),[CaseID,FtpErrStr]));
Result := False;
Exit;
end;
if not FtpCaseComplete(SendData) then //Ftp上傳後通知完成
begin
Showmessage(Format(_Msg('通知案件(%s)Ftp上傳完成時,發生錯誤!!'),[CaseID])+HttpErrStr);
Result := False;
Exit;
end;
finally
IIS_Ftp.FtpsClose;
end;
end;
end;
if FMode = 'ESCAN' then //上傳舊件引入檔案 //20140616 原本先搬舊件再搬新件,改為先搬新件再搬舊件
begin
if not TransOldCaseFile(ImageSavePath+CaseID+'\') then
begin
Result := False;
Exit;
end;
end;
// 呼叫Server完成 /////
{If not CaseComplete(Path,CaseID,MainCase) Then
begin
Showmessage(_Msg('通知案件傳送完成時,網路發生錯誤!!')+HttpErrStr);
DataLoading(False,False);
Result := False;
Exit;
end; }
/// 呼叫Server完成////
////刪檔////
//_DelTree(Path); //會只刪TransPath
//ShowMessage('STOP');
_DelTree(ImageSavePath+CaseID);
SetCaseList('D',-1,CaseID);
////刪檔////
end;
Function TCB_IMGPSScanX.GetNoNameCase(Path:String):String; //取未配號XXXX
var
i : Integer;
begin
for i := 1 to 9999 do
begin
if Not DirectoryExists(Path+_Msg('未配號')+Add_Zoo(i,4)) then
begin
Result := _Msg('未配號')+Add_Zoo(i,4);
Break;
end;
end;
end;
Procedure TCB_IMGPSScanX.CaseResort(Path:String); //案件的檔案重新排序(次文件依Docno排)
var
i,n,v,v1 : Integer;
S,S1 : TStringlist;
FormID,OldName,NewName,DocNo,Doc_Type:String;
x : Integer;
begin
S := TStringlist.Create;
S1 := TStringlist.Create;
try
S.LoadFromFile(Path+'Context.dat');
X := 0;
{for I := 1 to FORM_INF_List.Count - 1 do //在FormID有設定的 //主文件 照SQL排 20101028改
begin
FormID := GetSQLData(FORM_INF_List,'T1.FORM_ID',i);
if FormCode2FileName(FormID,S) = '' then
Continue;
Doc_Type := GetSQLData(FORM_INF_List,'T2.DOC_TYPE',i);
for n := 0 to S.Count - 1 do
begin
if (S.Strings[n][1] <> '*') and (FileName2FormCode(S.Strings[n]) = FormID) and (Doc_Type='1') then
begin
Inc(X);
OldName := S.Strings[n];
//NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3); //從原有數量加1開始編
NewName := Add_Zoo(S.Count+x,3)+FileName2NoQuene_Filename(OldName); //從原有數量加1開始編
S.Strings[n] := '*'+S.Strings[n];
S1.Add(OldName+','+NewName);
end;
end;
end;}
{for I := 0 to FORM_INF_List.Count - 1 do //次文件 照FormID 1~8碼+掃瞄順序排 20110512為了某個文件要先打的原因要求改
begin
for n := 0 to S.Count - 1 do
begin
FormID := GetSQLData(FORM_INF_List,'T1.FORM_ID',i);
Doc_Type := GetSQLData(FORM_INF_List,'T2.DOC_TYPE',i);
if (S.Strings[n][1] <> '*') and (Copy(FileName2FormCode(S.Strings[n]),1,8) = Copy(FormID,1,8)) and (Doc_Type='2') then
begin
Inc(X);
OldName := S.Strings[n];
NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3); //從原有數量加1開始編
S.Strings[n] := '*'+S.Strings[n];
S1.Add(OldName+','+NewName);
end;
end;
end;}
for I := 0 to Doc_Inf_List.Count - 1 do //主文件 照文件代碼+掃瞄順序排 20101101改 20110512晚上又說改回來
begin
DocNo := GetSQLData(Doc_Inf_List,'DOC_NO',i);
if DocNo2FileName(DocNo,S) = '' then
Continue;
Doc_Type := GetSQLData(Doc_Inf_List,'DOC_TYPE',i);
for n := 0 to S.Count - 1 do
begin
if (S.Strings[n][1] <> '*') and (FormCode2DocNo(FileName2FormCode(S.Strings[n])) = DocNo) and (Doc_Type='1') then
begin
Inc(X);
OldName := S.Strings[n];
//NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3); //從原有數量加1開始編
NewName := Add_Zoo(S.Count+x,3)+FileName2NoQuene_Filename(OldName); //從原有數量加1開始編
S.Strings[n] := '*'+S.Strings[n];
S1.Add(OldName+','+NewName);
end;
end;
end;
for I := 0 to Doc_Inf_List.Count - 1 do //次文件 照文件代碼+掃瞄順序排 20101101改 20110512晚上又說改回來
begin
DocNo := GetSQLData(Doc_Inf_List,'DOC_NO',i);
if DocNo2FileName(DocNo,S) = '' then
Continue;
Doc_Type := GetSQLData(Doc_Inf_List,'DOC_TYPE',i);
for n := 0 to S.Count - 1 do
begin
if (S.Strings[n][1] <> '*') and (FormCode2DocNo(FileName2FormCode(S.Strings[n])) = DocNo) and (Doc_Type='2') then
begin
Inc(X);
OldName := S.Strings[n];
//NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3); //從原有數量加1開始編
NewName := Add_Zoo(S.Count+x,3)+FileName2NoQuene_Filename(OldName); //從原有數量加1開始編
S.Strings[n] := '*'+S.Strings[n];
S1.Add(OldName+','+NewName);
end;
end;
end;
{for n := 0 to S.Count - 1 do //次文件 照掃瞄順序排 20101028改
begin
FormID := GetSQLData(FORM_INF_List,'T1.FORM_ID',i);
Doc_Type := GetSQLData(FORM_INF_List,'T2.DOC_TYPE',i);
for i := 0 to FORM_INF_List.Count - 1 do
begin
if (S.Strings[n][1] <> '*') and (FileName2FormCode(S.Strings[n]) = FormID) and (Doc_Type='2') then
begin
Inc(X);
OldName := S.Strings[n];
NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3); //從原有數量加1開始編
S.Strings[n] := '*'+S.Strings[n];
S1.Add(OldName+','+NewName);
end;
end;
end;}
for i := 0 to S.Count - 1 do //FormID沒設定的或附件
begin
if S.Strings[i][1] <> '*' then
begin
Inc(X);
OldName := S.Strings[i];
//NewName := Add_Zoo(S.Count+x,3)+Copy(OldName,4,length(OldName)-3);
NewName := Add_Zoo(S.Count+x,3)+FileName2NoQuene_Filename(OldName);
S.Strings[i] := '*'+S.Strings[i];
S1.Add(OldName+','+NewName);
end;
end;
S.Clear;
for i := 0 to S1.Count - 1 do //開始轉換檔名
begin
v := Pos(',',S1.Strings[i]);
v1 := length(S1.Strings[i]);
OldName := copy(S1.Strings[i],1,v-1);
NewName := copy(S1.Strings[i],v+1,v1-v);
if FileExists(Path+OldName) then
begin
ReNameFile(Path+OldName,Path+NewName);
S.Add(NewName);
S.SaveToFile(Path+'Context.dat');
end;
end;
ReSortFileName(Path);
finally
S.Free;
S1.Free;
end;
end;
Procedure TCB_IMGPSScanX.DistinctDocinCase(Path:String); //列出案件裡的Docno_版本
var
i,n,v : Integer;
S : TStringlist;
FormCode,DocNo,Ver : String;
Doc_Ver : String;
Exists : Boolean;
begin
S := TSTringlist.Create;
try
DocNo_VerinCase.Clear;
S.LoadFromFile(Path+'Context.dat');
for I := 0 to S.Count - 1 do
begin
if FWH_category='N' then
begin
if (ISExistImg(Path+S.Strings[i])) or (reSizeExistImgList.IndexOf(LoadFileGetMD5(Path+S.Strings[i]))<>-1) then
begin
Continue;
end;
end;
FormCode := FileName2FormCode(S.Strings[i]);
DocNo := FormCode2DocNo(FormCode);
Ver := FormCode2Version(FormCode);
if (Docno <> '') and (Ver <> '') then
begin
Doc_Ver := DocNo+'_'+Ver;
Exists := False;
for n := 0 to DocNo_VerinCase.Count-1 do
begin
if Doc_Ver = DocNo_VerinCase.Strings[n] then
begin
Exists := True;
Break;
end;
end;
if not Exists then
DocNo_VerinCase.Add(Doc_Ver);
end;
end;
finally
S.Free;
end;
end;
Procedure TCB_IMGPSScanX.DistinctDocNoinCase(Path:String); //列出案件裡的Docno
var
i,n,v : Integer;
S : TStringlist;
FormCode,DocNo,Ver : String;
Exists : Boolean;
begin
S := TSTringlist.Create;
try
CaseDocNoList.Clear;
S.LoadFromFile(Path+'Context.dat');
for I := 0 to S.Count - 1 do
begin
FormCode := FileName2FormCode(S.Strings[i]);
DocNo := FormCode2DocNo(FormCode);
if (Docno <> '') then
begin
Exists := False;
for n := 0 to CaseDocNoList.Count-1 do
begin
if DocNo = CaseDocNoList.Strings[n] then
begin
Exists := True;
Break;
end;
end;
if not Exists then
CaseDocNoList.Add(DocNo);
end;
end;
finally
S.Free;
end;
end;
Procedure TCB_IMGPSScanX.SetCaseList(Mode:Char;Index:Integer;text:String); //'A:加入,I:插入,D:刪除,E:修改'
var
i : Integer;
begin
CaseList.Clear;
if FileExists(ImageSavePath + 'CaseList.dat') then
CaseList.LoadFromFile(ImageSavePath + 'CaseList.dat');
case Mode of
'A':begin
CaseList.Add(Text);
end;
'I':begin
CaseList.Insert(Index,Text);
end;
'E':begin
CaseList.Strings[Index] := Text;
end;
'D':begin
if Index <> -1 then
CaseList.Delete(Index)
Else if (text <> '') then
begin
for i := 0 to CaseList.Count - 1 do
begin
if Text = CaseList.Strings[i] then
begin
CaseList.Delete(i);
Break;
end;
end;
end;
if CaseList.Count = 0 then
DeleteFile(ImageSavePath + 'CaseList.dat');
end;
end;
if CaseList.Count > 0 then
CaseList.SaveToFile(ImageSavePath+'CaseList.dat');
end;
Procedure TCB_IMGPSScanX.SetDocNoList(Mode:Char;Index:Integer;CaseNo,DocDir,Copies:String); //'A:加入,I:插入,D:刪除,E:修改'
var
i : Integer;
CaseDocNoList : TStringlist;
CaseDocNo_copiesList : TStringlist;
begin
CaseDocNoList := TStringlist.Create;
CaseDocNo_CopiesList := TStringlist.Create;
try
CaseDocNoList.Clear;
if FileExists(ImageSavePath+CaseNo+'\CaseDocNo.dat') then
CaseDocNoList.LoadFromFile(ImageSavePath+CaseNo+'\CaseDocNo.dat');
if FileExists(ImageSavePath+CaseNo+'\CaseDocNo_Copies.dat') then
CaseDocNo_CopiesList.LoadFromFile(ImageSavePath+CaseNo+'\CaseDocNo_Copies.dat');
case Mode of
'A':begin
CaseDocNoList.Add(DocDir);
CaseDocNo_CopiesList.Add(Copies);
SetRecordEditedDocDir('A',CaseNo,DocDir);
end;
'I':begin
CaseDocNoList.Insert(Index,DocDir);
CaseDocNo_CopiesList.Insert(Index,Copies);
end;
'E':begin
CaseDocNoList.Strings[Index] := DocDir;
CaseDocNo_CopiesList.Strings[Index] := Copies;
end;
'D':begin
if Index <> -1 then
begin
//SetRecordEditedDocDir('D',CaseNo,CaseDocNoList.Strings[Index]); //20140624 修改刪除文件時也記一筆異動,刪掉會無法通知前端網頁有異動
SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[Index]); //20170912 要刪除 不然我寫不下去
CaseDocNoList.Delete(Index);
CaseDocNo_CopiesList.Delete(Index);
end
Else if (DocDir <> '') then
begin
for i := 0 to CaseDocNoList.Count - 1 do
begin
if DocDir = CaseDocNoList.Strings[i] then
begin
//SetRecordEditedDocDir('D',CaseNo,CaseDocNoList.Strings[i]); //20140624 修改刪除文件時也記一筆異動,刪掉會無法通知前端網頁有異動
SetRecordEditedDocDir('A',CaseNo,CaseDocNoList.Strings[i]); //20170912 要刪除 不然我寫不下去
CaseDocNoList.Delete(i);
CaseDocNo_CopiesList.Delete(i);
Break;
end;
end;
end;
if ContextList.Count = 0 then
begin
DeleteFile(ImageSavePath+CaseNo+'\CaseDocNo.dat');
end;
end;
end;
//Showmessage('abc'+#13+ImageSavePath+CaseNo+'\CaseDocNo.dat'+#13+inttostr(CaseDocNoList.Count)+#13+CaseDocNoList.Text);
if CaseDocNoList.Count >= 0 then
begin
CaseDocNoList.SaveToFile(ImageSavePath+CaseNo+'\CaseDocNo.dat');
CaseDocNo_CopiesList.SaveToFile(ImageSavePath+CaseNo+'\CaseDocNo_Copies.dat');
//Showmessage('存了');
end;
finally
CaseDocNoList.Free;
CaseDocNo_CopiesList.Free;
end;
end;
Function TCB_IMGPSScanX.checkCaseOMRDone:Boolean; //檢查案件是否完成OMR檢核
var
i : Integer;
begin
Result := True;
for I := 0 to NewTreeNode.Count - 1 do
begin
if NewTreeNode.Item[i].ImageIndex <> 7 then
begin
Result := False;
Break;
end;
end;
end;
Function TCB_IMGPSScanX.CheckCaseID_OK:Boolean; //檢查是否有未配號的案件
var
i,n : Integer;
begin
Result := True;
for i := 0 to NewTreeNode.Count - 1 do
begin
if Pos(_msg('未配號'),NewTreeNode.Item[i].Text) > 0 then
begin
Result := False;
Break;
end;
end;
end;
Function TCB_IMGPSScanX.CheckCaseAttach_OK:Boolean; //檢查是否有未歸類的案件
var
i,j : Integer;
begin
Result := True;
for i := 0 to NewTreeNode.Count - 1 do
begin
for j := 0 to NewTreeNode.Item[i].Count - 1 do
begin
if Pos(_msg('未歸類'),NewTreeNode.Item[i].Item[j].Text) > 0 then
begin
Result := False;
Break;
end;
end;
end;
end;
Procedure TCB_IMGPSScanX.CreateEmptyCase(Path,CaseID:String); //產生空白案號(重掃件用)
var
S : TStringlist;
begin
S := TStringlist.Create;
try
S.SaveToFile(Path+CaseID+'\Context.dat');
S.Add(FCaseID);
S.SaveToFile(Path+'CaseList.dat')
finally
S.Free;
end;
end;
Procedure TCB_IMGPSScanX.ShowFileReplace(Path,NewFormID:String);//顯示的影像換成新的FormID
var
i,n : Integer;
OldFile,NewFile:String;
Ext : String;
begin
for i := 0 to NowShowFileList.Count - 1 do
begin
OldFile := NowShowFileList.Strings[i];
Ext := ExtractFileExt(OldFile);
NewFile := Add_Zoo(FileName2ScanPage(OldFile),3)+'_'+NewFormID+Ext;
ReNameFile(Path+OldFile,Path+NewFile);
SetContextList('E',FileName2Index(OldFile),NowCaseno,NowDocNo,NewFile);
end;
end;
Function TCB_IMGPSScanX.GetCasePage(Path,CaseID:String):Integer;
var
DocDirList,FileList,ST1 :TStringlist;
iDocDir,iDocNo : String;
i,n,Count : Integer;
begin
Count := 0;
DocDirList := TStringlist.Create;
FileList := TStringlist.Create;
ST1:=TStringList.Create;
try
if FileExists(Path+CaseID+'\CaseDocNo.dat') then
DocDirList.LoadFromFile(Path+CaseID+'\CaseDocNo.dat');
//Showmessage(DocDirList.Text);
for i := 0 to DocDirList.Count - 1 do
begin
iDocDir := DocDirList.Strings[i];
iDocno := DocNoDir2DocNo(iDocDir);
{if (((FIs_In_Wh = 'Y') and (not DocNoIs_In_WH(iDocNo))) or //入庫掃描不看非入庫文件
((FIs_In_Wh = 'N') and (DocNoIs_In_WH(iDocNo)))) and
((iDocNo <> 'Attach') and (Copy(iDocNo,1,5)<>'ZZZZZ')) then //非入庫掃描不看入庫文件
begin
Continue;
end;}
//if not DocNoAppear(iDocNo) then Continue; //20170817 先註解
FileList.Clear;
if FileExists(Path+CaseID+'\'+iDocDir+'\Context.dat') then
begin
FileList.LoadFromFile(Path+CaseID+'\'+iDocDir+'\Context.dat');
if (FWH_category='N') and (FIs_In_Wh='Y') then
begin
ST1.Clear;
for n := 0 to FileList.Count - 1 do
begin
if ISExistImg(Path+CaseID+'\'+iDocDir+'\'+FileList.Strings[n]) then
begin
ST1.Add(FileList.Strings[n]);
end;
end;
for n := 0 to ST1.Count - 1 do
begin
if (FileList.IndexOf(ST1.Strings[n])<>-1) and (not DocNoIs_In_WH(iDocNo)) then
begin
FileList.Delete(FileList.IndexOf(ST1.Strings[n]));
end;
end;
end
Else
if not DocNoAppear(iDocNo) then Continue; //20180925 Hong覺得應該要加這段
end;
Count := Count+ FileList.Count;
end;
if FileExists(Path+CaseID+'\'+AttName+'\Context.dat') then
begin
FileList.LoadFromFile(Path+CaseID+'\'+AttName+'\Context.dat');
Count := Count+ FileList.Count;
end;
Result := Count;
finally
DocDirList.Free;
FileList.Free;
ST1.free;
end;
end;
Procedure TCB_IMGPSScanX.SetFile2Case(CaseID,FileName:String);
var
S :TStringlist;
begin
S := TStringlist.Create;
try
S.LoadFromFile(ImageSavePath+CaseID+'\Context.dat');
S.Add(FileName);
S.SaveToFile(ImageSavePath+CaseID+'\Context.dat');
finally
S.Free;
end;
end;
Function TCB_IMGPSScanX.GetCase_PageCount(var CaseCount,PageCount:Integer):Boolean; //取出案件的數量及頁數
var
i,n,k: Integer;
CaseList,DocList,FileList,ST1 : TStringlist;
begin
Result := False;
CaseCount := 0;
PageCount := 0;
CaseList := TStringlist.Create;
DocList := TStringlist.Create;
FileList := TStringlist.Create;
ST1:= TStringlist.Create;
try
ImageSavePath := ImagePath;
CaseList.Clear;
if FileExists(ImageSavePath + 'CaseList.dat') then
CaseList.LoadFromFile(ImageSavePath + 'CaseList.dat');
CaseCount := CaseCount+CaseList.Count;
//ShowMessage('ImageSavePath='+ImageSavePath+#10#13+'CaseList.Count='+IntToStr(CaseList.Count));
for i := 0 to CaseList.Count - 1 do
begin
DocList.Clear;
If FileExists(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat') Then
DocList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat');
//ShowMessage('DocList='+DocList.Text);
for n := 0 to DocList.Count - 1 do
begin
//ShowMessage(DocList.Strings[n]+','+BoolToStr(DocNoAppear(DocNoDir2DocNo(DocList.Strings[n])),true));
if not DocNoAppear(DocNoDir2DocNo(DocList.Strings[n])) then Continue;
FileList.Clear;
If FileExists(ImageSavePath+CaseList.Strings[i]+'\'+DocList.Strings[n]+'\Context.dat') Then
FileList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\'+DocList.Strings[n]+'\Context.dat');
PageCount := PageCount+FileList.Count;
end;
//Showmessage(inttostr(PageCount));
FileList.Clear;
If FileExists(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat') Then
FileList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat');
//Showmessage(ImageSavePath+CaseList.Strings[i]+'\'+Attname+'\Context.dat');
//Showmessage('FileList='+FileList.Text);
PageCount := PageCount+FileList.Count;
//Showmessage('PageCount='+inttostr(PageCount));
if (FWH_category='N') and (FIs_In_Wh='Y') then //20170912 針對非入庫並當次掃描做頁數計算
begin
if FileExists(ImageSavePath+NowCaseno+'\EditedDocDir.dat') then
begin
ST1.LoadFromFile(ImageSavePath+NowCaseno+'\EditedDocDir.dat');
for n := 0 to ST1.Count - 1 do
begin
if ST1.Strings[n]=AttName then Continue;
//ShowMessage(ST1.Strings[n]+','+BoolToStr(DocNoIs_In_WH(DocNoDir2DocNo(ST1.Strings[n])),true));
if not DocNoIs_In_WH(DocNoDir2DocNo(ST1.Strings[n])) then
begin
FileList.Clear;
if FileExists(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\Context.dat') then
begin
FileList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\Context.dat');
for k := 0 to FileList.Count - 1 do
begin
if not ISExistImg(ImageSavePath+CaseList.Strings[i]+'\'+ST1.Strings[n]+'\'+FileList.Strings[k]) then
PageCount := PageCount+1;
end;
end;
end;
end;
end;
end;
end;
Finally
CaseList.Free;
DocList.Free;
FileList.Free;
ST1.Free
end;
Result := True;
end;
Function TCB_IMGPSScanX.BarCode2CaseID : String; //Barcode依規則轉成CaseID
var
i : Integer;
iCaseID : String;
begin
Result := ''; //沒找到
iCaseID := '';
for i := 1 to MpsBarcodeinf.Count do //20180920 拿掉-1
begin
if (Length(MpsBarcodeinf.text[i]) = CaseIDLength) then
begin
iCaseID := MpsBarcodeinf.text[i];
Result := iCaseID;
Break;
end;
end;
end;
Procedure TCB_IMGPSScanX.WriteCaseIndex(Path:String);
Var
S : TStringlist;
begin
if Path = '' then Exit;
S := TStringlist.Create;
try
try
S.Add(Case_loandoc);
S.SaveToFile(Path+'CaseIndex.dat');
except on E: Exception do
end;
finally
S.Free;
end;
end;
Procedure TCB_IMGPSScanX.ReadCaseIndex(Path:String);
Var
S : TStringlist;
begin
AddCredit1RG.ItemIndex := -1;
S := TStringlist.Create;
try
if FileExists(Path+'CaseIndex.dat') then
begin
S.LoadFromFile(Path+'CaseIndex.dat');
Case_loandoc := S.Strings[0];
end;
if (Case_loandoc = '') and (FLoanDoc_Value <> '') then
begin
Case_loandoc := FLoanDoc_Value;
WriteCaseIndex(Path);
end;
if Case_loandoc = 'Y' then
AddCredit1RG.ItemIndex := 0
Else if Case_loandoc = 'N' then
AddCredit1RG.ItemIndex := 1;
finally
S.Free;
end;
end;
procedure TCB_IMGPSScanX.ReduceLogFile; //20171011 必免log檔掌太大
var
ST1:TStringlist;
I:integer;
begin
ST1:=TStringList.Create;
if FileExists(LngPath+'IMGPSCheck.log') then
begin
ST1.LoadFromFile(LngPath+'IMGPSCheck.log');
if ST1.count>100000 then
begin
for I := 0 to 10000 do
begin
ST1.Delete(0);
end;
ST1.SaveToFile(LngPath+'IMGPSCheck.log');
end;
end;
ST1.Free;
end;
Procedure TCB_IMGPSScanX.ClearCaseIndex;
begin
AddCredit1RG.Enabled := False;
AddCredit1RG.ItemIndex := -1;
end;
Function TCB_IMGPSScanX.GetDocNoDir(Path,DocNo:String):String; //取出目前DocNo的份數
var
i : Integer;
iDocNo : String;
begin
if (DocNo <> '') then
begin
i := 0;
Repeat
begin
inc(i);
iDocNo := Format('%s_%d',[DocNo,i]);
end;
until not DirectoryExists(Path+iDocNo);
Result := iDocNo;
end
Else
begin
Result := AttName;
end;
end;
Function TCB_IMGPSScanX.DocNo2DocNoDir(Path,DocNo:String):String; //DocNo轉成DocNo(份數)目錄
var
i : Integer;
iDocNo : String;
begin
if (DocNo <> '') then
begin
i := 0;
Repeat
begin
inc(i);
iDocNo := Format('%s(%d)',[DocNo,i]);
end;
until not DirectoryExists(Path+iDocNo);
Result := iDocNo;
end
Else
begin
Result := AttName;
end;
end;
Function TCB_IMGPSScanX.DocNoDir2DocNo(DocNoDir:String):String; //DocNo(份數)目錄轉成DocNo
var
v,ln : Integer;
begin
if (DocNoDir <> 'Attach') and (DocNoDir <> 'S_Attach') then
begin
v := Pos('(',DocNoDir);
if v > 0 then
Result := Copy(DocNoDir,1,v-1)
else
Result := DocNoDir;
end
Else
Result := DocNoDir
end;
Function TCB_IMGPSScanX.DocNoDir2Index(Path,DocNoDir:String):Integer; //DocNo(份數)目錄轉成index
var
i : Integer;
CaseNo_List : TStringlist;
begin
Result := -1;
CaseNo_List := TStringlist.Create;
try
CaseNo_List.LoadFromFile(Path+'CaseDocNo.dat');
for i := 0 to CaseNo_List.Count - 1 do
begin
if DocNoDir = CaseNo_List.Strings[i] then
begin
Result := i;
Break;
end;
end;
finally
CaseNo_List.Free;
end;
end;
Procedure TCB_IMGPSScanX.ZipMainFile(SoPath,DePath,ZipName:String);
var
ZipFileList : TStringlist;
n : Integer;
begin
ZipFileList := TStringlist.Create;
try
if fileExists(DePath+ZipName) then
DeleteFile(DePath+ZipName);
{if FileExists(SoPath+'ReSize.dat') then
DeleteFile(SoPath+'ReSize.dat');}
//Showmessage(SoPath+#13+ContextList.Text);
for n := 0 to ContextList.Count - 1 do
begin
{WriteResize(SoPath+ContextList.Strings[n],SoPath+'ReSize.dat');}
ZipFileList.Add(SoPath+ContextList.Strings[n]);
if FileExists(SoPath+'@'+ContextList.Strings[n]) then
ZipFileList.Add(SoPath+'@'+ContextList.Strings[n]);
end;
if FileExists(SoPath+'Context.dat') then
ZipFileList.Add(SoPath+'Context.dat');
AttContextList.Clear;
if FileExists(SoPath+'ATTContext.dat') then
AttContextList.LoadFromFile(SoPath+'ATTContext.dat');
for n := 0 to AttContextList.Count - 1 do
begin
ZipFileList.Add(SoPath+AttContextList.Strings[n]);
end;
if FileExists(SoPath+'ATTContext.dat') then
ZipFileList.Add(SoPath+'ATTContext.dat');
if FileExists(SoPath+'Context_DocNo.dat') then
ZipFileList.Add(SoPath+'Context_DocNo.dat');
if FileExists(SoPath+'scanlist.dat') then
ZipFileList.Add(SoPath+'scanlist.dat');
if FileExists(SoPath+'FormCode_Name.dat') then
ZipfileList.Add(SoPath+'FormCode_Name.dat');
if FileExists(SoPath+'DocNo_Name.dat') then
ZipfileList.Add(SoPath+'DocNo_Name.dat');
if FileExists(SoPath+'ReSize.dat') then
ZipfileList.Add(SoPath+'ReSize.dat');
if FileExists(SoPath+'FormIDReplace.dat') then
ZipfileList.Add(SoPath+'FormIDReplace.dat');
if FileExists(SoPath+'AnchorError.dat') then
ZipfileList.Add(SoPath+'AnchorError.dat');
if FileExists(SoPath+'CaseDocNo.dat') then
ZipfileList.Add(SoPath+'CaseDocNo.dat');
if FileExists(SoPath+'CaseDocNo_Copies.dat') then
ZipfileList.Add(SoPath+'CaseDocNo_Copies.dat');
if FileExists(SoPath+'CustomDocNo.ini') then
ZipfileList.Add(SoPath+'CustomDocNo.ini');
if FileExists(SoPath+'DocDir.dat') then
ZipfileList.Add(SoPath+'DocDir.dat');
if FileExists(SoPath+'In_Wh.dat') then
ZipfileList.Add(SoPath+'In_Wh.dat');
if FileExists(SoPath+'UseCase.ini') then
ZipfileList.Add(SoPath+'UseCase.ini');
if FileExists(SoPath+'FirstImg.zip') then//20170315 加的
begin
ZipfileList.Add(SoPath+'FirstImg.zip');
end;
ExeCuteZip(DePath+ZipName,SoPath,ZipFileList,False,False);
//Showmessage('111');
finally
ZipFileList.Free;
end;
end;
Procedure TCB_IMGPSScanX.ZipMaskFile(SoPath,MarkPath,DePath,ZipName:String); //壓縮遮罩影像檔
var
ZipFileList : TStringlist;
n : Integer;
begin
ZipFileList := TStringlist.Create;
try
if fileExists(DePath+ZipName) then
DeleteFile(DePath+ZipName);
for n := 0 to ContextList.Count - 1 do
begin
ZipFileList.Add(MarkPath+ContextList.Strings[n]);
end;
if FileExists(SoPath+'Context.dat') then
ZipFileList.Add(SoPath+'Context.dat');
if FileExists(SoPath+'scanlist.dat') then
ZipFileList.Add(SoPath+'scanlist.dat');
if FileExists(SoPath+'FormCode_Name.dat') then
ZipfileList.Add(SoPath+'FormCode_Name.dat');
if FileExists(SoPath+'DocNo_Name.dat') then
ZipfileList.Add(SoPath+'DocNo_Name.dat');
if FileExists(SoPath+'ReSize.dat') then
ZipfileList.Add(SoPath+'ReSize.dat');
if FileExists(SoPath+'Err.jpg') then
ZipfileList.Add(SoPath+'Err.jpg');
if FileExists(SoPath+'auth.jpg') then
ZipfileList.Add(SoPath+'auth.jpg');
ExeCuteZip(DePath+ZipName,SoPath,ZipFileList,False,False);
finally
ZipFileList.Free;
end;
end;
Function TCB_IMGPSScanX.MemoInfoTransfer(Mode,Str:String;ID_S,Name_S:TStringlist):String; //註記代碼註記類別轉換 Mode 'ID':代碼轉名稱;'NAME':名稱轉代碼
var
i : Integer;
begin
if Mode = 'ID' then
begin
Result := _Msg('自行輸入');
for i := 0 to ID_S.Count - 1 do
begin
if Str = ID_S.Strings[i] then
begin
Result := Name_S.Strings[i];
Break;
end;
end;
end
else if Mode = 'NAME' then
begin
Result := '00';
for i := 0 to Name_S.Count - 1 do
begin
if Str = Name_S.Strings[i] then
begin
Result := ID_S.Strings[i];
Break;
end;
end;
end;
end;
Procedure TCB_IMGPSScanX.SetSQLData(ColumeStr:String;FromList,ToList:TStringlist); //把SQL值塞入
var
i : Integer;
begin
ToList.Clear;
ToList.Add(ColumeStr);
For i := 1 to FromList.Count -1 do
begin
ToList.Add(FromList.Strings[i]);
end;
end;
Function TCB_IMGPSScanX.GetSQLData(TableList:TStringlist;Colname:String;colNo:Integer):String; //依欄位及索引取值
var
i,col,v,v1 : Integer;
ColStr,DataStr: TStringList;
TmpStr : String;
P1,p2 : Integer;
begin
Result := '';
ColStr := TStringList.Create;
DataStr := TSTringList.Create;
ColStr.CommaText := TableList.Strings[0];
TmpStr := TableList.Strings[ColNo];
//DataStr.Text:=StringReplace(TmpStr,'!@!',#13,[rfReplaceAll]);
While Length(Tmpstr) > 0 do
begin
v:= Pos('!@!',TmpStr);
v1 := Length(TmpStr);
If v > 0 Then
begin
DataStr.Add(Copy(TmpStr,1,v-1));
TmpStr := Copy(TmpStr,v+3,V1-(V-2));
end
Else
begin
DataStr.Add(TmpStr);
TmpStr := '';
end;
end;
For i := 0 to ColStr.Count-1 do
begin
IF ColStr.Strings[i] = ColName Then
begin
Result := '';
If (DataStr.Count > 0) and (i<=DataStr.Count-1) Then
Result := DataStr.Strings[i];
//If (DataStr.Count > 0) and (i<=DataStr.Count-1) Then
//begin
{if i = 0 then
begin
P1 := 1;
p2 := PosN('!@!',TmpStr,1)-1;
end
else
begin
P1 := PosN('!@!',TmpStr,i)+3;
p2 := PosN('!@!',TmpStr,i+1)-p1;
end;
Result :=Copy(tmpstr,p1,p2);}
//end;
//Result := DataStr.Strings[i];
Break;
end;
end;
ColStr.Free;
DataStr.Free;
end;
Function TCB_IMGPSScanX.FindSQLData(TableList:TStringlist;ColumeStr,KeyColumeStr,KeyStr:String;ColNo:Integer;Var ResultList:TStringlist):Boolean; //找指定的資料
Var i,n,Findindex : Integer;
ColList,KeyColList,KeyList : TStringlist;
Cols,Keycols,keys :String;
Find:Boolean;
begin
ResultList.Clear;
if (KeyStr = '') or (TableList.Count <= 1) then
begin
Result := False;
Exit;
end;
ColList := TStringlist.Create;
KeyColList := TStringlist.Create;
KeyList := TStringlist.Create;
try
ColList.CommaText := ColumeStr;
KeyColList.CommaText := KeyColumeStr;
KeyList.CommaText := KeyStr;
if ColNo = 0 then
begin
for i := 1 to TableList.Count -1 do //找key對不對
begin
Findindex := i;
for n := 0 to KeyColList.Count - 1 do
begin
Find := True;
Keycols := KeyColList.Strings[n];
keys := KeyList.Strings[n];
//Showmessage(keys);
//Showmessage(TableList.Strings[i]);
if GetSQLData(TableList,Keycols,i) = keys then //對.繼續
//if Pos('!@!'+keys+'!@!','!@!'+TableList.Strings[i]+'!@!') >0 then //在資料列前後加!@! 用pos的方式來改善速度 //20130521發現找資料會有問題
Continue
Else //不對.離開
begin
Find := False;
Break;
end;
end;
if Find then Break; // 找到了離開
end;
end
Else
begin
i := ColNo;
Findindex := i;
for n := 0 to KeyColList.Count - 1 do
begin
Find := True;
Keycols := KeyColList.Strings[n];
keys := KeyList.Strings[n];
//if GetSQLData(TableList,Keycols,i) = keys then //對.繼續
if Pos('!@!'+keys+'!@!','!@!'+TableList.Strings[i]+'!@!') >0 then //在資料列前後加!@! 用pos的方式來改善速度
Continue
Else //不對.離開
begin
Find := False;
Break;
end;
end;
end;
if Find then //有找到key
begin
for n := 0 to ColList.Count -1 do
begin
Cols := ColList.Strings[n];
ResultList.Add(Cols+','+GetSQLData(TableList,Cols,Findindex));
end;
end;
finally
Result := Find;
ColList.Free;
KeyColList.Free;
KeyList.Free;
end;
end;
Procedure TCB_IMGPSScanX.DataLoading(Loading:Boolean;UseTimer:Boolean); //資料載入中要停止點選的動作
begin
If Loading Then
begin
Screen.Cursor := -11;
if UseTimer then
begin
Panel22.Caption := ShowText;
Panel22.Left := (Panel9.Width div 2) - (Panel22.Width div 2);
Panel22.Top := (Panel9.Height div 2) - (Panel22.Height div 2);
Panel22.Visible := True;
Timer2.Enabled := True;
end
Else
begin
Panel8.Left := (Panel9.Width div 2) - (Panel8.Width div 2);
Panel8.Top := (Panel9.Height div 2) - (Panel8.Height div 2);
Panel8.Visible := True;
end;
Application.ProcessMessages;
Panel1.Enabled := False;
Panel2.Enabled := False;
end
Else
begin
Panel22.Visible := False;
Panel8.Visible := False;
Timer2.Enabled := False;
Panel1.Enabled := True;
Panel2.Enabled := True;
Screen.Cursor := 0;
end;
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;
CasePage : integer;
TempName : String;
BarName : String;
DocName : String;
//S : String;
begin
ClearView(1);
PageLV.Clear;
AttListBox.Items.Clear;
AddAttFileLB.Enabled := False;
DelAttFileLB.Enabled := False;
DisplayPath := '';
ClearCaseIndex;
CaseHelpBtn.Visible := False;
//Del_Sub_NothingPath(ImageSavePath); //清掉案件目錄是空的
TreeView1.Items.Clear;
NewTreeNode := nil;
MyTreenode1 := nil;
MyTreenode2 := nil;
MyTreenode3 := nil;
NewTreeNode := TreeView1.Items.Add(nil,Format(_Msg('%s-共%d筆共%d頁'),[FModeName,0,0]));
NewTreenode.ImageIndex := 0;
NewTreenode.SelectedIndex := 0;
Del_Sub_NothingPath(ImageSavePath); //清掉案件目錄是空的
GetCase_PageCount(CaseCount,PageCount);
CaseList.Clear;
if FileExists(ImageSavePath + 'CaseList.dat') then
CaseList.LoadFromFile(ImageSavePath + 'CaseList.dat');
for i := 0 to CaseList.Count - 1 do
begin
CaseDocNoList.Clear;
if FileExists(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat') then
CaseDocNoList.LoadFromFile(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo.dat');
if not FileExists(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo_Copies.dat') then
begin
CaseDocNo_CopiesList.Clear;
for m := 0 to CaseDocNoList.Count - 1 do
begin
CaseDocNo_CopiesList.Add('1');
CaseDocNo_CopiesList.SaveToFile(ImageSavePath+CaseList.Strings[i]+'\CaseDocNo_Copies.dat');
end;
end;
CasePage := GetCasePage(ImageSavePath,CaseList.Strings[i]);
//ShowMessage('CasePage='+IntToStr(CasePage));
MytreeNode1 := TreeView1.Items.AddChild(NewTreeNode,Format(_Msg('%s-%d頁'),[CaseList.Strings[i],CasePage]));
MytreeNode1.ImageIndex := 1;
MytreeNode1.SelectedIndex := 1;
DrawDocItem2(MytreeNode1,CaseList.Strings[i]); //長出文件名稱的樹並傳回是否有申請書的影像
if Pos(_Msg('未配號'),CaseList.Strings[i]) > 0 then
begin
MytreeNode1.ImageIndex := 5;
MytreeNode1.SelectedIndex := 5;
end;
If FileExists(ImageSavePath+CaseList.Strings[i]+'\OMRCheckOk.dat') Then
begin
MytreeNode1.ImageIndex := 7;
MytreeNode1.SelectedIndex := 7;
CaseHelpBtn.Visible := False;
end
Else IF FileExists(ImageSavePath+CaseList.Strings[i]+'\Checkerr.ini') Then
begin
MyTreenode1.ImageIndex := 5;
MyTreenode1.SelectedIndex := 5;
//AllEnforceLb.Visible := True; //全部強迫送件
end;
end;
MyTreenode1 := nil;
MyTreenode2 := nil;
If NewTreeNode <> nil Then
begin
TreeView1.Selected := NewTreeNode;
NewTreeNode.Expand(False);
end;
IF (NewTreeNode <> nil) and (NewTreeNode.Count > 0) Then
begin
GetCase_PageCount(CaseCount,PageCount);
v := Pos('-',NewTreeNode.Text);
NewTreeNode.Text := Format(_Msg('%s-共%d筆共%d頁'),[Copy(NewTreeNode.Text,1,v-1),CaseCount,PageCount]);
end;
end;
procedure TCB_IMGPSScanX.LoadImgFile1; //載入新件及替換件
Var
i,n,v,v1,m : Integer;
p : integer;
iCaseNo,iDocNo : String;
TempName : String;
BarName : String;
DocName : String;
//S : String;
begin
ClearView(1);
PageLV.Clear;
DisplayPath := '';
ClearCaseIndex;
CaseHelpBtn.Visible := False;
//Del_Sub_NothingPath(ImageSavePath); //清掉案件目錄是空的
TreeView1.Items.Clear;
NewTreeNode := nil;
MyTreenode1 := nil;
MyTreenode2 := nil;
MyTreenode3 := nil;
NewTreeNode := TreeView1.Items.Add(nil,Format(_Msg('%s-共%d筆共%d頁'),[FModeName,0,0]));
NewTreenode.ImageIndex := 0;
NewTreenode.SelectedIndex := 0;
Del_Sub_NothingPath(ImageSavePath); //清掉案件目錄是空的
GetCase_PageCount(CaseCount,PageCount);
CaseList.Clear;
if FileExists(ImageSavePath + 'CaseList.dat') then
CaseList.LoadFromFile(ImageSavePath + 'CaseList.dat');
for n := 0 to CaseList.Count - 1 do
begin
iCaseNo := CaseList.Strings[n];
CaseDocNoList.Clear;
if FileExists(ImageSavePath+CaseList.Strings[n]+'\DocNoList.dat') then
CaseDocNoList.LoadFromFile(ImageSavePath+CaseList.Strings[n]+'\DocNoList.dat');
for m := 0 to CaseDocNoList.Count - 1 do
begin
iDocNo := CaseDocNoList.Strings[i];
MytreeNode1 := TreeView1.Items.AddChild(NewTreeNode,Format(_Msg('%s-%d頁'),[CaseList.Strings[n],p]));
MytreeNode1.ImageIndex := 1;
MytreeNode1.SelectedIndex := 1;
end;
ContextList.Clear;
Context_DocnoList.Clear;
If FileExists(ImageSavePath+CaseList.Strings[n]+'\Context.dat') Then
begin
ContextList.LoadFromFile(ImageSavePath+CaseList.Strings[n]+'\Context.dat');
if FileExists(ImageSavePath+CaseList.Strings[n]+'\Context_DocNo.dat') then
Context_DocnoList.LoadFromFile(ImageSavePath+CaseList.Strings[n]+'\Context_DocNo.dat')
else
begin
for m := 0 to ContextList.Count - 1 do
begin
Context_DocnoList.Add(FormCode2DocNo(FileName2FormCode(ContextList.Strings[m])));
end;
Context_DocnoList.SaveToFile(ImageSavePath+CaseList.Strings[n]+'\Context_DocNo.dat');
end;
Cust_DocNoList.Clear;
if FileExists(ImageSavePath+CaseList.Strings[n]+'\CustomDocNo.dat') then
Cust_DocNoList.LoadFromFile(ImageSavePath+CaseList.Strings[n]+'\CustomDocNo.dat');
P := ContextList.Count;
MytreeNode1 := TreeView1.Items.AddChild(NewTreeNode,Format(_Msg('%s-%d頁'),[CaseList.Strings[n],p]));
MytreeNode1.ImageIndex := 1;
MytreeNode1.SelectedIndex := 1;
//DrawDocItem1(MytreeNode1,Doc_Inf_List,CaseList.Strings[n]); //長出文件名稱的樹並傳回是否有申請書的影像
DrawDocItem2(MytreeNode1,CaseList.Strings[n]); //長出文件名稱的樹並傳回是否有申請書的影像 20140820改
if Pos(_Msg('未配號'),CaseList.Strings[n]) > 0 then
begin
MytreeNode1.ImageIndex := 5;
MytreeNode1.SelectedIndex := 5;
end;
If FileExists(ImageSavePath+CaseList.Strings[n]+'\OMRCheckOk.dat') Then
begin
MytreeNode1.ImageIndex := 7;
MytreeNode1.SelectedIndex := 7;
CaseHelpBtn.Visible := False;
end
Else IF FileExists(ImageSavePath+CaseList.Strings[n]+'\Checkerr.ini') Then
begin
MyTreenode1.ImageIndex := 5;
MyTreenode1.SelectedIndex := 5;
//AllEnforceLb.Visible := True; //全部強迫送件
end;
end;
end;
MyTreenode1 := nil;
MyTreenode2 := nil;
If NewTreeNode <> nil Then
begin
TreeView1.Selected := NewTreeNode;
NewTreeNode.Expand(False);
end;
ContextList.Clear;
IF (NewTreeNode <> nil) and (NewTreeNode.Count > 0) Then
begin
GetCase_PageCount(CaseCount,PageCount);
v := Pos('-',NewTreeNode.Text);
NewTreeNode.Text := Format(_Msg('%s-共%d筆共%d頁'),[Copy(NewTreeNode.Text,1,v-1),CaseCount,PageCount]);
end;
end;
procedure TCB_IMGPSScanX.LoadAttFile(CaseID:String); //載入附加檔案
var
AttContextList : TStringlist;
i : Integer;
begin
AttListBox.Clear;
AttContextList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\AttContext.dat') then
begin
AttContextList.LoadFromFile(ImageSavePath+CaseID+'\AttContext.dat');
end;
for i := 0 to AttContextList.Count - 1 do
begin
AttListBox.Items.Add(UTF8Decode(HTTPDEcode(AttContextList.Strings[i])));
end;
finally
AttContextList.Free;
end;
end;
function TCB_IMGPSScanX.logTimeString: String;
begin
Result:=FormatDateTime('yyyymmdd hh:mm:ss',now) +' caseNo='+NowCaseno+' ';
end;
Function TCB_IMGPSScanX.Case2Mask(SoPath,DePath:String):Boolean;//產生遮罩影像 20170639 發現沒用到
var
XT : TXMLTool;
i : Integer;
S : TStringlist;
SiteList : TStringlist;
FormID : String;
ColEName : String;
FileName : String;
nodename : String;
Site : String;
Anchor : String;
begin
Result := False;
if DirectoryExists(DePath) then
_DelTree(DePath);
Str2Dir(DePath);
DeleteFile(SoPath+'MaskImg.zip');
SiteList := TStringlist.Create;
S := TStringlist.Create;
XT := TXMLTool.Create;
try
S.LoadFromFile(SoPath+'Context.dat');
for I := 0 to S.Count - 1 do
begin
SiteList.Clear;
ImageScrollBox1.LoadFromFile(SoPath+S.Strings[i],1);
FormID := FileName2FormCode(S.Strings[i]);
Anchor := FormID2Anchor(FormID);
//ParserPoint(CropMpsV.FindPoint(Anchor));
FindPoint(ImageScrollBox1.Graphic,UpLPoint,UpRPoint,DownLPoint,Anchor);
if FileExists(CheckXmlPath+FWork_no+'\'+FormID+'.xml') then //沒有Xml就不用遮罩
begin
XT.LoadFromFile(CheckXmlPath+FWork_no+'\'+FormID+'.xml');
if XT.SubNodes['/form/settype10/'].First then
Repeat
ColEName := XT.SubNodes['/form/settype10/'].NodeName;
if XT.SubNodes['/form/settype10/'+ColEName+'/'].First then
Repeat
nodename := XT.SubNodes['/form/settype10/'+ColEName+'/'].NodeName;
If nodename <> '@coldesc' then
begin
Site := XT.Node['/form/settype10/'+ColEName+'/'+nodename+'/'].Attributes['colxy'];
SiteList.Add(Site);
Result := True; //有設定
end
Else
begin
//ColCName := XT['/form/settype1/'+ColEName+'/'+nodename+'/'];
end;
Until not XT.SubNodes['/form/settype10/'+ColEName+'/'].Next;
Until not XT.SubNodes['/form/settype10/'].Next ;
FieldMask(ImageScrollBox1,SiteList.Text,'Mask',UpLPoint);
end;
SaveAnnotation(ImageScrollBox1,DePath+S.Strings[i]);
end;
finally
SiteList.Free;
S.Free;
XT.Free;
end;
end;
Function TCB_IMGPSScanX.GetNewCustomDocNo(Path,DocName:String):String; //取出未使用的自訂文件代號
var
ini : Tinifile;
Ct:Integer;
DocNo,FormID : String;
{i,n,v,ln : Integer;
C_No,C_Name : String;
CNo : Integer;
S : TStringlist;
NewDocNo : String;}
begin
ini := Tinifile.Create(Path+'CustomDocNo.ini');
try
Ct := ini.ReadInteger('CustomCount','Count',0);
inc(Ct);
DocNo := 'ZZZZZ'+Add_Zoo(Ct,3);
if FIs_In_Wh <> 'Y' then //不是入庫文件
DocNo := 'YYYYY'+Add_Zoo(Ct,3);
if (FMode='ESCAN') and (FWH_category='N') then //20170914 補件下改成非入庫的自定文件
begin
DocNo := 'YYYYY'+Add_Zoo(Ct,3);
end;
FormID := DocNo+'010101A';
ini.WriteInteger('CustomCount','Count',Ct);
ini.WriteString(DocNo,'FormID',FormID);
ini.WriteString(DocNo,'Name',DocName);
Result := DocNo;
finally
ini.Free;
end;
{S := TStringlist.Create;
try
NewDocNo :='ZZZZZ001';
if FileExists(Path+'CustomDocNo.dat') then
begin
/// ZZZZZ001_自定文件名稱 001_自定文件名稱
S.LoadFromFile(Path+'CustomDocNo.dat');
for i := 0 to S.Count - 1 do
begin
v := Pos('_',S.Strings[i]);
ln := Length(S.Strings[i]);
C_No := Copy(S.Strings[i],1,v-1);
C_Name := Copy(S.Strings[i],v+1,ln-v);
if DocName = C_Name then
begin
Showmessage('文件名稱已存在');
Result := '';
Exit;
end;
end;
CNo := strtoint(Copy(C_No,6,3))+1;
NewDocNo := 'ZZZZZ'+Add_Zoo(CNo,3);
end;
S.Add(NewDocNo+'_'+DocName);
S.SaveToFile(Path+'CustomDocNo.dat');
Result := NewDocNo;
finally
S.Free;
end; }
end;
Function TCB_IMGPSScanX.GetCustomDocDir(Path,DocName:String):String; //取出自定文件DocDir
var
i,ct:integer;
ini : Tinifile;
begin
Result := '';
ini := Tinifile.Create(Path+'CustomDocNo.ini');
try
ct := ini.ReadInteger('CustomCount','Count',0);
for i := 1 to ct do
begin
if ini.ReadString('ZZZZZ'+Add_Zoo(i,3),'Name','') = DocName then
begin
Result := 'ZZZZZ'+Add_Zoo(i,3);
Break;
end;
if ini.ReadString('YYYYY'+Add_Zoo(i,3),'Name','') = DocName then
begin
Result := 'YYYYY'+Add_Zoo(i,3);
Break;
end;
end;
finally
ini.Free;
end;
end;
Procedure TCB_IMGPSScanX.DeleteCustomDocDir(Path,DocNo:String); //刪除自定文件DocNo
var
ini : Tinifile;
begin
ini := Tinifile.Create(Path+'CustomDocNo.ini');
try
ini.EraseSection(DocNo);
finally
ini.Free;
end;
end;
Function TCB_IMGPSScanX.FindLastestDocDir(CaseID,DocNo:String):String; //找出最新的DocDir
var
i : Integer;
DocNoList,FileList : TStringlist;
begin
Result := '';
DocNoList := TStringlist.Create;
FileList := 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
Result := DocNoList.Strings[i];
Break;
end;
end;
finally
DocNoList.Free;
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
i,n : Integer;
C_DocNoList,C_DocNameList : TStringlist;
DocNo,DocName,DocDir : String;
DocNo_Ct,NowDocNo_Ct :integer;
DocName_Ct : Integer;
inx : Integer;
begin
C_DocNoList := TStringlist.Create;
C_DocNameList := TStringlist.Create;
try
if FC_DocNoList <> '' then
begin
C_DocNoList.StrictDelimiter := True;
C_DocNoList.Delimiter := #9;
C_DocNoList.DelimitedText := FC_DocNoList;
//Showmessage(C_DocNoList.Text);
for i := 0 to C_DocNoList.Count - 1 do
begin
DocNo := C_DocNoList.Strings[i];
//舊件不長出錯誤的文件出來
if (FIs_OldCase = 'Y') and (FWork_no='HLN') and (DocNo = FormCode2DocNo('10000001011112A')) then
Continue;
NowDocNo_Ct := GetDocNoCount(CaseID,DocNo);
if DocNoNeedDiv(DocNo) then
begin
DocNo_Ct := 0;
for n := 0 to i do
begin
if C_DocNoList.Strings[n] = DocNo then
inc(DocNo_Ct);
end;
if DocNo_CT <= NowDocNo_Ct then
Continue;
if DirectoryExists(ImageSavePath+CaseID+'\'+DocNo+'('+inttostr(DocNo_Ct)+')') then //存在了
Continue;
if (DocNo_Ct = 1) and DirectoryExists(ImageSavePath+CaseID+'\'+DocNo) then //存在了 20140327加
Continue;
DocDir := DocNo2DocNoDir(ImageSavePath+CaseID+'\',DocNo)
end
else
begin
DocDir := DocNo;
end;
if not DirectoryExists(ImageSavePath+CaseID+'\'+DocDir) then
begin
MkDir(ImageSavePath+CaseID+'\'+DocDir);
SetDocNoList('A',-1,CaseID,DocDir,'1');
end;
if not DocNoNeedDiv(DocNo) then //不分份的秀數
SetDocDirCopies(CaseID,DocNo,GetCustomDocNoCount(DocNo));
end;
end;
if FC_DocNameList <> '' then
begin
C_DocNameList.StrictDelimiter := True;
C_DocNameList.Delimiter := #9;
C_DocNameList.DelimitedText := FC_DocNameList;
//Showmessage(C_DocNameList.Text);
for i := 0 to C_DocNameList.Count - 1 do
begin
DocName := C_DocNameList.Strings[i];
DocName_Ct := GetCustomNameCount(DocName);
if not FindCustomDocName(ImageSavePath+CaseID+'\',DocName) then
begin
DocDir := GetNewCustomDocNo(ImageSavePath+CaseID+'\',DocName);
if not DirectoryExists(ImageSavePath+CaseID+'\'+DocDir) then
begin
MkDir(ImageSavePath+CaseID+'\'+DocDir);
SetDocNoList('A',-1,CaseID,DocDir,inttostr(DocName_Ct));
end;
end
Else
begin
DocDir := GetCustomDocDir(ImageSavePath+CaseID+'\',DocName);
//inx := DocNoDir2Index(ImageSavePath+CaseID+'\',DocDir);
SetDocDirCopies(CaseID,DocDir,DocName_Ct);
end;
end;
end;
finally
C_DocNoList.Free;
C_DocNameList.Free;
end;
end;
Procedure TCB_IMGPSScanX.OldCasetoNewCase(CaseID:String); //將舊案份數轉成新規則
var
i,n : Integer;
C_DocNoList,C_DocNameList : TStringlist;
DocNoList,DocNo_CopiesList : TStringlist;
DocNo,DocName,DocDir : String;
DocNo_Ct :integer;
begin
C_DocNoList := TStringlist.Create;
C_DocNameList := TStringlist.Create;
DocNoList := TStringlist.Create;
DocNo_CopiesList := TStringlist.Create;
try
DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
for i := 0 to DocNoList.Count - 1 do
begin
DocNo_CopiesList.Add('0');
end;
//Showmessage(FC_DocNoList);
if FC_DocNoList <> '' then
begin
C_DocNoList.StrictDelimiter := True;
C_DocNoList.Delimiter := #9;
C_DocNoList.DelimitedText := FC_DocNoList;
//showmessage(C_DocNoList.Text+#13+#13+DocNoList.Text);
for i := 0 to DocNoList.Count - 1 do
begin
//DocNo := DocNoList.Strings[i];
DocNo := DocNoDir2DocNo(DocNoList.Strings[i]); //20140812 因轉舊案錯誤件會出現DocnoDir
DocNo_Ct := 0;
for n := 0 to C_DocNoList.Count - 1 do
begin
if DocNo = C_DocNoList.Strings[n] then
inc(DocNo_Ct);
end;
if DocNo_CT > 0 Then
DocNo_CopiesList.Strings[i] := inttostr(DocNo_CT);
end;
DocNo_CopiesList.SaveToFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
end;
if FC_DocNameList <> '' then
begin
C_DocNameList.StrictDelimiter := True;
C_DocNameList.Delimiter := #9;
C_DocNameList.DelimitedText := FC_DocNameList;
for i := 0 to DocNoList.Count - 1 do
begin
DocNo := DocNoList.Strings[i];
DocNo_Ct := 0;
for n := 0 to C_DocNameList.Count - 1 do
begin
if GetCustomDocName(ImageSavePath+CaseID+'\',DocNo) = C_DocNameList.Strings[n] then
inc(DocNo_Ct);
end;
if DocNo_CT > 0 Then
DocNo_CopiesList.Strings[i] :=inttostr(DocNo_CT);
end;
end;
DocNo_CopiesList.SaveToFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
finally
C_DocNoList.Free;
C_DocNameList.Free;
DocNoList.Free;
DocNo_CopiesList.Free;
end;
end;
Procedure TCB_IMGPSScanX.SetRecordEditedDocDir(Mode:Char;CaseID,DocDir:String); //記錄被異動的文件目錄 'A:加入D:刪掉'
var
i : Integer;
Exists : Boolean;
EditedDocDirList : TStringlist;
begin
EditedDocDirList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\EditedDocDir.dat') then
EditedDocDirList.LoadFromFile(ImageSavePath+CaseID+'\EditedDocDir.dat');
case Mode of
'A':begin
Exists := False;
for i := 0 to EditedDocDirList.Count - 1 do
begin
if EditedDocDirList.Strings[i]=DocDir then
begin
Exists := True;
Break;
end;
end;
if not Exists then
begin
EditedDocDirList.Add(DocDir);
EditedDocDirList.SaveToFile(ImageSavePath+CaseID+'\EditedDocDir.dat');
end;
end;
'D':begin
for i := 0 to EditedDocDirList.Count - 1 do
begin
if EditedDocDirList.Strings[i] = DocDir then
begin
EditedDocDirList.Delete(i);
if EditedDocDirList.Count > 0 then
EditedDocDirList.SaveToFile(ImageSavePath+CaseID+'\EditedDocDir.dat')
else
DeleteFile(ImageSavePath+CaseID+'\EditedDocDir.dat');
Break;
end;
end;
end;
end;
finally
EditedDocDirList.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocDir_Page(CaseID,DocDir:String):Integer;
var
FileList : TStringlist;
begin
Result := 0;
FileList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\'+DocDir+'\Context.dat') then
begin
FileList.LoadFromFile(ImageSavePath+CaseID+'\'+DocDir+'\Context.dat');
Result := FileList.Count;
end;
finally
FileList.Free;
end;
end;
Function TCB_IMGPSScanX.Path2DocDir(Path,CaseID:String):String;
var
i : Integer;
DocnoList : TStringlist;
begin
Result := '';
DocNoList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
if Path[length(Path)]<>'\' then
path := path+'\';
for i := 0 to DocNoList.Count - 1 do
begin
if (path=ImageSavePath+CaseID+'\'+DocNoList.Strings[i]+'\') then
begin
Result := DocNoList.Strings[i];
Break;
end;
end;
finally
DocNoList.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocNo_IS_WH(DocNo:String):Boolean; //DocNo是否為入庫文件
var
i :Integer;
begin
Result := False;
for i := 0 to IN_WH_DocNoList.Count - 1 do
begin
if DocNo = IN_WH_DocNoList.Strings[i] then
begin
Result := True;
Break;
end;
end;
end;
Function TCB_IMGPSScanX.DocNoIs_In_WH(DocNo:String):Boolean; //DocNo是否為入庫文件
var
i : Integer;
begin
Result := False;
if (Copy(DocNo,1,5)='ZZZZZ') then //20140728 yuu 說自訂文件也是入庫文件
begin
Result := True;
Exit;
end;
for i := 0 to IN_WH_DocNoList.Count -1 do
begin
if DocNo = IN_WH_DocNoList.Strings[i] then
begin
Result := True;
Break;
end;
end;
end;
Procedure TCB_IMGPSScanX.CreateCaseNeedData(Path:String);
var
FileList,DocNoList,CaseDocNoList,CaseDocNo_CopiesList : TStringlist;
i,n : Integer;
Docno : String;
Exists : Boolean;
begin
FileList := TStringlist.Create;
DocNoList := TStringlist.Create;
CaseDocNoList := TStringlist.Create;
CaseDocNo_CopiesList := TStringlist.Create;
try
if FileExists(Path+'Context.dat') then
begin
FileList.LoadFromFile(Path+'Context.dat');
for i := 0 to FileList.Count - 1 do
begin
Docno := FormCode2DocNo(FileName2FormCode(FileList.Strings[i]));
//ShowMessage('Docno='+Docno);
DocNoList.Add(DocNo);
Exists := False;
for n := 0 to CaseDocNoList.Count - 1 do
begin
if Docno = CaseDocNoList.Strings[n] then
Exists := True;
end;
if not Exists then
begin
CaseDocNoList.Add(DocNo);
CaseDocNo_CopiesList.Add('1');
end;
end;
//ShowMessage('CreateCaseNeedData DocNoList='+DocNoList.Text);
DocNoList.SaveToFile(Path+'DocDir.dat');
CaseDocNoList.SaveToFile(Path+'CaseDocNo.dat');
CaseDocNo_CopiesList.SaveToFile(Path+'CaseDocNo_Copies.dat')
end;
finally
FileList.Free;
DocNoList.Free;
CaseDocNoList.Free;
CaseDocNo_CopiesList.Free;
end;
end;
Procedure TCB_IMGPSScanX.SetDocDirtoSelected(CaseNode:TTreeNode;DocDir:String);
var
i : Integer;
begin
for i := 0 to CaseNode.Count - 1 do
begin
if Pos(DocDir+'{',CaseNode.Item[i].Text) > 0 then
begin
TreeView1.Selected := CaseNode.Item[i];
end;
end;
end;
Function TCB_IMGPSScanX.CheckSelectImg_UseCase(Path,CaseID:String):Boolean; //檢查選擇的影像是否有包含被引用的影像
var
i : Integer;
iISBName : String;
iISB : TImageScrollBox;
ImgPath,DocDir : String;
begin
Result := False;
for i := 0 to ComponentCount -1 do
begin
if (Components[i] is TShape) and (copy(Components[i].Name,1,2)='SP') then
begin
//Showmessage(Components[i].Name);
iISBName := ShapeName2PreViewISBName(TShape(Components[i]));
iISB := TImageScrollBox(FindComponent(iISBName));
ImgPath := ExtractFilePath(iISB.FileName);
DocDir := Path2DocDir(ImgPath,CaseID);
if GetUseCase('T',Path,DocDir) <> '' then
Result := True;
end;
end;
end;
Function TCB_IMGPSScanX.TransOldCaseFile(Path:String):Boolean;
var
i : Integer;
OldCaseID,Year,Data,Verify:String;
SendData : String;
OldCaseInfoList,Caseinfolist : TStringlist;
OldCasePath : String;
begin
Result := True;
OldCaseInfoList := TStringlist.Create;
Caseinfolist := TStringlist.Create;
try
OldCaseInfoList.StrictDelimiter := True;
OldCaseInfoList.Delimiter := #9;
OldCaseInfoList.DelimitedText := FOldCaseInfo;
for i := 0 to OldCaseInfoList.Count - 1 do
begin
Caseinfolist := SplitString('@#,',OldCaseInfoList.Strings[i]);
//Caseinfolist.Delimiter := '_';
//Caseinfolist.DelimitedText := OldCaseInfoList.Strings[i];
OldCaseID := Caseinfolist.Strings[0];
Year := Caseinfolist.Strings[1];
Data := Caseinfolist.Strings[4];
Verify := Caseinfolist.Strings[5];
OldCasePath := Path+OldCaseID+'\';
if FileExists(OldCasePath+'UseCase.dat') and FileExists(OldCasePath+'UseCase.ini') then
begin
//////壓檔/////
//ZipMainFile(Path,Path,'Img.zip');
////上傳/////
SendData:='data='+HTTPEncode(UTF8Encode(Data))+'&verify='+Verify+'&other_case_no='+OldCaseID;
//Showmessage(FUrl+'service/slic/SLIC02/useOther?'+senddata);
if not upFile(HTTPSClient,FUrl,'service/imgpsc/IMGPSC02/useOther',SendData,'file',OldCasePath+'UseCase.ini',FReWrite,Memo1,False) then
begin
Showmessage(Format(_Msg('傳送舊件編號(%s)檔案時,網路發生錯誤!!'),[OldCaseID])+_Msg('錯誤代碼:')+Inttostr(HttpError.HttpErrorCode)+' '+HttpError.HttpReason);
Result := False;
Exit;
end;
if memo1.Lines.Strings[0] = '1' then
begin
Showmessage(Format(_Msg('傳送舊件編號(%s)檔案時,網路發生錯誤!!'),[OldCaseID])+_Msg('錯誤原因:')+memo1.Lines.Strings[1]);
Result := False;
Exit;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
Showmessage(Format(_Msg('傳送舊件編號(%s)檔案時,網路發生錯誤!!'),[OldCaseID])+_Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入'));
Result := False;
Exit;
end;
end;
////上傳////
end;
finally
OldCaseInfoList.Free;
Caseinfolist.Free;
end;
end;
Function TCB_IMGPSScanX.Writelog(CaseID : String):Boolean;
var
SendData : String;
begin
Result := True;
SendData:='data='+HTTPEncode(UTF8Encode(FData))+'&verify='+FVerify+'&case_no='+CaseID;
If not ProcessServlet(HTTPSClient,FURL+'service/imgpsc/IMGPSC06/printlog',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
HttpErrStr := _Msg('錯誤原因:')+memo1.Lines.Strings[1];
Result := False;
Exit;
end
Else if Pos('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
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('',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;
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;
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('',Memo1.Lines.Text) > 0 then
begin
HttpErrStr := _Msg('錯誤原因:')+_Msg('閒置過久或被登出,請重新登入');
Result := False;
Exit;
end;
end;
Function TCB_IMGPSScanX.DocNoAppear(DocNo:String):Boolean; //DocNo是否可出現
begin
Result := True;
{if (((FIs_In_Wh = 'Y') and (not DocNoIs_In_WH(DocNo)) or (DocNo ='S_Attach')) or //入庫掃描不看非入庫文件
((FIs_In_Wh = 'N') and (DocNoIs_In_WH(DocNo)) or (DocNo ='Attach') )) {and //非入庫掃描不看入庫文件
(Copy(DocNo,1,5)<>'ZZZZZ')} {then
{Result := False;}
//20181031 應該要換成下面的判斷比較對,FIs_In_Wh傳空的話才會出全部
if (((FIs_In_Wh = 'Y') and ((not DocNoIs_In_WH(DocNo)) or (DocNo ='S_Attach'))) or //入庫掃描不看非入庫文件
((FIs_In_Wh = 'N') and ((DocNoIs_In_WH(DocNo)) or (DocNo ='Attach') ))) {and //非入庫掃描不看入庫文件
(Copy(DocNo,1,5)<>'ZZZZZ')} then
Result := False;
end;
Function TCB_IMGPSScanX.GetDocNoCount(CaseID,DocNo:String):Integer; //取DocNo數量
var
i : Integer;
Doc_Ct:Integer;
iDocNo : String;
DocNoList,DocNo_CopiesList : TStringlist;
begin
DocNoList := TStringlist.Create;
DocNo_CopiesList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
begin
DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
DocNo_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
end;
Doc_Ct := 0;
for i := 0 to DocNoList.Count - 1 do
begin
iDocNo := DocNoDir2DocNo(DocNoList.Strings[i]);
if iDocNo = DocNo then
Doc_Ct := Doc_Ct + strtoint(DocNo_CopiesList.Strings[i]);
end;
Result := Doc_Ct;
// Showmessage(DocNo+#13+inttostr(Doc_Ct));
finally
DocNoList.Free;
DocNo_CopiesList.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocDirCopies(CaseID,DocDir:String):Integer; //取DocDir數量
var
i : Integer;
DocNoList,DocNo_CopiesList : TStringlist;
begin
Result := 1; //預設回傳1 //20140521 由0改成1
DocNoList := TStringlist.Create;
DocNo_CopiesList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
if FileExists(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat') then
begin
DocNo_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
for i := 0 to DocNoList.Count - 1 do
begin
if (DocDir = DocNoList.Strings[i]) and (i <= DocNo_CopiesList.Count-1) then
begin
Result := strtoint(DocNo_CopiesList.Strings[i]);
Break;
end;
end;
end;
finally
DocNoList.Free;
DocNo_CopiesList.Free;
end;
end;
Procedure TCB_IMGPSScanX.SetDocDirCopies(CaseID,DocDir:String;NewCopies:Integer); //修改DocDir份數
var
i : Integer;
DocNoList,DocNo_CopiesList : TStringlist;
begin
DocNoList := TStringlist.Create;
DocNo_CopiesList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
begin
DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
DocNo_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
end;
for i := 0 to DocNoList.Count - 1 do
begin
if DocDir = DocNoList.Strings[i] then
begin
DocNo_CopiesList.Strings[i] := inttostr(NewCopies);
DocNo_CopiesList.SaveToFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
Break;
end;
end;
finally
DocNoList.Free;
DocNo_CopiesList.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocDirCopies_Rec(Path,CaseID,DocDir:String):Integer; //取記錄裡的DocDir份數
var
i,n,v,v1 : Integer;
OldCaseInfoList,Caseinfolist : TStringlist;
iCaseID,Year,iBS_No,iIS_Old,iDocNo,iCopies:String;
begin
Result := 1;
OldCaseInfoList := TStringlist.Create;
Caseinfolist := TStringlist.Create;
try
//OldCaseInfoList 案件編號@#,年度@#,業務別@#,是否舊件@#,Data@#,Verify@#,文件編號[份數]@#,文件編號[份數] tab 案件編號@#,年度@#,業務別@#,是否舊件@#,Data@#,Verify@#,文件編號[份數]@#,文件編號[份數]
OldCaseInfoList.StrictDelimiter := true;
OldCaseInfoList.Delimiter := #9;
OldCaseInfoList.DelimitedText := FOldCaseInfo;
for i := 0 to OldCaseInfoList.Count - 1 do
begin
Caseinfolist:=SplitString('@#,',OldCaseInfoList.Strings[i]);
//Caseinfolist.Delimiter := '_';
//Caseinfolist.DelimitedText := OldCaseInfoList.Strings[i];
iCaseID := Caseinfolist.Strings[0];
Year := Caseinfolist.Strings[1];
iBS_No := Caseinfolist.Strings[2];
iIS_Old := Caseinfolist.Strings[3];
if CaseID = iCaseID then
begin
for n := 6 to Caseinfolist.Count - 1 do
begin
v := Pos('[',Caseinfolist.Strings[n]);
v1 := Pos(']',Caseinfolist.Strings[n]);
iDocNo := Copy(Caseinfolist.Strings[n],1,v-1);
iCopies := Copy(Caseinfolist.Strings[n],v+1,v1-v-1);
if Copy(DocDir,1,5) = 'ZZZZZ' then
begin
if iDocNo = GetCustomDocName(Path,DocDir) then
Result := strtoint(iCopies);
end
else
begin
if iDocNo = DocNoDir2DocNo(DocDir) then
Result := strtoint(iCopies);
end;
end;
end;
end;
finally
OldCaseInfoList.Free;
Caseinfolist.Free;
end;
end;
Function TCB_IMGPSScanX.GetCustomDocNoCount(Docno:String):Integer; //取外傳的DocNo數量
var
i,ct : Integer;
C_DocNoList : TStringlist;
begin
C_DocNoList := TStringlist.Create;
try
C_DocNoList.StrictDelimiter := True;
C_DocNoList.Delimiter := #9;
C_DocNoList.DelimitedText := FC_DocNoList;
ct := 0;
for i := 0 to C_DocNoList.Count - 1 do
begin
if C_DocNoList.Strings[i] = Docno then
begin
inc(ct);
end;
end;
Result := ct;
finally
C_DocNoList.Free;
end;
end;
Function TCB_IMGPSScanX.CaseDelete_Enable(CaseID:String):Boolean; //案件可否被刪除
var
i : Integer;
CaseDocNoList : TStringlist;
begin
Result := True;
CaseDocNoList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then
CaseDocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
for i := 0 to CaseDocNoList.Count - 1 do
begin
if GetUseCase('T',DisplayPath,CaseDocNoList.Strings[i]) <> '' then //有被引用走的
Result := False;
end;
finally
CaseDocNoList.Free;
end;
end;
Procedure TCB_IMGPSScanX.SetUseCase(Mode:Char;Path,DocDir,FormCaseID,ToCaseID:String); //記錄引用其他案件 A:加入 D:刪掉
var
ini : Tinifile;
begin
ini := Tinifile.Create(Path+'UseCase.ini');
try
case Mode of
'A':begin
ini.WriteString(DocDir,'FROM_CASEID',FormCaseID);
ini.WriteString(DocDir,'TO_CASEID',ToCaseID);
end;
'D':begin
ini.EraseSection(DocDir);
end;
end;
finally
ini.Free;
end;
end;
Function TCB_IMGPSScanX.GetUseCase(Mode:Char;Path,DocDir:String):String; //F:取被引用 To:引用
var
ini : Tinifile;
begin
ini := Tinifile.Create(Path+'UseCase.ini');
try
case Mode of
'F':begin
Result := ini.ReadString(DocDir,'FROM_CASEID','');
end;
'T':begin
Result := ini.ReadString(DocDir,'TO_CASEID','');
end;
end;
finally
ini.Free;
end;
end;
Procedure TCB_IMGPSScanX.Case2upload(CaseID:String);
var
i,n:Integer;
OldPath,NewPath,DocDir : String;
OldFile,NewFile,AttFile : String;
DocNoList,FileList:TStringlist;
iFileList,iFile_DocNoList :TStringlist;
iDocDirList : TStringlist;
iAttFileList : TStringlist;
begin
DocNoList := TStringlist.Create;
FileList := TStringlist.Create;
iFileList := TStringlist.Create;
iFile_DocNoList := TStringlist.Create;
iDocDirList := TStringlist.Create;
iAttFileList := TStringlist.Create;
try
OldPath := ImageSavePath+CaseID+'\';
NewPath := ImageSavePath+CaseID+'\Upload\';
if DirectoryExists(NewPath) then
_DelTree(NewPath);
str2dir(NewPath);
CopyFile(PWideChar(OldPath+'CaseDocNo.dat'),PWideChar(NewPath+'CaseDocNo.dat'),False);
CopyFile(PWideChar(OldPath+'CaseDocNo_Copies.dat'),PWideChar(NewPath+'CaseDocNo_Copies.dat'),False);
CopyFile(PWideChar(OldPath+'CustomDocNo.ini'),PWideChar(NewPath+'CustomDocNo.ini'),False);
CopyFile(PWideChar(OldPath+'CaseIndex.dat'),PWideChar(NewPath+'CaseIndex.dat'),False);
CopyFile(PWideChar(OldPath+'In_Wh.dat'),PWideChar(NewPath+'In_Wh.dat'),False);
CopyFile(PWideChar(OldPath+'UseCase.ini'),PWideChar(NewPath+'UseCase.ini'),False);
if FileExists(OldPath+'CaseDocNo.dat') then
begin
DocNoList.LoadFromFile(OldPath+'CaseDocNo.dat');
end
else
begin
DocNoList.SaveToFile(OldPath+'CaseDocNo.dat');
CopyFile(PWideChar(OldPath+'CaseDocNo.dat'),PWideChar(NewPath+'CaseDocNo.dat'),False);
end;
for i := 0 to DocNoList.Count-1 do
begin
DocDir := DocNoList.Strings[i];
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
FileList.Clear;
if FileExists(OldPath+'Context.dat') then
begin
FileList.LoadFromFile(OldPath+'Context.dat');
for n := 0 to FileList.Count - 1 do
begin
OldFile := FileList.Strings[n];
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
iFileList.Add(NewFile);
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
iDocDirList.Add(DocDir);
end;
end;
end;
if DirectoryExists(ImageSavePath+CaseID+'\Attach') then
begin
DocDir := 'Attach';
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
FileList.Clear;
if FileExists(OldPath+'Context.dat') then
begin
FileList.LoadFromFile(OldPath+'Context.dat');
for n := 0 to FileList.Count - 1 do
begin
OldFile := FileList.Strings[n];
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
iFileList.Add(NewFile);
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
iDocDirList.Add(DocDir);
end;
end;
end;
if DirectoryExists(ImageSavePath+CaseID+'\S_Attach') then
begin
DocDir := 'S_Attach';
OldPath := ImageSavePath+CaseID+'\'+ DocDir+'\';
FileList.Clear;
if FileExists(OldPath+'Context.dat') then
begin
FileList.LoadFromFile(OldPath+'Context.dat');
for n := 0 to FileList.Count - 1 do
begin
OldFile := FileList.Strings[n];
NewFile := Add_Zoo(iFileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
CopyFile(PWideChar(OldPath+OldFile),PWideChar(NewPath+NewFile),False);
iFileList.Add(NewFile);
iFile_DocNoList.Add(DocNoDir2DocNo(DocDir));
iDocDirList.Add(DocDir);
end;
end;
end;
OldPath := ImageSavePath+CaseID+'\';
if FileExists(OldPath+'AttContext.dat') then
begin
iAttFileList.LoadFromFile(OldPath+'AttContext.dat');
for n := 0 to iAttFileList.Count - 1 do
begin
AttFile := iAttFileList.Strings[n];
CopyFile(PWideChar(OldPath+AttFile),PWideChar(NewPath+AttFile),False);
end;
iAttFileList.SaveToFile(NewPath+'AttContext.dat');
end;
iFileList.SaveToFile(NewPath+'Context.dat');
iFile_DocNoList.SaveToFile(NewPath+'Context_DocNo.dat');
iDocDirList.SaveToFile(NewPath+'DocDir.dat');
finally
iFileList.Free;
iAttFileList.Free;
iFile_DocNoList.Free;
DocNoList.Free;
FileList.Free;
end;
end;
Procedure TCB_IMGPSScanX.Download2Case(SoDir,DeDir:String);
var
i,n : Integer;
DocDir:String;
OldFile,NewFile,AttFile:String;
DocNoList,FileList : TStringlist;
iFileList,iFile_DocDirList :TStringlist;
iAttFileList :TStringlist;
AA,AA2,AA3,AA4:Boolean;
begin
if (not FileExists(SoDir+'CaseDocNo.dat')) or (not FileExists(SoDir+'DocDir.dat')) then //截畫面會沒這些檔
begin
//ShowMessage('產生必要的文字檔');
CreateCaseNeedData(SoDir); //產生必要的文字檔
end;
AA:=CopyFile(PWideChar(SoDir+'CaseDocNo.dat'),PWideChar(DeDir+'CaseDocNo.dat'),False);
AA2:=CopyFile(PWideChar(SoDir+'CaseDocNo_Copies.dat'),PWideChar(DeDir+'CaseDocNo_Copies.dat'),False);
AA3:=CopyFile(PWideChar(SoDir+'CustomDocNo.ini'),PWideChar(DeDir+'CustomDocNo.ini'),False);
AA4:=CopyFile(PWideChar(SoDir+'UseCase.ini'),PWideChar(DeDir+'UseCase.ini'),False);
//ShowMessage(BoolToStr(AA)+#10#13+BoolToStr(AA2)+#10#13+BoolToStr(AA3)+#10#13+BoolToStr(AA4));
if FileExists(SoDir+'DocDir.dat') then //20170222 新加
begin
CopyFile(PWideChar(SoDir+'DocDir.dat'),PWideChar(DeDir+'DocDir.dat'),False);
end;
DocNoList := TStringlist.Create;
FileList := TStringlist.Create;
iFileList := TStringlist.Create;
iFile_DocDirList := TStringlist.Create;
iAttFileList := TStringlist.Create;
try
//if Not FileExists(SoDir+'Context.dat') then Exit;
//iFileList.LoadFromFile(SoDir+'Context.dat');
//if iFileList.Count = 0 then Exit;
if FileExists(SoDir+'Context.dat') then
iFileList.LoadFromFile(SoDir+'Context.dat');
if FileExists(SoDir+'DocDir.dat') then
iFile_DocDirList.LoadFromFile(SoDir+'DocDir.dat');
if iFileList.Count <> iFile_DocDirList.Count then
begin
for i := 0 to iFileList.Count - 1 do
begin
if i > iFile_DocDirList.Count -1 then
begin
iFile_DocDirList.Add(FormCode2DocNo(FileName2FormCode(iFileList.Strings[i])));
end;
end;
end;
if FileExists(SoDir+'CaseDocNo.dat') then
DocNoList.LoadFromFile(SoDir+'CaseDocNo.dat');
if FileExists(DeDir+'CaseDocNo_Copies.dat') then
CaseDocNo_CopiesList.LoadFromFile(DeDir+'CaseDocNo_Copies.dat');
{for i := 0 to DocNoList.Count - 1 do
begin
DocDir := DocNoList.Strings[i];
MkDir(DeDir+DocDir);
end;}
//ShowMessage('DocNoList='+DocNoList.Text);
for i := DocNoList.Count - 1 downto 0 do
begin
DocDir := DocNoList.Strings[i];
if not DirectoryExists(DeDir+DocDir) then
begin
MkDir(DeDir+DocDir);
if not FileExists(DeDir+DocDir+'\Context.dat') then
StringtoFile('',DeDir+DocDir+'\Context.dat');
end
else
begin
//ShowMessage('GGG');
DocNoList.Delete(i);
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
if i <= CaseDocNo_CopiesList.Count-1 then
begin
//ShowMessage('KKKK');
CaseDocNo_CopiesList.Delete(i);
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
end;
end;
end;
//20170221 先註解起來 因為他在補充掃瞄時好像會有顯示的問題
for i := 0 to iFileList.Count - 1 do
begin
OldFile := iFileList.Strings[i];
DocDir := iFile_DocDirList.Strings[i];
if (DocDir = 'Attach') or (DocDir = 'S_Attach') then
begin
if not DirectoryExists(DeDir+DocDir) then
MkDir(DeDir+DocDir);
end;
FileList.Clear;
if FileExists(DeDir+DocDir+'\Context.dat') then
begin
FileList.LoadFromFile(DeDir+DocDir+'\Context.dat');
end;
NewFile := Add_Zoo(FileList.Count+1,3)+FileName2NoQuene_Filename(OldFile);
CopyFile(PWideChar(SoDir+OldFile),PWideChar(DeDir+DocDir+'\'+NewFile),False);
FileList.Add(NewFile);
FileList.SaveToFile(DeDir+DocDir+'\Context.dat');
end;
for i := DocNoList.Count -1 downto 0 do
begin
if (DocNoList.Strings[i] = 'Attach') or (DocNoList.Strings[i] = 'S_Attach') then
begin
DocNoList.Delete(i);
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
end;
end;
{if (DocNoList.Count > 0) and ((DocNoList.Strings[DocNoList.Count-1] = 'Attach') or (DocNoList.Strings[DocNoList.Count-1] = 'S_Attach')) then
begin
DocNoList.Delete(DocNoList.Count-1);
DocNoList.SaveToFile(DeDir+'CaseDocNo.dat');
end; }
CaseDocNo_CopiesList.Clear;
if FileExists(DeDir+'CaseDocNo_Copies.dat') then
CaseDocNo_CopiesList.LoadFromFile(DeDir+'CaseDocNo_Copies.dat');
if DocNoList.Count > CaseDocNo_CopiesList.Count then
begin
for i := 0 to DocNoList.Count - 1 do
begin
if i > CaseDocNo_CopiesList.Count-1 then
begin
CaseDocNo_CopiesList.Add('1');
//CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
end;
end;
end;
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
{if (not FileExists(DeDir+'CaseDocNo_Copies.dat') then
begin
CaseDocNo_CopiesList.Free;
for i := 0 to DocNoList.Count - 1 do
begin
CaseDocNo_CopiesList.Add('1');
CaseDocNo_CopiesList.SaveToFile(DeDir+'CaseDocNo_Copies.dat');
end;
end;}
if FileExists(SoDir+'AttContext.dat') then
begin
iAttFileList.LoadFromFile(SoDir+'AttContext.dat');
for i := 0 to iAttFileList.Count - 1 do
begin
AttFile := iAttFileList.Strings[i];
CopyFile(PWideChar(SoDir+AttFile),PWideChar(DeDir+AttFile),False);
end;
iAttFileList.SaveToFile(DeDir+'AttContext.dat');
end;
if FMode='ESCAN' then
begin
InitExistImgList(DeDir);
end;
finally
iFileList.Free;
FileList.Free;
DocNoList.Free;
iFile_DocDirList.Free;
end;
end;
Function TCB_IMGPSScanX.FileName2NoQuene_Filename(FileName:String):String; //取出沒有序號的檔名
var
v,v1 : Integer;
FName : String;
begin
FName := ExtractFileName(FileName);
v := Pos('_',FName);
if v = 0 then //附件
v := pos('.',FName);
v1 := length(FName);
Result := Copy(FName,v,v1-v+1);
end;
Function TCB_IMGPSScanX.FileName2Index(FileName:String):Integer; //從檔名取出在ContextList的序號
var
i : Integer;
begin
for i := 0 to ContextList.Count - 1 do
begin
if FileName = ContextList.Strings[i] then
begin
Result := i;
Break;
end;
end;
end;
Function TCB_IMGPSScanX.FileName2NowDcoNo(FileName:String;CtList,DNList:TStrings):String; //從檔名取出歸屬的文件代號
var
i : Integer;
begin
for I := 0 to CTList.Count -1 do
begin
if FileName = CTList.Strings[i] then
begin
Result := DNList.Strings[i];
break;
end;
end;
end;
Function TCB_IMGPSScanX.DocNo2DocName(CaseID,DocNo:String):String; //Docno轉Doc名稱
var
i,v,ln : Integer;
CusDocNo,CusDocName : String;
begin
Result := '';
if DocNo = AttName then
begin
Result := _Msg('未歸類');
end
Else
begin
If FindSQLData(Doc_Inf_List,'DOC_U_DESC','DOC_NO',DocNo,0,FindResult) Then
begin
//ShowMessage(FindResult.Text);
Result := GetFindResult('DOC_U_DESC');
end;
end;
if Result = '' then //去自訂文件裡找
begin
Result := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
{for i := 0 to Cust_DocNoList.Count - 1 do
begin
v := Pos('_',Cust_DocNoList.Strings[i]);
ln := length(Cust_DocNoList.Strings[i]);
CusDocNo := Copy(Cust_DocNoList.Strings[i],1,v-1);
CusDocName := Copy(Cust_DocNoList.Strings[i],v+1,ln-v);
if DocNo = CusDocNo then
begin
Result := CusDocName;
Break;
end;
end;}
end;
end;
Function TCB_IMGPSScanX.DocNo2FileName(DocNo:String;List:TStrings):String; //用DocNo找出檔名(第一頁)
var
i : Integer;
begin
Result := '';
for i := 0 to List.Count - 1 do
begin
IF DocNo = FormCode2DocNo(FileName2FormCode(List.Strings[i])) then
begin
Result := List.Strings[i];
Break;
end;
end;
end;
Function TCB_IMGPSScanX.DocNo2WorkNo(DocNo:String):String; //用DocNo取出作業別
begin
Result := '';
If FindSQLData(Doc_Inf_List,'WORK_NO','DOC_NO',DocNo,0,FindResult) Then
begin
Result := GetFindResult('WORK_NO');
end;
end;
Function TCB_IMGPSScanX.DocNoNeedDiv(DocNo:String):Boolean; //是否是需分份數的文件代號
var
NeedDiv : String;
begin
Result := False;
If FindSQLData(Doc_Inf_List,'IS_DOC_DIV','DOC_NO',DocNo,0,FindResult) Then
begin
NeedDiv := GetFindResult('IS_DOC_DIV');
if NeedDiv = 'Y' then
Result := True;
end;
end;
Function TCB_IMGPSScanX.DocnoNeedGroup(DocNo:String):Boolean; //傳入的DocNo是否需分組
begin
Result := False;
If FindSQLData(Doc_Inf_List,'IS_DOC_DIV','DOC_NO',DocNo,0,FindResult) Then
begin
if GetFindResult('IS_DOC_DIV') = 'Y' Then
Result := True;
end;
end;
Function TCB_IMGPSScanX.OMRCheckCase(CaseID:String):Boolean; //OMR檢核
var
i,n,m,v,v1 : Integer;
XT,RelaXT,ValueXT : TXmltool;
OMRFormCode,OMRFile,OMRFormName,ColEName,ColCName,Site : String;
Pixel : Integer;
RelaFormCode,RelaFile,RelaFormName,RelaColEName,RelaColCName,RelaSite : String;
RelaDocNo,RelaDocName : string;
RelaPixel : Integer;
s : String;
nodename : String;
OMROK : Boolean;
CaseOk : Boolean;
ErrStr : String;
SiteRec,RelaSiteRec : String; //多組位置記錄
OMRValue : String;
MainFormID,MainDocNo,MainVersion : String; //主FormID
MainFormPage,CaseFormPage : Integer; //主要文件需要的頁數
NeedDocNoStr,NoDocNoStr : String; //相依 互斥文件字串
List : TStringlist;
FormCode : String;
FormDataPages : Integer;
NoSite : Boolean; //未定位
Anchor,Anchor1 : String;
OMROkCount : Integer;
//Casecheck : Boolean; //是否要做檢核
//AllCheck : Boolean; //是否要做完整檢核
ISB8W,ISB8H:integer;
begin
///OMRErrInfo 1: 必要文件 2:相依文件 3:互斥文件 4:必填 5:欄位有值附文件 6:欄位有值不附文件
/// 7: 欄位有值相關欄位也要有值 8:欄位有值要寫備註 9:停用日期 10:最大頁數
//Casecheck := True;
//Allcheck := True;
//if (FMode = 'ISCAN') then
//Allcheck := False;
CaseOk := True;
//if Casecheck then
//begin
DeleteFile(ImageSavePath+CaseID+'\upload\Checkerr.ini');
DeleteFile(ImageSavePath+CaseID+'\upload\CheckMemo.dat');
//DeleteFile(ImageSavePath+CaseID+'\upload\ReSize.dat');
DeleteFile(ImageSavePath+CaseID+'\upload\RemoveMemo.dat');
DeleteFile(ImageSavePath+CaseID+'\upload\OMRCheckOk.dat');
Memo1.Lines.Clear;
OMRFileList.Clear;
MainFormID := GetCaseFormID(ImageSavePath+CaseID+'\upload\');
List := TStringlist.Create;
try
//if AllCheck then
//begin
if GetCasePage(ImageSavePath,CaseID) =0 then
begin
end;
//ShowMessage('MainFormID='+MainFormID);
LogFile1.LogToFile(logTimeString+' '+FModeName+' '+CaseID+' '+'MainFormID='+MainFormID);
if MainFormID = ''then
begin
//20131203 yuu說不檢查這個,先拿掉 20170315 楷琳說未歸類要擋 20170726 因此有檢查必要FormID 所以 可以拿掉
{if FCheck_main_form='Y' then
begin
if (FMode <> 'SSCAN') AND (FMode<>'ESCAN') then //簽署章件會換主FormID,先跳過 20170629 ESCAN 也不檢查
begin
ErrStr:=_Msg('找不到分案文件'); //找不到主文件
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,False,True);
CaseOk := false;
//ShowMessage('AAAAA');
end;
end;
}
end
Else
begin
//////主要非主要文件//////
DistinctDocinCase(ImageSavePath+CaseID+'\upload\');
//ShowMessage(DocNo_VerinCase.Text);
//DocNo_VerinCase.Add('31A00101_1706A');
LogFile1.LogToFile(logTimeString+' '+CaseID+' '+'DocNo_VerinCase.Text='+DocNo_VerinCase.Text);
if ModeNeedCheck(OMRErrInfo[1].Mode,FMode) then //是否要檢核
begin
for i := 0 to DocNo_VerinCase.Count - 1 do
begin
v := Pos('_', DocNo_VerinCase.Strings[i]);
v1 := length(DocNo_VerinCase.Strings[i]);
MainDocNo := Copy(DocNo_VerinCase.Strings[i],1,v-1); //FormCode2DocNo(MainFormID);
MainVersion :=Copy(DocNo_VerinCase.Strings[i],v+1,v1-v); //FormCode2Version(MainFormID);
MainFormPage := GetDataDocNoPage(MainDocNo,MainVersion); //資料庫記錄主文件頁數
CaseFormPage := CheckCaseDocNoPage(CaseID,MainDocNo,MainVersion,MainFormPage); //案件主文件的頁數
LogFile1.LogToFile(logTimeString+CaseID+',MainDocNo='+MainDocNo+',MainVersion='+MainVersion+',MainFormPage='+IntToStr(MainFormPage)+',CaseFormPage='+IntToStr(CaseFormPage));
//CheckFirstDocNoPage
IF (MainFormPage > 0) and (MainFormPage <> CaseFormPage) then
begin
ErrStr:=MainDocNo+Format(OMRErrInfo[1].Info,[Inttostr(MainFormPage),Inttostr(CaseFormPage)]); //主要文件需有XX頁僅附XX頁
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,OMRErrInfo[1].Ignore,OMRErrInfo[1].Display);
if OMRErrInfo[1].Display then
CaseOk := false;
end;
end;
end;
//////主要非主要文件/////
//showmessage(MainFormID);
MainDocNo := FormCode2DocNo(MainFormID);
MainVersion := FormCode2Version(MainFormID);
if FindSQLData(DM_FORM_INF_List,'DEPE_FORM_ID,MUTEX_FORM_ID','MAIN_FORM_ID,DOC_VERSION',MainDocNo+','+MainVersion,0,FindResult) then
begin
NeedDocNoStr := GetFindResult('DEPE_FORM_ID');
NoDocNoStr := GetFindResult('MUTEX_FORM_ID');
end
Else if FindSQLData(DM_FORM_INF_List,'DEPE_FORM_ID,MUTEX_FORM_ID','MAIN_FORM_ID,DOC_VERSION',MainDocNo+','+MainVersion,0,FindResult) then
begin
NeedDocNoStr := GetFindResult('DEPE_FORM_ID');
NoDocNoStr := GetFindResult('MUTEX_FORM_ID');
end;
//////相依文件/////
if ModeNeedCheck(OMRErrInfo[2].Mode,FMode) then //是否要檢核
begin
List.CommaText := NeedDocNoStr;
for I := 0 to List.Count - 1 do
begin
if not Case_DocNoExists(CaseID,List.Strings[i]) then //沒附相依文件
begin
if FWH_category='N' then
begin
if ISExistImg(ImageSavePath+CaseID+'\upload\'+List.Strings[i]) then
begin
Continue;
end;
end;
ErrStr:=Format(OMRErrInfo[2].Info,[DocNo2DocName(CaseID,List.Strings[i])]); //沒附相依文件
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,OMRErrInfo[2].Ignore,OMRErrInfo[2].Display);
if OMRErrInfo[2].Display then
CaseOk := false;
end;
end;
end;
//////相依文件/////
//////互斥文件/////
if ModeNeedCheck(OMRErrInfo[3].Mode,FMode) then //是否要檢核
begin
List.CommaText := NoDocNoStr;
for I := 0 to List.Count - 1 do
begin
if Case_DocNoExists(CaseID,List.Strings[i]) then //附了互斥文件
begin
if FWH_category='N' then
begin
if ISExistImg(ImageSavePath+CaseID+'\upload\'+List.Strings[i]) then
begin
Continue;
end;
end;
ErrStr:=Format(OMRErrInfo[3].Info,[DocNo2DocName(CaseID,List.Strings[i])]); //有附互斥文件
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,OMRErrInfo[3].Ignore,OMRErrInfo[3].Display);
if OMRErrInfo[3].Display then
CaseOk := false;
end;
end;
end;
//////互斥文件/////
end; //MainFormID結束
//end;
List.LoadFromFile(ImageSavePath + CaseID+'\upload\Context.dat');
for i := 0 to List.Count - 1 do
begin
FormCode := FileName2FormCode(List.Strings[i]);
/////未歸類///
{IF FormCode = 'Attach' Then //20140211 yuu說不檢查了
begin
ErrStr:=_Msg('尚有文件未歸類');
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,False,True);
CaseOk := false;
end; }
/////未歸類//////
/////未註冊文件/////
{IF not FormIDExists(FormCode,False) then //未註冊文件
begin
ErrStr:=FormCode+_Msg('不為此業務的表單代碼');
OMRErr2ini(CaseID,ErrStr,'','','','',False,False,True);
CaseOk := false;
end }
/////未註冊文件/////
//////停用文件//
{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;
//////停用文件////
end;
finally
List.Free;
end;
//if AllCheck then
//begin
//////最大頁數///
LogFile1.LogToFile(logTimeString+'最大頁數A段 '+CaseID+' '+'OMRFileList.Text='+OMRFileList.Text);
DistinctFormCode(CaseID);
if ModeNeedCheck(OMRErrInfo[10].Mode,FMode) then //是否要檢核
begin
//ShowMessage('AAA'+OMRFileList.Text);
LogFile1.LogToFile(logTimeString+'最大頁數B段 '+CaseID+' '+'OMRFileList.Text='+OMRFileList.Text);
For i := 0 to OMRFileList.Count - 1 do
begin
if FModeName=_Msg('異動件') then Continue;
if FWH_category='N' then
begin
if ISExistImg(ImageSavePath+CaseID+'\upload\'+OMRFileList.Strings[i]) then
begin
Continue;
end;
end;
FormCode := FileName2FormCode(OMRFileList.Strings[i]);
FormDataPages := GetDataFormCodePages(FormCode);
IF (FormCode <> '') and (FormDataPages > 0) and (FindFormCodePages(CaseID,FormCode) > FormDataPages) then //有超過最大頁數的文件
begin
ErrStr:=Format(OMRErrInfo[10].Info,[FormCode2FormName(CaseID,FormCode),inttostr(FormDataPages)]); //有超過最大頁數文件
OMRErr2ini(CaseID,ErrStr,'','','','','','',False,OMRErrInfo[10].Ignore,OMRErrInfo[10].Display);
if OMRErrInfo[10].Display then
CaseOk := false;
end;
end;
end;
/////最大頁數/////
//end;
ImageScrollBox1.FileName := '';
//if FWork_No = 'CW' then //理賠就不做下面的檢核了
//begin
//////OMR檢核///////
ContextList.LoadFromFile(ImageSavePath+CaseID+'\upload\Context.dat');
DistinctFormCode(CaseID);
ValueXT := TXmltool.Create;
Try
//ShowMessage('必填'+OMRFileList.Text);
LogFile1.LogToFile(logTimeString+'必填 '+CaseID+' '+'OMRFileList.Text='+OMRFileList.Text);
For i := 0 to OMRFileList.Count - 1 do
begin
//ShowMessage('OMRFileList.Strings['+IntToStr(i)+']'+OMRFileList.Strings[i]);
if CheckRequiredColumnValues(FWork_NO,CaseID) then Continue;
OMRFile := OMRFileList.Strings[i];
OMRFormCode := FileName2FormCode(OMRFileList.Strings[i]);
OMRFormName := FormCode2FormName(CaseID,OMRFormCode);
Anchor := FormID2Anchor(OMRFormCode);
///依十字定位點縮放////
ImageReSize_FormID(CaseID,OMRFile);
////依十字定位點縮放///
//Display1.Lines.Add('OMRFile='+OMRFile+',OMRFormCode='+OMRFormCode+',OMRFormName='+OMRFormName);
LogFile1.LogToFile(logTimeString+'OMRFile='+OMRFile+',OMRFormCode='+OMRFormCode+',OMRFormName='+OMRFormName);
//ShowMessage('KKKKK');
if not FileExists(CheckXmlPath+FWork_no+'\'+OMRFormCode+'.xml') then //沒有Xml就不用檢核
Continue;
//ShowMessage('11638 OMRFileList.Strings['+IntToStr(i)+']'+OMRFileList.Strings[i]);
XT := TXmltool.Create(CheckXmlPath+FWork_no+'\'+OMRFormCode+'.xml');
RelaXT := TXmltool.Create;
//ShowMessage('ModeNeedCheck='+BoolToStr(ModeNeedCheck(OMRErrInfo[4].Mode,FMode),true));
try
//*******必填********
if ModeNeedCheck(OMRErrInfo[4].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype1/'].First then
Repeat
OMROK := False;
SiteRec := ''; //清掉
ColEName := XT.SubNodes['/form/settype1/'].NodeName;
ColCName := XT.Node['/form/settype1/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
if XT.SubNodes['/form/settype1/'+ColEName+'/'].First then
Repeat
nodename := XT.SubNodes['/form/settype1/'+ColEName+'/'].NodeName;
If nodename <> '@coldesc' then
begin
Pixel := Strtoint(XT.Node['/form/settype1/'+ColEName+'/'+nodename+'/'].Attributes['pixel']);
Site := XT.Node['/form/settype1/'+ColEName+'/'+nodename+'/'].Attributes['colxy'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
//有填就ok
//Showmessage(ColCName +','+ inttostr(OMRMpsV1.GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site))+','+inttostr(Pixel + SafePixel));
//SafePixel:=90000;
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
//FindPoint(ISB_BW.Graphic,UpLPoint,UpRPoint,DownLPoint,ANCHOR);
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
//Showmessage('oh');
OMROK := True;
Break;
end;
end
Else
begin
//ColCName := XT['/form/settype1/'+ColEName+'/'+nodename+'/'];
end;
Until not XT.SubNodes['/form/settype1/'+ColEName+'/'].Next;
if not OMROk then
begin
ErrStr:=Format(OMRErrInfo[4].Info,[ColCName]); //XX欄位未填寫
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,'','',Anchor,Anchor1,False,OMRErrInfo[4].Ignore,OMRErrInfo[4].Display);
if OMRErrInfo[4].Display then
CaseOk := false;
end;
Until not XT.SubNodes['/form/settype1/'].Next ;
end;
//*******必填********
//ShowMessage('11692 OMRFileList.Strings['+IntToStr(i)+']'+OMRFileList.Strings[i]);
//if AllCheck then
//begin
//*******有值相關文件的欄位也要有值*******
if ModeNeedCheck(OMRErrInfo[7].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype3/'].First then
Repeat
SiteRec := '';
RelaSiteRec := '';
ColEName := XT.SubNodes['/form/settype3/'].NodeName;
ColCName := XT.Node['/form/settype3/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
Site := XT.Node['/form/settype3/'+ColEName+'/'].Attributes['colxy'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
Pixel := XT.Node['/form/settype3/'+ColEName+'/'].Attributes['pixel'];
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
////有填寫////
if XT.SubNodes['/form/settype3/'+ColEName+'/'].First then
Repeat
RelaSiteRec := '';
nodename := XT.SubNodes['/form/settype3/'+ColEName+'/'].NodeName;
If (nodename <> '@coldesc') and (not XT.SubNodes['/form/settype3/'+ColEName+'/'].NodeIsAttr) then
begin
RelaFormCode := XT.node['/form/settype3/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaColEName := XT.node['/form/settype3/'+ColEName+'/'+nodename+'/'].Attributes['rela_col_name'];
RelaColCName := XT.node['/form/settype3/'+ColEName+'/'+nodename+'/'].Attributes['relacoldesc'];
RelaColCName := Copy(RelaColCName,1,length(RelaColCName)-6);
RelaFile := FormCode2FileName(RelaFormCode,ContextList);
RelaFormName := FormCode2FormName(CaseID,RelaFormCode);
Anchor1 := FormID2Anchor(RelaFormCode);
RelaXT.LoadFromFile(CheckXmlPath+FWork_no+'\'+RelaFormCode+'.xml');
Display1.Lines.Add(RelaFile+','+RelaFormName);
//ShowMessage(RelaFile);
//ShowMessage(ImageSavePath+CaseID+'\upload\'+RelaFile);
if RelaFile<>'' then
begin
ISB8.LoadFromFile(ImageSavePath+CaseID+'\upload\'+RelaFile,1); //20170815
ISB8W:= ISB8.Graphic.Width;
ISB8H:= ISB8.Graphic.Height;
FindPoint(ISB8.Graphic,UpLPoint,UpRPoint,DownLPoint,ISB8W,ISB8H,ANCHOR); //20170815 抓相關然欄位所在圖檔的定位
end;
OMROK := False;
//OMROK := False;
//if RelaXT.SubNodes['/form/settype2/'].First then
//Repeat
NoSite := True;
if RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].Count >0 then
NoSite := False;
if RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].First then
Repeat
nodename := RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].NodeName;
If nodename <> '@coldesc' then
begin
RelaPixel := Strtoint(RelaXT.Node['/form/settype2/'+RelaColEName+'/'+nodename+'/'].Attributes['pixel']);
RelaSite := RelaXT.Node['/form/settype2/'+RelaColEName+'/'+nodename+'/'].Attributes['colxy'];
if RelaSiteRec= '' then //記錄位置
RelaSiteRec := RelaSite
else
RelaSiteRec := RelaSiteRec+'@'+RelaSite;
if FileExists(ImageSavePath+CaseID+'\upload\'+RelaFile) then
begin
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+RelaFile,RelaSite,Bt) > (RelaPixel + SafePixel) then
begin
OMROK := True;
Break;
end;
///依十字定位點縮放////
ImageReSize_FormID(CaseID,OMRFile); //20170815 重新抓定位
////依十字定位點縮放////
end;
end;
Until not RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].Next;
if not OMROk then
begin
if not FileExists(ImageSavePath+CaseID+'\upload\'+RelaFile) then
ErrStr:=Format(OMRErrInfo[7].Info,[ColCName,RelaColCName])+'('+_msg('未附')+RelaFormName+')' //XX欄位填寫時,XX欄位未填寫
Else if NoSite then
ErrStr:=Format(OMRErrInfo[7].Info,[ColCName,RelaColCName])+'('+_msg('未定位')+')'
Else
ErrStr:=Format(OMRErrInfo[7].Info,[ColCName,RelaColCName]); //XX欄位填寫時,XX欄位未填寫
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,ImageSavePath+CaseID+'\upload\'+RelaFile,RelaSiteRec,Anchor,Anchor1,False,OMRErrInfo[7].Ignore,OMRErrInfo[7].Display);
if OMRErrInfo[7].Display then
CaseOk := false;
end;
//Until not RelaXT.SubNodes['/form/settype2/'].Next ;
end;
Until not XT.SubNodes['/form/settype3/'+ColEName+'/'].Next;
end;
Until not XT.SubNodes['/form/settype3/'].Next ;
end;
//*******有值相關文件的欄位也要有值*******
//ShowMessage('11788 OMRFileList.Strings['+IntToStr(i)+']'+OMRFileList.Strings[i]);
//*******有值相關文件的欄位不能有值*******
if ModeNeedCheck(OMRErrInfo[11].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype8/'].First then
Repeat
SiteRec := '';
RelaSiteRec := '';
OMROkCount := 0;
ColEName := XT.SubNodes['/form/settype8/'].NodeName;
ColCName := XT.Node['/form/settype8/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
Site := XT.Node['/form/settype8/'+ColEName+'/'].Attributes['colxy'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
Pixel := XT.Node['/form/settype8/'+ColEName+'/'].Attributes['pixel'];
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
////有填寫// //
inc(OMROkCount);
end;
if XT.SubNodes['/form/settype8/'+ColEName+'/'].First then
Repeat
RelaSiteRec := '';
nodename := XT.SubNodes['/form/settype8/'+ColEName+'/'].NodeName;
If (nodename <> '@coldesc') and (not XT.SubNodes['/form/settype8/'+ColEName+'/'].NodeIsAttr) then
begin
RelaFormCode := XT.node['/form/settype8/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaColEName := XT.node['/form/settype8/'+ColEName+'/'+nodename+'/'].Attributes['rela_col_name'];
RelaColCName := XT.node['/form/settype8/'+ColEName+'/'+nodename+'/'].Attributes['relacoldesc'];
RelaColCName := Copy(RelaColCName,1,length(RelaColCName)-6);
RelaFile := FormCode2FileName(RelaFormCode,ContextList);
RelaFormName := FormCode2FormName(CaseID,RelaFormCode);
Anchor1 := FormID2Anchor(RelaFormCode);
RelaXT.LoadFromFile(CheckXmlPath+FWork_no+'\'+RelaFormCode+'.xml');
if RelaFile<>'' then
begin
ISB8.LoadFromFile(ImageSavePath+CaseID+'\upload\'+RelaFile,1); //20170815
ISB8W:= ISB8.Graphic.Width;
ISB8H:= ISB8.Graphic.Height;
FindPoint(ISB8.Graphic,UpLPoint,UpRPoint,DownLPoint,ISB8W,ISB8H,ANCHOR); //20170815 抓相關然欄位所在圖檔的定位
end;
OMROK := False;
//OMROK := False;
//if RelaXT.SubNodes['/form/settype2/'].First then
//Repeat
NoSite := True;
if RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].Count >0 then
NoSite := False;
if RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].First then
Repeat
nodename := RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].NodeName;
If nodename <> '@coldesc' then
begin
RelaPixel := Strtoint(RelaXT.Node['/form/settype2/'+RelaColEName+'/'+nodename+'/'].Attributes['pixel']);
RelaSite := RelaXT.Node['/form/settype2/'+RelaColEName+'/'+nodename+'/'].Attributes['colxy'];
if RelaSiteRec= '' then //記錄位置
RelaSiteRec := RelaSite
else
RelaSiteRec := RelaSiteRec+'@'+RelaSite;
if FileExists(ImageSavePath+CaseID+'\upload\'+RelaFile) then
begin
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+RelaFile,RelaSite,Bt) > (RelaPixel + SafePixel) then
begin
inc(OMROkCount);
//OMROK := True;
//Break;
end;
///依十字定位點縮放////
ImageReSize_FormID(CaseID,OMRFile);
////依十字定位點縮放////
end;
end;
//Else
//begin
//ColCName := XT['/form/settype1/'+ColEName+'/'+nodename+'/'];
//end;
Until not RelaXT.SubNodes['/form/settype2/'+RelaColEName+'/'].Next;
if OMROkCount > 1 then
begin
if not FileExists(ImageSavePath+CaseID+'\upload\'+RelaFile) then
ErrStr:=Format(OMRErrInfo[11].Info,[ColCName,RelaColCName])+'('+_msg('未附')+RelaFormName+')' //XX欄位填寫時,XX欄位也填寫
Else if NoSite then
ErrStr:=Format(OMRErrInfo[11].Info,[ColCName,RelaColCName])+'('+_msg('未定位')+')'
Else
ErrStr:=Format(OMRErrInfo[11].Info,[ColCName,RelaColCName]); //XX欄位填寫時,XX欄位也填寫
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,ImageSavePath+CaseID+'\upload\'+RelaFile,RelaSiteRec,Anchor,Anchor1,False,OMRErrInfo[7].Ignore,OMRErrInfo[7].Display);
if OMRErrInfo[11].Display then
CaseOk := false;
end;
//Until not RelaXT.SubNodes['/form/settype2/'].Next ;
end;
Until not XT.SubNodes['/form/settype8/'+ColEName+'/'].Next;
Until not XT.SubNodes['/form/settype8/'].Next ;
end;
//*******有值相關文件的欄位不能有值*******
//ShowMessage('11889 OMRFileList.Strings['+IntToStr(i)+']'+OMRFileList.Strings[i]);
//*******有值相依文件*******
if ModeNeedCheck(OMRErrInfo[5].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype4/'].First then
Repeat
SiteRec := '';
RelaSiteRec := '';
ColEName := XT.SubNodes['/form/settype4/'].NodeName;
ColCName := XT.Node['/form/settype4/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
Site := XT.Node['/form/settype4/'+ColEName+'/'].Attributes['colxy'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
Pixel := XT.Node['/form/settype4/'+ColEName+'/'].Attributes['pixel'];
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
////有填寫////
if XT.SubNodes['/form/settype4/'+ColEName+'/'].First then
Repeat
nodename := XT.SubNodes['/form/settype4/'+ColEName+'/'].NodeName;
If (nodename <> 'coldesc') and (not XT.SubNodes['/form/settype4/'+ColEName+'/'].NodeIsAttr) then
begin
{RelaFormCode := XT.Node['/form/settype4/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaFile := FormCode2FileName(RelaFormCode);
RelaFormName := FormCode2FormName(RelaFormCode); }
RelaDocNo := XT.Node['/form/settype4/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaFile := DocNo2FileName(RelaDocNo,ContextList);
RelaDocName := XT.Node['/form/settype4/'+ColEName+'/'+nodename+'/'].Attributes['relaformname'];
if RelaFile='' then
begin
ErrStr:=Format(OMRErrInfo[5].Info,[ColCName,RelaDocName]); //XX文件XX欄位填寫時,需附XX文件
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,'','',Anchor,Anchor1,False,OMRErrInfo[5].Ignore,OMRErrInfo[5].Display);
if OMRErrInfo[5].Display then
CaseOk := false;
end;
end;
Until not XT.SubNodes['/form/settype4/'+ColEName+'/'].Next;
end;
Until not XT.SubNodes['/form/settype4/'].Next ;
end;
//*******有值相依文件*******
//*******有值互斥文件*******
if ModeNeedCheck(OMRErrInfo[6].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype5/'].First then
Repeat
SiteRec := '';
RelaSiteRec := '';
ColEName := XT.SubNodes['/form/settype5/'].NodeName;
ColCName := XT.Node['/form/settype5/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
Site := XT.Node['/form/settype5/'+ColEName+'/'].Attributes['colxy'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
Pixel := XT.Node['/form/settype5/'+ColEName+'/'].Attributes['pixel'];
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
////有填寫////
if XT.SubNodes['/form/settype5/'+ColEName+'/'].First then
Repeat
nodename := XT.SubNodes['/form/settype5/'+ColEName+'/'].NodeName;
If (nodename <> 'coldesc') and (not XT.SubNodes['/form/settype5/'+ColEName+'/'].NodeIsAttr) then
begin
{RelaFormCode := XT.Node['/form/settype5/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaFile := FormCode2FileName(RelaFormCode);
RelaFormName := FormCode2FormName(RelaFormCode);}
RelaDocNo := XT.Node['/form/settype5/'+ColEName+'/'+nodename+'/'].Attributes['relaformid'];
RelaFile := DocNo2FileName(RelaDocNo,ContextList);
RelaDocName := XT.Node['/form/settype5/'+ColEName+'/'+nodename+'/'].Attributes['relaformname'];
if RelaFile<>'' then //有附 20130604看到(='')改的(未測)
begin
ErrStr:=Format(OMRErrInfo[6].Info,[ColCName,RelaDocName]); //XX文件XX欄位填寫時,不能附XX文件
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,'','',Anchor,Anchor1,False,OMRErrInfo[6].Ignore,OMRErrInfo[6].Display);
if OMRErrInfo[6].Display then
CaseOk := false;
end;
end;
Until not XT.SubNodes['/form/settype5/'+ColEName+'/'].Next;
end;
Until not XT.SubNodes['/form/settype5/'].Next ;
end;
//*******有值互斥文件*******
//*******有值寫備註*******
if ModeNeedCheck(OMRErrInfo[8].Mode,FMode) then //是否要檢核
begin
if XT.SubNodes['/form/settype6/'].First then
Repeat
SiteRec := '';
ColEName := XT.SubNodes['/form/settype6/'].NodeName;
ColCName := XT.Node['/form/settype6/'+ColEName+'/'].Attributes['coldesc'];
ColCName := Copy(ColCName,1,length(ColCName)-6);
Site := XT.Node['/form/settype6/'+ColEName+'/'].Attributes['colxy'];
Pixel := XT.Node['/form/settype6/'+ColEName+'/'].Attributes['pixel'];
if SiteRec= '' then //記錄位置
SiteRec := Site
else
SiteRec := SiteRec+'@'+Site;
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
////有填寫////
if not FileExists(ImageSavePath+CaseID+'ScanMemo.dat') then
begin
ErrStr:=Format(OMRErrInfo[8].Info,[ColCName]); //XX文件XX欄位填寫時,需寫備註
OMRErr2ini(CaseID,ErrStr,ImageSavePath+CaseID+'\upload\'+OMRFile,SiteRec,'','',Anchor,Anchor1,False,OMRErrInfo[8].Ignore,OMRErrInfo[8].Display);
if OMRErrInfo[8].Display then
CaseOk := false;
end;
end;
Until not XT.SubNodes['/form/settype6/'].Next ;
end;
//*******有值寫備註*******
//*******OMR帶值********
if XT.SubNodes['/form/settype7/'].First then
Repeat
ColEName := XT.SubNodes['/form/settype7/'].NodeName;
ValueXT['/content/'+ColEName+'/@savevalue'] := ''; //先給預設空白
if XT.SubNodes['/form/settype7/'+ColEName+'/'].First then
Repeat
nodename := XT.SubNodes['/form/settype7/'+ColEName+'/'].NodeName;
If nodename <> '@coldesc' then
begin
Pixel := Strtoint(XT.Node['/form/settype7/'+ColEName+'/'+nodename+'/'].Attributes['pixel']);
Site := XT.Node['/form/settype7/'+ColEName+'/'+nodename+'/'].Attributes['colxy'];
OMRValue := XT.Node['/form/settype7/'+ColEName+'/'+nodename+'/'].Attributes['getvalue'];
//有填就ok
Display1.Lines.Add(ColEName+' '+ColCName+' 圖像實際點數='+IntToStr(GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt))+' 設定點數='+IntToStr( (Pixel + SafePixel)));
if GetSiteOMR(ImageSavePath+CaseID+'\upload\'+OMRFile,Site,Bt) > (Pixel + SafePixel) then
begin
ValueXT['/content/'+ColEName+'/@savevalue'] := OMRValue; //有填就換成設定的值
Break;
end;
end;
Until not XT.SubNodes['/form/settype7/'+ColEName+'/'].Next;
Until not XT.SubNodes['/form/settype7/'].Next ;
//*******OMR帶值********
//end;
Finally
if (OMRValue <> '') then
ValueXT.SaveToFile(ImageSavePath+CaseID+'/GetValue.xml');
XT.Free;
RelaXT.Free;
end;
end;
//必填迴圈結束
Finally
ValueXT.Free;
end;
//end;
//end;
Result := CaseOk;
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;
Procedure TCB_IMGPSScanX.CreateDocNo_DocName(Path,CaseID:String); //產生DocNo_DocName.dat
var
i : Integer;
S : TStringlist;
Doc_Name : String;
begin
S := TStringlist.Create;
try
DistinctDocNoinCase(Path);
for i := 0 to CaseDocNoList.Count - 1 do
begin
Doc_Name := CaseDocNoList.Strings[i]+'_'+DocNo2DocName(CaseID,CaseDocNoList.Strings[i]);
if not DocnoNeedGroup(CaseDocNoList.Strings[i]) Then //不用分組的加*號給智豪
Doc_Name := '*'+Doc_Name;
S.Add(Doc_Name);
end;
S.SaveToFile(Path+'DocNo_Name.dat',TEnCoding.UTF8);
finally
S.Free;
end;
end;
Function TCB_IMGPSScanX.CreateDocNo_Info(CaseID:String):String; //產生 DocNo[tab]份數[tab]總頁數[tab]是否異動[換行]DocNo[tab]份數[tab]總頁數[tab]是否異動
var
i,n : Integer;
DocDirList,DocDir_CopiesList,FileList,C_DocNoList : TStringlist;
DocNo,iDocDir,iDocNo,iEdit:String;
icopys,ipages : integer;
S,S1 : TStringlist;
Str : String;
begin
DocDirList := TStringlist.Create;
DocDir_CopiesList := TStringlist.Create;
FileList := TStringlist.Create;
C_DocNoList := TStringlist.Create;
try
Str := '';
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
if DocDirList.Count =0 then exit;//20170222 新加
DocDir_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
while DocDirList.Count > 0 do
begin
iDocDir := DocDirList.Strings[0];
DocNo := DocNoDir2DocNo(iDocDir);
if Copy(iDocDir,1,5) <> 'ZZZZZ' then //不為自定文件
begin
//icopys := 1;
icopys := GetDocNoCount(CaseID,DocNo);
ipages := GetDocDir_Page(CaseID,iDocDir);
iEdit := GetDocNoEdit(CaseID,DocNo,'');
for i := DocDirList.Count - 1 downto 1 do
begin
iDocDir := DocDirList.Strings[i];
iDocNo := DocNoDir2DocNo(iDocDir);
if iDocNo = DocNo then
begin
//inc(icopys);
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
DocDirList.Delete(i);
end;
end;
if str = '' then
Str := Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocNo,iCopys,iPages,iEdit])
else
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocNo,iCopys,iPages,iEdit]);
end;
DocDirList.Delete(0);
end;
finally
DocDirList.Free;
DocDir_CopiesList.Free;
FileList.Free;
C_DocNoList.Free;
end;
Result := Str;
{S := TStringlist.Create;
S1 := TStringlist.Create;
try
S.LoadFromFile(Path+'Context.dat');
S1.LoadFromFile(Path+'Context_DocNo.dat');
for i := 0 to CaseDocNoList.Count - 1 do
begin
iDocNo := CaseDocNoList.Strings[i];
iCopys := GetDocNo_Count(Path,iDocNo);
iPages := GetDocNo_Page(Path,iDocNo);
if str = '' then
Str := Format('%s,%d,%d',[iDocNo,iCopys,iPages])
else
Str := Str+';'+ Format('%s,%d,%d',[iDocNo,iCopys,iPages]);
end;
Result := Str;
finally
S.Free;
S1.Free;
end; }
end;
Function TCB_IMGPSScanX.CreateCustDocNo_Info(CaseID:String):String; //產生自訂文件 DocName[tab]份數[tab]總頁數[tab]是否異動[#13#10]DocName[tab]份數[tab]總頁數[tab]是否異動
var
i,n : Integer;
DocDirList,FileList : TStringlist;
DocNo,DocName,iDocDir,iDocNo,iEdit:String;
icopys,ipages : integer;
S,S1 : TStringlist;
Str : String;
begin
DocDirList := TStringlist.Create;
FileList := TStringlist.Create;
try
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];
DocNo := DocNoDir2DocNo(iDocDir);
if Copy(iDocDir,1,5) = 'ZZZZZ' then //是自定文件
begin
//icopys := 1;
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
icopys := GetDocNoCount(CaseID,DocNo);
ipages := GetDocDir_Page(CaseID,iDocDir);
iEdit := GetDocNoEdit(CaseID,DocNo,DocName);
for i := DocDirList.Count - 1 downto 1 do
begin
iDocDir := DocDirList.Strings[i];
iDocNo := DocNoDir2DocNo(iDocDir);
if iDocNo = DocNo then
begin
//inc(icopys);
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
DocDirList.Delete(i);
end;
end;
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
if str = '' then
Str := Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocName,iCopys,iPages,iEdit])
else
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%d'+#9+'%s',[DocName,iCopys,iPages,iEdit]);
end;
DocDirList.Delete(0);
end;
finally
DocDirList.Free;
FileList.Free;
end;
Result := Str;
end;
Function TCB_IMGPSScanX.CreateDocnoFrom_Info(CaseID:String):String; //產生被引進的保管袋文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
var
i,n : Integer;
DocDirList,DocDir_CopiesList,FileList : TStringlist;
DocNo,iDocDir,iDocNo,iEdit:String;
FromCaseID : string;
icopys,ipages : integer;
S,S1 : TStringlist;
Str : String;
begin
DocDirList := TStringlist.Create;
DocDir_CopiesList := TStringlist.Create;
FileList := TStringlist.Create;
try
Str := '';
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
if DocDirList.Count=0 then exit;//20170222 新加
DocDir_CopiesList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo_Copies.dat');
while DocDirList.Count > 0 do
begin
iDocDir := DocDirList.Strings[0];
DocNo := DocNoDir2DocNo(iDocDir);
if (Copy(iDocDir,1,5) <> 'ZZZZZ') then //不為自定文件
begin
//icopys := 1;
//icopys := GetDocNoCount(CaseID,DocNo);
icopys := GetDocDirCopies(CaseID,iDocDir);
ipages := GetDocDir_Page(CaseID,iDocDir);
iEdit := GetDocNoEdit(CaseID,DocNo,'');
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
if FromCaseID <> '' then
begin
for i := DocDirList.Count - 1 downto 1 do
begin
iDocDir := DocDirList.Strings[i];
iDocNo := DocNoDir2DocNo(iDocDir);
if (iDocNo = DocNo) and (GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir)<>'') then
begin
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
//inc(icopys);
icopys := icopys + GetDocDirCopies(CaseID,iDocDir);
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
DocDirList.Delete(i);
end;
end;
if str = '' then
Str := Format('%s'+#9+'%d'+#9+'%s',[DocNo,iCopys,FromCaseID])
else
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%s',[DocNo,iCopys,FromCaseID]);
end;
end;
DocDirList.Delete(0);
end;
finally
DocDirList.Free;
DocDir_CopiesList.Free;
FileList.Free;
end;
Result := Str;
end;
Function TCB_IMGPSScanX.CreateCustDocNoFrom_Info(CaseID:String):String; //產生被引進的自定文件資訊 Docno[tab]份數[tab]案件編號#13#10Docno[tab]份數[tab]案件編號
var
i,n : Integer;
DocDirList,FileList : TStringlist;
DocNo,DocName,iDocDir,iDocNo,iEdit:String;
FromCaseID : string;
icopys,ipages : integer;
S,S1 : TStringlist;
Str : String;
begin
DocDirList := TStringlist.Create;
FileList := TStringlist.Create;
try
Str := '';
if Not FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then Exit;
DocDirList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat');
while DocDirList.Count > 0 do
begin
iDocDir := DocDirList.Strings[0];
DocNo := DocNoDir2DocNo(iDocDir);
if Copy(iDocDir,1,5) = 'ZZZZZ' then //是自定文件
begin
//icopys := 1;
//icopys := GetDocNoCount(CaseID,DocNo);
icopys := GetDocDirCopies(CaseID,iDocDir);
ipages := GetDocDir_Page(CaseID,iDocDir);
iEdit := GetDocNoEdit(CaseID,DocNo,DocName);
FromCaseID := GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir);
if FromCaseID <> '' then
begin
for i := DocDirList.Count - 1 downto 1 do
begin
iDocDir := DocDirList.Strings[i];
iDocNo := DocNoDir2DocNo(iDocDir);
if (iDocNo = DocNo) and (GetUseCase('F',ImageSavePath+CaseID+'\',iDocDir)<>'') then
begin
FromCaseID := GetUseCase('F',DisplayPath,iDocDir);
//inc(icopys);
ipages := ipages + GetDocDir_Page(CaseID,iDocDir);
DocDirList.Delete(i);
end;
end;
DocName := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo);
if str = '' then
Str := Format('%s'+#9+'%d'+#9+'%s',[DocName,iCopys,FromCaseID])
else
Str := Str+#13#10+ Format('%s'+#9+'%d'+#9+'%s',[DocName,iCopys,FromCaseID]);
end;
end;
DocDirList.Delete(0);
end;
finally
DocDirList.Free;
FileList.Free;
end;
Result := Str;
end;
Function TCB_IMGPSScanX.GetDocNoEdit(CaseID,DocNo,DocName:String):String; //取出DocNo是否被異動 (Y/N)
var
i : Integer;
EditedDocDirList : TStringlist;
C_DocNoList,C_DocNameList : TStringlist;
begin
Result := 'N';
EditedDocDirList := TStringlist.Create;
C_DocNoList := TStringlist.Create;
C_DocNameList := TStringlist.Create;
try
if FileExists(ImageSavePath+CaseID+'\EditedDocDir.dat') then
EditedDocDirList.LoadFromFile(ImageSavePath+CaseID+'\EditedDocDir.dat');
C_DocNoList.StrictDelimiter := True;
C_DocNoList.Delimiter := #9;
C_DocNoList.DelimitedText := FC_DocNoList;
C_DocNameList.StrictDelimiter := True;
C_DocNameList.Delimiter := #9;
C_DocNameList.DelimitedText := FC_DocNameList;
//Showmessage(C_DocNoList.Text);
if (DocName = '') and (C_DocNoList.IndexOf(DocNo)=-1 ) then
Result := 'Y';
if (DocName <> '') and (C_DocNameList.IndexOf(DocName)=-1) then
Result := 'Y';
for i := 0 to EditedDocDirList.Count - 1 do
begin
if (DocNo = DocNoDir2DocNo(EditedDocDirList.Strings[i])) then
begin
Result := 'Y';
Break;
end;
end;
finally
EditedDocDirList.Free;
C_DocNoList.Free;
C_DocNameList.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocNo_Count(Path,DocNo:String):Integer; //取出文件份數
var
i : Integer;
iCopys : integer;
S,S1 : TStringlist;
iFormID : String;
DocFirst : Boolean;
begin
Result := 0;
if not DocnoNeedGroup(DocNo) then
begin
Result := 1;
Exit;
end;
S := TStringlist.Create;
S1 := TStringlist.Create;
try
S.LoadFromFile(Path+'Context.dat');
S1.LoadFromFile(Path+'Context_DocNo.dat');
iCopys := 0;
for i := 0 to S.Count - 1 do
begin
iFormID := FileName2FormCode(S.Strings[i]);
DocFirst := False;
if FormCode2Page(iFormID) = '01' then
DocFirst := True;
if ((iCopys = 0) or DocFirst) and (Docno = S1.Strings[i]) then
begin
inc(iCopys);
end;
end;
Result := iCopys;
finally
S.Free;
S1.Free;
end;
end;
Function TCB_IMGPSScanX.GetDocNo_Page(Path,DocNo:String):Integer; //取出文件總頁數
var
i : Integer;
ipages : integer;
S,S1 : TStringlist;
begin
Result := 0;
S := TStringlist.Create;
S1 := TStringlist.Create;
try
S.LoadFromFile(Path+'Context.dat');
S1.LoadFromFile(Path+'Context_DocNo.dat');
iPages := 0;
for i := 0 to S.Count - 1 do
begin
if Docno = S1.Strings[i] then
begin
inc(iPages);
end;
end;
Result := ipages;
finally
S.Free;
S1.Free;
end;
end;
Function TCB_IMGPSScanX.Case_DocNoExists(CaseID,Docno:String):Boolean; //Docno是否存在案件裡
var
i : Integer;
S : TStringlist;
iDocNo : String;
begin
Result := False;
S := TStringlist.Create;
try
S.LoadFromFile(ImageSavePath + CaseID+'\Context.dat');
for i := 0 to S.Count - 1 do
begin
iDocNo := FormCode2DocNo(FileName2FormCode(S.Strings[i]));
if Docno = iDocNo then
begin
Result := True;
Break;
end;
end;
finally
S.Free;
end;
end;
Procedure TCB_IMGPSScanX.ReSortFileName(Path:String); //檔名重新排序
var
i : Integer;
OldName,NewName : String;
Filelist : TStringlist;
begin
Filelist := TStringlist.Create;
try
if FileExists(Path+'Context.dat') then
begin
Filelist.LoadFromFile(Path+'Context.dat');
for i := 0 to Filelist.Count - 1 do
begin
OldName := Filelist.Strings[i];
//NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
//ShowMessage(OldName+#10#13+NewName);
ReNameFile(Path+OldName,Path+NewName);
Filelist.Strings[i] := NewName;
end;
Filelist.SaveToFile(Path+'Context.dat');
ContextList.LoadFromFile(Path+'Context.dat');
end;
finally
Filelist.Free;
end;
end;
Procedure TCB_IMGPSScanX.ReSortFileName_New(Path:String); //檔名重新排序
var
i : Integer;
OldName,NewName : String;
Filelist : TStringlist;
begin
Filelist := TStringlist.Create;
try
if FileExists(Path+'Context.dat') then
begin
Filelist.LoadFromFile(Path+'Context.dat');
for i := Filelist.Count - 1 downto 0 do
begin
OldName := Filelist.Strings[i];
//NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
ReNameFile(Path+OldName,Path+NewName);
Filelist.Strings[i] := NewName;
end;
Filelist.SaveToFile(Path+'Context.dat');
ContextList.LoadFromFile(Path+'Context.dat');
end;
finally
Filelist.Free;
end;
end;
Function TCB_IMGPSScanX.CaseAsk(CaseID: string):Integer;
var
SendData : String;
begin
//Memo1.Clear;
SendData := 'data='+HTTPEncode(UTF8Encode(FData))+'&verify='+FVerify+'&case_no='+CaseID+'&work_no='+FWork_no;
if (FMode = 'NSCAN') or (FMode = 'DSCAN') then
begin
//ShowMessage('JJJJJ');
If not ProcessServlet_Get(HTTPSClient,FURL+'service/imgpsc/IMGPSC05/isnew',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := -1;
Exit;
end;
end;
//ShowMessage(SendData);
IF memo1.Lines.Strings[0] <> '0' Then
begin
HttpErrStr := _Msg('')+memo1.Lines.Strings[1]+'。';
Result := -1;
Exit;
end
Else
begin
if (memo1.Lines.Count < 2) then
begin
HttpErrStr := _Msg('')+'OCX:Index Count error';
Result := -1;
Exit;
end
Else
begin
if memo1.Lines.Strings[1] = '0' then
begin
Result := 0;
end
Else if memo1.Lines.Strings[1] = '1' then
Result := 1
Else
begin
HttpErrStr := _Msg('')+'OCX:Value error';
Result := -1;
Exit;
end;
end;
end;
end;
Function TCB_IMGPSScanX.CaseComplete(Path,CaseID:String;MainCase:Boolean):Boolean; //通知傳送完成
var
OMRValue,Batchnum,Usermemo,Checkmemo,UpformID,ReMoveMemo: String;
Case_type,Handle_no,Format_id,Cen_Uid,Cen_Cliname,Cen_Platno,Cen_Apolyno,Case_priority : String;
Pages : Integer;
EnCodeDateTime : String;
SendData : String;
S : TStringlist;
i,v,v1 : Integer;
UpSortID : String;
begin
Result := True;
S := TStringlist.Create;
try
EnCodeDateTime := En_DecryptionStr_Base64('E',ServerDate+GetBalance2Time(Balance),Mpskey);
UpformID := GetCaseFormID(Path);
Case_type := '0';
if FileExists(Path+'Context.dat') then //掃描頁數
begin
S.LoadFromFile(Path+'Context.dat');
Pages := S.Count;
end;
if not FileExists(ImageSavePath+CaseID+'\CaseIndex.dat') then //如果沒這個檔就重產生預設值
begin
ClearCaseIndex;
WriteCaseIndex(ImageSavePath+CaseID+'\');
end;
{if FileExists(ImageSavePath+CaseID+'\CaseIndex.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\CaseIndex.dat');
Handle_No := S.Strings[0]; //經辦代號
Cen_Uid := S.Strings[1]; //被保人ID
Cen_Cliname := S.Strings[2]; //被保人姓名
Cen_Platno := S.Strings[3]; //車號
Case_Priority := S.Strings[4];//案件等級
if FMode = 'SSCAN' then //簽署章件的時候一律傳Format_ID
begin
Format_ID := S.Strings[5]; //主鍵值 (報價單號or續保單號or保單號碼or保險證號)
end
Else
begin
if (Length(UpformID) = 12) and (UpformID[2] = '-') then
Format_ID := S.Strings[5] //主鍵值 (報價單號or續保單號or保單號碼or保險證號)
else
Cen_Apolyno := S.Strings[5]; //強制證號
end;
if (FMode = 'MSCAN') and (length(Format_ID) = 16) and (Copy(Format_ID,1,2) = '05') then
begin
Format_ID := Copy(Format_ID,3,14); //20130606 yuu說監理站件的主鍵值為16碼且開開為05的要去掉
end;
end; }
if FileExists(ImageSavePath+CaseID+'\GetValue.xml') then //掃描帶值
begin
S.LoadFromFile(ImageSavePath+CaseID+'\GetValue.xml');
OMRValue := Trim(S.Text);
end;
if MainCase then //雙主約的主要案件
begin
if FileExists(ImageSavePath+CaseID+'\Batchnum.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\Batchnum.dat');
Batchnum := Trim(S.Text);
end;
end
Else //雙主約的第二案件
begin
if FileExists(ImageSavePath+CaseID+'\SecBatchnum.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\SecBatchnum.dat');
Batchnum := Trim(S.Text);
end;
end;
if FileExists(ImageSavePath+CaseID+'\Scan_Memo.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\Scan_Memo.dat');
Usermemo := Trim(S.Text);
end;
if FileExists(ImageSavePath+CaseID+'\CheckMemo.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\CheckMemo.dat');
Checkmemo := Trim(S.Text);
end;
if FileExists(ImageSavePath+CaseID+'\RemoveMemo.dat') then
begin
S.LoadFromFile(ImageSavePath+CaseID+'\RemoveMemo.dat');
ReMoveMemo := Trim(S.Text);
end;
finally
S.Free;
end;
case_priority:='0';
if (FMode = 'NSCAN') or (FMode = 'ASCAN') or (FMode = 'DSCAN') or (FMode = 'SSCAN') or (FMode = 'MSCAN') or (FMode = 'RI_SCAN') then
begin
SendData := 'checktime='+EnCodeDateTime
+'&work_no='+FWork_No //作業別
+'&case_id='+CaseID //受理編號
+'&form_id='+UpformID //表單代號
+'&scan_page='+inttostr(pages) //掃描頁數
+'&scan_get_value='+HTTPEncode(UTF8Encode(OMRValue)) //掃描帶值
+'&case_priority='+case_priority //案件等級
+'&batch_no='+batchnum //車隊批號
+'&user_memo='+HTTPEncode(UTF8Encode(usermemo)) //使用者註記
+'&check_memo='+HTTPEncode(UTF8Encode(checkmemo)) //檢核註記
+'&remove_memo='+HTTPEncode(UTF8Encode(ReMoveMemo)) //檢核移除註記
+'&case_type='+Case_type //進件種類 進件0 歸檔1
+'&handle_no='+Handle_no //經辦代號
+'&format_id='+Format_id //案件主鍵值
+'&cen_uid='+Cen_Uid //被保人ID
+'&cen_cliname='+HTTPEncode(UTF8Encode(Cen_Cliname)) //被保人姓名
+'&cen_platno='+Cen_Platno //車牌
+'&cen_apolyno='+Cen_Apolyno //強制證號
+'&has_authorize='+Has_Authorize; //是否有授權書影像
Showmessage(SendData);
if not RejectCase then
begin
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC05',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end
Else
begin
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC06',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end;
end
Else if FMode = 'ISCAN' then
begin
SendData := 'checktime='+EnCodeDateTime
+'&work_no='+FWork_No
+'&case_id='+CaseID
+'&form_id='+UpformID
+'&format_id='+Format_id
+'&scan_page='+inttostr(pages)
+'&user_memo='+HTTPEncode(UTF8Encode(usermemo))
+'&check_memo='+HTTPEncode(UTF8Encode(checkmemo))
+'&remove_memo='+HTTPEncode(UTF8Encode(ReMoveMemo))
+'&has_authorize='+Has_Authorize; //是否有授權書影像
//Showmessage(SendData);
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC08',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end
Else if FMode = 'FSCAN' then
begin
SendData := 'checktime='+EnCodeDateTime
+'&work_no='+FWork_No
+'&case_id='+CaseID
+'&scan_page='+inttostr(pages)
+'&user_memo='+HTTPEncode(UTF8Encode(usermemo))
+'&check_memo='+HTTPEncode(UTF8Encode(checkmemo))
+'&remove_memo='+HTTPEncode(UTF8Encode(ReMoveMemo))
+'&has_authorize='+Has_Authorize; //是否有授權書影像
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC09',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end
Else if FMode = 'RSCAN' then
begin
SendData := 'checktime='+EnCodeDateTime
+'&act=rescan'
+'&workno='+FWork_No
+'&caseid='+CaseID
+'&formid='+UpformID
+'&scanpage='+inttostr(pages)
// +'&areano='+FUserArea
+'&scangetvalue='+HTTPEncode(UTF8Encode(OMRValue))
+'&usermemo='+HTTPEncode(UTF8Encode(usermemo))
+'&checkmemo='+HTTPEncode(UTF8Encode(checkmemo))
+'&removememo='+HTTPEncode(UTF8Encode(ReMoveMemo))
+'&has_authorize='+Has_Authorize; //是否有授權書影像
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC01',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end
Else if FMode = 'ESCAN' then
begin
SendData := 'checktime='+EnCodeDateTime
+'&act=escan'
+'&workno='+FWork_No
+'&caseid='+CaseID
+'&formid='+UpformID
+'&scanpage='+inttostr(pages)
+'&batchnum='+batchnum
+'&usermemo='+HTTPEncode(UTF8Encode(usermemo))
+'&checkmemo='+HTTPEncode(UTF8Encode(checkmemo))
+'&removememo='+HTTPEncode(UTF8Encode(ReMoveMemo))
+'&has_authorize='+Has_Authorize; //是否有授權書影像
If not ProcessServlet(HTTPSClient,FURL+'servlet/CWC01',SendData,FReWrite,Memo1,False) Then
begin
HttpErrStr := _Msg('錯誤代碼:')+inttostr(HttpError.HttpErrorCode)+','+HttpError.HttpReason;
Result := False;
Exit;
end;
end;
if Memo1.Lines.Strings[0] <> '0'then
begin
HttpErrStr := _Msg('錯誤原因:')+Memo1.Lines.Strings[1];
Result := False;
Exit;
end;
end;
procedure TCB_IMGPSScanX.Set_caseid(const Value: WideString);
begin
FCaseID := Value;
end;
procedure TCB_IMGPSScanX.Set_data(const Value: WideString);
begin
FData := Value;
end;
procedure TCB_IMGPSScanX.Set_c_docnolist(const Value: WideString);
begin
FC_DocNoList := Value;
end;
procedure TCB_IMGPSScanX.Set_fixfilelist(const Value: WideString);
begin
FFixFileList := Value;
end;
procedure TCB_IMGPSScanX.Set_oldcaseinfo(const Value: WideString);
begin
FOldCaseInfo := Value;
end;
function TCB_IMGPSScanX.Get_c_docnolist: WideString;
begin
end;
function TCB_IMGPSScanX.Get_caseid: WideString;
begin
end;
function TCB_IMGPSScanX.Get_data: WideString;
begin
end;
function TCB_IMGPSScanX.Get_fixfilelist: WideString;
begin
end;
function TCB_IMGPSScanX.Get_oldcaseinfo: WideString;
begin
end;
function TCB_IMGPSScanX.Get_is_oldcase: WideString;
begin
end;
procedure TCB_IMGPSScanX.Set_is_oldcase(const Value: WideString);
begin
FIs_OldCase := UpperCase(Value);
end;
function TCB_IMGPSScanX.Get_casenolength: WideString;
begin
end;
function TCB_IMGPSScanX.Get_filesizelimit: WideString;
begin
end;
procedure TCB_IMGPSScanX.Set_casenolength(const Value: WideString);
begin
if Value ='' then
begin
FCaseNoLength := 0 ;
CaseIDLength := FCaseNoLength;
end
else
begin
FCaseNoLength := StrToInt(Value) ;
CaseIDLength := FCaseNoLength;
end;
end;
procedure TCB_IMGPSScanX.Set_filesizelimit(const Value: WideString);
begin
//ShowMessage(Value);
FFileSizeLimit:=0;
if Value ='' then
begin
FFileSizeLimit := 5*1024;
end
else
begin
FFileSizeLimit := StrToInt(Value);
end;
end;