⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfmactionfactory.java

📁 BPO作业管理系统DMP的插件
💻 JAVA
字号:
package com.cmspad.dmp.bundles.gfm;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.Map;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.DirectoryDialog;import org.eclipse.swt.widgets.Shell;import com.cmspad.dmp.DMPDatabase;import com.cmspad.dmp.DMPException;import com.cmspad.dmp.IActionFactory;import com.cmspad.dmp.util.DMPUtil;public class GFMActionFactory implements IActionFactory {	private Shell shell;		protected long uId;		public GFMActionFactory(Shell shell, long uid){		this.shell = shell;		this.uId = uid;	}		@Override	public void create(long pid, Map<String, Object> properties) {		try{			Connection conn = DMPDatabase.getConnection();			PreparedStatement stmt = conn.prepareStatement("INSERT INTO gfm_project(p_id,p_prog) VALUES(?,?)");			stmt.setLong(1, pid);			stmt.setString(2, (String)properties.get("prog"));			stmt.executeUpdate();			stmt.close();			conn.close();		}catch(SQLException e){			throw new DMPException("创建作业时出现数据库错误", e);		}	}	@Override	public void delete(long pid) {	// TODO Auto-generated method stub	}	@Override	public void export(long pid) {		DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);		dialog.setText("交付");		dialog.setMessage("请选择要导出交付数据的目录");		String path = dialog.open();		if (path != null) {			File dir = new File(path);			if (dir.exists() && dir.isDirectory()) {				try {					Connection conn = DMPDatabase.getConnection();					PreparedStatement stmt = conn.prepareStatement("SELECT pd_name,pd_data_4 FROM dmp_project_data WHERE p_id = ?");					stmt.setLong(1, pid);					ResultSet rs = stmt.executeQuery();					while (rs.next()) {						File file = new File(dir.getAbsolutePath() + File.separator + rs.getString(1));						InputStream is = rs.getBinaryStream(2);						if(is != null){							FileOutputStream os = new FileOutputStream(file);							byte[] cache = new byte[4096];							for (int i = is.read(cache); i != -1; i = is.read(cache)) {								os.write(cache, 0, i);							}							is.close();							os.close();						}					}					rs.close();					stmt.close();					conn.close();				} catch (SQLException e) {					throw new DMPException("导出作业时出现数据库错误", e);				} catch (IOException e) {					throw new DMPException("导出作业时出现文件读写错误", e);				}			}		}	}	@Override	public boolean preCreate(Map<String, Object> properties) {		if(!properties.containsKey("prog")){			DMPUtil.error("错误", "请选择可用的应用程序");			return false;		}		File progFile = new File((String)properties.get("prog"));		if(!progFile.exists()){			DMPUtil.error("错误", "应用程序不存在:\n\n" + progFile.getAbsolutePath());			return false;		}		return true;	}	@Override	public boolean preDelete(long pid) {		return true;	}	@Override	public boolean preExport(long pid) {		return true;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -