hooyantsing's Blog

第52次课程-S1_WebTimeMachina

字数统计: 13.9k阅读时长: 82 min
2019/08/01

源辰74班

第52次课程

08.01.2019-08.11.2019

内容

S1项目

WebTimeMachina

项目组成员:胡燕卿 容创伟 肖理达 邵子芸

项目效果图:

**9ad6efaa1c6239e05bfa6e94844dcd31.png

**

**d3334964e9b85217ce14b92f05d7da7f.png

**

**b07b0b86f3f9aeeb0fdb08e35d225069.png

**

**9822ec9930f0a138b6b6fd3c4ecb559c.png

**

**41a20b382d3081bc14436eea2f8e0f68.png

**

项目简介:

本项目核心为网页爬虫,获取目标网页数据并保存于本地。

项目源码:

WTMwindow

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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
package org.wtm.demo;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Menu;

import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.SQLSyntaxErrorException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tray;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.swt.events.ShellEvent;

public class WTMwindow {

    protected Shell shellwindow;
    private Table table;
    private Text settaskname;
    private Text settaskresultfile;
    private Text settaskurlstr;
    private Text SQLoption;
    private Text text_6;
    private Text timerhour;
    private Text timerminute;
    private Text text;
    private Text text_1;// 网站名输入框 肖理达
    private Table table_1;// 爬取记录表 肖理达
    private Text text_2;// URL输入框 肖理达
    private Text text_3;// 任务编号记录框 肖理达
    private DateTime dateTime;// 时间下限 肖理达
    private DateTime dateTime_1;// 时间上限 肖理达
    private Combo combo;// 爬取状态下拉框 肖理达
    private Button button_12;// 时间下限勾选框 肖理达
    private Button button_13;// 时间上限勾选框 肖理达
    private Spinner spinner;// 页码显示器
    private Label countrec;// 记录计数器 肖理达
    private int recPage = 1; // 当前记录页数,默认第一页 肖理达
    private int countRec;// 查询记录总数 肖理达

