📄 logon.java
字号:
/*
* Created on 2005-6-22
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package wsx.agile.com;
import java.util.HashMap;
import com.agile.api.*;
/**
* @author tmao
*/
public class Logon {
private final String USERNAME = "yvonnec";
private final String PASSWORD = "agile";
private AgileSessionFactory factory = null;
private IAgileSession session = null;
public String login2Server(String userName,String pwd) throws Exception {
String res=null;
try{
factory = AgileSessionFactory.getInstance(null);
HashMap map = new HashMap();
map.put(AgileSessionFactory.USERNAME, userName);
map.put(AgileSessionFactory.PASSWORD, pwd);
session = factory.createSession(null);
String uid=session.getCurrentUser().getName();
res=uid;
}catch(APIException e){
System.out.println(e.getMessage());
res=e.getMessage();
}
return res;
}///:~ init() Ends
public String loginNoPara() throws Exception{
String res=null;
try{
String SDK_url="http://localhost/Agile";
factory = AgileSessionFactory.getInstance(SDK_url); //: get the instance from the Remote Server
HashMap map = new HashMap();
map.put(AgileSessionFactory.USERNAME,USERNAME);
map.put(AgileSessionFactory.PASSWORD,PASSWORD);
System.out.println("...implicated session...");
this.session = factory.createSession(map);
String uid=session.getCurrentUser().getName();
// if(uid.equalsIgnoreCase(USERNAME))
res=uid;
}catch(APIException e){
System.out.println("Connect throws APIException : " + e.getErrorCode());
e.printStackTrace();
res=e.getMessage();
}
return res;
}
public String getECO(String userName,String pwd){
String res=null;
try{
factory = AgileSessionFactory.getInstance(null);
HashMap map = new HashMap();
map.put(AgileSessionFactory.USERNAME, userName);
map.put(AgileSessionFactory.PASSWORD, pwd);
session = factory.createSession(null);
res=getECO(session);
}catch(APIException e){
res=e.getMessage();
}
return res;
}
private String getECO(IAgileSession m_session){
String name=null;
try{
IAgileClass ecoClass = m_session.getAdminInstance().getAgileClass(ChangeConstants.CLASS_ECO);
IAutoNumber[] ecoAutoNumbers = ecoClass.getAutoNumberSources();
IAutoNumber ecoAutoNumber = ecoAutoNumbers[0];
String ecoNumber = ecoAutoNumber.getNextNumber();
IChange eco = (IChange)m_session.createObject(ecoClass, ecoNumber);
name= eco.getName();
}catch(APIException ae){
name=ae.getMessage();
}
return "ECO NAME IS:"+name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -