Example #1
0
  public void setRelaTableMaxNo(SiteTableRela.TableRela tr, DataRow dr, boolean newIDFlag) {
    for (int i = 0; i < this.NoRelas.length; ++i) {
      SiteTableRela.NoType nr = this.NoRelas[i];
      if (nr.TableCode.equalsIgnoreCase(tr.TableCode)) {
        String id = dr.getString(nr.FieldName);
        if (newIDFlag) {
          id = String.valueOf(NoUtil.getMaxID(nr.NoType));
        }
        addIDMapping(nr.TableCode + "." + nr.FieldName, dr.getString(nr.FieldName), id);
        dr.set(nr.FieldName, id);
      }
    }
    for (int i = 0; i < this.TableRelas.length; ++i)
      if (this.TableRelas[i].TableCode.equals(tr.TableCode)) {
        String type = this.TableRelas[i].RelaTable;
        if ((((type.equals("ZCArticle"))
                || (type.equals("ZCAttachment"))
                || (type.equals("ZCImage"))
                || (type.equals("ZCAudio"))
                || (type.equals("ZCVideo"))))
            && (this.TableRelas[i].RelaField.equals("ID"))) {
          type = "Document";
        }

        String id =
            getIDMapping(
                type + "." + this.TableRelas[i].RelaField,
                dr.getString(this.TableRelas[i].KeyField));
        if (StringUtil.isNotEmpty(id)) dr.set(this.TableRelas[i].KeyField, id);
      }
  }
Example #2
0
  public void setSiteIDTableMaxNo(String tableName, DataRow dr, boolean newIDFlag) {
    try {
      if (dr.getDataColumn("SiteID") != null)
        dr.set("SiteID", getIDMapping("ZCSite", String.valueOf(this.siteID)));
    } catch (Throwable t) {
      t.printStackTrace();
      LogUtil.warn(tableName);
    }
    for (int i = 0; i < this.NoRelas.length; ++i) {
      SiteTableRela.NoType nr = this.NoRelas[i];
      if (nr.TableCode.equalsIgnoreCase(tableName)) {
        String id = dr.getString(nr.FieldName);
        if (newIDFlag) {
          if ((nr.TableCode.equals("ZCCatalog")) && (nr.FieldName.equals("InnerCode")))
            if (id.length() == 6) {
              id = CatalogUtil.createCatalogInnerCode(null);
            } else {
              String parent = id.substring(0, id.length() - 6);
              parent = getIDMapping(nr.TableCode + "." + nr.FieldName, parent);
              id = CatalogUtil.createCatalogInnerCode(parent);
            }
          else {
            id = String.valueOf(NoUtil.getMaxID(nr.NoType));
          }
        }
        String type = nr.TableCode;
        if ((((type.equals("ZCArticle"))
                || (type.equals("ZCAttachment"))
                || (type.equals("ZCImage"))
                || (type.equals("ZCAudio"))
                || (type.equals("ZCVideo"))))
            && (nr.NoType.equals("DocID"))) {
          type = "Document";
        }

        addIDMapping(type + "." + nr.FieldName, dr.getString(nr.FieldName), id);
        dr.set(nr.FieldName, id);
      }
    }
    for (int i = 0; i < this.TableRelas.length; ++i)
      if (this.TableRelas[i].TableCode.equals(tableName)) {
        String type = this.TableRelas[i].RelaTable;
        if ((((type.equals("ZCArticle"))
                || (type.equals("ZCAttachment"))
                || (type.equals("ZCImage"))
                || (type.equals("ZCAudio"))
                || (type.equals("ZCVideo"))))
            && (this.TableRelas[i].RelaField.equals("ID"))) {
          type = "Document";
        }

        String id =
            getIDMapping(
                type + "." + this.TableRelas[i].RelaField,
                dr.getString(this.TableRelas[i].KeyField));
        if (StringUtil.isNotEmpty(id)) dr.set(this.TableRelas[i].KeyField, id);
      }
  }
