【Java开源代码栏目提醒】:以下是网学会员为您推荐的Java开源代码-TicketGetAction.java,希望本篇文章对您学习有所帮助。
package atbs.view;
import java.util.*;
import javax.naming.Context;
import javax.naming.NamingException;
import atbs.entity.*;
import atbs.session.*;
public class TicketGetAction {
private Context ctx;
private TicketSessionRemote ticketSession;
private UserLogSessionRemote userLogSession;
private List<Ticket> ticketList;
private String userName;
private String userError;
public TicketGetAction() {
try {
ctx = RemoteContext.getContextInstance();
} catch (NamingException ex) {
ex.printStackTrace();
}
try {
ticketSession = (TicketSessionRemote) ctx.lookup("atbs/TicketSession/remote");
userLogSession = (UserLogSessionRemote) ctx.lookup("atbs/UserLogSession/remote");
} catch (NamingException ex1) {
ex1.printStackTrace();
}
}
public String findPayTicket(){
this.ticketList = ticketSession.getTicketByUserName(userName, Ticket.Ticket_STATUS_PAYMENT);
if(ticketList==null||ticketList.isEmpty()){
this.userError = "You userName is error,or you have not pay any ticket...";
}
return null;
}
public String handOutTicket(){
System.out.println(userName);
this.ticketList = ticketSession.getTicketByUserName(userName, Ticket.Ticket_STATUS_PAYMENT);
if(ticketList==null||ticketList.isEmpty()){
return null;
}
if(this.ticketSession.saleManyTicket(ticketList)){
SysUser user = ticketList.get(0).getCustomer();
Map<String,String> map = new HashMap<String,String>();
map.put("address", user.getEmail());
map.put("subject", "TicketEasy:You get all booked tickets Success");
StringBuffer content = new StringBuffer();
content.append("Welcome to TicketEasy,Access TicketEasy ,you can expediently cancell ticket you want.\r\n");
content.append("You :Get Tickets\r\n");
for(Ticket ticket:ticketList){
content.append("id:");
content.append(ticket.getId());
content.append(",value:");
content.append(ticket.getValue());
content.append(",airplane:");
content.append(ticket.getAirplane().getId());
content.append(",fly Time");
content.append(ticket.getAirplane().getStartTime().toString());
content.append("\r\n");
}
content.append("------------------------------------------TicketEasy");
map.put("content", content.toString());
RemoteContext.sendEmail(map);
UserLog userLog = new UserLog();
userLog.setTitle(UserLog.Get_TICKET);
userLog.setCustomer(user);
userLog.setContent(content.toString());
this.userLogSession.addUserLog(userLog);
this.ticketList = null;
}
return null;
}
public List<Ticket> getTicketList() {
return ticketList;
}
public void setTicketList(List<Ticket> ticketList) {
this.ticketList = ticketList;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserError() {
return userError;
}
public void setUserError(String userError) {
this.userError = userError;
}
}