    /**
     * Launch the application.
     *
     * @param args
     */
    public static void main(String[] arg) {
        try {
            WTMwindow window = new WTMwindow();
            window.open();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Open the window.
     */
    Display display = Display.getDefault();

    public void open() {
        createContents();
        // 居中显示
        int x = (display.getBounds().width - shellwindow.getBounds().width) / 2;
        int y = (display.getBounds().height - shellwindow.getBounds().height) / 2;
        shellwindow.setLocation(x, y);
        shellwindow.open();
        shellwindow.layout();
        while (!shellwindow.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }

    /**
     * Create contents of the window.
     */

    protected void createContents() {
        shellwindow = new Shell(SWT.CLOSE | SWT.MIN);
        shellwindow.setSize(800, 450);
        shellwindow.setText("WebTimeMachine 3.2");

        Menu menu = new Menu(shellwindow, SWT.BAR);
        shellwindow.setMenuBar(menu);

        MenuItem menuItem = new MenuItem(menu, SWT.CASCADE);
        menuItem.setText("\u7CFB\u7EDF");

        Menu menu_1 = new Menu(menuItem);
        menuItem.setMenu(menu_1);

        /*
         * MenuItem menuItem_3 = new MenuItem(menu_1, SWT.NONE);
         * menuItem_3.addSelectionListener(new SelectionAdapter() {
         *
         * @Override public void widgetSelected(SelectionEvent e) { try { //打开应用路径
         * 打开配置文件路径 String str =
         * "C:\\WINDOWS\\system32\\notepad.exe G:\\WebTimeMachine\\Java\\src\\db.properties"
         * ; Runtime.getRuntime().exec(str); } catch (IOException | NullPointerException
         * e2) { MessageBox mb = new MessageBox(shellwindow,SWT.ICON_ERROR |
         * SWT.OK); mb.setText("配置文件遇到异常"); mb.setMessage(e2.getMessage()); mb.open(); }
         *
         * } }); menuItem_3.setText("\u914D\u7F6E\u6587\u4EF6");
         */
        
        MenuItem menuItem_7 = new MenuItem(menu_1, SWT.NONE);
        menuItem_7.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dd=new DirectoryDialog(shellwindow);
                dd.setText("目录浏览");  
                dd.setMessage("请选择库目录所在位置");  
                //dd.setFilterPath("C:\\");  
                String locationPath = dd.open();  
                if(locationPath!=null){                
                    Runtime rt = Runtime.getRuntime();
                    try {
                        rt.exec("explorer.exe " + locationPath);
                    } catch (IOException e1) {
                        MessageBox mb = new MessageBox(shellwindow,SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-0214  库目录获取错误");
                        mb.setMessage(e1.getMessage());
                        mb.open();    
                    }
                }  
            }
        });
        menuItem_7.setText("\u5E93\u76EE\u5F55");

        MenuItem mntmDmp = new MenuItem(menu_1, SWT.NONE);
        mntmDmp.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new OracleFileOut(shellwindow, countRec).open();
            }
        });
        mntmDmp.setText("DMP\u6587\u4EF6\u5BFC\u51FA");

        MenuItem mntmDmp_1 = new MenuItem(menu_1, SWT.NONE);
        mntmDmp_1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new OracleFileIn(shellwindow, countRec).open();
            }
        });
        mntmDmp_1.setText("DMP\u6587\u4EF6\u5BFC\u5165");

        MenuItem menuItem_4 = new MenuItem(menu_1, SWT.NONE);
        menuItem_4.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                System.exit(0);
            }
        });
        menuItem_4.setText("\u5B89\u5168\u9000\u51FA");

        MenuItem menuItem_8 = new MenuItem(menu, SWT.CASCADE);
        menuItem_8.setText("\u4E2A\u4EBA");

        Menu menu_4 = new Menu(menuItem_8);
        menuItem_8.setMenu(menu_4);

        MenuItem menuItem_3 = new MenuItem(menu_4, SWT.NONE);
        menuItem_3.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new PersonalCenter(shellwindow, SWT.NONE).open();
            }
        });
        menuItem_3.setText("\u4E2A\u4EBA\u4E2D\u5FC3");

        MenuItem menuItem_1 = new MenuItem(menu, SWT.CASCADE);
        menuItem_1.setText("\u5E2E\u52A9");

        Menu menu_2 = new Menu(menuItem_1);
        menuItem_1.setMenu(menu_2);

        MenuItem menuItem_6 = new MenuItem(menu_2, SWT.NONE);
        menuItem_6.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                HelpFile helpfile = new HelpFile(shellwindow, SWT.NONE);
                helpfile.open();
            }
        });
        menuItem_6.setText("\u4F7F\u7528\u6587\u6863");

        MenuItem menuItem_2 = new MenuItem(menu, SWT.CASCADE);

        menuItem_2.setText("\u5173\u4E8E");

        Menu menu_3 = new Menu(menuItem_2);
        menuItem_2.setMenu(menu_3);

        MenuItem menuItem_5 = new MenuItem(menu_3, SWT.NONE);
        menuItem_5.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                About about = new About(shellwindow, SWT.NONE);
                about.open();
            }
        });
        menuItem_5.setText("\u7248\u672C");

        TabFolder tabFolder = new TabFolder(shellwindow, SWT.NONE);
        tabFolder.setBounds(0, 0, 794, 401);

        TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
        tabItem.setText("\u4EFB\u52A1\u8868");

        Composite composite = new Composite(tabFolder, SWT.NONE);
        tabItem.setControl(composite);

        table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        table.setBounds(10, 10, 649, 351);
        table.setHeaderVisible(true);
        table.setLinesVisible(true);

        TableColumn tableColumn = new TableColumn(table, SWT.NONE);
        tableColumn.setWidth(80);
        tableColumn.setText("\u7F16\u53F7");

        TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);
        tableColumn_1.setWidth(130);
        tableColumn_1.setText("\u540D\u79F0");

        TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);
        tableColumn_2.setWidth(180);
        tableColumn_2.setText("\u8DEF\u5F84");

        // TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);
        // tableColumn_3.setWidth(130);
        // tableColumn_3.setText("\u7F13\u5B58\u8DEF\u5F84");

        TableColumn tblclmnUrl = new TableColumn(table, SWT.NONE);
        tblclmnUrl.setWidth(255);
        tblclmnUrl.setText("Url");

        Button button = new Button(composite, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                String sql = " select * from tasksheet where 1=1 ";
                List<String> paramList = new ArrayList<>();
                if (text.getText().trim().length() > 0) {
                    sql += " and TASKNAME like ? ";
                    paramList.add("%" + text.getText() + "%");
                }
                try {
                    table.removeAll();
                    List<Map<String, Object>> ret = WTMbackstage.query(sql, paramList.toArray());
                    for (Map<String, Object> row : ret) {
                        TableItem tableItem = new TableItem(table, SWT.NONE);
                        tableItem.setText(new String[] { row.get("TASKID") + "", // 避免空表格
                                row.get("TASKNAME") + "", row.get("TASKRESULTFILE") + "",
                                // row.get("TASKCACHEFILE")+"",
                                row.get("TASKURLSTR") + "" });
                        tableItem.setData(row);
                    }
                } catch (SQLException e1) {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0201  获取数据失败");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                }
            }
        });

        button.setBounds(684, 74, 80, 27);
        button.setText("\u67E5\u8BE2");

        Button button_1 = new Button(composite, SWT.NONE);
        button_1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (table.getSelectionCount() > 0) {
                    TableItem[] items = table.getSelection();
                    TableItem item = items[0];
                    @SuppressWarnings("unchecked")
                    Map<String, Object> row = (Map<String, Object>) item.getData();
                    String flag = "false";
                    try {
                        flag = Reptile6.Init(row.get("TASKNAME") + "", row.get("TASKRESULTFILE") + "",
                                row.get("TASKURLSTR") + "");
                        Map<String, Object> result = new LinkedHashMap<>();
                        result.put("MARK", flag);
                        result.put("TASKID", row.get("TASKID"));
                        result.put("TASKNAME", row.get("TASKNAME"));
                        result.put("TASKRESULTFILE", row.get("TASKRESULTFILE"));
                        result.put("TASKURLSTR", row.get("TASKURLSTR"));
                        // 调用 肖理达方法(result);
                        RecordBackstage.addRecord(result);

                    } catch (Exception e1) {
                        MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-0202  获取数据失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                        return;
                    }
                    if (flag.equals("true")) {
                        MessageBox mb1 = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);
                        mb1.setText("系统提示");
                        mb1.setMessage("数据爬取成功:1条");
                        mb1.open();
                    } else {
                        MessageBox mb2 = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                        mb2.setText("WTM-0203  爬取数据失败");
                        mb2.setMessage("爬取数据失败:1条");
                        mb2.open();
                    }

                } else {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0204  请选中爬取对象");
                    mb.setMessage("请选中爬取对象");
                    mb.open();
                }
            }
        });
        button_1.setBounds(684, 278, 80, 27);
        button_1.setText("\u7ACB\u5373\u6267\u884C");

        Button button_7 = new Button(composite, SWT.NONE);
        button_7.setBounds(684, 145, 80, 27);
        button_7.setText("\u65B0\u589E");

        Button delete = new Button(composite, SWT.NONE);
        delete.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (table.getSelectionCount() > 0) {
                    try {
                        TableItem[] items = table.getSelection();
                        TableItem item = items[0];
                        @SuppressWarnings("unchecked")
                        Map<String, Object> row = (Map<String, Object>) item.getData();
                        String sql = " delete from tasksheet where taskid = ? ";
                        WTMbackstage.update(sql, row.get("TASKID"));
                        MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);
                        mb.setText("系统提示");
                        mb.setMessage("删除任务成功");
                        mb.open();
                    } catch (SQLException e1) {
                        MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-0205  删除任务失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    }
                } else {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0206  请选中删除对象");
                    mb.setMessage("请选中删除对象");
                    mb.open();
                }
            }
        });
        delete.setBounds(684, 211, 80, 27);
        delete.setText("\u5220\u9664");

        Button button_9 = new Button(composite, SWT.NONE);
        button_9.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (table.getSelectionCount() > 0) {
                    TableItem[] items = table.getSelection();
                    TableItem item = items[0];
                    @SuppressWarnings("unchecked")
                    Map<String, Object> row = (Map<String, Object>) item.getData();
                    new Modify(shellwindow, SWT.NONE, row).open();
                } else {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0207  请选中修改对象");
                    mb.setMessage("请选中修改对象");
                    mb.open();
                }
            }
        });
        button_9.setBounds(684, 178, 80, 27);
        button_9.setText("\u4FEE\u6539");

        Button button_10 = new Button(composite, SWT.NONE);
        button_10.setBounds(684, 311, 80, 27);
        button_10.setText("\u5B9A\u65F6\u6267\u884C");

        text = new Text(composite, SWT.BORDER);
        text.setBounds(684, 45, 80, 23);

        Label label_14 = new Label(composite, SWT.NONE);
        label_14.setBounds(711, 22, 24, 17);
        label_14.setText("\u540D\u79F0");

        TabItem tabItem_2 = new TabItem(tabFolder, SWT.NONE);
        tabItem_2.setText("\u4EFB\u52A1\u8BA1\u5212");

        Composite composite_2 = new Composite(tabFolder, SWT.NONE);
        tabItem_2.setControl(composite_2);

        Label lblNewLabel = new Label(composite_2, SWT.NONE);
        lblNewLabel.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
        lblNewLabel.setBounds(10, 24, 64, 21);
        lblNewLabel.setText("\u6DFB\u52A0\u8BB0\u5F55");

        Label label = new Label(composite_2, SWT.NONE);
        label.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 9, SWT.NORMAL));
        label.setBounds(80, 47, 24, 17);
        label.setText("\u540D\u79F0");

        settaskname = new Text(composite_2, SWT.BORDER);
        settaskname.setBounds(137, 44, 250, 23);

        Label label_1 = new Label(composite_2, SWT.NONE);
        label_1.setBounds(80, 74, 48, 17);
        label_1.setText("\u8DEF\u5F84");

        settaskresultfile = new Text(composite_2, SWT.BORDER);
        settaskresultfile.setBounds(137, 71, 250, 23);

        Label label_3 = new Label(composite_2, SWT.NONE);
        label_3.setBounds(80, 103, 36, 17);
        label_3.setText("\u6E90\u7F51\u5740");

        settaskurlstr = new Text(composite_2, SWT.BORDER);
        settaskurlstr.setBounds(137, 100, 500, 23);

        Button button_2 = new Button(composite_2, SWT.NONE);
        button_2.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (settaskname.getText().trim().length() > 0 && settaskresultfile.getText().trim().length() > 0
                        && settaskurlstr.getText().length() > 0) {
                    try {
                        WTMbackstage.insertTask(settaskname.getText(), settaskresultfile.getText(), null,
                                settaskurlstr.getText());
                        MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);
                        mb.setText("系统提示");
                        mb.setMessage("添加任务成功");
                        mb.open();
                    } catch (SQLException e1) {
                        MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-0208  添加任务失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    }
                }else {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0213  添加任务失败");
                    mb.setMessage("文本框不能为空");
                    mb.open();
                }
            }
        });
        button_2.setBounds(137, 129, 80, 27);
        button_2.setText("\u786E\u8BA4\u6DFB\u52A0");

        Label lblOracle = new Label(composite_2, SWT.NONE);
        lblOracle.setText("Oracle\u63A7\u5236\u53F0");
        lblOracle.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
        lblOracle.setBounds(10, 244, 106, 21);

        Label label_6 = new Label(composite_2, SWT.NONE);
        label_6.setBounds(80, 273, 24, 17);
        label_6.setText("\u6307\u4EE4");

        SQLoption = new Text(composite_2, SWT.BORDER);
        SQLoption.setBounds(137, 270, 500, 23);

        /*
         * Button button_3 = new Button(composite_2, SWT.NONE);
         * button_3.addSelectionListener(new SelectionAdapter() {
         *
         * @Override public void widgetSelected(SelectionEvent e) { try {
         * WTMbackstage.deleteTask(Integer.parseInt(deletetask.getText())); MessageBox
         * mb = new MessageBox(shellwindow,SWT.ICON_INFORMATION | SWT.OK);
         * mb.setText("表记录删除成功"); mb.setMessage("表记录删除成功"); mb.open(); } catch
         * (SQLException e1) { MessageBox mb = new
         * MessageBox(shellwindow,SWT.ICON_ERROR | SWT.OK);
         * System.out.println(e1); mb.setText("表记录删除失败");
         * mb.setMessage(e1.getMessage()); mb.open(); } } });
         * button_3.setText("\u786E\u8BA4\u5220\u9664"); button_3.setBounds(137, 232,
         * 80, 27);
         */

        Button button_4 = new Button(composite_2, SWT.NONE);
        button_4.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    WTMbackstage.SQLOption(SQLoption.getText());
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);;
                    mb.setText("系统提示 指令发送成功");
                    mb.setMessage("指令发送成功:" + SQLoption.getText());
                    mb.open();
                } catch (SQLException e1) {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_ERROR | SWT.OK);
                    System.out.println(e1);
                    mb.setText("WTM-0209  数据库遇到错误");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                }
            }
        });
        button_4.setText("\u53D1\u9001");
        button_4.setBounds(137, 299, 80, 27);

        Label label_8 = new Label(composite_2, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_8.setBounds(10, 205, 766, 2);

        Button button_3 = new Button(composite_2, SWT.NONE);
        button_3.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                settaskname.setText("");
                settaskurlstr.setText("");
            }
        });
        button_3.setBounds(223, 129, 80, 27);
        button_3.setText("\u91CD\u7F6E");
        
        Button btnNewButton = new Button(composite_2, SWT.NONE);
        btnNewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dd=new DirectoryDialog(shellwindow);
                dd.setText("目录浏览");  
                dd.setMessage("请选择库目录所在位置");  
                dd.setFilterPath("C:\\");  
                String locationPath = dd.open();  
                if(locationPath!=null){                
                    settaskresultfile.setText(locationPath);  
                }  
            }
        });
        btnNewButton.setBounds(400, 71, 60, 23);
        btnNewButton.setText("\u6D4F\u89C8");

        TabItem tabItem_3 = new TabItem(tabFolder, SWT.NONE);
        tabItem_3.setText("\u5B9A\u65F6\u4EFB\u52A1");

        Composite composite_3 = new Composite(tabFolder, SWT.NONE);
        tabItem_3.setControl(composite_3);

        Label label_9 = new Label(composite_3, SWT.NONE);
        label_9.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 10, SWT.NORMAL));
        label_9.setBounds(10, 10, 282, 19);
        label_9.setText(
                "\u8B66\u544A\uFF1A\u5373\u65F6\u542F\u52A8\u8BF7\u5728\u5F53\u524D\u65F6\u95F4\u57FA\u7840\u4E0A\u540E\u5EF6\u4E00\u5206\u949F");

        Label lblNewLabel_1 = new Label(composite_3, SWT.NONE);
        lblNewLabel_1.setBounds(49, 58, 61, 17);
        lblNewLabel_1.setText("\u542F\u52A8\u65F6\u95F4\uFF1A");

        Label label_10 = new Label(composite_3, SWT.SEPARATOR | SWT.HORIZONTAL);
        label_10.setBounds(10, 35, 756, 2);

        text_6 = new Text(composite_3, SWT.BORDER);
        text_6.setEnabled(false);
        text_6.setText("\u5F53\u5929");
        text_6.setBounds(117, 55, 73, 23);

        Label label_11 = new Label(composite_3, SWT.NONE);
        label_11.setBounds(196, 58, 12, 17);
        label_11.setText("\u65E5");

        timerhour = new Text(composite_3, SWT.BORDER);
        timerhour.setText("23");
        timerhour.setBounds(214, 55, 73, 23);

        Label label_12 = new Label(composite_3, SWT.NONE);
        label_12.setBounds(293, 58, 12, 17);
        label_12.setText("\u65F6");

        timerminute = new Text(composite_3, SWT.BORDER);
        timerminute.setText("59");
        timerminute.setBounds(311, 55, 73, 23);

        Label label_13 = new Label(composite_3, SWT.NONE);
        label_13.setBounds(390, 58, 61, 17);
        label_13.setText("\u5206");

        Button button_5 = new Button(composite_3, SWT.NONE);
        button_5.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                WTMbackstage.spiderTimer(Integer.parseInt(timerhour.getText()),
                        Integer.parseInt(timerminute.getText()));
                MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);
                mb.setText("已启动定时器");
                mb.setMessage("每天" + timerhour.getText() + "时" + timerminute.getText() + "分将自动运行");
                mb.open();
            }
        });
        button_5.setBounds(117, 100, 80, 27);
        button_5.setText("\u5B9A\u65F6\u542F\u52A8");

        Button button_6 = new Button(composite_3, SWT.NONE);
        button_6.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                WTMbackstage.spiderTimerStop();
                MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION | SWT.OK);
                mb.setText("已停止定时器");
                mb.setMessage("定时器已经安全解除");
                mb.open();
            }
        });
        button_6.setBounds(214, 100, 80, 27);
        button_6.setText("\u505C\u6B62");

        TabItem tabItem_1 = new TabItem(tabFolder, SWT.NONE);
        tabItem_1.setText("\u722C\u53D6\u8BB0\u5F55");

        Composite composite_1 = new Composite(tabFolder, SWT.NONE);
        tabItem_1.setControl(composite_1);

        button_7.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                tabFolder.setSelection(tabItem_2);
            }
        });

        button_10.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                tabFolder.setSelection(tabItem_3);
            }
        });

        // 容创伟 图标
        // Image image = new Image(display,"G:\\WebTimeMachine\\img\\图标.ico");
        // 容创伟 最小化托盘
        shellwindow.setImage(SWTResourceManager.getImage(WTMwindow.class, "/img/\u56FE\u6807.ico"));
        final Tray tray = display.getSystemTray();
        final TrayItem trayItem = new TrayItem(tray, SWT.NONE);
        trayItem.setImage(SWTResourceManager.getImage(WTMwindow.class, "/img/\u56FE\u6807.ico"));
        trayItem.setVisible(false);
        trayItem.setToolTipText("WebTimeMachine 2.8");
        trayItem.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                toggleDisplay(shellwindow, tray);
            }
        });
        shellwindow.addShellListener(new ShellAdapter() {
            @Override
            public void shellIconified(ShellEvent e) {
                toggleDisplay(shellwindow, tray);
            }

            @Override
            public void shellClosed(ShellEvent e) {
                trayItem.dispose();
                System.exit(0);
            }
        });
        final Menu trayMenu = new Menu(shellwindow, SWT.POP_UP);
        MenuItem showMenuItem = new MenuItem(trayMenu, SWT.PUSH);
        showMenuItem.setText("显示窗口");
        // 显示窗口,并隐藏托盘图标
        showMenuItem.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                toggleDisplay(shellwindow, tray);
            }
        });
        trayMenu.setDefaultItem(showMenuItem);
        new MenuItem(trayMenu, SWT.SEPARATOR);
        // 托盘中的退出菜单,程式只能通过这个菜单退出
        MenuItem exitMenuItem = new MenuItem(trayMenu, SWT.PUSH);

        exitMenuItem.setText("退出程序");
        exitMenuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                ///shellwindow.dispose();
                System.exit(0);
            }
        });
        // 在托盘图标上点击鼠标右键时,弹出系统菜单
        trayItem.addMenuDetectListener(new MenuDetectListener() {
            public void menuDetected(MenuDetectEvent e) {
                trayMenu.setVisible(true);
            }
        });

        // 肖理达
        Label label_2 = new Label(composite_1, SWT.NONE);
        label_2.setText("\u540D\u79F0\uFF1A");
        label_2.setBounds(29, 12, 35, 17);

        text_1 = new Text(composite_1, SWT.BORDER);
        text_1.setBounds(70, 9, 260, 23);

        Label label_4 = new Label(composite_1, SWT.NONE);
        label_4.setText("\u722C\u53D6\u72B6\u6001:");
        label_4.setBounds(357, 47, 57, 17);

        Label lblUrl = new Label(composite_1, SWT.NONE);
        lblUrl.setAlignment(SWT.CENTER);
        lblUrl.setText("URL\uFF1A");
        lblUrl.setBounds(29, 47, 35, 17);

        Label label_7 = new Label(composite_1, SWT.NONE);
        label_7.setText("\u4EFB\u52A1\u7F16\u53F7\uFF1A");
        label_7.setBounds(357, 12, 57, 17);

        Button button_8 = new Button(composite_1, SWT.NONE);

        button_8.setText("\u67E5\u8BE2");
        button_8.setBounds(40, 334, 80, 27);

        table_1 = new Table(composite_1, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
        table_1.setLinesVisible(true);
        table_1.setHeaderVisible(true);
        table_1.setBounds(10, 82, 766, 239);

        TableColumn tableColumn_3 = new TableColumn(table_1, SWT.LEFT);
        tableColumn_3.setWidth(60);
        tableColumn_3.setText("\u8BB0\u5F55\u7F16\u53F7");

        TableColumn tableColumn_4 = new TableColumn(table_1, SWT.LEFT);
        tableColumn_4.setWidth(150);
        tableColumn_4.setText("\u65F6\u95F4");

        TableColumn tblclmnNewColumn = new TableColumn(table_1, SWT.LEFT);
        tblclmnNewColumn.setWidth(70);
        tblclmnNewColumn.setText("\u72B6\u6001");

        TableColumn tblclmnNewColumn_1 = new TableColumn(table_1, SWT.NONE);
        tblclmnNewColumn_1.setWidth(70);
        tblclmnNewColumn_1.setText("\u4EFB\u52A1\u7F16\u53F7");

        TableColumn tblclmnNewColumn_2 = new TableColumn(table_1, SWT.LEFT);
        tblclmnNewColumn_2.setWidth(100);
        tblclmnNewColumn_2.setText("\u540D\u79F0");

        TableColumn tblclmnNewColumn_3 = new TableColumn(table_1, SWT.LEFT);
        tblclmnNewColumn_3.setWidth(140);
        tblclmnNewColumn_3.setText("\u8DEF\u5F84");

        TableColumn tblclmnUrl_1 = new TableColumn(table_1, SWT.LEFT);
        tblclmnUrl_1.setWidth(170);
        tblclmnUrl_1.setText("URL");

        combo = new Combo(composite_1, SWT.NONE);
        combo.setBounds(420, 44, 120, 25);
        combo.setItems(new String[] { "true", "false" });

        Label label_15 = new Label(composite_1, SWT.NONE);
        label_15.setText("\u722C\u53D6\u65F6\u95F4\uFF1A");
        label_15.setBounds(570, 12, 61, 17);

        dateTime = new DateTime(composite_1, SWT.BORDER);
        dateTime.setBounds(642, 9, 98, 24);

        Label label_16 = new Label(composite_1, SWT.NONE);
        label_16.setText("\u81F3");
        label_16.setAlignment(SWT.CENTER);
        label_16.setBounds(594, 47, 20, 17);

        dateTime_1 = new DateTime(composite_1, SWT.BORDER);
        dateTime_1.setBounds(642, 44, 98, 24);

        button_12 = new Button(composite_1, SWT.CHECK);
        button_12.setBounds(746, 12, 13, 17);

        button_13 = new Button(composite_1, SWT.CHECK);
        button_13.setBounds(746, 47, 13, 17);

        Button button_15 = new Button(composite_1, SWT.NONE);
        button_15.setText("\u91CD\u7F6E");
        button_15.setBounds(240, 334, 80, 27);

        Button button_16 = new Button(composite_1, SWT.NONE);
        button_16.setText("\u5220\u9664");
        button_16.setBounds(140, 334, 80, 27);

        text_2 = new Text(composite_1, SWT.BORDER);
        text_2.setBounds(70, 44, 260, 23);

        text_3 = new Text(composite_1, SWT.BORDER);
        text_3.setBounds(420, 9, 120, 23);

        Button button_11 = new Button(composite_1, SWT.NONE);
        button_11.setBounds(440, 334, 60, 27);
        button_11.setText("\u4E0A\u4E00\u9875");

        Button button_14 = new Button(composite_1, SWT.NONE);
        button_14.setText("\u4E0B\u4E00\u9875");
        button_14.setBounds(580, 334, 60, 27);

        spinner = new Spinner(composite_1, SWT.BORDER);
        spinner.setBounds(510, 334, 60, 27);

        countrec = new Label(composite_1, SWT.NONE);
        countrec.setBounds(656, 339, 120, 17);
        
        // 记录查询 肖理达
        button_8.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                countRec = search(1);
            }
        });

        // 重置按钮 肖理达
        button_15.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                text_1.setText("");
                text_2.setText("");
                text_3.setText("");
                combo.setText("");
                button_12.setSelection(false);
                button_13.setSelection(false);

            }
        });

        // 删除按钮:弹出密码输入框 肖理达
        button_16.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (table_1.getSelectionCount() > 0) {
                    UserCheck userCheck = new UserCheck(shellwindow, SWT.NONE);
                    boolean access = userCheck.open();
                    if (access == false) {
                        return;
                    }
                    TableItem[] tableItems = table_1.getSelection();
                    @SuppressWarnings("unchecked")
                    Map<String, Object> ret = (Map<String, Object>) tableItems[0].getData();

                    String sql = "delete from records where recno=?";
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_INFORMATION);
                    mb.setText("系统提示");
                    mb.setMessage("删除记录成功");
                    mb.open();
                    try {
                        WTMbackstage.update(sql, ret.get("RECNO"));
                        recPage = 1;
                        search(recPage);
                    } catch (SQLException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                } else {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING);
                    mb.setText("WTM-0210  记录选取错误");
                    mb.setMessage("请选中记录对象");
                    mb.open();
                }

            }
        });

        // 记录查询:上一页 肖理达
        button_11.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (recPage <= 1) {
                    return;
                }
                recPage--;
                search(recPage);
            }
        });

        // 记录查询:下一页 肖理达
        button_14.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (recPage <= countRec / 10 && (recPage != countRec / 10 || countRec % 10 != 0)) {
                    recPage++;
                    search(recPage);
                }
            }
        });

        // 输入页码跳转 肖理达
        spinner.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                int index = spinner.getSelection();
                if (index < 1 || (index - 1 > countRec / 10 || (index - 1 == countRec / 10 && countRec % 10 == 0))) {
                    MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING);
                    mb.setText("WTM-0211  无效的索引");
                    mb.setMessage("页码无效!");
                    mb.open();
                } else {
                    recPage = spinner.getSelection();
                    search(recPage);
                }
            }
        });
    }

    // 托盘和窗口状态
    public void toggleDisplay(Shell shell, Tray tray) {
        try {
            shell.setVisible(!shell.isVisible());
            tray.getItem(0).setVisible(!shell.isVisible());
            if (shell.getVisible()) {
                shell.setMinimized(false);
                shell.setActive();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * private Image resize(Image src, int width, int height) { Image scaled = new
     * Image(Display.getDefault(), width, height); GC gc = new GC(scaled); try{
     * gc.setAdvanced(true); // 打开高级绘图模式 gc.setAntialias(SWT.ON);// 设置消除锯齿
     * gc.setInterpolation(SWT.HIGH); // 设置插值 gc.drawImage(src, 0, 0,
     * src.getBounds().width, src.getBounds().height,0, 0, width, height); }finally{
     * gc.dispose(); } return scaled; }
     */

    // 查询函数 肖理达
    public int search(int recPage) {
        table_1.removeAll();
        List<Object> param = new ArrayList<>();
        String sql = "select * from records where 1=1";
        if (text_1.getText().length() > 0) {
            sql += " and webname like ?";
            param.add("%" + text_1.getText() + "%");
        }
        if (combo.getText().length() > 0) {
            sql += " and success=?";
            param.add(combo.getText());
        }
        if (text_2.getText().length() > 0) {
            sql += " and url like ?";
            param.add("%" + text_2.getText() + "%");
        }
        if (text_3.getText().length() > 0) {
            sql += " and taskid=?";
            param.add(text_3.getText());
        }
        if (button_12.getSelection()) {
            Date start = Date.valueOf(dateTime.getYear() + "-" + (dateTime.getMonth() + 1) + "-" + dateTime.getDay());
            sql += " and time >= ?";
            param.add(start);
        }
        if (button_13.getSelection()) {
            Date end = Date
                    .valueOf(dateTime_1.getYear() + "-" + (dateTime_1.getMonth() + 1) + "-" + dateTime_1.getDay());
            sql += " and time <= ?";
            param.add(end);
        }
        Object[] paramArray = param.toArray();
        List<Map<String, Object>> queryPage = null;
        List<Map<String, Object>> query = null;
        try {
            queryPage = RecordBackstage.queryPage(sql, recPage, 10, paramArray);
            query = WTMbackstage.query(sql, paramArray);
            countRec = query.size();
        } catch (SQLSyntaxErrorException e1) {
            MessageBox mb = new MessageBox(shellwindow, SWT.ICON_WARNING);
            mb.setText("WTM-0212  参数类型错误");
            mb.setMessage("任务编号仅为数字");
            mb.open();
        } catch (SQLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        if (queryPage != null) {
            for (int i = 0; i < queryPage.size(); i++) {
                Map<String, Object> map = queryPage.get(i);
                TableItem tableItem = new TableItem(table_1, SWT.NONE);
                tableItem.setText(new String[] { map.get("RECNO").toString(), map.get("TIME").toString(),
                        map.get("SUCCESS").toString(), map.get("TASKID").toString(),
                        (map.get("WEBNAME") + "").toString(), (map.get("TASKRESULTFILE") + "").toString(),
                        (map.get("URL") + "").toString() });
                tableItem.setData(map);
                spinner.setSelection(recPage);
                countrec.setText("共" + countRec + "条记录");

            }
        }
        if (query == null || query.size() == 0) {
            spinner.setSelection(0);
            countrec.setText("无符合条件的记录");
            return 0;
        }
        return countRec;
    }
}

WTMbackstage

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
package org.wtm.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;

public class WTMbackstage {
    private static String url;
    private static String username;
    private static String password;
    public static Connection conn;
    private static Timer timer = null;

    public static void start() throws IOException, ClassNotFoundException, SQLException {
        Properties p = new Properties();
        System.out.println("正在尝试读取配置文件...");
        InputStream in = WTMbackstage.class.getClassLoader().getResourceAsStream("db.properties");
        p.load(in);
        String driver = p.getProperty("driver");
        url = p.getProperty("url");
        username = p.getProperty("username");
        password = p.getProperty("password");
        System.out.println("配置文件读取完成");
        System.out.println("正在尝试启动Oracle数据库驱动...");
        Class.forName(driver);
        System.out.println("启动数据库驱动完成");
        System.out.println("正在尝试连接到数据库...");
        conn = DriverManager.getConnection(url, username, password);
        System.out.println("连接到数据库完成");
    }

    public static void main() {
        // 用于自启动
    }

    // 查询所有TaskSheet表记录
    public static void queryTask() throws SQLException {
        String sql = "select * from tasksheet";
        PreparedStatement ps = conn.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();
        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
            String columnName = rsmd.getColumnName(i);
            System.out.print(columnName + "\t\t");
        }
        System.out.println();
        while (rs.next()) {
            for (int j = 1; j <= rsmd.getColumnCount(); j++) {
                Object columnValue = rs.getObject(j);
                System.out.print(columnValue + "\t");
            }
            System.out.println();
        }
        if (ps != null) {
            ps.close();
        }
    }

    public static List<Map<String, Object>> query(String sql, Object... paramArray) throws SQLException {
        PreparedStatement ps = conn.prepareStatement(sql);
        for (int i = 0; i < paramArray.length; i++) {
            ps.setObject(i + 1, paramArray[i]);
        }
        ResultSet rs = ps.executeQuery();
        // 获取元数据
        ResultSetMetaData rsmd = rs.getMetaData();
        List<Map<String, Object>> ret = new ArrayList<>();
        while (rs.next()) {
            Map<String, Object> row = new LinkedHashMap<>();
            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                String columnName = rsmd.getColumnName(i);
                Object columnValue = rs.getObject(i);
                row.put(columnName, columnValue);
            }
            ret.add(row);
        }
        return ret;
    }

    // 遍历TaskSheet任务表,爬以上网页
    public static void spider() throws Exception {
        String sql = "select * from tasksheet";
        PreparedStatement ps = conn.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            Map<String, Object> result = new LinkedHashMap<>();
            String mark = Reptile6.Init(rs.getString("TASKNAME"), rs.getString("TASKRESULTFILE"),
                    rs.getString("TASKURLSTR"));
            result.put("MARK", mark);
            result.put("TASKID", rs.getInt("TASKID"));
            result.put("TASKNAME", rs.getString("TASKNAME"));
            result.put("TASKRESULTFILE", rs.getString("TASKRESULTFILE"));
            result.put("TASKURLSTR", rs.getString("TASKURLSTR"));
            // 调用 肖理达方法(result);
            RecordBackstage.addRecord(result);
        }
        if (ps != null) {
            ps.close();
        }
    }

    // 添加TaskSheet表记录
    public static void insertTask(String... data) throws SQLException {
        String sql = "insert into tasksheet values (Seq_tasksheet_taskid.nextval,?,?,?,?)";
        PreparedStatement ps = conn.prepareStatement(sql);
        for (int i = 0; i < data.length; i++) {
            ps.setObject(i + 1, data[i]);
        }
        ps.executeUpdate();
        if (ps != null) {
            ps.close();
        }
    }

    /*
     * // 删除TaskSheet表记录 已废弃 public static void deleteTask(int taskid) throws
     * SQLException { String sql = "delete from tasksheet where taskid = ?";
     * PreparedStatement ps = conn.prepareStatement(sql); ps.setInt(1, taskid);
     * ps.executeUpdate(); if (ps != null) { ps.close(); } }
     */

    public static int update(String sql, Object... paramArray) throws SQLException {
        PreparedStatement ps = conn.prepareStatement(sql);
        for (int i = 0; i < paramArray.length; i++) {
            ps.setObject(i + 1, paramArray[i]);
        }
        return ps.executeUpdate();
    }

    // 数据库操作
    public static void SQLOption(String sql) throws SQLException {
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.executeUpdate();
        if (ps != null) {
            ps.close();
        }
    }

    /*
     * // 网页爬虫 已废弃 private static void reptile(String urlName, String resultFile,
     * String cacheFile, String urlStr) throws IOException { URL url = new
     * URL(urlStr); // 获取爬虫时间 long currentTime = System.currentTimeMillis(); //
     * 设置时间格式 DateFormat df = new SimpleDateFormat("yyyy_MM_dd_HH"); String format =
     * df.format(currentTime);
     *
     * InputStream in = null; OutputStream out = null; Reader r = null; Writer w =
     * null; // cache缓存 URLConnection conin = url.openConnection(); in =
     * conin.getInputStream(); out = new FileOutputStream(cacheFile +
     * "\\" + urlName + "Cache" + format + ".html"); byte b[] = new byte[1024]; int
     * len = 0; while ((len = in.read(b)) != -1) { out.write(b, 0, len); } // 成品 r =
     * new FileReader(cacheFile + "\\" + urlName + "Cache" + format + ".html"); w =
     * new FileWriter(resultFile + "\\" + urlName + " " + format + ".html");
     * BufferedReader br = new BufferedReader(r); BufferedWriter bw = new
     * BufferedWriter(w); String value = null; boolean flag = true; while ((value =
     * br.readLine()) != null) { // 过滤器 String[] str = value.split(" "); for (int i
     * = 0; i < str.length; i++) { if (str[i].startsWith("id=\"bd_snap")) { flag =
     * false; break; } else { flag = true; } } // 写入 if (flag) { bw.write(value);
     * bw.newLine(); } }
     *
     * bw.flush();
     *
     * if (in != null) { in.close(); } if (out != null) { out.close(); } if (r !=
     * null) { r.close(); } if (w != null) { w.close(); }
     *
     * }
     */

    public static void spiderTimer(int hour, int minute) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, hour); // 控制时
        calendar.set(Calendar.MINUTE, minute); // 控制分
        calendar.set(Calendar.SECOND, 0); // 控制秒
        Date time = calendar.getTime();

        DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        String format = df.format(time);
        System.out.println(format);

        timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                System.out.println("-------设定要指定任务--------");
                try {
                    spider();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            // 启动时间//启动间隔 1000 * 60 * 60 * 24 单位毫秒 (一天24小时)
        }, time, 1000 * 60 * 60 * 24);

    }

    public static void spiderTimerStop() {
        if (timer != null) {
            timer.cancel();
        }
    }

    // 容创伟
    // 导出 //dmp文件名 dmp文件路径 表名
    public static boolean backupData(String trim, String address, String trim3) throws InterruptedException, IOException {
        boolean isSuccess = false;
        String commandStr = "cmd.exe /c exp "+username+"/"+password+"@orcl file=" + address + "\\" + trim + ".dmp tables=(" + trim3 + ")";
        Runtime run = Runtime.getRuntime();
        Process process = null;
        try {
            process = run.exec(commandStr);
        } catch (IOException e1) {
            throw new IOException(e1);
        }
        String line = null;
        // 读取ErrorStream很关键,解决了挂起的问题
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        try {
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            br.close();
            process.getOutputStream().close();
            process.waitFor();
            isSuccess = true;
        } catch (IOException ex) {
            throw new IOException(ex);
        } catch (InterruptedException e) {
            throw new InterruptedException();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return isSuccess;
    }
    
    //容创伟
    //导入 文件名 路径
    public static boolean InputData(String address) throws InterruptedException, IOException {
        boolean isSuccess = false;
        String commandStr = "cmd.exe /c imp "+username+"/"+password+"@orcl file=" + address + " full=y";
        Runtime run = Runtime.getRuntime();
        Process process = null;
        try {
            process = run.exec(commandStr);
        } catch (IOException e1) {
            throw new IOException(e1);
        }
        String line = null;
        // 读取ErrorStream很关键,解决了挂起的问题
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        try {
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            br.close();
            process.getOutputStream().close();
            process.waitFor();
            isSuccess = true;
        } catch (IOException ex) {
            throw new IOException(ex);
        } catch (InterruptedException e) {
            throw new InterruptedException();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return isSuccess;
    }
}

UserWin

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.wb.swt.SWTResourceManager;

public class UserWin {

    protected Shell shell;
    private Text text;
    private Text text_1;
    private static int index;

    /**
     * Launch the application.
     *
     * @param args
     */
    public static void main(String[] args) {
        try {
            UserWin window = new UserWin();
            window.open();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Open the window.
     */
    public void open() {
        Display display = Display.getDefault();
        createContents();
        // 居中显示
        int x = (display.getBounds().width - shell.getBounds().width) / 2;
        int y = (display.getBounds().height - shell.getBounds().height) / 2;
        shell.setLocation(x, y);
        shell.open();
        // 自启动
        //WTMbackstage.main();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }

    /**
     * Create contents of the window.
     */
    Display display = new Display();
    protected void createContents() {
        
        shell = new Shell(SWT.CLOSE | SWT.MIN);
        shell.setSize(600, 450);
        shell.setText("\u7BA1\u7406\u5458\u9996\u9875");
        
        //Image image = new Image(display, "G:\\WebTimeMachine\\img\\图标.ico");
        shell.setImage(SWTResourceManager.getImage(UserWin.class, "/img/\u56FE\u6807.ico"));

        /*Label lblNewLabel = new Label(shell, SWT.NONE);
        Image logo = new Image(display,"G:\\WebTimeMachine\\img\\logo1.png");
        lblNewLabel.setImage(resize(logo,296,401));
        lblNewLabel.setBounds(0, 0, 296, 401);*/
        
        Label label = new Label(shell, SWT.NONE);
        label.setBounds(320, 109, 48, 20);
        label.setText("\u7BA1\u7406\u5458\uFF1A");
    
        text = new Text(shell, SWT.BORDER);
        text.setBounds(388, 106, 170, 26);

        Label label_1 = new Label(shell, SWT.NONE);
        label_1.setBounds(320, 163, 48, 20);
        label_1.setText("\u5BC6   \u94A5\uFF1A");

        text_1 = new Text(shell, SWT.BORDER | SWT.PASSWORD);
        text_1.setBounds(388, 160, 170, 26);

        Button button = new Button(shell, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                //配置文件 数据库驱动 数据库连接 启动
                try {
                    WTMbackstage.start();
                } catch (ClassNotFoundException e1) {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0101  初始化可能遇到错误");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                    return;
                } catch (IOException e1) {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0102  初始化可能遇到错误");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                    return;
                } catch (SQLException e1) {
                    MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0103  初始化可能遇到错误");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                    return;
                }
                
                
                try {
                    String sql = "select * from AdminisAcount";
                                                    //触发WTMbackstage的静态块
                    List<Map<String, Object>> ret = WTMbackstage.query(sql);
                    WTMwindow window = new WTMwindow();
                    boolean flag = false;
                    for (int i = 0; i < ret.size(); i++) {
                        if (text.getText().trim().equals(ret.get(i).get("ADNAME"))
                                && text_1.getText().trim().equals(ret.get(i).get("ADPASSWORD"))) {
                            shell.setVisible(false);
                            WTMbackstage.SQLOption(
                                    "update AdminisAcount set ADTIME = sysdate where ADID = " + ret.get(i).get("ADID"));
                            index = Integer.parseInt(ret.get(i).get("ADID")+"");
                            window.open();
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
                        mb.setText("WTM-0104  访问被拒绝");
                        mb.setMessage("管理员/密钥不合法,拒绝访问");
                        mb.open();
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        });
        button.setBounds(388, 239, 98, 30);
        button.setText("\u767B\u5F55");
        
        Menu menu = new Menu(shell, SWT.BAR);
        shell.setMenuBar(menu);
        
        MenuItem menuItem = new MenuItem(menu, SWT.CASCADE);
        menuItem.setText("\u7CFB\u7EDF\u914D\u7F6E");
        
        Menu menu_1 = new Menu(menuItem);
        menuItem.setMenu(menu_1);
        
        MenuItem menuItem_1 = new MenuItem(menu_1, SWT.NONE);
        menuItem_1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    FileDialog fileDialog = new FileDialog(shell);
                    String flag = fileDialog.open();
                    String address = fileDialog.getFilterPath()+"\\"+fileDialog.getFileName();
                    //打开应用路径    打开配置文件路径
                    if(flag!=null) {
                        String str = "C:\\WINDOWS\\system32\\notepad.exe " + address;
                        Runtime.getRuntime().exec(str);
                    }
                } catch (IOException | NullPointerException e2) {
                    MessageBox mb = new MessageBox(shell,SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0105  获取配置文件失败");
                    mb.setMessage(e2.getMessage());
                    mb.open();    
                }
            }
        });
        menuItem_1.setText("\u914D\u7F6E\u6587\u4EF6");
        
        Label lblNewLabel = new Label(shell, SWT.NONE);
        lblNewLabel.setImage(SWTResourceManager.getImage(UserWin.class, "/img/logo1.png"));
        lblNewLabel.setBounds(0, 0, 300, 401);

    }
    
    /*private Image resize(Image src, int width, int height) {
        Image scaled = new Image(Display.getDefault(), width, height);
        GC gc = new GC(scaled);
        try{
            gc.setAdvanced(true); // 打开高级绘图模式
            gc.setAntialias(SWT.ON);// 设置消除锯齿
            gc.setInterpolation(SWT.HIGH); // 设置插值
            gc.drawImage(src, 0, 0, src.getBounds().width, src.getBounds().height,0, 0, width, height);
        }finally{
            gc.dispose();
        }
        return scaled;
    }*/

    public static int getIndex() {
        return index;
    }
}

UserCheck

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.wb.swt.SWTResourceManager;

public class UserCheck extends Dialog {
    // 删除时验证记录

    //private static int userId;
    protected Object result;
    protected Shell shell;
    private Label label_1;
    private Text text_1;
    private boolean access;

    /**
     * Create the dialog.
     *
     * @param parent
     * @param style
     */
    public UserCheck(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     *
     * @return the result
     */
    public boolean open() {
        createContents();
        Display display = getParent().getDisplay();
        int x = (display.getBounds().width - shell.getBounds().width) / 2;
        int y = (display.getBounds().height - shell.getBounds().height) / 2;
        shell.setLocation(x, y);
        
        Label label = new Label(shell, SWT.NONE);
        label.setImage(SWTResourceManager.getImage(UserCheck.class, "/img/delete.png"));
        label.setBounds(0, 0, 133, 171);
        shell.open();
        shell.layout();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return access;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shell.setSize(400, 200);
        shell.setText("\u767B\u5F55\u9A8C\u8BC1");

        label_1 = new Label(shell, SWT.NONE);
        label_1.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
        label_1.setAlignment(SWT.CENTER);
        label_1.setText("\u5BC6\u7801\uFF1A");
        label_1.setBounds(147, 44, 56, 23);

        text_1 = new Text(shell, SWT.BORDER | SWT.PASSWORD);
        text_1.setBounds(209, 45, 160, 23);

        Button btnNewButton = new Button(shell, SWT.NONE);
        btnNewButton.setBounds(175, 87, 80, 27);
        btnNewButton.setText("\u786E\u8BA4");

        Button button = new Button(shell, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                shell.close();
                return;
            }
        });
        button.setText("\u53D6\u6D88");
        button.setBounds(269, 87, 80, 27);

        btnNewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                int userId=UserWin.getIndex();
                List<Object> param = new ArrayList<>();
                String sql = "select Adpassword from AdminisAcount where adid=?";
                param.add(userId);
                Object[] paramArray = param.toArray();
                Map<String, Object> query = null;
                query = RecordBackstage.queryOne(sql, paramArray);
                if (query != null) {
                    if (!(query.get("ADPASSWORD").toString().equals(text_1.getText()))) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING);
                        mb.setText("WTM-0701 访问被拒绝");
                        mb.setMessage("密钥不合法,拒绝访问");
                        mb.open();
                        access = false;
                        return;
                    }
                    access = true;
                    shell.close();
                    return;
                }
                access=false;
            }
        });
    }
}

