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

📄 dbcss.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.laoer.bbscs.bbs.business;

import com.laoer.bbscs.db.*;
import java.util.*;
import com.laoer.bbscs.exception.ObjectException;
import com.laoer.bbscs.exception.ObjectNoExistException;
import java.sql.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.sysinfo.*;
import org.apache.log4j.*;
import java.io.*;
import com.laoer.bbscs.servlet.*;

/**
 * <p>Title: 天乙社区V5.0</p>
 * <p>Description: BBS-CS天乙社区V5.0</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: laoer.com</p>
 * @author 龚天乙
 * @version 5.0
 */

public class DBCSS
    extends CSS
    implements DBInf {

  ResultSet rs = null;
  String SQL = "";
  static Logger logger = Logger.getLogger(DBCSS.class.getName());

  private static final String INSERT_CSS = "insert into css (ID,leftbgcolor,letftextcolor,rightbgcolor,righttextcolor,tablemaincolor,tabletintcolor,tabledarkcolor,left_a,left_alink,left_avisited,left_ahover,left_aactive,right_a,right_alink,right_avisited,right_ahover,right_aactive,allfonts) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  private static final String LOAD_CSS_BYID = "select * from css where ID = ?";
  private static final String LOAD_CSSS = "select * from css order by ID";
  private static final String UPDATE_CSS = "update css set leftbgcolor = ?,letftextcolor = ?,rightbgcolor = ?,righttextcolor = ?,tablemaincolor = ?,tabletintcolor = ?,tabledarkcolor = ?,left_a = ?,left_alink = ?,left_avisited = ?,left_ahover = ?,left_aactive = ?,right_a = ?,right_alink = ?,right_avisited = ?,right_ahover = ?,right_aactive = ?,allfonts=? where ID = ?";
  private static final String DEL_CSS = "delete from css where ID = ?";

  public DBCSS() {
  }

  public int updateCSS(TranContext aTranContext, String key) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    try {
      this.updateDB(myDBTrans, key);
      String paths1 = Util.getCSSPath(this.myCSSInfo.getID()) + "css1.css";
      String paths2 = Util.getCSSPath(this.myCSSInfo.getID()) + "css2.css";
      String sWebPro = "";
      sWebPro = "body { font-size: 14px; background-color: " +
          this.myCSSInfo.getLeftbgcolor() + "; color: " +
          this.myCSSInfo.getLetftextcolor() + ";FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += "input {FONT-FAMILY:" + this.myCSSInfo.getAllfonts() +
          ";font-size: 14px;}\n";
      sWebPro += "textarea {FONT-FAMILY:" + this.myCSSInfo.getAllfonts() +
          "; font-size: 14px;}\n";
      sWebPro += ".bt { font-size: 9pt;FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += ".T1 { background-color: " + this.myCSSInfo.getTablemaincolor() +
          ";}\n";
      sWebPro += ".T2 { background-color: " + this.myCSSInfo.getTabletintcolor() +
          ";}\n";
      sWebPro += ".T3 { background-color: " + this.myCSSInfo.getTabledarkcolor() +
          ";}\n";
      sWebPro += "a            { " + this.myCSSInfo.getLeft_a() + " }\n";
      sWebPro += "a:link       { " + this.myCSSInfo.getLeft_alink() + " }\n";
      sWebPro += "a:visited    { " + this.myCSSInfo.getLeft_avisited() + " }\n";
      sWebPro += "a:hover      { " + this.myCSSInfo.getLeft_ahover() + " }\n";
      sWebPro += "a:active     { " + this.myCSSInfo.getLeft_aactive() + " }\n";
      File f = new File(paths1);
      PrintWriter outf1 = new PrintWriter(new FileWriter(f));
      outf1.print(sWebPro);
      outf1.close();
      sWebPro = "body { font-size: 9pt; background-color: " +
          this.myCSSInfo.getRightbgcolor() + "; color: " +
          this.myCSSInfo.getRighttextcolor() + ";FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += "table { font-size: 9pt; FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += ".bt { font-size: 14px;}\n";
      sWebPro += ".T1 { background-color: " + this.myCSSInfo.getTablemaincolor() +
          ";}\n";
      sWebPro += ".T2 { background-color: " + this.myCSSInfo.getTabletintcolor() +
          ";}\n";
      sWebPro += ".T3 { background-color: " + this.myCSSInfo.getTabledarkcolor() +
          ";}\n";
      sWebPro += "a            { " + this.myCSSInfo.getRight_a() + " }\n";
      sWebPro += "a:link       { " + this.myCSSInfo.getRight_alink() + " }\n";
      sWebPro += "a:visited    { " + this.myCSSInfo.getRight_avisited() +
          " }\n";
      sWebPro += "a:hover      { " + this.myCSSInfo.getRight_ahover() + " }\n";
      sWebPro += "a:active     { " + this.myCSSInfo.getRight_aactive() + " }\n";
      f = new File(paths2);

      PrintWriter outf2 = new PrintWriter(new FileWriter(f));
      outf2.print(sWebPro);
      outf2.close();
      setInitCSS();
      UpMsg aUpMsg = new UpMsg(4);
      ServerSession.upMsg(aUpMsg);
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    catch (IOException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public int createCSS(TranContext aTranContext) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    try {
      this.insertDB(myDBTrans);
      String paths1 = Util.getCSSPath(this.myCSSInfo.getID()) + "css1.css";
      String paths2 = Util.getCSSPath(this.myCSSInfo.getID()) + "css2.css";
      String sWebPro = "";
      sWebPro = "body { font-size: 14px; background-color: " +
          this.myCSSInfo.getLeftbgcolor() + "; color: " +
          this.myCSSInfo.getLetftextcolor() + ";FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() +
          "}\n";
      sWebPro += "input {FONT-FAMILY:" + this.myCSSInfo.getAllfonts() +
          ";font-size: 14px;}\n";
      sWebPro += "textarea {FONT-FAMILY:" + this.myCSSInfo.getAllfonts() +
          "; font-size: 14px;}\n";

      sWebPro += ".bt { font-size: 9pt;FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += ".T1 { background-color: " + this.myCSSInfo.getTablemaincolor() +
          ";}\n";
      sWebPro += ".T2 { background-color: " + this.myCSSInfo.getTabletintcolor() +
          ";}\n";
      sWebPro += ".T3 { background-color: " + this.myCSSInfo.getTabledarkcolor() +
          ";}\n";
      sWebPro += "a            { " + this.myCSSInfo.getLeft_a() + " }\n";
      sWebPro += "a:link       { " + this.myCSSInfo.getLeft_alink() + " }\n";
      sWebPro += "a:visited    { " + this.myCSSInfo.getLeft_avisited() + " }\n";
      sWebPro += "a:hover      { " + this.myCSSInfo.getLeft_ahover() + " }\n";
      sWebPro += "a:active     { " + this.myCSSInfo.getLeft_aactive() + " }\n";
      File f = new File(paths1);
      PrintWriter outf1 = new PrintWriter(new FileWriter(f));
      outf1.print(sWebPro);
      outf1.close();
      sWebPro = "body { font-size: 9pt; background-color: " +
          this.myCSSInfo.getRightbgcolor() + "; color: " +
          this.myCSSInfo.getRighttextcolor() + ";FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + "}\n";
      sWebPro += "table { font-size: 9pt;FONT-FAMILY:" +
          this.myCSSInfo.getAllfonts() + " }\n";
      sWebPro += ".bt { font-size: 14px;}\n";
      sWebPro += ".T1 { background-color: " + this.myCSSInfo.getTablemaincolor() +
          ";}\n";
      sWebPro += ".T2 { background-color: " + this.myCSSInfo.getTabletintcolor() +
          ";}\n";
      sWebPro += ".T3 { background-color: " + this.myCSSInfo.getTabledarkcolor() +
          ";}\n";
      sWebPro += "a            { " + this.myCSSInfo.getRight_a() + " }\n";
      sWebPro += "a:link       { " + this.myCSSInfo.getRight_alink() + " }\n";
      sWebPro += "a:visited    { " + this.myCSSInfo.getRight_avisited() +
          " }\n";
      sWebPro += "a:hover      { " + this.myCSSInfo.getRight_ahover() + " }\n";
      sWebPro += "a:active     { " + this.myCSSInfo.getRight_aactive() + " }\n";
      f = new File(paths2);

      //System.out.println(f);
      PrintWriter outf2 = new PrintWriter(new FileWriter(f));
      outf2.print(sWebPro);
      outf2.close();
      setInitCSS();
      UpMsg aUpMsg = new UpMsg(4);
      ServerSession.upMsg(aUpMsg);
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    catch (IOException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public List getCSSList(TranContext aTranContext, String key) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    try {
      List alist = null;
      alist = this.loadDBs(myDBTrans, key);
      return alist;
    }
    catch (ObjectException e) {
      logger.error(e);
      return (List) Sys.RESULT_NULL;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public synchronized void setInitCSS() {
    CSSInfo aCSSInfo = null;
    List csslist = this.getCSSList(null, "All");
    Hashtable cssht = new Hashtable();
    int len = csslist.size();
    for (int i = 0; i < len; i++) {
      aCSSInfo = (CSSInfo) csslist.get(i);
      cssht.put(String.valueOf(aCSSInfo.getID()), aCSSInfo);
    }
    Sys.CSSHT = cssht;
  }

  public int delCSS(TranContext aTranContext) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    try {
      this.delDB(myDBTrans, "ID");
      String paths1 = Util.getCSSPath(this.myCSSInfo.getID()) + "css1.css";
      String paths2 = Util.getCSSPath(this.myCSSInfo.getID()) + "css2.css";
      File f = new File(paths1);
      if (f.exists()) {
        f.delete();
      }
      f = new File(paths2);
      if (f.exists()) {
        f.delete();
      }
      setInitCSS();
      UpMsg aUpMsg = new UpMsg(4);
      ServerSession.upMsg(aUpMsg);
      return Sys.RESULT_RIGHT;
    }
    catch (ObjectException e) {
      logger.error(e);
      return Sys.RESULT_OBJECTEXCEPTION;
    }
    finally {
      if (aTranContext == null && myDBTrans != null) {
        myDBTrans.freeCon();
      }
    }
  }

  public int getCSS(TranContext aTranContext, String key, boolean isLoad) {
    TranContext myDBTrans = null;
    if (aTranContext == null) {
      myDBTrans = new TranContext();
    }
    else {
      myDBTrans = aTranContext;
    }
    try {
      this.loadDB(myDBTrans, key, isLoad);

⌨️ 快捷键说明

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