Example #3
0
  public void add() {
    ZCApplySchema apply = new ZCApplySchema();
    apply.setAddTime(new Date());
    apply.setID(NoUtil.getMaxID("ID"));
    apply.setValue(this.Request);
    apply.setAddUser("");
    apply.setAddTime(new Date());

    if (apply.insert()) this.Response.setLogInfo(1, "新增成功");
    else this.Response.setLogInfo(0, "新增" + apply.getName() + "失败!");
  }
Example #4
0
 public void save() {
   ZCDatabaseSchema db = new ZCDatabaseSchema();
   if (StringUtil.isEmpty($V("ID"))) {
     db.setValue(this.Request);
     db.setID(NoUtil.getMaxID("DatabaseID"));
     db.setAddTime(new Date());
     db.setAddUser(User.getUserName());
     db.setSiteID(Application.getCurrentSiteID());
     if (db.insert()) this.Response.setMessage("添加数据库连接成功");
     else this.Response.setError("发生错误,添加数据库连接失败");
   } else {
     db.setID(Long.parseLong($V("ID")));
     db.fill();
     db.setValue(this.Request);
     db.setModifyTime(new Date());
     db.setModifyUser(User.getUserName());
     if (db.update()) this.Response.setMessage("修改数据库连接成功");
     else {
       this.Response.setError("发生错误,修改数据库连接失败");
     }
   }
   removeConnPool(db.getID());
   addConnPool(db);
 }
Example #5
0
  public void dealZCSite(DataRow dr) {
    if (this.isNewSite) {
      if ((LicenseInfo.getName().equals("TrailUser"))
          && (new QueryBuilder("select count(*) from ZCSite").executeInt() >= 1)) {
        throw new RuntimeException("站点数超出限制,请联系泽元软件更换License!");
      }
      this.newSiteID = NoUtil.getMaxID("SiteID");
      ZCSiteSchema site = new ZCSiteSchema();
      site.setValue(dr);
      site.setID(this.newSiteID);
      site.setName(this.map.getString("Name"));
      site.setAlias(this.map.getString("Alias"));
      site.setURL(this.map.getString("URL"));
      site.setHitCount(0L);
      site.setChannelCount(0L);
      site.setSpecialCount(0L);
      site.setMagzineCount(0L);
      site.setArticleCount(0L);
      site.setImageLibCount(1L);
      site.setVideoLibCount(1L);
      site.setAudioLibCount(1L);
      site.setAttachmentLibCount(1L);
      site.setBranchInnerCode(User.getBranchInnerCode());
      site.setAddTime(new Date());
      site.setAddUser(User.getUserName());
      site.setConfigXML(ConfigImageLib.imageLibConfigDefault);
      this.da.insert(site);
      Transaction trans = new Transaction();
      Site.addDefaultPriv(this.newSiteID, trans);
      trans.setDataAccess(this.da);
      trans.commit(false);
      addIDMapping("ZCSite", String.valueOf(this.siteID), String.valueOf(this.newSiteID));
    } else {
      ZCSiteSchema site = new ZCSiteSchema();
      site.setID(this.map.getString("ID"));
      this.newSiteID = site.getID();
      site.fill();

      this.task.setCurrentInfo("正在备份数据,可能需要较长时间,请耐心等待");

      SiteExporter se = new SiteExporter(site.getID());
      se.exportSite(
          Config.getContextRealPath()
              + "WEB-INF/data/backup/"
              + site.getAlias()
              + "_"
              + System.currentTimeMillis()
              + ".dat");

      addIDMapping("ZCSite", dr.getString("ID"), String.valueOf(site.getID()));
      this.da.deleteAndBackup(site);
      BlockingTransaction tran = new BlockingTransaction(this.da);
      Site.delSiteRela(site.getID(), tran);

      String sitePath =
          Config.getContextRealPath()
              + Config.getValue("Statical.TemplateDir")
              + "/"
              + site.getAlias();
      FileUtil.delete(sitePath);

      site = new ZCSiteSchema();
      site.setValue(dr);

      this.da.insert(site);
    }
  }