Reptile6

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
package org.wtm.demo;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Reptile6 {
    
    
    
    public static void main(String[] args) {
        //测试系统
        /*try {
            Init("腾讯游戏","G:\\WebMuseum\\result\\腾讯游戏","https://www.qq.com/");
        } catch (IOException e) {
        }*/
    }

    

    @SuppressWarnings("resource")
    public static String Init(String urlName, String resultFile, String urlStr) {
        URL url = null;
        String address = null;
        InputStream in = null;
        // 判断url是否存在
        try {
            url = new URL(urlStr);
        } catch (MalformedURLException e1) {
            return "false";
        }
        URLConnection conin;
        try {
            conin = url.openConnection();
            in = conin.getInputStream();
        } catch (IOException e1) {
            return "false";
        }

        // 判断路径是否存在
        address = resultFile;
        File hasFile = new File(address);
        if (!(hasFile.exists())) {
            return "false";
        }

        // 时间戳
        long currentTime = System.currentTimeMillis();
        DateFormat df = new SimpleDateFormat("yyyy_MM_dd_HH");
        String format = df.format(currentTime);

        // 创建时间戳分类文件夹
        File file = new File(address + "\\" + urlName + "_" + format);
        if (!(file.exists())) {
            file.mkdirs();
        }

        FileOutputStream out;
        try {
            out = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + "Main.html");
        } catch (FileNotFoundException e1) {
            return "false";
        }
        byte b[] = new byte[1024];
        int len = 0;
        try {
            while ((len = in.read(b)) != -1) {
                out.write(b, 0, len);
            }
        } catch (IOException e1) {
            return "false";
        }

        // 获取CSS
        FileReader readCss;
        try {
            readCss = new FileReader(address + "\\" + urlName + "_" + format + "\\" + "Main.html");
        } catch (FileNotFoundException e1) {
            return "false";
        }

        BufferedReader brCss = new BufferedReader(readCss);
        String Cssvalue = null;
        try {
            while ((Cssvalue = brCss.readLine()) != null) {
                String[] valueCss = Cssvalue.split(" ");
                for (int i = 0; i < valueCss.length; i++) {
                    if (valueCss[i].startsWith("<link") | valueCss[i].endsWith("<link")) {
                        String findLink = Cssvalue;
                        String[] findHREF = findLink.split(" ");
                        for (int j = 0; j < findHREF.length; j++) {
                            if (findHREF[j].startsWith("href=")) {
                                String[] findURL = findHREF[j].split("\"");
                                InputStream inCss = null;
                                URL urlCss = null;
                                try {
                                    if (findURL[1].startsWith("http")) {
                                        urlCss = new URL(findURL[1]);
                                    } else {
                                        urlCss = new URL("http:" + findURL[1]);
                                    }
                                    URLConnection coninCss = urlCss.openConnection();
                                    inCss = coninCss.getInputStream();
                                } catch (MalformedURLException e1) {
                                    continue;
                                } catch (IOException e2) {
                                    continue;
                                } catch (Exception e3) {
                                    continue;
                                }

                                FileOutputStream outCss = null;

                                try {
                                    if (findURL[1].endsWith(".ico")) {
                                        outCss = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + findURL[1].hashCode() + ".ico");
                                    }
                                    if (findURL[1].endsWith(".svg")) {
                                        outCss = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + findURL[1].hashCode() + ".svg");
                                    }
                                    if (findURL[1].endsWith(".png")) {
                                        outCss = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + findURL[1].hashCode() + ".png");
                                    }
                                    if (findURL[1].endsWith(".css")) {
                                        outCss = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + findURL[1].hashCode() + ".css");
                                    }
                                    if (outCss == null) {
                                        outCss = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + findURL[1].hashCode() + ".css");
                                    }
                                } catch (FileNotFoundException e) {
                                    continue;
                                }
                                if (outCss != null) {
                                    byte bCss[] = new byte[1024];
                                    int lenCss = -1;
                                    try {
                                        while ((lenCss = inCss.read(bCss)) != -1) {
                                            outCss.write(bCss, 0, lenCss);
                                        }
                                    } catch (IOException e) {
                                        continue;
                                    }
                                    System.out.println("http:" + findURL[1]);
                                }
                                if(inCss!=null) {
                                    inCss.close();
                                }
                                if(outCss!=null) {
                                    outCss.close();
                                }
                            }
                        }
                    }
                }
            }
            if(brCss!=null) {
                brCss.close();
            }
            if(readCss!=null) {
                readCss.close();
            }
        } catch (IOException e1) {
            //e1.printStackTrace();
        }

        // 获取Img
        FileReader readImg;
        try {
            readImg = new FileReader(address + "\\" + urlName + "_" + format + "\\" + "Main.html");
        } catch (FileNotFoundException e1) {
            //e1.printStackTrace();
            return "false";
        }
        BufferedReader bfImg = new BufferedReader(readImg);
        String imgValue = null;
        try {
            while ((imgValue = bfImg.readLine()) != null) {
                String[] valueImg = imgValue.split(" ");
                for (int i = 0; i < valueImg.length; i++) {
                    if (valueImg[i].startsWith("<img") | valueImg[i].endsWith("<img")) {
                        String findImg = imgValue;
                        String[] find = findImg.split(" ");
                        for (int j = 0; j < find.length; j++) {
                            if (find[j].startsWith("src=")) {
                                String findSrc = find[j];
                                String[] findURL = findSrc.split("\"");
                                if (findURL.length > 1) {
                                    String URL = findURL[1];
                                    try {
                                        getImg(URL, address, urlName, format);
                                    } catch (IOException e) {
                                        continue;
                                    }
                                } else {
                                    continue;
                                }

                            }
                            if (find[j].startsWith("data-original=")) {
                                String findData = find[j];
                                String[] findURL = findData.split("\"");
                                if (findURL.length > 1) {
                                    String URL = findURL[1];
                                    try {
                                        getImg(URL, address, urlName, format);
                                    } catch (IOException e) {
                                        continue;
                                    }
                                } else {
                                    continue;
                                }
                            }
                            if (find[j].startsWith("data-ysrc=")) {
                                String findData = find[j];
                                String[] findURL = findData.split("\"");
                                if (findURL.length > 1) {
                                    String URL = findURL[1];
                                    try {
                                        getImg(URL, address, urlName, format);
                                    } catch (IOException e) {
                                        continue;
                                    }
                                } else {
                                    continue;
                                }
                            }

                        }
                    }
                }
            }
            if(bfImg!=null) {
                bfImg.close();
            }
            if(readImg!=null) {
                readImg.close();
            }
        } catch (IOException e1) {
            //e1.printStackTrace();
        }
        

        // 获取js
        FileReader readJs;
        try {
            readJs = new FileReader(address + "\\" + urlName + "_" + format + "\\" + "Main.html");
        } catch (FileNotFoundException e1) {
            //e1.printStackTrace();
            return "false";
        }
        BufferedReader brJs = new BufferedReader(readJs);
        String JsValues = null;
        try {
            while ((JsValues = brJs.readLine()) != null) {
                String[] valueJs = JsValues.split(" ");
                for (int i = 0; i < valueJs.length; i++) {
                    if (valueJs[i].startsWith("<script") | valueJs[i].endsWith("<script")) {
                        String findJs = JsValues;
                        String[] find = findJs.split(" ");
                        for (int j = 0; j < find.length; j++) {
                            if (find[j].startsWith("src=")) {
                                String findURL = find[j];
                                String[] getURL = findURL.split("\"");

                                InputStream inJs = null;
                                URL urlJs = null;
                                try {
                                    if (getURL.length > 1) {
                                        if (getURL[1].startsWith("http")) {
                                            urlJs = new URL(getURL[1]);
                                        } else {
                                            urlJs = new URL("https:" + getURL[1]);
                                        }
                                    }
                                    URLConnection coninJs = urlJs.openConnection();
                                    inJs = coninJs.getInputStream();
                                } catch (MalformedURLException e) {
                                    continue;
                                } catch (IOException e) {
                                    continue;
                                } catch (Exception e) {
                                    continue;
                                }

                                FileOutputStream outJs = null;
                                if (getURL.length > 1) {
                                    try {
                                        outJs = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\"
                                                + getURL[1].hashCode() + ".js");
                                    } catch (FileNotFoundException e) {
                                        continue;
                                    }
                                } else {
                                    continue;
                                }
                                if (outJs != null) {
                                    byte bJs[] = new byte[1024];
                                    int lenJs = -1;
                                    try {
                                        while ((lenJs = inJs.read(bJs)) != -1) {
                                            outJs.write(bJs, 0, lenJs);
                                        }
                                    } catch (IOException e) {
                                        continue;
                                    }
                                    System.out.println("http:" + getURL[1]);
                                }
                                if(inJs!=null) {
                                    inJs.close();
                                }
                                if(outJs!=null) {
                                    outJs.close();
                                }
                            }
                        }
                    }
                }
            }
            if(brJs!=null) {
                brJs.close();
            }
            if(readJs!=null) {
                readJs.close();
            }
        } catch (IOException e) {
        }
        try {
            if(in!=null) {
                in.close();
            }
            if(out!=null) {
                out.close();
            }
        } catch (Exception e) {
            //
        }
        return "true";
    }

    
    
    
    public static void getImg(String url, String address, String urlName, String format) throws IOException {
        URL imgUrl = null;
        InputStream imgIn = null;
        try {
            if (url.startsWith("http")) {
                imgUrl = new URL(url);
            } else {
                imgUrl = new URL("http:" + url);
            }
            URLConnection imgCon = imgUrl.openConnection();
            imgIn = imgCon.getInputStream();
        } catch (Exception e) {
            return;
        }

        FileOutputStream imgOut = null;
        if (url.endsWith(".gif")) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".gif");
        }
        if (url.endsWith(".png")) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".png");
        }
        if (url.endsWith(".jpg")) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".jpg");
        }
        if (url.endsWith(".jpeg")) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".jpeg");
        }
        if (url.endsWith("/0")) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".jpeg");
        }
        if (imgOut == null) {
            imgOut = new FileOutputStream(address + "\\" + urlName + "_" + format + "\\" + imgUrl.hashCode() + ".webp");
        }

        if (imgOut != null) {
            byte i1[] = new byte[1024];
            int imgLen = 0;
            while ((imgLen = imgIn.read(i1)) != -1) {
                imgOut.write(i1, 0, imgLen);
            }
            System.out.println(imgUrl);
        }
        if(imgIn!=null) {
            imgIn.close();
        }
        if(imgOut!=null) {
            imgOut.close();
        }
    }
}

RecordBackstage

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
package org.wtm.demo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class RecordBackstage {
    

    // 添加记录
    public static void addRecord(Map<String, Object> record) throws SQLException {
        String sql = "insert into records values(seq_rec_no.nextval,sysdate,?,?,?,?,?,?)";
        List<Object> param = new ArrayList<>();
        param.add(record.get("MARK"));
        param.add(record.get("TASKID"));
        param.add(record.get("TASKRESULTFILE"));
        param.add(record.get("TASKNAME"));
        param.add(record.get("TASKURLSTR"));
        param.add(null);
        Object[] paramArray = param.toArray();
        WTMbackstage.update(sql, paramArray);
    }

    // 分页查询
    public static List<Map<String, Object>> queryPage(String sql, int page, int rows, Object... paramArray)
            throws SQLException {
        int startrows = (page - 1) * rows;
        int endrows = page * rows;
        sql = "select t.* from(select t.*,rownum rn from(" + sql + ") t) t where t.rn <=? and t.rn>?";
        Object[] newparamArray = new Object[paramArray.length + 2];
        System.arraycopy(paramArray, 0, newparamArray, 0, paramArray.length);
        newparamArray[newparamArray.length - 2] = endrows;
        newparamArray[newparamArray.length - 1] = startrows;
        return WTMbackstage.query(sql, newparamArray);
    }
    
    public static Map<String, Object> queryOne(String sql, Object... paramArray) {
        Connection conn = null;
        try {
            conn = WTMbackstage.conn;
            PreparedStatement ps = conn.prepareStatement(sql);
            for (int i = 0; i < paramArray.length; i++) {
                ps.setObject(i + 1, paramArray[i]);
            }
            ResultSet rs = ps.executeQuery();
            ResultSetMetaData rsmd = rs.getMetaData();
            Map<String, Object> row = new LinkedHashMap<>();
            if (rs.next()) {
                for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                    String columnName = rsmd.getColumnName(i);
                    Object columValue = rs.getObject(i);
                    row.put(columnName, columValue);
                }
            }
            return row;

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}

PersonalCenter

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.wb.swt.SWTResourceManager;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class PersonalCenter extends Dialog {

    protected Object result;
    protected Shell shell;
    private Text text;
    private Text text_1;
    private Text text_2;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public PersonalCenter(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        createContents();
        Display display = getParent().getDisplay();
        int x = (display.getBounds().width - shell.getBounds().width) / 2;
        int y = (display.getBounds().height - shell.getBounds().height) / 2;
        shell.setLocation(x, y);
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shell.setSize(450, 300);
        shell.setText("\u4E2A\u4EBA\u4E2D\u5FC3");
        
        Label lblNewLabel = new Label(shell, SWT.NONE);
        lblNewLabel.setImage(SWTResourceManager.getImage(PersonalCenter.class, "/img/bg_1.png"));
        lblNewLabel.setBounds(0, 0, 444, 34);
        
        Label label = new Label(shell, SWT.NONE);
        label.setImage(SWTResourceManager.getImage(PersonalCenter.class, "/img/bg_1.png"));
        label.setBounds(0, 237, 444, 34);
        
        Label label_1 = new Label(shell, SWT.CENTER);
        label_1.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.NORMAL));
        label_1.setBounds(175, 40, 76, 25);
        label_1.setText("\u4E2A\u4EBA\u4E2D\u5FC3");
        
        Label label_2 = new Label(shell, SWT.NONE);
        label_2.setBounds(104, 88, 47, 17);
        label_2.setText("\u7BA1\u7406\u5458\uFF1A");
        
        text = new Text(shell, SWT.BORDER);
        text.setEnabled(false);
        text.setBounds(157, 85, 170, 23);
        
        text_1 = new Text(shell, SWT.BORDER);
        text_1.setBounds(157, 114, 170, 23);
        
        Label label_3 = new Label(shell, SWT.NONE);
        label_3.setBounds(104, 117, 47, 17);
        label_3.setText("\u65B0\u5BC6\u94A5\uFF1A");
        
        Label label_4 = new Label(shell, SWT.NONE);
        label_4.setBounds(86, 146, 65, 17);
        label_4.setText("\u786E\u8BA4\u65B0\u5BC6\u94A5\uFF1A");
        
        text_2 = new Text(shell, SWT.BORDER);
        text_2.setBounds(157, 143, 170, 23);
        
        int index = UserWin.getIndex();
        
        Button button = new Button(shell, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if(text_1.getText().trim().length()>0 && text_2.getText().trim().length()>0) {
                    if(text_1.getText().equals(text_2.getText())) {
                        String sql = " update AdminisAcount set ADPASSWORD = "+ text_1.getText() +" where ADID = " + index;
                        try {
                            WTMbackstage.SQLOption(sql);
                            MessageBox mb = new MessageBox(shell,SWT.ICON_INFORMATION | SWT.OK);
                            mb.setText("系统提示");
                            mb.setMessage("密码修改成功,请重新登陆");
                            mb.open();
                            System.exit(0);
                        } catch (SQLException e1) {
                            MessageBox mb = new MessageBox(shell,SWT.ICON_ERROR | SWT.OK);
                            mb.setText("WTM-1301  数据库遇到错误");
                            mb.setMessage(e1.getMessage());
                            mb.open();
                            return;
                        }                        
                    }else {
                        MessageBox mb = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK);
                        mb.setText("WTM-1302  输入密钥两次不一致");
                        mb.setMessage("输入密钥两次不一致");
                        mb.open();
                    }
                }else {
                    MessageBox mb = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-1303  密钥不可为空");
                    mb.setMessage("密钥不可为空");
                    mb.open();
                }
            }
        });
        button.setBounds(137, 185, 80, 27);
        button.setText("\u786E\u8BA4");
        
        Button button_1 = new Button(shell, SWT.NONE);
        button_1.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                shell.close();
            }
        });
        button_1.setBounds(223, 185, 80, 27);
        button_1.setText("\u53D6\u6D88");
        
        String sql = "select ADNAME from AdminisAcount where ADID = ?";
        try {
            List<Map<String,Object>> ret = WTMbackstage.query(sql,index);
            String ADname = ret.get(0).get("ADNAME")+"";
            text.setText(ADname);
        } catch (SQLException e1) {
            MessageBox mb = new MessageBox(shell,SWT.ICON_ERROR | SWT.OK);
            mb.setText("WTM-1304  数据库遇到错误");
            mb.setMessage(e1.getMessage());
            mb.open();
            return;
        }
    }
}

