package cn.myapps.runtime.notice;

import cn.myapps.authtime.common.dao.PersistenceUtils;
import cn.myapps.common.auth.IUser;
import cn.myapps.runtime.dynaform.document.model.IDocument;
import cn.myapps.runtime.workflow.notification.ejb.SendMode;
import cn.myapps.support.lanxin.service.LanxinService;

public class LanxinMode implements SendMode{

//	@Override
//	public boolean send(String subject, SummaryCfgVO summaryCfg, IDocument doc, IUser responsible) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(SummaryCfgVO summaryCfg, IDocument doc, IUser responsible) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, String content, IUser responsible) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String docid, String subject, String content, IUser responsible) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, String content, String receiver) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String docid, String subject, String content, String receiver) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, String content, IUser receiver, boolean mass) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, String content, String receiver, String replyPrompt, String code, boolean mass)
//			throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String docid, String subject, String content, String receiver, String replyPrompt, String code,
//			boolean mass) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, String content, String receiver, Map<String, String> defineReply, boolean mass)
//			throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String docid, String subject, String content, String receiver, Map<String, String> defineReply,
//			boolean mass) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String docid, String subject, String content, String receiver, boolean isNeedReply,
//			boolean mass) throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
//
//	@Override
//	public boolean send(String subject, SummaryCfgVO summaryCfg, IDocument doc, IUser responsible, boolean approval)
//			throws Exception {
//		throw new UnsupportedOperationException("method unsupport!");
//	}
	/**
	 * 发生消息
	 * @param title 标题
	 * @param discription 描述
	 * @param touser 接收用户账号
	 * @param doc 文档对象
	 * @param webUser 当前用户
	 * @return
	 * @throws Exception
	 */
//	public boolean send(final String title,final String description,final String flowTypeMessage,final String touser,final IDocument doc,final IUser webUser) throws Exception {
//		
//		new Thread(new Runnable() {
//			public void run() {
//				try {
//					LanxinService.send(title,description,flowTypeMessage,touser,doc,webUser);
//				} catch (Exception e) {
//					e.printStackTrace();
//				} finally {
//                	try {
//						PersistenceUtils.closeSessionAndConnection();
//					} catch (Exception e) {
//						e.printStackTrace();
//					}
//                }
//			}
//		}).start();
//		
//		return true;
//	}

	@Override
	public boolean send(String subject, int subjectType, String summary, IUser responsible, IDocument document,
			IUser webUser) {
		new Thread(new Runnable() {
			public void run() {
				try {
					LanxinService.send(subject,summary,responsible.getLoginno(),document,webUser);
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
                	try {
						PersistenceUtils.closeSessionAndConnection();
					} catch (Exception e) {
						e.printStackTrace();
					}
                }
			}
		}).start();
		
		return true;
	}
}
