📄 observerusrmgr.java
字号:
package Wearnes;
/**
*
* @author dongliang.guo
*/
public class ObserverUsrMgr implements ObserverOfRequest{
/** Creates a new instance of ITReceivedObserver */
ITRequest request;
ObserverProfile observerProfile;
public ObserverUsrMgr(ITRequest r,ObserverProfile profile) {
request=r;
observerProfile=profile;
request.attachObserver(this);
persistObserver(profile);
}
public void updateOnRequestStatusChange(String status)
{
String content="User:"+request.user_name()+"\r\n";
content=content+"Request Date:"+request.req_date()+"\r\n";
content=content+"Expected Completion Date:"+request.expected_completion_date()+"\r\n";
content=content+"Category:"+request.category()+"\r\n";
content=content+"Item:"+request.item()+"\r\n";
content=content+"Description:"+request.description()+"\r\n";
content=content+"Business Impact:"+request.impact()+"\r\n\n";
java.util.Vector observersProfile=request.observersProfile();
String req_status=(String)(new RequestStatus()).get(request.process_status());
content=content+"Request Status:"+req_status+"\r\n\n";
for(int i=0;i<observersProfile.size();i++)
{
ObserverProfile observerProfile=(ObserverProfile)observersProfile.get(i);
content=content+"Name:"+observerProfile.observerName+"\r\n Approve Date:"+observerProfile.observerDate+"\r\n\n Approve Status:"+observerProfile.observerApprove+"\r\n\n";
}
String itAccountMgr="dongliang.guo";
/* if(request.category()!=null)
itAccountMgr=RequestCategory.getDefaultAccountManager(request.category());*/
String webHost=(new CommonUtility()).getWebHost();
String approveLink=webHost+"/itreq/approveRequest.jsp?req_id="+(new Integer(request.req_id())).toString()+"&process_status=2&observerDate="+(new CommonUtility()).getCurrentDate()+"&observerName="+itAccountMgr+"&observerApprovement=Y";
String rejectLink=webHost+"/itreq/approveRequest.jsp?req_id="+(new Integer(request.req_id())).toString()+"&process_status=2&observerDate="+(new CommonUtility()).getCurrentDate()+"&observerName="+itAccountMgr+"&observerApprovement=N";
String loginApproveLink=webHost+"/itreq/requestToBeApprovedList.jsp?status=2";
//content=content+"If you approve this request, please click this link:\r"+approveLink+"\r\n\n";
// content=content+"If you reject this request, please click this link:\r"+rejectLink+"\r\n\n";
content=content+"If you login system to approve the request, please click this link:\r"+loginApproveLink+"\r\n";
if(status.equals(RequestStatus.USER_MANAGER_APPROVED)&&observerProfile.observerApprove.trim().equals("Y"))
{
SendMailBean.send(ITRequest.itServiceEmail, ITRequest.itServiceEmail, itAccountMgr+"@wearnes.com", "",
"IT Request",content, (new CommonUtility()).getEmailHost());
}
}
public void updateRequestDetail(String sql)
{
try
{
WearnesDB db=new WearnesDB();
db.update(sql);
}catch(Exception e)
{
}
}
public void persistObserver(ObserverProfile profile)
{
try{
String sql="insert into ObserverOfRequest(requestID,process_Status,observerName,observerDate,observerApprovement,observerComment) values("+profile.requestID+",'"+profile.process_status+"','"+profile.observerName+"','"+profile.observerDate+"','"+profile.observerApprove+"','"+profile.observerComment+"')";
String updatesql="update request set process_status='"+profile.process_status+"' where req_id="+profile.requestID;
WearnesDB db=WearnesDB.getInstance((new CommonUtility()).getConnectionURL());
db.insert(sql);
db.update(updatesql);
}catch(Exception e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -