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

📄 dynamicstaticpairaction.java

📁 EasyJF官网(www.easyjf.com)全站系统源码使用说明 全站源码是EasyJF开源团队站务组及核心成员共同开发及维护的系统
💻 JAVA
字号:
package com.easyjf.news.action;

import java.util.ArrayList;
import java.util.Collection;
import com.easyjf.dbo.EasyJDB;
import com.easyjf.news.business.ActiveUser;
import com.easyjf.news.business.AutoHtmlGenerater;
import com.easyjf.news.business.DynamicStaticPair;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
//import com.easyjf.web.Globals;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IPageList;

public class DynamicStaticPairAction extends BaseAction {	
	public Object doBefore(WebForm form, Module module) {		
		ActiveUser u=(ActiveUser)this.getCurrentUser(form);
		if(u==null)return new Page("popedomError","/nologin.htm","page");		
		return null;
	}
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) {				
		String scope="1=1";		
		Collection paras=new ArrayList();		
		DbPageList pList=new DbPageList(DynamicStaticPair.class,scope,paras);
		pList.doList(currentPage,pageSize);
		form.addResult("auto",AutoHtmlGenerater.getInstance());
		return pList;
	}
	public Object form2Obj(WebForm form) {
		String cid=CommUtil.null2String(form.get("cid"));
		DynamicStaticPair obj=null;
		if(cid.equals(""))
		{
			obj=(DynamicStaticPair)form.toPo(DynamicStaticPair.class);			
			//obj.setInputUser(this.getCurrentUser(form).getUserName());
			obj.setStatus(new Integer(0));
		}
		else
		{
			obj=DynamicStaticPair.read(cid);
			form.toPo(obj);
		}		
		return obj;
	}
	public Page doMulitDel(WebForm form, Module module) throws Exception {
		String MulitCid=CommUtil.null2String(form.get("mulitCid"));		
		boolean opSuccess=false;
		if(!MulitCid.equals("")){//执行批量删除
		String[] s=MulitCid.split(",");
		String scope="cid in('";
		for(int i=0;i<s.length;i++)
		{
			scope+=s[i]+"'"+(i==s.length-1?"":",'");
		}
		scope+=")";
		EasyJDB db=EasyJDB.getInstance();	
		if(db.execute("delete from DynamicStaticPair where "+scope)>0)opSuccess=true;
		if(!opSuccess)
			form.addResult("msg","删除数据失败!");
			else
			form.addResult("msg","删除数据成功!");		
		}				
		return super.doQuery(form,module,this.getCurrentUser(form));
	}	
	public Page doPublish(WebForm form, Module module) throws Exception {
		String MulitCid=CommUtil.null2String(form.get("mulitCid"));
		String msg="";
		int num=0;
		if(!MulitCid.equals("")){//执行批量发布
		String[] s=MulitCid.split(",");
		if(s!=null){
		for(int i=0;i<s.length;i++)
		{
			if(!"".equals(s[i]))
			{
				DynamicStaticPair dsp=DynamicStaticPair.read(s[i]);
				dsp.changeSiteRootpath("http://"+ActionContext.getContext().getRequest().getServerName()+":"+ActionContext.getContext().getRequest().getServerPort());
				 try{
						if(dsp.generater())num++;
						 }
						 catch(Exception e)
						 {
							 msg+="转换"+dsp.getDynamicUrl()+"出错了,请检测配置是否正确!\\r\\n错误信息:"+e;
						 }
				/*
				String dynamicUrl=dsp.getDynamicUrl();
				String staticUrl=dsp.getStaticUrl();				
				//String site=ActionContext.getContext().getRequest().getServerName()+	ActionContext.getContext().getRequest().getServerPort();
				if(dynamicUrl!=null && dynamicUrl.indexOf("http://")!=0)
				{
					dynamicUrl="http://"+ActionContext.getContext().getRequest().getServerName()+":"+ActionContext.getContext().getRequest().getServerPort()+(dynamicUrl.indexOf("/")==0?"":"/")+dynamicUrl;					
				}				
				if(dynamicUrl!=null && (!dynamicUrl.equals(""))&& (staticUrl!=null)&& (!staticUrl.equals("")))
				{
					 dynamicUrl+=(dynamicUrl.indexOf("?")>=0?"":"?")+"&publish=1";
					 try{
					if(HTMLGenerater.urlSaveTo(dynamicUrl,Globals.APP_BASE_DIR+staticUrl))num++;
					 }
					 catch(Exception e)
					 {
						 msg+="转换"+dynamicUrl+"出错了,请检测配置是否正确!\\r\\n错误信息:"+e;
					 }
				}*/
			}			
		}
		}
		}	
		msg+="\\r\\n成功生成了"+num+"条记录的静态文件!";		
		form.addResult("msg",msg);
		return super.doQuery(form,module,this.getCurrentUser(form));
	}
	public Page doStart(WebForm form, Module module) throws Exception {
		AutoHtmlGenerater.getInstance().setSiteRootPath("http://"+ActionContext.getContext().getRequest().getServerName()+":"+ActionContext.getContext().getRequest().getServerPort());		
		AutoHtmlGenerater.getInstance().start();
		form.addResult("msg","成功启动!");
		return super.doQuery(form,module,this.getCurrentUser(form));
	}
	public Page doStop(WebForm form, Module module) throws Exception {
		AutoHtmlGenerater.getInstance().pause();
		form.addResult("msg","已经暂停自动转换进程!");
		return super.doQuery(form,module,this.getCurrentUser(form));
	}
}

⌨️ 快捷键说明

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