OracleFileOut

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;

import java.io.IOException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.wb.swt.SWTResourceManager;

public class OracleFileOut extends Dialog {

    protected Object result;
    protected Shell shlDmp;
    private Text txtFile;
    private Text txtGwebtimemachinedemotable;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public OracleFileOut(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        createContents();
        // 居中显示
        Display display = Display.getDefault();
        int x = (display.getBounds().width - shlDmp.getBounds().width) / 2;
        int y = (display.getBounds().height - shlDmp.getBounds().height) / 2;
        shlDmp.setLocation(x, y);
        shlDmp.open();
        shlDmp.layout();
        //Display display = getParent().getDisplay();
        while (!shlDmp.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shlDmp = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shlDmp.setSize(400, 300);
        shlDmp.setText("DMP\u6587\u4EF6\u5BFC\u51FA");
        
        Label label = new Label(shlDmp, SWT.NONE);
        label.setBounds(35, 64, 61, 17);
        label.setText("\u6587\u4EF6\u540D\uFF1A");
        
        Label label_1 = new Label(shlDmp, SWT.NONE);
        label_1.setBounds(35, 142, 61, 17);
        label_1.setText("\u5BFC\u51FA\u8DEF\u5F84\uFF1A");
        
        Label label_2 = new Label(shlDmp, SWT.NONE);
        label_2.setBounds(35, 104, 61, 17);
        label_2.setText("\u76EE\u6807\u8868\u540D\uFF1A");
        
        txtFile = new Text(shlDmp, SWT.BORDER);
        txtFile.setText("file");
        txtFile.setBounds(102, 61, 131, 23);
        
        txtGwebtimemachinedemotable = new Text(shlDmp, SWT.BORDER);
        txtGwebtimemachinedemotable.setBounds(102, 139, 210, 23);
        
        Combo combo = new Combo(shlDmp, SWT.NONE);
        combo.setItems(new String[] {"TASKSHEET", "ADMINISACOUNT", "RECORDS"});
        combo.setBounds(102, 101, 131, 25);
        
        Button button = new Button(shlDmp, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if(txtFile.getText().trim().length()>0 && txtGwebtimemachinedemotable.getText().trim().length()>0 && combo.getText().trim().length()>0) {
                    try {
                        WTMbackstage.backupData(txtFile.getText().trim(),txtGwebtimemachinedemotable.getText().trim(),combo.getText().trim());
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_INFORMATION | SWT.OK);
                        mb.setText("系统提示  导出成功");
                        mb.setMessage("导出文件位置:"+txtGwebtimemachinedemotable.getText().trim()+"\\"+txtFile.getText().trim());
                        mb.open();
                    } catch (InterruptedException e1) {
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-1101  导出失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    } catch (IOException e1) {
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-1102  导出失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    }
                }else {
                    MessageBox mb = new MessageBox(shlDmp,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-1103  导出失败");
                    mb.setMessage("文本框不能为空");
                    mb.open();
                }
            }
        });
        button.setBounds(153, 182, 80, 27);
        button.setText("\u5BFC\u51FA");
        
        Label label_3 = new Label(shlDmp, SWT.NONE);
        label_3.setImage(SWTResourceManager.getImage(OracleFileOut.class, "/img/bg3_3.jpg"));
        label_3.setBounds(0, 237, 394, 34);
        
        Label label_4 = new Label(shlDmp, SWT.NONE);
        label_4.setImage(SWTResourceManager.getImage(OracleFileOut.class, "/img/bg3_4.jpg"));
        label_4.setBounds(0, 0, 394, 34);
        
        Button btnNewButton = new Button(shlDmp, SWT.NONE);
        btnNewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                DirectoryDialog dd=new DirectoryDialog(shlDmp);
                dd.setText("目录浏览");  
                dd.setMessage("请选择导出数据库文件存放的目录位置");  
                dd.setFilterPath("C:\\");  
                String locationPath = dd.open();  
                if(locationPath!=null){                
                    txtGwebtimemachinedemotable.setText(locationPath);  
                }  
            }
        });
        btnNewButton.setBounds(318, 139, 60, 23);
        btnNewButton.setText("\u6D4F\u89C8");
    }
}

OracleFileIn

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;

import java.io.IOException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.wb.swt.SWTResourceManager;

public class OracleFileIn extends Dialog {

    protected Object result;
    protected Shell shlDmp;
    private Text text_1;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public OracleFileIn(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        Display display = Display.getDefault();
        createContents();
        // 居中显示
        int x = (display.getBounds().width - shlDmp.getBounds().width) / 2;
        int y = (display.getBounds().height - shlDmp.getBounds().height) / 2;
        shlDmp.setLocation(x, y);
        
        Button button = new Button(shlDmp, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                FileDialog fileDialog = new FileDialog(shlDmp);
                String flag = fileDialog.open();
                if(flag!=null) {
                    text_1.setText(fileDialog.getFilterPath()+"\\"+fileDialog.getFileName());
                }
            }
        });
        button.setBounds(304, 92, 60, 23);
        button.setText("\u6D4F\u89C8");
        shlDmp.open();
        shlDmp.layout();
        //Display display = getParent().getDisplay();
        while (!shlDmp.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shlDmp = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shlDmp.setSize(400, 300);
        shlDmp.setText("DMP\u6587\u4EF6\u5BFC\u5165");
        
        Label label_1 = new Label(shlDmp, SWT.NONE);
        label_1.setBounds(30, 95, 61, 17);
        label_1.setText("\u5BFC\u5165\u8DEF\u5F84\uFF1A");
        
        text_1 = new Text(shlDmp, SWT.BORDER);
        text_1.setBounds(97, 92, 200, 23);
        
        Button button = new Button(shlDmp, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if(text_1.getText().trim().length()>0) {
                    try {
                        WTMbackstage.InputData(text_1.getText().trim());
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_INFORMATION | SWT.OK);
                        mb.setText("系统提示  导入成功");
                        mb.setMessage("导入文件位置:"+text_1.getText().trim());
                        mb.open();
                    } catch (InterruptedException e1) {
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-1201  导入失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    } catch (IOException e1) {
                        MessageBox mb = new MessageBox(shlDmp,SWT.ICON_ERROR | SWT.OK);
                        mb.setText("WTM-1202  导入失败");
                        mb.setMessage(e1.getMessage());
                        mb.open();
                    }
                }else {
                    MessageBox mb = new MessageBox(shlDmp,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-1203  导入失败");
                    mb.setMessage("文本框不能为空");
                    mb.open();
                }
            }
        });
        button.setBounds(160, 147, 80, 27);
        button.setText("\u5BFC\u5165");
        
        Label label_3 = new Label(shlDmp, SWT.NONE);
        label_3.setImage(SWTResourceManager.getImage(OracleFileIn.class, "/img/bg3_3.jpg"));
        label_3.setBounds(0, 237, 394, 34);
        
        Label label_4 = new Label(shlDmp, SWT.NONE);
        label_4.setImage(SWTResourceManager.getImage(OracleFileIn.class, "/img/bg3_4.jpg"));
        label_4.setBounds(0, 0, 394, 34);
    }
}

