dengzedong
2024-12-19 85b2001c0ec2f1adc598db3bf47ad457dcca7074
提交 | 用户 | 时间
149dd0 1 package com.iailab.netsdk.demo.frame.vto;
H 2
3 import com.sun.jna.Memory;
4 import com.sun.jna.Pointer;
5
6 import com.iailab.netsdk.common.Base64;
7 import com.iailab.netsdk.common.PaintPanel;
8 import com.iailab.netsdk.common.Res;
9 import com.iailab.netsdk.demo.module.LoginModule;
10 import com.iailab.netsdk.lib.NetSDKLib;
11 import com.iailab.netsdk.lib.ToolKits;
12
13 import java.awt.BorderLayout;
14 import java.awt.Color;
15 import java.awt.FlowLayout;
16 import java.awt.event.*;
17 import java.io.IOException;
18
19 import javax.swing.*;
20 import javax.swing.border.EmptyBorder;
21 import javax.swing.border.TitledBorder;
22 import javax.swing.event.ChangeEvent;
23 import javax.swing.event.ChangeListener;
24
7412dd 25 import static com.iailab.netsdk.lib.NetSDKLib.CtrlType.*;
149dd0 26
H 27 public class OperateInfo extends JDialog {
28
29     private final JPanel contentPanel = new JPanel();
30     private JTextField cardNoTextField;
31     private JTextField roomNoTextField;
32     private CollectionFingerPrint fingerPrint = new CollectionFingerPrint();
33     private PaintPanel paintPanel;
34     private Memory memory;
35     private JCheckBox needFingerCheckBox;
36
37     private boolean bListen = false;
38     /**
39      * 窗口使用的类型:
40      * 0:新增卡信息
41      * 1:修改卡信息
42      */
43     private int infoType;
44     private String userId;
45     private String cardNo;
46     private String fingerPrintData;
47
48     public void setCardNoTextFieldEditEnable(boolean enable) {
49         this.cardNoTextField.setEditable(enable);
50     }
51     public void setRoomNoTextFieldEditEnable(boolean enable){
52         this.roomNoTextField.setEditable(enable);
53     }
54     public void syncData(String userId, String cardNo, String fingerPrintData) {
55         this.userId = userId;
56         this.cardNo = cardNo;
57         this.fingerPrintData = fingerPrintData;
58         if (fingerPrintData == null || fingerPrintData.trim().equals("")) {
59             needFingerCheckBox.setSelected(false);
60         } else {
61             needFingerCheckBox.setSelected(true);
62         }
63         cardNoTextField.setText(cardNo);
64         roomNoTextField.setText(userId);
65
66     }
67
68     public int getInfoType() {
69         return infoType;
70     }
71
72     public void setInfoType(int infoType) {
73         this.infoType = infoType;
74     }
75
76     public void receiveData(int infoType, String userId, String cardNo, String fingerPrintData) {
77         this.infoType = infoType;
78         //新增卡
79         if (infoType == 0) {
80             this.userId = "";
81             this.cardNo = "";
82             this.fingerPrintData = "";
83         } else if (infoType == 1) {
84             //修改卡
85             this.userId = userId;
86             this.cardNo = cardNo;
87             this.fingerPrintData = fingerPrintData;
88         }
89         this.cardNoTextField.setText(this.cardNo);
90         this.roomNoTextField.setText(this.userId);
91         if (!this.fingerPrintData.trim().equals("")) {
92             needFingerCheckBox.setSelected(true);
93         } else {
94             needFingerCheckBox.setSelected(false);
95         }
96     }
97
98     /**
99      * Launch the application.
100      */
101     public static void main(String[] args) {
102         try {
103             OperateInfo dialog = new OperateInfo();
104             dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
105             dialog.setVisible(true);
106         } catch (Exception e) {
107             e.printStackTrace();
108         }
109     }
110
111     /**
112      * Create the dialog.
113      */
114     public OperateInfo() {
115         setTitle(Res.string().getVTOOperateInfoTitle());
116         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
117         try {
118             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
119         } catch (ClassNotFoundException e) {
120             e.printStackTrace();
121         } catch (InstantiationException e) {
122             e.printStackTrace();
123         } catch (IllegalAccessException e) {
124             e.printStackTrace();
125         } catch (UnsupportedLookAndFeelException e) {
126             e.printStackTrace();
127         }
128         setBounds(100, 100, 476, 294);
129         getContentPane().setLayout(new BorderLayout());
130         contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
131         getContentPane().add(contentPanel, BorderLayout.CENTER);
132         contentPanel.setLayout(null);
133         {
134             JPanel panel = new JPanel();
135             panel.setBorder(new TitledBorder(null, Res.string().getCardInfo(), TitledBorder.LEFT, TitledBorder.TOP,
136                     null, null));
137             panel.setBounds(0, 0, 285, 87);
138             contentPanel.add(panel);
139             panel.setLayout(null);
140             {
141                 JLabel lblNewLabel = new JLabel(Res.string().getCardNo());
142                 lblNewLabel.setBounds(10, 22, 89, 15);
143                 panel.add(lblNewLabel);
144             }
145             {
146                 cardNoTextField = new JTextField();
147                 cardNoTextField.setBounds(111, 19, 164, 21);
148                 panel.add(cardNoTextField);
149                 cardNoTextField.setColumns(10);
150             }
151             {
152                 JLabel lblNewLabel_1 = new JLabel(Res.string().getVTOOperateManagerRoomNo());
153                 lblNewLabel_1.setBounds(10, 62, 96, 15);
154                 panel.add(lblNewLabel_1);
155             }
156             {
157                 roomNoTextField = new JTextField();
158                 roomNoTextField.setColumns(10);
159                 roomNoTextField.setBounds(111, 59, 164, 21);
160                 panel.add(roomNoTextField);
161             }
162         }
163
164         needFingerCheckBox = new JCheckBox(Res.string().getNeedFingerPrint());
165         needFingerCheckBox.setSelected(true);
166         needFingerCheckBox.setBounds(6, 106, 190, 23);
167         contentPanel.add(needFingerCheckBox);
168
169
170         JPanel panel = new JPanel();
171         panel.setBorder(new TitledBorder(null, Res.string().getFingerPrint(), TitledBorder.LEFT,
172                 TitledBorder.TOP, null, null));
173         panel.setBounds(0, 135, 285, 84);
174         contentPanel.add(panel);
175         panel.setLayout(null);
176
177         JLabel lblNewLabel_2 = new JLabel(Res.string().getFingerPrint());
178         lblNewLabel_2.setBounds(10, 35, 109, 28);
179         panel.add(lblNewLabel_2);
180
181         final JButton btnGetFinger = new JButton(Res.string().getGet());
182         btnGetFinger.setBounds(129, 38, 93, 23);
183         panel.add(btnGetFinger);
184         btnGetFinger.addMouseListener(new MouseAdapter() {
185             @Override
186             public void mouseClicked(MouseEvent e) {
187                 super.mouseClicked(e);
188                 if (fingerPrint == null) {
189                     fingerPrint = new CollectionFingerPrint();
190                     fingerPrint.setVisible(true);
191                     fingerPrint.setFocusable(true);
192                 } else {
193                     //清除信息数据
194                     fingerPrint.dispose();
195                     //显示信息对话框
196                     fingerPrint.setVisible(true);
197                 }
198             }
199         });
200         needFingerCheckBox.addChangeListener(new ChangeListener() {
201             @Override
202             public void stateChanged(ChangeEvent e) {
203                 //获取事件源
204                 JCheckBox checkBox = (JCheckBox) e.getSource();
205                 //选中
206                 if (checkBox.isSelected()) {
207                     btnGetFinger.setEnabled(true);
208                 } else {
209                     btnGetFinger.setEnabled(false);
210                 }
211             }
212         });
213
214         {
215             paintPanel = new PaintPanel();
216             paintPanel.setBackground(Color.GRAY);
217             paintPanel.setBorder(new TitledBorder(null, Res.string().getFaceInfo(), TitledBorder.LEADING,
218                     TitledBorder.TOP, null, null));
219             paintPanel.setBounds(295, 10, 155, 209);
220             contentPanel.add(paintPanel);
221             paintPanel.setLayout(null);
222             {
223                 JButton open = new JButton(Res.string().getOpen());
224                 open.setBounds(26, 90, 93, 23);
225                 paintPanel.add(open);
226                 // 选择图片,获取图片的信息
227                 open.addActionListener(new ActionListener() {
228                     @Override
229                     public void actionPerformed(ActionEvent arg0) {
230                         String picPath = "";
231
232                         // 选择图片,获取图片路径,并在界面显示
233                         picPath = ToolKits.openPictureFile(paintPanel);
234
235                         if (!picPath.equals("")) {
236                             try {
237                                 memory = ToolKits.readPictureFile(picPath);
238                             } catch (IOException e) {
239                                 // TODO Auto-generated catch block
240                                 e.printStackTrace();
241                             }
242                         }
243
244                     }
245                 });
246             }
247         }
248         {
249             JPanel buttonPane = new JPanel();
250             buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
251             getContentPane().add(buttonPane, BorderLayout.SOUTH);
252             {
253                 JButton okButton = new JButton("OK");
254                 okButton.setActionCommand("OK");
255                 buttonPane.add(okButton);
256                 getRootPane().setDefaultButton(okButton);
257                 okButton.addMouseListener(new MouseAdapter() {
258                     @Override
259                     public void mouseClicked(MouseEvent e) {
260                         super.mouseClicked(e);
261                         //获取到信息
262                         if (fingerPrint.isCollectionResult()) {
263                             fingerPrintData = Base64.getEncoder().encodeToString(fingerPrint.getPackageData()).trim();
264                         }
265                         if (infoType == 0) {
266                             //新增卡信息
267                             if (!checkCardNo(cardNoTextField.getText().trim().getBytes(), true)) {
268                                 //卡号已存在
269                                 return;
270                             }
271                             //添加失败,直接返回,不隐藏窗口
272                             if (!addCard(cardNoTextField.getText().trim().getBytes(), roomNoTextField.getText().getBytes(), needFingerCheckBox.isSelected() ? 1 : 0, fingerPrintData)) {
273                                 return;
274                             }
275
276                         } else if (infoType == 1) {
277                             //修改卡信息
278                             if (!checkCardNo(cardNoTextField.getText().trim().getBytes(), false)) {
279                                 //卡号不存在,不能修改
280                                 return;
281                             }
282                             //修改失败,则直接返回,不隐藏界面
283                             if (!modifyCard(cardNoTextField.getText().trim().getBytes(), roomNoTextField.getText().trim().getBytes(), needFingerCheckBox.isSelected() ? 1 : 0, fingerPrintData)) {
284                                 return;
285                             }
286                         }
287                         dispose();
288                     }
289                 });
290             }
291             {
292                 JButton cancelButton = new JButton("Cancel");
293                 cancelButton.setActionCommand("Cancel");
294                 buttonPane.add(cancelButton);
295                 cancelButton.addMouseListener(new MouseAdapter() {
296                     @Override
297                     public void mouseClicked(MouseEvent e) {
298                         super.mouseClicked(e);
299                         dispose();
300                     }
301                 });
302             }
303             addWindowListener(new WindowAdapter() {
304                 @Override
305                 public void windowClosed(WindowEvent e) {
306                     super.windowClosed(e);
307                     //清除信息状态
308                     if (fingerPrint.isCollectionResult()) {
309                         fingerPrint.clearStatus();
310                     }
311                 }
312             });
313         }
314     }
315
316     /**
317      * 检查下卡号是否存在
318      * true:不存在
319      * false:存在
320      *
321      * @param type true:卡存在即弹窗
322      * @return
323      */
324     public boolean checkCardNo(byte[] cardNo, boolean type) {
325         if (cardNo.length == 0) {
326             JOptionPane.showMessageDialog(null, Res.string().getInputCardNo(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
327             return false;
328         }
329
330         //check whether the card number already exists查询一下卡号是否已经存在
331         NetSDKLib.NET_IN_FIND_RECORD_PARAM inParam = new NetSDKLib.NET_IN_FIND_RECORD_PARAM();
332         inParam.emType = NetSDKLib.EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD;
333         //查询条件
334         NetSDKLib.FIND_RECORD_ACCESSCTLCARD_CONDITION condition = new NetSDKLib.FIND_RECORD_ACCESSCTLCARD_CONDITION();
335         //卡号查询有效
336         condition.abCardNo = 1;
337         if (cardNo.length > condition.szCardNo.length - 1) {
338             JOptionPane.showMessageDialog(null, Res.string().getCardNoExceedLength(), Res.string().getErrorMessage(),
339                     JOptionPane.ERROR_MESSAGE);
340             return false;
341         }
342         System.arraycopy(cardNo, 0, condition.szCardNo, 0, cardNo.length);
343         inParam.pQueryCondition = new Memory(condition.size());
344         ToolKits.SetStructDataToPointer(condition, inParam.pQueryCondition, 0);
345         NetSDKLib.NET_OUT_FIND_RECORD_PARAM outParam = new NetSDKLib.NET_OUT_FIND_RECORD_PARAM();
346         boolean startFind = LoginModule.netsdk.CLIENT_FindRecord(LoginModule.m_hLoginHandle, inParam, outParam, 5000);
347         if (!startFind) {
348             JOptionPane.showMessageDialog(null, Res.string().getQueryCardExistFailed(), Res.string().getErrorMessage(),
349                     JOptionPane.ERROR_MESSAGE);
350             return false;
351         }
352         //查询卡号是否已存在
353         int max = 1;
354         NetSDKLib.NET_IN_FIND_NEXT_RECORD_PARAM inNextParam = new NetSDKLib.NET_IN_FIND_NEXT_RECORD_PARAM();
355         inNextParam.lFindeHandle = outParam.lFindeHandle;
356         inNextParam.nFileCount = max;
357         NetSDKLib.NET_OUT_FIND_NEXT_RECORD_PARAM outNextParam = new NetSDKLib.NET_OUT_FIND_NEXT_RECORD_PARAM();
358         outNextParam.nMaxRecordNum = max;
359         NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD[] card = new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD[1];
360         card[0] = new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD();
361         outNextParam.pRecordList = new Memory(card[0].size() * max);
362         ToolKits.SetStructArrToPointerData(card, outNextParam.pRecordList);
363         LoginModule.netsdk.CLIENT_FindNextRecord(inNextParam, outNextParam, 5000);
364         if (outNextParam.nRetRecordNum != 0 && type) {
365             //卡号已存在
366             JOptionPane.showMessageDialog(null, Res.string().getFindCardExist(), Res.string().getErrorMessage(),
367                     JOptionPane.ERROR_MESSAGE);
368             //停止查询
369             LoginModule.netsdk.CLIENT_FindRecordClose(outParam.lFindeHandle);
370             return false;
371         }
372         //停止查询
373         LoginModule.netsdk.CLIENT_FindRecordClose(outParam.lFindeHandle);
374         return true;
375     }
376
377     /**
378      * 新增卡
379      */
380     public boolean addCard(byte[] cardNo, byte[] userID, int enableFinger, String fingerPrintData) {
381         if (cardNo.length == 0) {
382             JOptionPane.showMessageDialog(null, Res.string().getInputCardNo(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
383             return false;
384         }
385         if (userID.length == 0) {
386             JOptionPane.showMessageDialog(null, Res.string().getInputRoomNo(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
387             return false;
388         }
389         if (memory == null) {
390             JOptionPane.showMessageDialog(null, Res.string().getChooseFacePic(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
391             return false;
392         }
393         NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD card = new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD();
394         if (cardNo.length > card.szCardNo.length - 1) {
395             JOptionPane.showMessageDialog(null, Res.string().getCardNoExceedLength(), Res.string().getErrorMessage(),
396                     JOptionPane.ERROR_MESSAGE);
397             return false;
398         }
399         if (userID.length > card.szUserID.length - 1) {
400             JOptionPane.showMessageDialog(null, Res.string().getRoomNoExceedLength(), Res.string().getErrorMessage(),
401                     JOptionPane.ERROR_MESSAGE);
402             return false;
403         }
404         System.arraycopy(cardNo, 0, card.szCardNo, 0, cardNo.length);
405         System.arraycopy(userID, 0, card.szUserID, 0, userID.length);
406
407         card.nDoorNum = 1;
408         card.sznDoors[0] = 0;
409         if (enableFinger == 1) {
410             //信息不存在
411             if (fingerPrintData == null || fingerPrintData.trim().equals("")) {
412                 JOptionPane.showMessageDialog(null, Res.string().getFingerPrintIdNotExist(), Res.string().getErrorMessage(),
413                         JOptionPane.ERROR_MESSAGE);
414                 return false;
415             }
416             //base64 string to bytes
417             byte[] bytes = Base64.getDecoder().decode(fingerPrintData);
418             //增加信息
419             card.bEnableExtended = 1;
420             card.stuFingerPrintInfoEx.nCount = 1;
421             card.stuFingerPrintInfoEx.nLength = bytes.length;
422             card.stuFingerPrintInfoEx.nPacketLen = bytes.length;
423             card.stuFingerPrintInfoEx.pPacketData = new Memory(bytes.length);
424             card.stuFingerPrintInfoEx.pPacketData.clear(bytes.length);
425
426             card.stuFingerPrintInfoEx.pPacketData.write(0, bytes, 0, bytes.length);
427         } else {
428             card.bEnableExtended = 0;
429         }
430
431         NetSDKLib.NET_CTRL_RECORDSET_INSERT_PARAM inParam = new NetSDKLib.NET_CTRL_RECORDSET_INSERT_PARAM();
432         inParam.stuCtrlRecordSetInfo.emType = NetSDKLib.EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD;
433         inParam.stuCtrlRecordSetInfo.nBufLen = card.size();
434         inParam.stuCtrlRecordSetInfo.pBuf = new Memory(card.size());
435         ToolKits.SetStructDataToPointer(card, inParam.stuCtrlRecordSetInfo.pBuf, 0);
436         Pointer pointer = new Memory(inParam.size());
437         ToolKits.SetStructDataToPointer(inParam, pointer, 0);
438         // 插入信息必须用  CTRLTYPE_CTRL_RECORDSET_INSERTEX,不能用 CTRLTYPE_CTRL_RECORDSET_INSERT
439         boolean res = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, CTRLTYPE_CTRL_RECORDSET_INSERTEX, pointer, 5000);
440         if (!res) {
441             JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(),
442                     JOptionPane.ERROR_MESSAGE);
443             return res;
444         }
445         ToolKits.GetPointerData(pointer, inParam);
446
447         if (memory != null) {
448             //增加人脸图片
449             NetSDKLib.NET_IN_ADD_FACE_INFO inAddFaceInfo = new NetSDKLib.NET_IN_ADD_FACE_INFO();
450             System.arraycopy(userID, 0, inAddFaceInfo.szUserID, 0, userID.length);
451             inAddFaceInfo.stuFaceInfo.nFacePhoto = 1;
452             inAddFaceInfo.stuFaceInfo.nFacePhotoLen[0] = (int) memory.size();
453             inAddFaceInfo.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto = new Memory(memory.size());
454             inAddFaceInfo.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto.write(0, memory.getByteArray(0, (int) memory.size()), 0, (int) memory.size());
455             inAddFaceInfo.stuFaceInfo.nRoom = 1;
456             System.arraycopy(userID, 0, inAddFaceInfo.stuFaceInfo.szRoomNoArr[0].szRoomNo, 0, userID.length);
457
458             NetSDKLib.NET_OUT_ADD_FACE_INFO outAddFaceInfo = new NetSDKLib.NET_OUT_ADD_FACE_INFO();
459             Pointer outFaceParam = new Memory(outAddFaceInfo.size());
460             ToolKits.SetStructDataToPointer(outAddFaceInfo, outFaceParam, 0);
461             Pointer inFace = new Memory(inAddFaceInfo.size());
462             ToolKits.SetStructDataToPointer(inAddFaceInfo, inFace, 0);
463             boolean result = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, NetSDKLib.EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_ADD,
464                     inFace, outFaceParam, 10000);
465             if (!result) {
466                 JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(),
467                         JOptionPane.ERROR_MESSAGE);
468                 return false;
469             }
470         }
471         return true;
472
473     }
474
475     /**
476      * 修改卡信息
477      *
478      * @param cardNo 卡号
479      * @param userID 房间号
480      * @param enableFinger 是否使用信息
481      * @param fingerPrintData 信息数据,Base64编码字符串
482      */
483     public boolean modifyCard(byte[] cardNo, byte[] userID, int enableFinger, String fingerPrintData) {
484         //modify card
485         NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD card = new NetSDKLib.NET_RECORDSET_ACCESS_CTL_CARD();
486         NetSDKLib.NET_CTRL_RECORDSET_PARAM inParam = new NetSDKLib.NET_CTRL_RECORDSET_PARAM();
487         inParam.emType = NetSDKLib.EM_NET_RECORD_TYPE.NET_RECORD_ACCESSCTLCARD;
488         card.nDoorNum = 1;
489         card.sznDoors[0] = 0;
490         System.arraycopy(cardNo, 0, card.szCardNo, 0, cardNo.length);
491         System.arraycopy(userID, 0, card.szUserID, 0, userID.length);
492         if (enableFinger == 1) {
493             //信息不存在,输入信息
494             if (fingerPrintData == null || fingerPrintData.trim().equals("")) {
495                 JOptionPane.showMessageDialog(null, Res.string().getFingerPrintIdNotExist(), Res.string().getErrorMessage(),
496                         JOptionPane.ERROR_MESSAGE);
497                 return false;
498             }
499             byte[] data = Base64.getDecoder().decode(fingerPrintData);
500             //modify finger print
501             card.bEnableExtended = 1;
502             card.stuFingerPrintInfoEx.nCount = 1;
503             card.stuFingerPrintInfoEx.nLength = data.length;
504             card.stuFingerPrintInfoEx.nPacketLen = data.length;
505             card.stuFingerPrintInfoEx.pPacketData = new Memory(data.length);
506             card.stuFingerPrintInfoEx.pPacketData.clear(data.length);
507             card.stuFingerPrintInfoEx.pPacketData.write(0, data, 0, data.length);
508         } else {
509             card.bEnableExtended = 0;
510         }
511         inParam.pBuf = new Memory(card.size());
512         ToolKits.SetStructDataToPointer(card, inParam.pBuf, 0);
513
514         Pointer pointer = new Memory(inParam.size());
515         ToolKits.SetStructDataToPointer(inParam, pointer, 0);
516
517         boolean res = LoginModule.netsdk.CLIENT_ControlDevice(LoginModule.m_hLoginHandle, CTRLTYPE_CTRL_RECORDSET_UPDATEEX, pointer, 10000);
518         if (!res) {
519             JOptionPane.showMessageDialog(null, Res.string().getFailedModifyCard() + ", " + ToolKits.getErrorCodeShow(),
520                     Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
521             return res;
522         }
523         //modify face
524         if (memory != null) {
525             NetSDKLib.NET_IN_UPDATE_FACE_INFO inUpdateFaceInfo = new NetSDKLib.NET_IN_UPDATE_FACE_INFO();
526             System.arraycopy(userID, 0, inUpdateFaceInfo.szUserID, 0, userID.length);
527             inUpdateFaceInfo.stuFaceInfo.nFacePhoto = 1;
528             inUpdateFaceInfo.stuFaceInfo.nFacePhotoLen[0] = (int) memory.size();
529             //inUpdateFaceInfo.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto=memory;
530             inUpdateFaceInfo.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto = new Memory(memory.size());
531             inUpdateFaceInfo.stuFaceInfo.pszFacePhotoArr[0].pszFacePhoto.write(0, memory.getByteArray(0, (int) memory.size()), 0, (int) memory.size());
532             inUpdateFaceInfo.stuFaceInfo.nRoom = 1;
533             System.arraycopy(userID, 0, inUpdateFaceInfo.stuFaceInfo.szRoomNoArr[0].szRoomNo, 0, userID.length);
534
535             NetSDKLib.NET_OUT_UPDATE_FACE_INFO outUpdateFaceInfo = new NetSDKLib.NET_OUT_UPDATE_FACE_INFO();
536             Pointer inUpdateParam = new Memory(inUpdateFaceInfo.size());
537             ToolKits.SetStructDataToPointer(inUpdateFaceInfo, inUpdateParam, 0);
538             Pointer outUpdateParam = new Memory(outUpdateFaceInfo.size());
539             ToolKits.SetStructDataToPointer(outUpdateFaceInfo, outUpdateParam, 0);
540             boolean result = LoginModule.netsdk.CLIENT_FaceInfoOpreate(LoginModule.m_hLoginHandle, NetSDKLib.EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE, inUpdateParam, outUpdateParam, 5000);
541             if (!result) {
542                 JOptionPane.showMessageDialog(null, Res.string().getFailedModifyCard() +","+ ToolKits.getErrorCodeShow(),
543                         Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE);
544                 return result;
545             }
546         }
547         return true;
548     }
549
550     /**
551      * 清除人脸图片
552      */
553     public void clearImage() {
554         paintPanel.setOpaque(false);
555         paintPanel.setImage(null);
556         paintPanel.repaint();
557         memory = null;
558     }
559 }