田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.JPanel;
 
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.ConfigUtils;
import com.vci.client.common.objects.DeptObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.framework.systemConfig.object.TransmitMethod;
import com.vci.client.framework.util.RightControlUtil;
import com.vci.client.omd.enumManager.ui.EnumClient;
import com.vci.client.ui.excel.ExcelCellStyleSettingCallback;
import com.vci.client.ui.excel.ExcelDocumentUtils;
import com.vci.client.ui.excel.ExcelFileOperation;
import com.vci.client.ui.excel.SheetDataSet;
import com.vci.client.ui.excel.WorkboolStyleSetting;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.process.QANProcessBar;
import com.vci.client.ui.process.QANProcessBarFrame;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJOptionPane;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.etm.EnumChild;
import com.vci.corba.omd.etm.EnumItem;
 
public class UsersExcelImportDialogActionListener  extends JPanel implements ActionListener  {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    /**
     * 父窗体
     */
    private static final String ENUM_USERSECURITYENUM = "usersecurityenum";
    private UsersImportDialog ownerDialog = null;
    /**
     *  必填列
     */
    private ArrayList<Integer> ColumnNameisRed = new ArrayList<Integer>();
    /**
     * 所有user信息。
     */
    private ArrayList<UserObject> fileDatas = new ArrayList<UserObject>();
    /**
     * 用户
     */
    private ArrayList<String[]> deptAndUserRelation = new ArrayList<String[]>();
    
    private UserObject logonUserInfo;//
    private String userName = LogonApplication.getUserEntityObject().getUserName();
    public UsersExcelImportDialogActionListener(
            UsersImportDialog excelImprotDialog) {
        this.ownerDialog = excelImprotDialog;
    }
 
    public UsersExcelImportDialogActionListener() {
        // TODO Auto-generated constructor stub
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        try{
            logonUserInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName);
        }catch(VCIException ex) {
            VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", ex);
            return;
        }
        String actionCommand = e.getActionCommand();
        if (actionCommand.equals(ownerDialog.getBtnSave().getActionCommand())) {
            LinkedList<File> selectedFiles = this.ownerDialog.getSelectedFiles();
            if (selectedFiles == null || selectedFiles.isEmpty()) {
                VCIOptionPane.showMessageDialog(LogonApplication.frame,
                        "未选择文件!");
                return;
            }
            fileDatas.clear();
            deptAndUserRelation.clear();
            save();
        } else if (actionCommand.equals(ownerDialog.getBtnSelect()
                .getActionCommand())) {
            getFile();
        } else if (actionCommand.equals(ownerDialog.getBtnExport()
                .getActionCommand())) {
            downloadImportStuffTemplate();
        }
    }
 
    /**
     * 保存对象
     */
    private void save() {
        final QANProcessBarFrame frame = new QANProcessBarFrame();
        Thread t = new Thread() {
            public void run() {
                boolean b = false;
                frame.setContent("正在进行处理数据,请稍等......");
                try {
                    b = importData(frame);
                } catch (VCIError e) {
                    frame.setProcessBarCancel(true);
                    VCIOptionPane.showMessageDialog(LogonApplication.frame,
                            e.code);
                } catch (VCIException e){
                    
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    frame.setProcessBarCancel(true);
                    if (b) {
                        VCIOptionPane.showMessageDialog(LogonApplication.frame,
                                "导入成功!");
                        ownerDialog.dispose();
                    }else{
                        VCIOptionPane.showMessageDialog(LogonApplication.frame,
                                "导入失败!");
                    }
                }
            }
        };
        QANProcessBar bar = new QANProcessBar(t, frame, frame,
                "导入人员数据......", false);
        bar.setVisible(true);
    }
 
    /**
     * 导入
     * 
     * @param sheetDataSet
     * @return
     * @throws IOException 
     * @throws VCIError 
     * @throws VCIException 
     * @autor caicong
     * @data 2014-3-12
     */
    private boolean importData(QANProcessBarFrame frame) throws VCIError, VCIException, IOException {
 
        frame.setContent("正在获取系统部门数据......");
        HashMap<String, String> allDept = ownerDialog.getAllDept();
        if (allDept.size() == 0) {
            fetchAllDeptMessage();
        }
        frame.setContent("正在收集表单数据......");
        boolean isSuccess = collectionDatas();
        if(!isSuccess) return false;
        frame.setContent("正在导入表单人员信息......");
        boolean b = importExcelData();
        return b;
    }
 
    /**
     * 收集表单信息。
     * 
     * @throws VCIError
     * @throws IOException
     */
    private boolean collectionDatas() throws VCIError, IOException, VCIException{
        UserObject[] users = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfo();
        Map<String, UserObject> mapUser = new HashMap<String, UserObject>();
        for (UserObject u : users) {
            mapUser.put(u.getUserName(), u); 
        }
        String flag = ConfigUtils.getConfigValue("exportSecretGrade");
        LinkedList<File> selectedFiles = this.ownerDialog.getSelectedFiles();
        for (File f : selectedFiles) {
            List<SheetDataSet> sheetDataSets = this.getFileList(f);
            if (sheetDataSets != null && !sheetDataSets.isEmpty()) {
                for (SheetDataSet sheet : sheetDataSets) {
                    // sheet不能为空并且必须有出表头外的一条数据
                    if (sheet != null && sheet.getDataSet() != null && sheet.getDataSet().size() > 1) {
                        List<String[]> dataSet = sheet.getDataSet();
                        for (int i = 1; i < dataSet.size(); i++) {
                            String[] oneData = dataSet.get(i);
                            String userName = oneData[0]; // 账户
                            
                            UserObject userObj = null;
                            userObj = mapUser.get(userName);
                            if (userObj == null) {
                                String userId = ObjectUtility.getNewObjectID36();
                                if (ownerDialog.getAllDept().size() != 0) {
                                    boolean b = validateExcelDatas(oneData, i, userId);//
                                    if(!b) return false;
                                }
                                userObj = new UserObject();
                                userObj.setId(userId);
                                userObj.setUserName(userName);
                            } else {
                                String userId = userObj.getId();
                                if (ownerDialog.getAllDept().size() != 0) {
                                    boolean b = validateExcelDatas(oneData, i, userId);//
                                    if(!b) return false;
                                }
                            }
                            userObj.setPwd(oneData[1]);// 密码
                            userObj.setTrueName(oneData[2]);// 姓名
                            userObj.setEmail(oneData[3]);// 邮箱
                            userObj.setSpecialties(oneData[4]);// 专业
                            userObj.setDesc(oneData[5]);// 描述
                            // oneData[6]为部门信息,不在此处赋值处理
                            //判断是否导入密级
                            if (flag != null && flag.equalsIgnoreCase("true")) {
                                userObj.setSecretGrade(oneData[7]);// 密级                        
                            }
                            userObj.setPwdUpdateTime(System.currentTimeMillis());//"1970-1-1 00:00:00");
                            userObj.setGrantor("");
                            userObj.setUserType(logonUserInfo.getUserType());
                            userObj.setCreateTime(System.currentTimeMillis());
                            userObj.setCreateUser(userName);
                            userObj.setUpdateTime(System.currentTimeMillis());
                            userObj.setUpdateUser(userName);
                            fileDatas.add(userObj);
                        }
                    }
                }
            }
        }
        return true;
    }
 
    /**
     * 获取所有部门信息。
     * @throws VCIException 
     */
    private void fetchAllDeptMessage() throws VCIException {
        DeptObject[] fetchDepartmentInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfo();
        if(fetchDepartmentInfo == null){
            return;
        }
        HashMap<String, String[]> depts = new HashMap<String,String[]>();
        for(DeptObject obj : fetchDepartmentInfo){
            depts.put(obj.getId(),new String[]{obj.getParentId(), obj.getName()});
            
        }
        Set<String> keySet = depts.keySet();
        Iterator<String> iterator = keySet.iterator();
        while(iterator.hasNext()){
            String key = iterator.next();
            String[] PidAndName = depts.get(key);
            LinkedList<String> nameList = new LinkedList<String>();
            nameList.add(PidAndName[1]);
            while(PidAndName[0]!=null && !PidAndName[0].equals("")){
                PidAndName = depts.get(PidAndName[0]);
                if(PidAndName == null) break;
                nameList.add(PidAndName[1]);
            }
            StringBuffer absoluteName = new StringBuffer();
            String[] arrayNames = nameList.toArray(new String[]{});
            for(int i = arrayNames.length-1 ; i >= 0 ; i-- ){
                if(i == arrayNames.length-1){
                    absoluteName.append(arrayNames[i]);
                }else{
                    absoluteName.append("/"+arrayNames[i]);
                }
            }
            
            ownerDialog.getAllDept().put(absoluteName.toString(), key);
        }
    }
 
    /**
     * 校验表单信息。
     * 
     * @param oneData
     * @param i
     * @param userId
     */
    private boolean validateExcelDatas(String[] oneData, int i, String userId) {
        boolean check = check(oneData,i);
        if(!check){
            return false;
        }
        try {
            EnumItem item = EnumClient.getService().getEmItemByName(ENUM_USERSECURITYENUM);
            EnumChild[] children = item.children;
            boolean isExist = true; 
            String flag = ConfigUtils.getConfigValue("exportSecretGrade");
            if (flag != null && flag.equalsIgnoreCase("true")) {
                for(EnumChild child: children){
                    if(child.value.equals(oneData[7])||child.name.equals(oneData[7])){
                        oneData[7] = child.value;
                        isExist = false;
                        break;
                    }
                }
            } else {
                isExist = false;
            }
            if (isExist) {
                VCIOptionPane.showMessageDialog(LogonApplication.frame, "传入的密级不符合规则!");
                return false;
            }
        } catch (VCIError e) {
            e.printStackTrace();
        }
        HashMap<String, String> departments = ownerDialog.getAllDept();
        if(oneData[6].trim()!=null && !oneData[6].trim().equals("")){
            String deptId = departments.get(oneData[6].trim());
            if ("".equals(deptId) || deptId == null) {
                VCIOptionPane.showMessageDialog(ownerDialog,
                        LocaleDisplay.getI18nString("第【"+i+"】行"+"的部门在系统中不存在!", "RMIPFramework", getLocale()));
                return false;
            }else{
                String[] deptIdAndUserId = new String[2];
                deptIdAndUserId[0] = userId;
                deptIdAndUserId[1] = deptId;
                deptAndUserRelation.add(deptIdAndUserId);
                return true;
            }
        }else return true;
    }
 
    /**
     * 导入表单数据
     * @throws VCIException 
     */
    private boolean importExcelData() throws VCIError {
        boolean b = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).batchSaveUsers(fileDatas.toArray(new UserObject[]{}),deptAndUserRelation.toArray(new String[][]{}));
        return b;
    }
 
    /**
     * 下载导入人员的excel模板。
     */
    public void downloadImportStuffTemplate() {
        String[] columns = new String[] { "账号", "密码", "姓名", "电子邮箱", "专业", "描述", "部门(上下级部门之间以反斜杠隔开(/))"};// 设置表单列名
        //获取是否导出密级配置项
        String flag = ConfigUtils.getConfigValue("exportSecretGrade");
        if (flag != null && flag.equalsIgnoreCase("true")) {
            columns = new String[] { "账号", "密码", "姓名", "电子邮箱", "专业", "描述", "部门(上下级部门之间以反斜杠隔开(/))" ,"密级"};
        }
        ColumnNameisRed.clear();
        ColumnNameisRed.add(0);
        ColumnNameisRed.add(1);
        ColumnNameisRed.add(2);
        final boolean[] ress = new boolean[1];
        String[][] datas = new String[1][columns.length];
        datas[0] = columns;
        ress[0] = exportExcel(datas, "人员模板");
        final QANProcessBarFrame frame = new QANProcessBarFrame();
    //    final QANProcessBarFrame frame = null;
        final QANProcessBar[] bar = new QANProcessBar[1];
        bar[0] = new QANProcessBar(new Thread() {
            public void run() {
                try {
                    frame.setContent("正在导出Excel文件,请稍等......");
//                    String[][] datas = new String[1][columns.length];
//                    datas[0] = columns;
//                    ress[0] = exportExcel(datas, "人员模板");                    
                } finally {
                    frame.setProcessBarCancel(true);
                }
            }
        }, frame, frame, "人员模板导出", false);
        bar[0].setVisible(true);
        if (ress[0]) {
            VCIOptionPane.showMessageDialog(LogonApplication.frame, "导出成功!");
        }
 
    }
 
    /**
     * 获取选中的文件
     * 
     * @return
     * @autor caicong
     * @data 2014-3-12
     */
    @SuppressWarnings({ "deprecation", "unused" })
    private LinkedList<File> getSelectedFiles() {
        LinkedList<File> selectedFiles = ownerDialog.tablePanel
                .getSelectedRowObjects();
        return selectedFiles;
    }
 
    /**
     * 获取表单数据
     * 
     * @param f
     * @return
     * @throws IOException
     * @throws VCIError
     * @autor caicong
     * @data 2014-3-11
     */
    private List<SheetDataSet> getFileList(File f) throws VCIError, IOException {
        // 获取流
        BufferedInputStream fileInputStream = new BufferedInputStream(
                new FileInputStream(f));
        String name = f.getName();
        // 获取表list
        List<SheetDataSet> sheetDataSets = ExcelDocumentUtils
                .readExcelDocument(name, fileInputStream);
        return sheetDataSets;
    }
 
    private void getFile() {
        File f = getRequiredFile(true);
        if (f == null)
            return;
        ArrayList<File> lists = ownerDialog.getLists();
        /** 判断导入的文件是否被使用的校验,如果文件已经打开,不允许导入 **/
        if (lists.contains(f)) {
            VCIOptionPane.showMessageDialog(LogonApplication.frame,
                    "文件重复,请重新选择!");
            return;
        }
        // 将文件保存到table中
        lists.add(f);
        ownerDialog.tablePanel.refreshTableData();
    }
 
    private File getRequiredFile(boolean isRead) {
        File files = getExcelFile();
        // add by xchao 2014.04.15 begin
        // 有错误数据要输出时,必须选择有效的excel文件
        while (files == null) {
            return null;
        }
        String fileName = files.getAbsolutePath();
        // 需要写入时,必须选择一个有效的、可以写入的文件
        if (!isRead) {
            // 如果文件被打开着,则必须选择其它的未打开着的文件
            while (files.exists() && !files.renameTo(new File(fileName))) {
                VCIJOptionPane.showMessageDialog(null,
                        "另一个程序正在使用此文件,进程无法访问,请重新选择!");
                // 重新选择文件时,也必须选择有效的excel文件
                files = null;
                while (files == null) {
                    files = getExcelFile();
                    while (files == null) {
                        return null;
                    }
                }
                fileName = files.getAbsolutePath();
            }
        }
        return files;
    }
 
    public String[] getExcel() {
        return null;
    }
 
    private boolean exportExcel(String[][] datas, String sheetName) {
        File file = getRequiredFile(false);
        if (file == null) {
            return false;
        }
        String fileName = file.getAbsolutePath();
        // add by xchao 2014.05.15 end
        new ExcelFileOperation().writeExcelFileInfo(fileName, sheetName, datas,
            new ExcelCellStyleSettingCallback() {
                @Override
                public WorkboolStyleSetting doSetWorkbookStyle(
                        final Workbook workbook) {
                    WorkboolStyleSetting setting = new WorkboolStyleSetting() {
                        @Override
                        public LinkedHashMap<String, CellStyle> getStyleMap() {
                            LinkedHashMap<String, CellStyle> styleMap = new LinkedHashMap<String, CellStyle>();
                            org.apache.poi.ss.usermodel.CellStyle style = workbook.createCellStyle();
                            org.apache.poi.ss.usermodel.Font font = (org.apache.poi.ss.usermodel.Font) workbook.createFont();
                            font.setColor(HSSFFont.COLOR_RED);
                            style.setFont(font);
                            for (int column : ColumnNameisRed) {
                                styleMap.put("0*" + (column) + "", style);
                            }
                            return styleMap;
                        }
                    };
                    return setting;
                }
            });
        return true;
    }
 
    private File getExcelFile() {
        File file = null;
        String filePath = VCISwingUtil.getExcelFileURL(ownerDialog, true, "");
        if (filePath != null) {
            file = new File(filePath);
        }
        return file;
    }
    @SuppressWarnings("static-access")
    private boolean check(String[] oneData, int i){
        
        String userName = oneData[0]; 
        String pwd = oneData[1];
        String trueName = oneData[2];
        String email = oneData[3];
        String desc = oneData[4];
//        String companyId = panel.getCompanyId();
        if(new RightControlUtil().isAdminOrDeveloperOrRoot(userName)){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.usernameerror1", "RMIPFramework", getLocale()));
            return false;
        }
        if("".equals(userName)){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.usernameerror2", "RMIPFramework", getLocale()));
            return false;
        }
        if("".equals(pwd)){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.pwderror1", "RMIPFramework", getLocale()));
            return false;
        }
        if (userName.getBytes().length > 128){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.usernameerror3", "RMIPFramework", getLocale()));
            return false;
        }
        if (pwd.getBytes().length > 128){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.pwderror3", "RMIPFramework", getLocale()));
            return false;
        }
        if (trueName.getBytes().length > 64){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.firstnameerror", "RMIPFramework", getLocale()));
            return false;
        }
        if (email.getBytes().length > 128){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第"+i+"行"+"rmip.stafforg.operate.emailerror", "RMIPFramework", getLocale()));
            return false;
        }
        if (desc.getBytes().length > 255 ){
            VCIOptionPane.showMessageDialog(ownerDialog,
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.descerror", "RMIPFramework", getLocale()));
            return false;
        }
        
        String regEx = "^[A-Za-z0-9_]+$";
        if (!TransmitMethod.checkCharacter(userName, regEx)) {
            VCIOptionPane.showMessageDialog(ownerDialog, 
                    LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.usernameerror4", "RMIPFramework", getLocale()));
            return false;
        }
        if(trueName.equals("")){
                VCIOptionPane.showMessageDialog(ownerDialog,
                        LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.firstnameerror1", "RMIPFramework", getLocale()));
                return false;
        }
        
        if (!email.equals("")){
            regEx = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
            if (!TransmitMethod.checkCharacter(email, regEx)) {
                VCIOptionPane.showMessageDialog(ownerDialog, 
                        LocaleDisplay.getI18nString("第【"+i+"】行"+"rmip.stafforg.operate.emailerror1", "RMIPFramework", getLocale()));
                return false;
            }
        }
 
        boolean rs = checkName(userName,i);
        if (!rs) {
            return rs;
        }
        return true;
    }
    /***
     *  看用户名是否重复
     * @param name 用户名
     * @return
     */
    private boolean checkName(String name,int line) {
        UserObject[] userInfo = null;
        try {
            userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfo();
        
        int size = userInfo.length;
        for(int i = 0; i < size; i++){
            if (name.equals(userInfo[i].getUserName())) {
                VCIOptionPane.showMessageDialog(ownerDialog,
                        "第【"+line+"】行用户名在系统中已经存在,请修改!");
                return false;
            }
        }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
            return false;
        }
        return true;
    }
}