curtis
14小時前 3af5c004b4f2d2005d22ee85dccc2c80a66b1556
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
{ ==============================================================================
  方法名稱:DefinePropertyPages
  引用相依:
  方法描述:Delphi ActiveForm 用於定義屬性頁面的存根方法,目前未實作具體內容。
============================================================================== }
procedure TCB_IMGPSScanX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
begin
  { Define property pages here.  Property pages are defined by calling
    DefinePropertyPage with the class id of the page.  For example,
      DefinePropertyPage(Class_CBS_IMScanXPage); }
end;
 
 
{ ==============================================================================
  方法名稱:EventSinkChanged
  引用相依:
  方法描述:當事件接收器改變時觸發。將傳入的 EventSink 轉換為 ICB_IMGPSScanXEvent
            s 並賦值給 FEvents,同時呼叫繼承的 EventSinkChanged 方法。
============================================================================== }
procedure TCB_IMGPSScanX.EventSinkChanged(const EventSink: IUnknown);
begin
  FEvents := EventSink as ICB_IMGPSScanXEvents;
  inherited EventSinkChanged(EventSink);
end;
 
 
{ ==============================================================================
  方法名稱:ActivateEvent
  引用相依:
  方法描述:觸發 COM 介面的 OnActivate 事件。
============================================================================== }
procedure TCB_IMGPSScanX.ActivateEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnActivate;
end;
 
 
{ ==============================================================================
  方法名稱:ClickEvent
  引用相依:
  方法描述:觸發 COM 介面的 OnClick 事件。
============================================================================== }
procedure TCB_IMGPSScanX.ClickEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnClick;
end;
 
 
{ ==============================================================================
  方法名稱:CreateEvent
  引用相依:
  方法描述:觸發 COM 介面的 OnCreate 事件。
============================================================================== }
procedure TCB_IMGPSScanX.CreateEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnCreate;
end;
 
 
{ ==============================================================================
  方法名稱:DblClickEvent
  引用相依:
  方法描述:觸發 COM 介面的 OnDblClick 事件。
============================================================================== }
procedure TCB_IMGPSScanX.DblClickEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnDblClick;
end;
 
 
{ ==============================================================================
  方法名稱:DeactivateEvent
  引用相依:
  方法描述:觸發 COM 介面的 OnDeactivate 事件。
============================================================================== }
procedure TCB_IMGPSScanX.DeactivateEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnDeactivate;
end;
 
 
{ ==============================================================================
  方法名稱:DestroyEvent
  引用相依:_DelTree
  方法描述:銷毀元件時的清理工作。負責釋放大量的 TStringList 物件,包含各類資訊清
            單(表單、規則、註記、工作、影像路徑、條碼等)。針對特定模式(DSCAN/ESCAN),若
             ImagePath 不為空則刪除該目錄及其子目錄。最後觸發 COM 介面的 OnDestro
            y 事件。
============================================================================== }
procedure TCB_IMGPSScanX.DestroyEvent(Sender: TObject);
begin
  //********清單區********
  Doc_Inf_List.Free;  //Doc_Inf 清單   Docno + 版本為key
  DM_FORM_INF_List.Free;  //DM_FORM_INF 清單   Docno + 版本為key
  FORM_INF_List.Free; //FORM_INF的清單
  CHECK_RULE_INF_List.Free;  //CHECK_RULE_INF  清單
  MEMO_INF_List.Free;  //MEMO_INF 清單
  WORK_INF_List.Free;  //WORK_INF 清單
  LASTEST_FORM_INF_List.Free; // LASTEST_FORM_INF 清單
  FindResult.Free ;  //找SQLData的結果
  OMRFileList.Free;  //要OMR檢核的文件(只檢查每種Form的第一頁)
  FormCode_PageSize.Free; //文件的預設大小  FormCode_Height_Width
  DocNo_NeedDoc.Free; //有Docno時要相依的文件   DocNo_相依文件_相依文件
  DocNo_NoDoc.Free; //有Docno時互斥的文件   DocNo_互斥文件_互斥文件
  DocNo_VerinCase.Free; //案件裡的DocNo+版本的清單
  CaseDocNoList.Free;  //案件裡的DocNo清單
  CaseDocNo_CopiesList.Free; //案件裡的DocNo份數清單
  CaseList.Free;    //記錄掃瞄案件的順序
  NoSaveBarCodeList.Free; //不儲存的條碼清單
  FormID_List.Free;  //FormID清單
  DocNo_List.Free; //DocNo清單
  Context_DocnoList.Free; //案件裡的檔案Docno清單
  ContextList.Free; //案件裡的檔案清單
  AttContextList.Free; //案件裡的附加檔案清單
  NowShowFileList.Free;  //目前顯示的影像清單
  NowSelectFileList.Free; //目前被點選的影像清單
  Cust_DocNoList.Free; //自行定義文件名稱
  IN_WH_DocNoList.Free; //入庫的文件清單
  GuideFormIDList.Free; //要當導引頁表單清單
  DivPageFormIDList.Free; //要當分案頁表單清單
  LastInitFormidList.Free;
  LastAddFormidList.Free;
  SampleFormIDList.Free;
  ExistImgList.Free;
  reSizeExistImgList.Free;
  //********清單區********
  if (FMode = 'DSCAN') or (FMode = 'ESCAN')  then //重掃件及異動件要只能掃指定編號的件
  begin
    if ImagePath<>'' then
      _Deltree(ImagePath);
  end;
 
  if FEvents <> nil then FEvents.OnDestroy;
end;
 
 
{ ==============================================================================
  方法名稱:KeyPressEvent
  引用相依:
  方法描述:處理鍵盤按鈕事件,並將按鍵資訊傳遞至 COM 介面的 OnKeyPress 事件。
============================================================================== }
procedure TCB_IMGPSScanX.KeyPressEvent(Sender: TObject; var Key: Char);
var
  TempKey: Smallint;
begin
  TempKey := Smallint(Key);
  if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  Key := Char(TempKey);
end;
 
 
{ ==============================================================================
  方法名稱:MouseEnterEvent
  引用相依:
  方法描述:當滑鼠進入元件時,觸發 COM 介面的 OnMouseEnter 事件。
============================================================================== }
procedure TCB_IMGPSScanX.MouseEnterEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnMouseEnter;
end;
 
 
{ ==============================================================================
  方法名稱:MouseLeaveEvent
  引用相依:
  方法描述:當滑鼠離開元件時,觸發 COM 介面的 OnMouseLeave 事件。
============================================================================== }
procedure TCB_IMGPSScanX.MouseLeaveEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnMouseLeave;
end;
 
 
{ ==============================================================================
  方法名稱:PaintEvent
  引用相依:
  方法描述:當元件需要重繪時,觸發 COM 介面的 OnPaint 事件。
============================================================================== }
procedure TCB_IMGPSScanX.PaintEvent(Sender: TObject);
begin
  if FEvents <> nil then FEvents.OnPaint;
end;
 
 
{ ==============================================================================
  方法名稱:ActiveFormCreate
  引用相依:
  方法描述:ActiveForm 建立時的初始化處理。發送啟動訊息、設定預設檢視模式並初始化
            影像顯示區域。遍歷所有影像捲軸盒(ISB),設定預設滑鼠模式為 mmUser 並將
            縮放模式設為全頁顯示,最後延遲啟動 Timer。
============================================================================== }
procedure TCB_IMGPSScanX.ActiveFormCreate(Sender: TObject);
var IScrollBox : TImageScrollBox;
    i          :integer;
