田源
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
package com.vci.client.framework.delegate;
 
import com.vci.client.ClientSession;
import com.vci.client.common.objects.LogObject;
import com.vci.client.common.objects.UserEntityObject;
import com.vci.client.framework.systemConfig.log.LogPeriodObject;
import com.vci.client.framework.systemConfig.log.SystemCfgObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.corba.common.VCIError;
import com.vci.corba.framework.data.LogInfo;
import com.vci.corba.framework.data.LogPeriodInfo;
 
 
/**
 * 日志管理clientdelegate
 * @author xiongfei
 *
 */
public class LogManagementClientDelegate extends ClientBaseDelegate{
    
    public LogManagementClientDelegate(UserEntityObject userEntityObject) {
        super(userEntityObject);
    }
    
    /**
     * 获取日志删除配置,
     * @return true 自动,false 手动
     * @throws VCIError
     */
    public boolean getIsAutoDelete() throws VCIError {
        boolean res = false;
        res = ClientSession.getFrameworkService().getIsAutoDelete();
        return res;
    }
    
    /**
     * 获取日志信息
     * @return
     * @throws VCIError
     */
    public LogObject[] fetchLogInfo(int pageNo,int pageSize,String sql) throws VCIException {
        LogObject[] objs = null;
        try {
            LogInfo[] logInfos = ClientSession.getFrameworkService().fetchLogInfo((long)pageNo,(long)pageSize,sql);
            objs = new LogObject[logInfos.length];
            for(int i = 0;i < logInfos.length;i++){
                objs[i] = this.changeLogInfoToLogObjcet(logInfos[i]);
            }
            
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return objs;
    }
    
    /**
     * 获取日志信息
     * @return
     * @throws VCIError
     */
    public LogObject[] getLogListByContion(int pageNo,int pageSize,String sql) throws VCIException {
        LogObject[] objs = null;
        try {
            LogInfo[] logInfos = ClientSession.getFrameworkService().getLogListByContion(pageNo,pageSize,sql);
            objs = new LogObject[logInfos.length];
            for(int i = 0;i < logInfos.length;i++){
                objs[i] = this.changeLogInfoToLogObjcet(logInfos[i]);
            }
            
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return objs;
    }
    
    /**
     * 取得日志条数
     * @return
     * @throws VCIError 
     */
    public long getSumLogRows(String sql) throws VCIException {
        long sumCount = 0;
        try {
            sumCount = ClientSession.getFrameworkService().getSumLogRows(sql);
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return sumCount;
    }
    
    /**
     * 获取保存期限下拉框的值
     * @return
     * @throws VCIError 
     */
    public LogPeriodObject[] getPeriods() throws VCIException {
        LogPeriodObject[] objs = null;
        try{
            LogPeriodInfo[] infos = null;
            infos = ClientSession.getFrameworkService().getPeriods();
            objs = new LogPeriodObject[infos.length];
            for(int i=0;i<infos.length;i++) {
                objs[i] = changePeriodInfoToObj(infos[i]);
            }
            
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return objs;
    }
 
    /**
     * 获取日志查询页面显示条数
     * @return 页面显示条数
     * @throws VCIError
     */
    public int getPageSize() throws VCIException {
        try {
            return (int)ClientSession.getFrameworkService().getPageSize();
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return 0;
    }
    
    /**
     * 获取当前期限设置
     * @param type 判断是保存还是备份期限
     * @return
     * @throws VCIError
     */
    public int getCurPeriod(String type) throws VCIException {
        try {
            return (int)ClientSession.getFrameworkService().getCurPeriod(type);
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return 0;
    }
    
    /**
     * 保存期限设置
     * @param systemCfgObject
     * @param userEntityObject
     * @return
     * @throws VCIError
     */
    public boolean savePeriod(SystemCfgObject systemCfgObject) throws VCIException {
        try {
            return ClientSession.getFrameworkService().savePeriod(new SystemCfgClientDelegate().changeSystemCfgObjectToSystemCfgInfo(systemCfgObject), UserEntityClientDelegate.changeUserEntityToInfo(userEntityObject));
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return false;
    }
    
    /**
     * 保存备份期限设置
     * @param systemCfgObject
     * @param userEntityObject
     * @return
     * @throws VCIError
     */
    public boolean saveBackupPeriod(SystemCfgObject systemCfgObject) throws VCIException {
        try {
            return ClientSession.getFrameworkService().savePeriod(new SystemCfgClientDelegate().changeSystemCfgObjectToSystemCfgInfo(systemCfgObject), UserEntityClientDelegate.changeUserEntityToInfo(userEntityObject));
        } catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return false;
    }
    
    public boolean deleteLog(String deleteDate) throws VCIException {
        try {
            return ClientSession.getFrameworkService().deleteLog(deleteDate);
        }catch(VCIError e) {
            this.convertVCIErrorToVCIException(e);
        }
        return false;
    }
    
    
    /**
     * period对象的转换
     * CORBA端对象转成客户端对象
     */
    private LogPeriodObject changePeriodInfoToObj(LogPeriodInfo info) {
        LogPeriodObject obj = new LogPeriodObject();
        obj.setCode(info.code);
        obj.setValue(info.value);
        return obj;
    }
    
    /**
     * Log对象的转换
     * CORBA端对象转成客户端对象
     * @param info
     * @return
     */
    private LogObject changeLogInfoToLogObjcet(LogInfo info) {
        LogObject obj = new LogObject();
        obj.setDate(info.date);
        obj.setPuid(info.puid);
        obj.setUsername(info.username);
        obj.setTruename(info.truename);
        obj.setUserIp(info.userIp);
        obj.setType(info.type);
        obj.setEntityDesc(info.entityDesc);
        obj.setProperty(info.property);
        obj.setPreviousVal(info.previousVal);
        obj.setNewVal(info.newVal);
        obj.setResult(info.result);
        obj.setModule(info.moduleName);
        return obj;
    }
    
}