Modify

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class Modify extends Dialog {

    protected Object result;
    protected Shell shlAbout;
    private Text id;
    private Text name;
    private Text resultfile;
    private Text url;
    private Map<String, Object> row;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public Modify(Shell parent, int style,Map<String, Object> row) {
        super(parent, style);
        setText("SWT Dialog");
        this.row = row;
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        createContents();
        Display display = getParent().getDisplay();
        int x = (display.getBounds().width - shlAbout.getBounds().width) / 2;
        int y = (display.getBounds().height - shlAbout.getBounds().height) / 2;
        shlAbout.setLocation(x, y);
        shlAbout.open();
        shlAbout.layout();
        while (!shlAbout.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shlAbout = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shlAbout.setSize(300, 375);
        shlAbout.setText("\u4FEE\u6539\u4EFB\u52A1");
        
        Label label = new Label(shlAbout, SWT.NONE);
        label.setBounds(57, 65, 36, 17);
        label.setText("\u7F16\u53F7\uFF1A");
        
        id = new Text(shlAbout, SWT.BORDER);
        id.setEnabled(false);
        id.setBounds(109, 62, 130, 23);
        
        Label label_1 = new Label(shlAbout, SWT.NONE);
        label_1.setBounds(57, 107, 36, 17);
        label_1.setText("\u540D\u79F0");
        
        name = new Text(shlAbout, SWT.BORDER);
        name.setBounds(109, 104, 130, 23);
        
        Label label_2 = new Label(shlAbout, SWT.NONE);
        label_2.setBounds(57, 152, 36, 17);
        label_2.setText("\u8DEF\u5F84");
        
        resultfile = new Text(shlAbout, SWT.BORDER);
        resultfile.setBounds(109, 149, 130, 23);
        
        Label lblUrl = new Label(shlAbout, SWT.NONE);
        lblUrl.setBounds(57, 193, 36, 17);
        lblUrl.setText("URL");
        
        url = new Text(shlAbout, SWT.BORDER);
        url.setBounds(109, 190, 130, 23);
        
        Button btnNewButton = new Button(shlAbout, SWT.NONE);
        btnNewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                String sql = " update tasksheet set TASKNAME=?,TASKRESULTFILE=?,TASKURLSTR=? where TASKID = " + row.get("TASKID");
                List<String> paramList = new ArrayList<>();
                if(name.getText().trim().length()>0) {
                    paramList.add(name.getText());
                }else {
                    MessageBox mb = new MessageBox(shlAbout,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0601  请填写名称");
                    mb.setMessage("请填写名称");
                    mb.open();
                    return;
                }
                if(resultfile.getText().trim().length()>0) {
                    paramList.add(resultfile.getText());
                }else {
                    MessageBox mb = new MessageBox(shlAbout,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0602  请填写路径");
                    mb.setMessage("请填写路径");
                    mb.open();
                    return;
                }
                if(url.getText().trim().length()>0) {
                    paramList.add(url.getText());
                }else {
                    MessageBox mb = new MessageBox(shlAbout,SWT.ICON_WARNING | SWT.OK);
                    mb.setText("WTM-0603  请填写URL");
                    mb.setMessage("请填写URL");
                    mb.open();
                    return;
                }
                try {
                    WTMbackstage.update(sql, paramList.toArray());
                } catch (SQLException e1) {
                    MessageBox mb = new MessageBox(shlAbout,SWT.ICON_ERROR | SWT.OK);
                    mb.setText("WTM-0604  数据库遇到错误");
                    mb.setMessage(e1.getMessage());
                    mb.open();
                    return;
                }
                MessageBox mb = new MessageBox(shlAbout,SWT.ICON_INFORMATION | SWT.OK);
                mb.setText("系统提示");
                mb.setMessage("修改成功");
                mb.open();
            }
        });
        btnNewButton.setBounds(57, 256, 80, 27);
        btnNewButton.setText("\u4FDD\u5B58");
        
        Button button = new Button(shlAbout, SWT.NONE);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                shlAbout.close();
            }
        });
        button.setBounds(159, 256, 80, 27);
        button.setText("\u53D6\u6D88");
        
        id.setText(row.get("TASKID")+"");
        name.setText(row.get("TASKNAME")+"");
        resultfile.setText(row.get("TASKRESULTFILE")+"");
        url.setText(row.get("TASKURLSTR")+"");
    }
}

HelpFile

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
package org.wtm.demo;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class HelpFile extends Dialog {

    protected Object result;
    protected Shell shell;
    private Text txtsearchEnginealtavistayahoogoogle;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public HelpFile(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        Display display = Display.getDefault();
        createContents();
        //居中显示
        int x = (display.getBounds().width - shell.getBounds().width) / 2;
        int y = (display.getBounds().height - shell.getBounds().height) / 2;
        shell.setLocation(x, y);
        shell.setLayout(null);
        shell.open();
        shell.layout();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shell.setSize(450, 500);
        shell.setText("\u7BA1\u7406\u5458\u4F7F\u7528\u624B\u518C");
        
        txtsearchEnginealtavistayahoogoogle = new Text(shell, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
        txtsearchEnginealtavistayahoogoogle.setBounds(10, 62, 424, 341);
        txtsearchEnginealtavistayahoogoogle.setText("\u9996\u9875\r\n1\u3001\u767B\u5F55\u754C\u9762\uFF1A\u6B63\u786E\u8F93\u5165\u7BA1\u7406\u5458\u540D\u5B57\u548C\u5BC6\u7801\u70B9\u51FB\u767B\u5F55\u5373\u53EF\u8FDB\u5165WebTimeMachine\u4E3B\u754C\u9762\uFF1B\r\n2\u3001\u7CFB\u7EDF\u914D\u7F6E\uFF1A\u70B9\u51FB\u914D\u7F6E\u6587\u4EF6\u6309\u94AE\u5373\u53EF\u81EA\u52A8\u6253\u5F00\u5176\u6240\u5728\u7684\u6587\u4EF6\u5939\uFF0C\u65B9\u4FBF\u53CA\u65F6\u4FEE\u6539\uFF1B\r\n\r\n\u4E3B\u754C\u9762\r\n1\u3001\u5BFC\u822A\u680F\r\n    \uFF081\uFF09\u7CFB\u7EDF\uFF1A\u76F4\u63A5\u70B9\u51FB\u53EF\u6D4F\u89C8\u5E93\u76EE\u5F55\uFF1BDMP\u6587\u4EF6\u7684\u5BFC\u5165\u5BFC\u51FA\uFF1B\u5B89\u5168\u9000\u51FA\uFF1B\r\n    \uFF082\uFF09\u4E2A\u4EBA\uFF1A\u7BA1\u7406\u5458\u53EF\u5728\u4E2A\u4EBA\u4E2D\u5FC3\u4FEE\u6539\u5BC6\u7801\uFF1B\r\n    \uFF083\uFF09\u5E2E\u52A9\uFF1A\u53EF\u67E5\u770B\u4F7F\u7528\u624B\u518C\uFF0C\u65B9\u4FBF\u8BE5\u8F6F\u4EF6\u7684\u64CD\u4F5C\u4F7F\u7528\uFF1B\r\n    \uFF084\uFF09\u5173\u4E8E\uFF1A\u53EF\u67E5\u770B\u8BE5\u8F6F\u4EF6\u5F53\u524D\u7248\u672C\u4EE5\u53CA\u5176\u5F00\u53D1\u8005\uFF1B\r\n2\u3001\u4EFB\u52A1\u680F\r\n    \uFF081\uFF09\u4EFB\u52A1\u8868\uFF1A\u663E\u793A\u9700\u8981\u6267\u884C\u7684\u4EFB\u52A1\uFF0C\u5305\u62EC\uFF1A\u7F16\u53F7\u3001\u540D\u79F0\u3001\u8DEF\u5F84\u3001Url\u7B49\uFF1B\u53EF\u8F93\u5165\u540D\u79F0\u8FDB\u884C\u8BE6\u7EC6\u67E5\u8BE2\u4EFB\u52A1\uFF0C\u4E5F\u53EF\u76F4\u63A5\u67E5\u8BE2\u6240\u6709\u4EFB\u52A1\uFF1B\u53EF\u5BF9\u4EFB\u52A1\u8FDB\u884C\u589E\u3001\u5220\u3001\u6539\uFF1B\u53EF\u7ACB\u5373\u6267\u884C\u4E5F\u53EF\u5B9A\u65F6\u6267\u884C\uFF0C\u70B9\u51FB\u5B9A\u65F6\u6267\u884C\u8DF3\u8F6C\u5B9A\u65F6\u4EFB\u52A1\u754C\u9762\uFF1B\r\n    \uFF082\uFF09\u4EFB\u52A1\u8BA1\u5212\uFF1A\u6DFB\u52A0\u722C\u53D6\u4EFB\u52A1\uFF0C\u6240\u6DFB\u52A0\u7684\u4EFB\u52A1\u53EF\u5728\u4EFB\u52A1\u680F\u67E5\u770B\uFF1B\r\n    \uFF083\uFF09\u5B9A\u65F6\u4EFB\u52A1\uFF1A\u53EF\u9009\u62E9\u4E00\u4E2A\u65F6\u95F4\u6BB5\u6765\u5F00\u542F\u4EFB\u52A1\uFF0C\u6B64\u65F6\u4EFB\u52A1\u680F\u4E2D\u6240\u6709\u4EFB\u52A1\u5C06\u4F1A\u5728\u8BE5\u65F6\u95F4\u6BB5\u81EA\u52A8\u8FDB\u884C\u722C\u53D6\u5E76\u4FDD\u5B58\u5728\u6587\u4EF6\u5939\u4E2D\uFF1B\r\n    \uFF084\uFF09\u722C\u53D6\u8BB0\u5F55\uFF1A\u5206\u9875\u663E\u793A\u722C\u53D6\u7684\u5386\u53F2\u8BB0\u5F55\uFF0C\u5305\u62EC\uFF1A\u8BB0\u5F55\u7F16\u53F7\u3001\u722C\u53D6\u65F6\u95F4\u3001\u722C\u53D6\u72B6\u6001\u3001\u4EFB\u52A1\u7F16\u53F7\u3001\u540D\u79F0\u3001\u8DEF\u5F84\u3001Url\u7B49\uFF1B\u53EF\u5BF9\u722C\u53D6\u8BB0\u5F55\u4ECE\u540D\u79F0\u3001Url\u3001\u4EFB\u52A1\u7F16\u53F7\u3001\u722C\u53D6\u72B6\u6001\u4EE5\u53CA\u722C\u53BB\u65F6\u95F4\u7B49\u65B9\u9762\u8FDB\u884C\u6A21\u7CCA\u3001\u7CBE\u786E\u67E5\u8BE2\uFF1B\r\n");
        
        Label label = new Label(shell, SWT.CENTER);
        label.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
        label.setBounds(164, 21, 112, 25);
        label.setText("\u7BA1\u7406\u5458\u4F7F\u7528\u624B\u518C");
        
        Button btnNewButton = new Button(shell, SWT.CENTER);
        btnNewButton.setBounds(143, 423, 158, 30);
        btnNewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                shell.close();
            }
        });
        btnNewButton.setText("\u5173\u95ED");
    }
}

About

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
package org.wtm.demo;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.wb.swt.SWTResourceManager;

public class About extends Dialog {

    protected Object result;
    protected Shell shlAbout;

    /**
     * Create the dialog.
     * @param parent
     * @param style
     */
    public About(Shell parent, int style) {
        super(parent, style);
        setText("SWT Dialog");
    }

    /**
     * Open the dialog.
     * @return the result
     */
    public Object open() {
        createContents();
        Display display = getParent().getDisplay();
        int x = (display.getBounds().width - shlAbout.getBounds().width) / 2;
        int y = (display.getBounds().height - shlAbout.getBounds().height) / 2;
        shlAbout.setLocation(x, y);
        shlAbout.open();
        shlAbout.layout();
        while (!shlAbout.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        return result;
    }

    /**
     * Create contents of the dialog.
     */
    private void createContents() {
        shlAbout = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
        shlAbout.setSize(450, 300);
        shlAbout.setText("About");
        
        Label lblAbout = new Label(shlAbout, SWT.NONE);
        lblAbout.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.NORMAL));
        lblAbout.setBounds(192, 12, 56, 25);
        lblAbout.setText("About");
        
        Label label = new Label(shlAbout, SWT.SEPARATOR | SWT.HORIZONTAL);
        label.setBounds(10, 43, 424, 2);
        
        Label lblWebtimemoine = new Label(shlAbout, SWT.NONE);
        lblWebtimemoine.setBounds(47, 64, 104, 17);
        lblWebtimemoine.setText("WebTimeMachine");
        
        Label lblNewLabel = new Label(shlAbout, SWT.NONE);
        lblNewLabel.setBounds(47, 87, 104, 17);
        lblNewLabel.setText("Version 3.2");
        
        Label lblHooyantsingChuangweirong = new Label(shlAbout, SWT.NONE);
        lblHooyantsingChuangweirong.setBounds(47, 110, 181, 34);
        lblHooyantsingChuangweirong.setText("Hooyantsing Chuangwei-Rong\r\nLida-Xiao Ziyun-Shao");
    }
}

数据库脚本

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
create table Tasksheet(
       taskid number(6) primary key,
       taskname varchar2(40),
       taskresultfile varchar2(60),
       taskcachefile varchar2(60),
       taskurlstr varchar2(600) unique
);
create sequence Seq_tasksheet_taskid ;

create table AdminisAcount(
       Adid number(4)primary key,
       Adname varchar2(10),
       Adpassword varchar(20),
       Adcontact varchar2(11)  not null,
       Ademail varchar2(100) constraint ck_adm_email check (Ademail like '_%@_%._%'),
       Adtime date

);
create sequence Ad_table start with 1001 increment by 1;

insert into AdminisAcount values(Ad_table.Nextval,'胡燕卿','123456','123','1111@qq.com',sysdate);
insert into AdminisAcount values(Ad_table.Nextval,'容创伟','123456','123456','2222@qq.com',sysdate);
insert into AdminisAcount values(Ad_table.Nextval,'肖理达','123456','123456','123@qq.com',sysdate);
insert into AdminisAcount values(Ad_table.Nextval,'邵子芸','123456','123456','4444@qq.com',sysdate);

create table records(
      recno int primary key, --记录编号,主键,序列生成
      time date,        --爬取时间,调用数据库时间
      success varchar2(6) constraint ck_rec_succ check(success in('true','false')), --爬取状态,约束为字符串true/false
      taskid int ,  --任务编号
      taskresultfile varchar2(60),   --爬取文件路径
      webname varchar2(60),         --网站名称
      url varchar2(600),            --url
      cache varchar2(60)    --缓存文件,暂定null
)                      
create sequence seq_rec_no          --创建主键序列

select * from tasksheet;
select * from AdminisAcount;

项目工程

WTM 3.2

**Demo.zip

**

CATALOG