begin
  {HotKeyId1 := GlobalAddAtom('MyHotKey1')-$C000;
  HotKeyId2 := GlobalAddAtom('MyHotKey2')-$C000;
  HotKeyId3 := GlobalAddAtom('MyHotKey3')-$C000;
  HotKeyId4 := GlobalAddAtom('MyHotKey4')-$C000;
  RegisterHotKey(handle,HotKeyId1,0,VK_UP);      //printscreen
  RegisterHotKey(handle,HotKeyId1,0,VK_Down);      //printscreen }
  PostMessage(Handle,WM_ACTIVATE,WA_CLICKACTIVE,0);
  vmode := 1;
  DesableImage;
  For i:= 1 to 8 do begin
    IScrollBox := TImageScrollBox( FindComponent('ISB'+IntToStr(i)));
    IScrollBox.MouseMode := mmUser;
    iScrollBox.ZoomMode := zmFullPage;
  end;
  Sleep(500);
  Timer1.Enabled := True;
end;
 
 
{ ==============================================================================
  方法名稱:HotKeyDown
  引用相依:
  方法描述:熱鍵按下處理程序,目前為空實作。
============================================================================== }
procedure TCB_IMGPSScanX.HotKeyDown (var Msg : TMessage);
begin
 
end;
 
 
{ ==============================================================================
  方法名稱:InitialLanguage
  引用相依:
  方法描述:元件多國語言初始化核心函式。讀取 Language.Lng 設定檔,根據指定的語系遞
            迴設定畫面上所有控制項(按鈕、選單、標籤、清單、群組框等)的 Caption 或 Hi
            nt 文字,實現介面語系動態切換。
============================================================================== }
procedure TCB_IMGPSScanX.InitialLanguage(Sender: TObject);
var
  ini : Tmeminifile;
  i,n : Integer;
  FormName : String;
  NowForm : TComponent;
begin
  if Sender is TActiveForm then
    NowForm := TActiveForm(Sender);
  if Sender is TForm then
    NowForm := TForm(Sender);
 
  FormName := NowForm.Name;
  IISUnit.IIS_LngfileName := LngPath+'Language.Lng';  //給IISUnit 轉多國語言字串用
  if FLanguage = '' then
    FLanguage := 'zh_tw';
  IISUnit.IIS_NowLng := FLanguage;
  ini := TMeminifile.Create(LngPath+'Language.Lng');
  try
    IF NowForm is TForm Then
      TForm(NowForm).Caption := ini.ReadString(FLanguage,FormName+'.FormTitle','');
    for i := 0 to NowForm.ComponentCount - 1 do
    begin
//ShowMessage(NowForm.Components[i].Name);
      if NowForm.Components[i] is TButton then
      begin
        TButton(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TButton(NowForm.Components[i]).Name,'');
        //TBitBtn(NowForm.Components[i]).Caption := ini.ReadString(FormName,TBitBtn(NowForm.Components[i]).Name,'');
        //TButton(NowForm.Components[i]).OnMouseEnter := BtnMouseEnter;
      end
      Else if NowForm.Components[i] is TBitBtn then
      begin
        TBitBtn(NowForm.Components[i]).Hint := ini.ReadString(FLanguage,FormName+'.'+TBitBtn(NowForm.Components[i]).Name,'');
        //TBitBtn(NowForm.Components[i]).Caption := ini.ReadString(FormName,TBitBtn(NowForm.Components[i]).Name,'');
        TBitBtn(NowForm.Components[i]).OnMouseEnter := BtnMouseEnter;
      end
      Else if NowForm.Components[i] is TMenuItem then
      begin
        if ini.ValueExists(FLanguage,FormName+'.'+TMenuItem(NowForm.Components[i]).Name) then
          TMenuItem(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TMenuItem(NowForm.Components[i]).Name,'');
      end
      Else if NowForm.Components[i] is TCheckBox then
      begin
        TCheckBox(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TCheckBox(NowForm.Components[i]).Name,'');
      end
      Else if NowForm.Components[i] is TPJMenuSpeedButton then
      begin
        TPJMenuSpeedButton(NowForm.Components[i]).Hint := ini.ReadString(FLanguage,FormName+'.'+TPJMenuSpeedButton(NowForm.Components[i]).Name,'');
      end
      Else if NowForm.Components[i] is TLabel then
      begin
        TLabel(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TLabel(NowForm.Components[i]).Name,'');
      end
      Else if NowForm.Components[i] is TGroupBox then
      begin
        TGroupBox(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TGroupBox(NowForm.Components[i]).Name,'');
      end
      Else if NowForm.Components[i] is TListView then
      begin
        for n := 0 to TListView(NowForm.Components[i]).Columns.Count - 1 do
        begin
          TListView(NowForm.Components[i]).Columns.Items[n].Caption := ini.ReadString(FLanguage,FormName+'.'+TListView(NowForm.Components[i]).Name+'_'+inttostr(n),'');
        end;
      end
      Else if NowForm.Components[i] is TRadioGroup then
      begin
        TRadioGroup(NowForm.Components[i]).Caption := ini.ReadString(FLanguage,FormName+'.'+TRadioGroup(NowForm.Components[i]).Name,'');
        for n := 0 to TRadioGroup(NowForm.Components[i]).Items.Count - 1 do
        begin
          TRadioGroup(NowForm.Components[i]).Items.Strings[n] := ini.ReadString(FLanguage,FormName+'.'+TRadioGroup(NowForm.Components[i]).Name+'_'+inttostr(n),'');
        end;
      end;
    end;
  finally
  ini.Free;
  end;
end;
 
 
{ ==============================================================================
  方法名稱:Timer1Timer
  引用相依:FJpgCompression, GetLocalAppDir, Str2Dir, _DelTree, FileExists, init
            kscan
  方法描述:OCX 元件初始化的核心程序。負責從伺服器下載各類基礎資訊(業務、表單、文件
            、檢核規則、常用片語、系統參數等),並設定本地暫存路徑(ScanTemp)。針對異動
            或重掃模式,會自動建立空案件並下載既有影像。最後執行各類屬性與語系設定
            ,確保掃描環境就緒。
============================================================================== }
procedure TCB_IMGPSScanX.Timer1Timer(Sender: TObject);
var
  StampDate,StampTime : String;
  i: Integer;
begin
  Timer1.Enabled := False;
  //FIs_In_Wh:='Y'; /// test 記得關掉
  //FWH_category :='N';  // test 記得關掉
//  FImgDelete := 'Y'; //test 記得關掉
  //Showmessage('a');
  //self.FIs_OldCase := 'Y';
  PageLVclear := True;
  InitialOk := False;
 
  FMaxUploadSize:='10';
  FJpgCompression:=50;
  FFtpRootPath := '';  //影像平台沒有給FtpRoot目錄,會直接用FFtpExtraPath切換至指定目錄
  //FMode := 'DSCAN' ;
  //FIs_In_Wh := 'Y';
  if FIs_In_Wh = 'Y' then
    AttName := 'Attach'  //入庫附件
  else
    AttName := 'S_Attach'; //Smartlending 附件
//ShowMessage('1111111');
  if FMode = 'SAMPLESCAN' then
  begin
    NewScanBtn.Visible := False;
    PJLinkedMenuSpeedButton2.Visible := False;
    AddScanBtn.Visible := False;
    CheckCaseBtn.Visible := False;
    Panel18.Visible := False;
    TransBtn.Visible := False;
    FC6.Visible := False;
    SampleScanBtn.Visible := True;
    Panel1.Visible := True;
    Panel6.Visible := True;
    ScanDuplexCB.Visible := False; //雙面掃描
  end
  Else if (FMode = 'NSCAN') then
  begin
    Panel18.Visible := True;
    Panel1.Visible := True;
    Panel6.Visible := True;
    Panel21.Visible := True;
    Panel23.Visible := True;
 
    AttFileGB.Visible := True;
    Splitter2.Visible := True;
    ScanDuplexCB.Visible := True; //雙面掃描
  end
  Else if FMode = 'FSCAN' then
  begin
    Panel1.Visible := True;
    //Panel6.Visible := True;
  end
  Else
  begin
    Panel18.Visible := True;
    Panel1.Visible := True;
    Panel6.Visible := True;
    Panel21.Visible := True;
    Panel23.Visible := True;
    AttFileGB.Visible := True;
    Splitter2.Visible := True;
  end;
  DisplayMode(1,1,1,Panel9);
  Application.ProcessMessages;
  StatusBar1.Panels[0].Text := 'Ver'+GetCurrentVersionNo;
  StatusBar1.Panels[1].Text := 'Login User:'+FUserName;
  {$IFDEF Test}
    StatusBar1.Panels[0].Text := StatusBar1.Panels[0].Text+'(test)';
  {$ENDIF}
    StatusBar1.Panels[0].Text := StatusBar1.Panels[0].Text;
 
  if FPrintyn = 'Y' then
    PrtLB.Visible := True;
 
  initParameter;  //20170222 針對新加的parameter 作初始化參數
  InitScrollRec;
  If FUrl = '' then
  begin
    Showmessage(_Msg('URL cannot be empty,please contact system administrator'));
    Exit;
  end;
  if FUrl[length(FUrl)]<>'/' then
    FUrl := FUrl + '/';
  //20221028 把語言檔改放至 Local目錄裡,才不會有些文字來不及使用
  LngPath := GetLocalAppDir(Handle)+'MPS\CB_IMGPS\';
  Str2Dir(LngPath);
  ////下載語言檔/////  20170218 先拿調以便測試
  If not DownLanguage Then
  begin
    Showmessage('Language File error!!'+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
 
  InitialLanguage(Self);  //載入多國語言
 
 
  if FWork_no='' then
  begin
    Showmessage(_Msg('業務別不能為空白,請洽詢程式人員'));
    Exit;
  end;
 
  if CaseIDLength = 0 then
  begin
    Showmessage(_Msg('案件編號長度限制不能為空白,請洽詢程式人員'));
    //Exit;  //測試時不退出
  end;
 
  //********清單區********
 
  Doc_Inf_List := TStringList.Create;  //Doc_Inf 清單   Docno + 版本為key
  DM_FORM_INF_List := TStringList.Create;  //DM_FORM_INF 清單   Docno + 版本為key
  FORM_INF_List := TStringList.Create; //FORM_INF的清單
  CHECK_RULE_INF_List := TStringList.Create;  //CHECK_RULE_INF  清單
  MEMO_INF_List := TStringList.Create;  //MEMO_INF 清單
  WORK_INF_List := TStringList.Create;  //WORK_INF 清單
  LASTEST_FORM_INF_List := TStringList.Create;  // LASTEST_FORM_INF 清單
  FindResult := TStringlist.Create;  //找SQLData的結果
 
  OMRFileList := TStringList.Create; //要OMR檢核的文件(只檢查每種Form的第一頁)
  FormCode_PageSize := TStringList.Create; //文件的預設大小  FormCode_Height_Width
  DocNo_NeedDoc := TStringList.Create; //有Docno時要相依的文件   DocNo_相依文件_相依文件
  DocNo_NoDoc := TStringList.Create; //有Docno時互斥的文件   DocNo_互斥文件_互斥文件
  DocNo_VerinCase := TStringList.Create; //案件裡的DocNo+版本的清單
  CaseDocNoList := TStringlist.Create;  //案件裡的DocNo清單
  CaseDocNo_CopiesList := TStringlist.Create; //案件裡的DocNo份數清單
  CaseList := TStringList.Create;    //記錄掃瞄案件的順序
  Context_DocnoList := TStringlist.Create; //案件裡的檔案Docno清單
  ContextList := TStringlist.Create; //案件裡的檔案清單
  AttContextList := TStringlist.Create; //案件裡的附加檔案清單
  NoSaveBarCodeList := TStringlist.Create; //不儲存的條碼清單
  FormID_List := TStringlist.Create;  //FormID清單
  DocNo_List := TStringlist.Create; //DocNo清單
  NowShowFileList := TStringlist.Create;  //目前顯示的影像清單
  NowSelectFileList := TStringlist.Create; //目前被點選的影像清單
  Cust_DocNoList := TStringlist.Create; //自行定義的文件名稱
  IN_WH_DocNoList := TStringlist.Create; //入庫的文件清單
  GuideFormIDList := TStringlist.Create; //要當導引頁表單清單
  DivPageFormIDList := TStringList.Create; //要當分案頁表單清單
  LastInitFormidList :=TStringList.Create;
  LastAddFormidList := TStringList.Create;
  SampleFormIDList := TStringList.Create;//20170627 加入
  ExistImgList := TStringList.Create;  //20170724 新增
  reSizeExistImgList :=TStringList.Create; //20171012 新增
  //********清單區********
 
  ShowText := _Msg('資料載入中,請稍候');
  DataLoading(True,True);
 
  IF not GetServerDate Then
  begin
    Showmessage(_Msg('取主機時間時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
 
  if FMode='SAMPLESCAN' then
  begin
    IF not GetSampleInf Then  //取已存在sample
    begin
      Showmessage(_Msg('取存在範本資訊時,網路發生錯誤!!')+HttpErrStr);
      DataLoading(False,False);
      Exit;
    end;
  end;
 
 
 
//ShowMessage('GetServerDate  '+ServerDate+' , '+ServerTime);
  ////下載系統資訊////
  IF not GetSetInf1 Then  //取DOC_INF  文件資訊
  begin
    Showmessage(_Msg('取文件資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf1');
  //showmessage(self.Doc_Inf_List.Text);
  IF not GetSetInf2 Then  //取DM_FORM_INF     相依互斥資訊
  begin
    Showmessage(_Msg('取相依互斥資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf2');
  //Showmessage(self.Doc_Inf_List.Text);
  IF not GetSetInf3 Then   //取FORM_INF  表單資訊
  begin
    Showmessage(_Msg('取表單資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf3');
  IF not GetSetInf4 Then   //取CHECK_RULE_INF   檢核規則資訊
  begin
    Showmessage(_Msg('取檢核規則資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
  //showmessage(self.CHECK_RULE_INF_List.Text);
//ShowMessage('GetSetInf4');
  IF not GetSetInf5 Then   //取MEMO_INF   常用片語資訊
  begin
    Showmessage(_Msg('取常用片語資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf5');
  //showmessage(self.MEMO_INF_List.Text);
  IF not GetSetInf6 Then   //取WORK_INF   系統參數資訊
  begin
    Showmessage(_Msg('取系統參數資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf6');
  //showmessage(FORM_INF_List.Text);
  IF not GetSetInf7 Then   //取LASTES_FORM_INF   系統參數資訊
  begin
    Showmessage(_Msg('取最新版FORMID參數資訊時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
//ShowMessage('GetSetInf7');
  //Showmessage(LASTEST_FORM_INF_List.Text);
  SetFormID_DocNo;  //將FormID及Docno抽出塞入List裡  20130403增加
  SetIn_WH_DocNo; //將要入庫的DocNo抽出來另存入list裡
  GetDefScanIni; //取得掃描預設值及相關設定
 
  ////下載系統資訊/////
  if ImagePath = '' then
  begin
    Showmessage(_Msg('本機暫存路徑不得為空白'));
    DataLoading(False,False);
    Panel1.Enabled := False;
    Panel2.Enabled := False;
    Exit;
  end;
  initkscan;
  if ImagePath[Length(ImagePath)] <> '\' then
    ImagePath := ImagePath + '\';
//ShowMessage('ImagePath='+ImagePath);
  //CheckXmlPath := ImagePath+'OMRSITE\'+FWork_No;
  CheckXmlPath := ImagePath+'OMRSITE\';  // 20200612 發現影像平台是取回所有業務的設定,所以不能有業務別目錄
//ShowMessage('CheckXmlPath='+CheckXmlPath);
  //SitePath := ImagePath+'Site\'+FWork_No+'\';
  SitePath := ImagePath+'Site\';  // 20200612 發現影像平台是取回所有業務的設定,所以不能有業務別目錄
  //LngPath := ImagePath; //改放至上面取Local目錄
  SamplePath := ImagePath+'Sample\'+FWork_No+'\';
  ImagePath := ImagePath + 'Scantemp\';
//ShowMessage('AA  ImagePath='+ImagePath);
  ScaniniPath :=ImagePath+FWork_No+'\'+FUserUnit +'\';
//ShowMessage('ScaniniPath='+ScaniniPath);
  ImagePath := ImagePath + FWork_No+'\'+FUserUnit+'\'+FMode+'\';
  ImagePath := StringReplace(ImagePath, '\\', '\',[rfReplaceAll, rfIgnoreCase]);
//ShowMessage('BB  ImagePath='+ImagePath);
  ImageSavePath := ImagePath;
  str2dir(CheckXmlPath);
  str2dir(SitePath);
  str2dir(ImagePath);
  str2dir(SamplePath);
  Del_Sub_NothingPath(ImagePath);  //清掉案件目錄是空的
 
 
  LogFile1.LogFile:=LngPath+'IMGPSCheck.log';
 
  ReduceLogFile;
 
  LogFile1.LogToFile(logTimeString+'OCX取表data結束');
 
  ShowText := _Msg('資料載入中,請稍候');
  DataLoading(True,True);
 
//  if not CheckAvailable Then   //檢查授權  20170218 說不用了
//  begin
//    DataLoading(False,False);
//    Panel1.Enabled := False;
//    Panel2.Enabled := False;
//    Exit;
//  end;
 
//Button3Click(Self);
//ShowMessage('CheckAvailable');
  ShowText := _Msg('資料載入中,請稍候');
  DataLoading(True,True);
 
 
  StatusBar1.Panels[1].Text := _Msg('登入人員:')+FUserName;
  //FCaseID:='20150302180133';//測試用
  ////下載語言檔/////
//ShowMessage('OOOO');
 
  if (FMode = 'RSCAN')  or (FMode = 'DSCAN') or (FMode = 'ESCAN') or (FMode = 'FSCAN') then //重掃件及異動件要只能掃指定編號的件
  begin
    _Deltree(ImagePath);
    str2dir(ImagePath);
    ImageSavePath := ImagePath;
    str2dir(ImageSavePath);
    MkDir(ImageSavePath+FCaseID);
    CreateEmptyCase(ImageSavePath,FCaseID);
    MkDir(ImageSavePath+FCaseID+'\Download');
    IF (FMode = 'ESCAN') or (FMode = 'DSCAN') then  //異動件先下載影像
    begin
      ShowText := _Msg('案件下載中,請稍候');
      DataLoading(True,True);
      If not DownLoadImage(ImageSavePath+FCaseID+'\Download\',FCaseID) Then
      begin
        Showmessage(FCaseID+_msg('載入異動影像時,網路發生錯誤')+DownFileErrStr);
        DataLoading(False,False);
        Exit;
      end;
 
      {If not Down_Img(ImageSavePath+FCaseID+'\Download\',FCaseID) then
      begin
        Showmessage(FCaseID+_msg('載入異動影像時,網路發生錯誤')+HttpErrStr);
        DataLoading(False,False);
        Exit;
      end;}
//Showmessage(ImageSavePath+FCaseID+'\Download\'+#10#13+ImageSavePath+FCaseID+'\');
      Download2Case(ImageSavePath+FCaseID+'\Download\',ImageSavePath+FCaseID+'\');
//Showmessage('aaa');
      //Download2Case('C:\Users\Hong\Downloads\沒有括號\',ImageSavePath+FCaseID+'\');
      if (FIs_OldCase = 'Y') then
      begin
        if (FWork_no='HLN') then
          ErrFormtoCurrentForm(FCaseID,'10000001011112A','11000001011112A');  //換掉錯的FormID
        //if not FileExists(ImageSavePath+FCaseID+'\CaseDocNo_Copies.dat') then   //這個會在Download2Case時一律產生所以不能有這行 20141013
        OldCasetoNewCase(FCaseID);
        //ErrFormtoCurrentForm(FCaseID,'11B00005011312A','11000001011112A');  //換掉錯的FormID
        //LoadImgFile;
      end;
//      if (FIs_OldCase = 'Y') and (FWork_no='HLN') then   //77版的
//      begin
//        ErrFormtoCurrentForm(FCaseID,'10000001011112A','11000001011112A');  //換掉錯的FormID
//        if not FileExists(ImageSavePath+FCaseID+'\CaseDocNo_Copies.dat') then
//          OldCasetoNewCase(FCaseID);
//        //ErrFormtoCurrentForm(FCaseID,'11B00005011312A','11000001011112A');  //換掉錯的FormID
//        //LoadImgFile;
//      end;
      Create_Cust_DocDir(FCaseID); //產生外面傳入的文件
      if FMode='ESCAN' then
        LastInitFormidListCreate(ImageSavePath+FCaseID+'\Download\');
    end;
  end;
 
//ShowMessage('GetOMRCheckSet前');
  ////下載檢核XML//////
  IF not GetOMRCheckSet Then
  begin
    Showmessage(_Msg('下載檢核定位檔案時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
  ////下載檢核XML/////
//ShowMessage('GetOMRCheckSet後來');
  ////下載登打設定/////
  IF not GetKeyinSet Then
  begin
    Showmessage(_Msg('下載登打定位檔案時,網路發生錯誤!!')+HttpErrStr);
    DataLoading(False,False);
    Exit;
  end;
  ////下載登打設定/////
//ShowMessage('GetKeyinSet');
  if ScanDenialHint <> '' then   //有設定提示字串就秀在右上角
  begin
    DenialTimeLb.Visible := True;
    DenialTimeLb.Caption := Format(ScanDenialHint,[ScanDenialTime]);
  end;
//ShowMessage(IntToStr(ScanDpi));
  R_W_Scanini('R'); //掃瞄設定的ini
//ShowMessage(IntToStr(ScanDpi));
//ShowMessage('停掉DataLoading');
//DataLoading(False,False);
  ScanDuplexCB.Checked := ScanDuplex;
  if FMode <> 'SAMPLESCAN' then
    LoadImgFile;
  if (FMode = 'RSCAN') or (FMode = 'ESCAN') or (FMode = 'FSCAN') then
  begin
    if TreeView1.Items.Count > 0 then
    begin
      TreeView1.Selected := NewTreeNode.Item[0];
      TreeView1click(self);
    end;
  end;
  InitialOk := True;
 
  {AttFileGB.Visible := True; //附加電子檔窗  //20120207楊玉說不在這加電子檔先拿掉
  Splitter2.Visible := True;
  AttFileGB.Visible := False; //附加電子檔窗
  Splitter2.Visible := False; }
//ShowMessage('ImageSavePath='+ImageSavePath);
  DataLoading(False,False);
 
  LogFile1.LogToFile(logTimeString+'OCX初始化結束');
  LogFile1.LogToFile(logTimeString+'FUrl='+FUrl+
    ',FCaseID='+FCaseID+
    ',FMode='+FMode+
    ',FModeName='+FModeName+
    ',FWork_no='+FWork_no+
    ',FUserID='+FUserID+
    ',FUserName='+FUserName+
    ',FUserUnit='+FUserUnit+
    ',FData='+FData+
    ',FVerify='+FVerify+
    ',FReWrite='+FReWrite+
    ',FLanguage='+FLanguage+
    ',FLoanDoc_Value='+FLoanDoc_Value+
    ',FLoanDoc_Enable='+FLoanDoc_Enable+
    ',FUseProxy='+FUseProxy+
    ',FC_DocNoList='+FC_DocNoList+
    ',FC_DocNameList='+FC_DocNameList+
    ',FFixFileList='+FFixFileList+
    ',FIs_In_Wh='+FIs_In_Wh+
    ',FOldCaseInfo='+FOldCaseInfo+
    ',FPrintyn='+FPrintyn+
    ',FIs_OldCase='+FIs_OldCase+
    ',FCustDocYN='+FCustDocYN);
  LogFile1.LogToFile(logTimeString+'FImgDPI='+IntToStr(FImgDPI)+
    ',FScanColor='+    IntToStr(FScanColor)+
    ',FFileSizeLimit='+  IntToStr(FFileSizeLimit)+
    ',FCaseNoLength='+ IntToStr(FCaseNoLength)+
    ',FImgDelete='+FImgDelete+
    ',FIsExternal='+FIsExternal+
    ',FWH_category='+FWH_category+
    ',FCheck_main_form='+FCheck_main_form+
    ',FMaxUploadSize='+FMaxUploadSize);
 
end;
 
 
{ ==============================================================================
  方法名稱:Timer2Timer
  引用相依:
  方法描述:處理進度條或提示文字的動態點點動畫。每觸發一次就會在 ShowText 後方增
            加一個點,模擬載入中的視覺效果。
============================================================================== }
procedure TCB_IMGPSScanX.Timer2Timer(Sender: TObject);
begin
  IF Panel22.Caption = ShowText+'......' Then
    Panel22.Caption := ShowText
  Else
    Panel22.Caption := Panel22.Caption + '.';
  Application.ProcessMessages;
end;