fuliqi
2024-08-29 4163c93761115c7524ef74a557a1f5e01eafb429
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
package com.ycl.api.YS.playback.play;
 
import com.ycl.api.YS.NetDemo;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_MONTH_INFO_S;
import com.ycl.api.YS.lib.NetDEVSDKLib.NETDEV_MONTH_STATUS_S;
 
import javax.swing.*;
import java.util.Vector;
 
/**
 * 
 * @introduction Monthly Record
 * @description Support NVR
 */
public class QueryPlayBackRecordByMonth {
    
    /**
     * 
     * @introduction Query the records for each month in a year 
     * @description  Calling the interface of NETDEV_QuickSearch
     *
     */
    public static void queryPlayBackRecordByMonth() {
        NetDemo.RecordByMonthTableModel.setRowCount(0);
        if(null == NetDemo.lpUserID){
            JOptionPane.showMessageDialog(null, "Please Login device first. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }
        if(NetDemo.ChannelID == 0){
            JOptionPane.showMessageDialog(null, "Please select an online channel after login.");
            return;
        }
        
        NETDEV_MONTH_INFO_S pstMonthInfo=new NETDEV_MONTH_INFO_S();
        NETDEV_MONTH_STATUS_S pstMonthStatus=new NETDEV_MONTH_STATUS_S();
        int Month=1;
        switch (NetDemo.jComboBoxPlayRecordMonth.getItemAt(NetDemo.jComboBoxPlayRecordMonth.getSelectedIndex())) {
        case "January":
            Month = 1;
            break;
        case "February":
            Month = 2;
            break;
        case "March":
            Month = 3;
            break;
        case "April":
            Month = 4;
            break;
        case "May":
            Month = 5;
            break;
        case "June":
            Month = 6;
            break;
        case "July":
            Month = 7;
            break;
        case "August":
            Month = 8;
            break;
        case "September":
            Month = 9;
            break;
        case "October":
            Month = 10;
            break;
        case "November":
            Month = 11;
            break;
        case "December":
            Month = 12;
            break;
        default: 
            break;
        }
        
        String year=NetDemo.jTextFieldPlayBackRecordByMonthISYear.getText();
        int getYear=2020;
        if(year==null || year.equals("")) {
            JOptionPane.showMessageDialog(null, "Year is null");
            return;
        }    
        try {
            getYear=Integer.parseInt(year);
        }catch(Exception e) {
            JOptionPane.showMessageDialog(null, "Year transformation Exception");
            NetDemo.jTextFieldPlayBackRecordByMonthISYear.setText(null);
            return;
        }
        if(getYear<1970) {
            JOptionPane.showMessageDialog(null, "Year can not less than 1970");
            NetDemo.jTextFieldPlayBackRecordByMonthISYear.setText(null);
            return;
        }
                
        pstMonthInfo.udwYear=getYear;
        pstMonthInfo.udwMonth=Month;
        pstMonthInfo.write();
        boolean bRet = NetDemo.netdevsdk.NETDEV_QuickSearch(NetDemo.lpUserID,NetDemo.ChannelID,pstMonthInfo,pstMonthStatus);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "Get record failed. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            NetDemo.RecordByMonthTableModel.setRowCount(0);
            System.out.printf("NETDEV_QuickSearch failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }else {
            pstMonthStatus.read();
            for(int i=0;i<pstMonthStatus.udwDayNumInMonth;i++) {
                Vector<Object> data=new Vector<>();
                data.add(getYear);
                data.add(Month);
                data.add(i+1);
                String type=null;
                if(pstMonthStatus.szVideoStatus[i]==0) {
                    type="No Video";
                }else if(pstMonthStatus.szVideoStatus[i]==1){
                    type="Event Video";
                }else if(pstMonthStatus.szVideoStatus[i]==2){
                    type="Ordinary Video";
                }
                data.add(type);
                NetDemo.RecordByMonthTableModel.insertRow(i, data);
            }
        }
    }
    
    /**
     * 
     * @introduction Change the month to refresh data
     * @description 
     *
     */
    public static void ComboxQueryPlayBackRecordByMonth() {
        NetDemo.RecordByMonthTableModel.setRowCount(0);
        
        if(null == NetDemo.lpUserID || NetDemo.ChannelID == 0){
            return;
        }
        
        NETDEV_MONTH_INFO_S pstMonthInfo=new NETDEV_MONTH_INFO_S();
        NETDEV_MONTH_STATUS_S pstMonthStatus=new NETDEV_MONTH_STATUS_S();
        int Month=1;
        switch (NetDemo.jComboBoxPlayRecordMonth.getItemAt(NetDemo.jComboBoxPlayRecordMonth.getSelectedIndex())) {
        case "January":
            Month = 1;
            break;
        case "February":
            Month = 2;
            break;
        case "March":
            Month = 3;
            break;
        case "April":
            Month = 4;
            break;
        case "May":
            Month = 5;
            break;
        case "June":
            Month = 6;
            break;
        case "July":
            Month = 7;
            break;
        case "August":
            Month = 8;
            break;
        case "September":
            Month = 9;
            break;
        case "October":
            Month = 10;
            break;
        case "November":
            Month = 11;
            break;
        case "December":
            Month = 12;
            break;
        default:
            break;
        }
        String year=NetDemo.jTextFieldPlayBackRecordByMonthISYear.getText();
        int getYear=2020;
        if(year==null||year.equals("")) {
            JOptionPane.showMessageDialog(null, "Year is null");
            return;
        }
 
        try {
            getYear=Integer.parseInt(year);
        }catch(Exception ee) {
            JOptionPane.showMessageDialog(null, "Year transformation exception");
            NetDemo.jTextFieldPlayBackRecordByMonthISYear.setText(null);
            return;
        }
             
        if(getYear<1970) {
            JOptionPane.showMessageDialog(null, "Year can not less than 1970");
            NetDemo.jTextFieldPlayBackRecordByMonthISYear.setText(null);
            return;
        }
        
        pstMonthInfo.udwYear=getYear;
        pstMonthInfo.udwMonth=Month;
        pstMonthInfo.write();
        boolean bRet = NetDemo.netdevsdk.NETDEV_QuickSearch(NetDemo.lpUserID,NetDemo.ChannelID,pstMonthInfo,pstMonthStatus);
        if(bRet != true)
        {
            JOptionPane.showMessageDialog(null, "Get record failed. error code"+NetDemo.netdevsdk.NETDEV_GetLastError());
            System.out.printf("NETDEV_GetDevConfig failed:%d\n", NetDemo.netdevsdk.NETDEV_GetLastError());
            return;
        }else {
            pstMonthStatus.read();
            for(int i=0;i<pstMonthStatus.udwDayNumInMonth;i++) {
                Vector<Object> data=new Vector<>();
                data.add(getYear);
                data.add(Month);
                data.add(i+1);
                String type=null;
                if(pstMonthStatus.szVideoStatus[i]==0) {
                    type="No Video";
                }else if(pstMonthStatus.szVideoStatus[i]==1){
                    type="Event Video";
                }else if(pstMonthStatus.szVideoStatus[i]==2){
                    type="Ordinary Video";
                }
                data.add(type);
                NetDemo.RecordByMonthTableModel.insertRow(i, data);
            }
        }
    }
}