| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- package rtx;
- public class RTXUtils {
- public static int addDept(String deptId, String DetpInfo, String DeptName, String ParentDeptId) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.addDept(deptId, DetpInfo, DeptName, ParentDeptId);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int addUser(String userName, String deptID, String chsName, String pwd) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.addUser(userName, deptID, chsName, pwd);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int deleteDept(String deptId, String type) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.deleteDept(deptId, type);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int deleteUser(String userName) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.deleteUser(userName);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int sendSms(String receiver, String sender, String smsInfo, int autoCut, int noTitle) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.sendSms(sender, receiver, smsInfo, autoCut, noTitle);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int sendNotify(String receivers, String title, String msg, String type, String delayTime) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.sendNotify(receivers, title, msg, type, delayTime);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int setUserDetailInfo(String userName, String ADDRESS, String AGE, String BIRTHDAY, String BLOODTYPE, String CITY, String COLLAGE, String CONSTELLATION, String COUNTRY, String FAX, String HOMEPAGE, String MEMO, String POSITION, String POSTCODE, String PROVINCE, String STREET, String PHONE, String MOBILE) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.setUserDetailInfo(userName, ADDRESS, AGE, BIRTHDAY, BLOODTYPE, CITY, COLLAGE, CONSTELLATION, COUNTRY, FAX, HOMEPAGE, MEMO, POSITION, POSTCODE, PROVINCE, STREET, PHONE, MOBILE);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int setUserSimpleInfo(String userName, String ChsName, String email, String gender, String mobile, String phone, String pwd) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.SetUserSimpleInfo(userName, ChsName, email, gender, mobile, phone, pwd);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int setUserSimpleInfoEx(String userName, String deptID, String ChsName, String email, String gender, String mobile, String phone, String pwd) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.SetUserSimpleInfoEx(userName, deptID, ChsName, email, gender, mobile, phone, pwd);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static int setDept(String deptId, String DetpInfo, String DeptName, String ParentDeptId) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.setDept(deptId, DetpInfo, DeptName, ParentDeptId);
- }
- RtxsvrapiObj.UnInit();
- return iRet;
- }
- public static boolean deptIsExist(String deptId) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.deptIsExist(deptId);
- }
- RtxsvrapiObj.UnInit();
- if (iRet == -5) {
- return true;
- } else {
- return false;
- }
- }
- public static boolean userIsExist(String username) {
- int iRet = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iRet = RtxsvrapiObj.userIsExist(username);
- }
- RtxsvrapiObj.UnInit();
- if (iRet == 0) {
- return true;
- } else {
- return false;
- }
- }
- public static String[] getChildDepts(String pdeptId) {
- String depts[] = null;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- depts = RtxsvrapiObj.getChildDepts(pdeptId);
- }
- RtxsvrapiObj.UnInit();
- return depts;
- }
- public static String getDeptName(String deptID) {
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- String DeptName = "";
- if (RtxsvrapiObj.Init()) {
- DeptName = RtxsvrapiObj.GetDeptName(deptID);
- }
- RtxsvrapiObj.UnInit();
- return DeptName;
- }
- public static String[] getDeptUsers(String deptId) {
- String users[] = null;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- users = RtxsvrapiObj.getDeptUsers(deptId);
- }
- RtxsvrapiObj.UnInit();
- return users;
- }
- public static String getSessionKey(String username) {
- String szKey = "";
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- szKey = RtxsvrapiObj.getSessionKey(username);
- }
- RtxsvrapiObj.UnInit();
- return szKey;
- }
- public static String uinToUserName(String uin) {
- String userName = null;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- userName = RtxsvrapiObj.UinToUserName(uin);
- }
- RtxsvrapiObj.UnInit();
- return userName;
- }
- public static String[][] getUserDetailInfo(String userName) {
- String[][] info = null;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- info = RtxsvrapiObj.GetUserDetailInfo(userName);
- }
- RtxsvrapiObj.UnInit();
- return info;
- }
- public static String[][] getUserSimpleInfo(String userName) {
- String[][] info = null;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- info = RtxsvrapiObj.GetUserSimpleInfo(userName);
- }
- RtxsvrapiObj.UnInit();
- return info;
- }
- public static int queryUserState(String userName) {
- int iState = -1;
- RTXSvrApi RtxsvrapiObj = new RTXSvrApi();
- if (RtxsvrapiObj.Init()) {
- iState = RtxsvrapiObj.QueryUserState(userName);
- switch (iState) {
- case 0:
- System.out.println("用户: " + userName + "状态为: " + "离线");
- break;
- case 1:
- System.out.println("用户: " + userName + "状态为: " + "在线");
- break;
- case 2:
- System.out.println("用户: " + userName + "状态为: " + "离开");
- break;
- case -984:
- System.out.println("用户: " + userName + "不存在");
- break;
- default:
- System.out.println("访问RTX服务器出错!");
- break;
- }
- }
- RtxsvrapiObj.UnInit();
- return iState;
- }
- }
|