Exemplo n.º 1
0
 public void add() {
   Transaction tran = new Transaction();
   ZCFullTextSchema ft = new ZCFullTextSchema();
   if (XString.isEmpty($V("ID"))) {
     ft.setValue(this.request);
     ft.setID(NoUtil.getMaxID("FullTextID"));
     ft.setSiteID(ApplicationPage.getCurrentSiteID());
     ft.setAddTime(new Date());
     ft.setAddUser(User.getUserName());
     tran.add(ft, OperateType.INSERT);
   } else {
     ft.setID(Long.parseLong($V("ID")));
     ft.fill();
     ft.setValue(this.request);
     ft.setModifyTime(new Date());
     ft.setModifyUser(User.getUserName());
     tran.add(ft, OperateType.UPDATE);
   }
   if (tran.commit()) this.response.setMessage("保存成功");
   else this.response.setError("发生错误,保存失败");
 }
Exemplo n.º 2
0
  public static void dealAutoIndex(long siteID, boolean autoIndex) {
    ZCFullTextSchema ft = new ZCFullTextSchema();
    ft.setSiteID(siteID);
    ft.setProp1("AutoIndex");
    ZCFullTextSet set = ft.query();
    if (!autoIndex) {
      if (set.size() == 0) {
        return;
      }
      long sourceID = set.get(0).getID();
      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setSourceID(sourceID);
      ZDScheduleSet sdSet = sd.query();
      if (sdSet.size() == 0) {
        return;
      }
      sd = sdSet.get(0);
      if ("N".equals(sd.getIsUsing())) {
        return;
      }
      sd.setIsUsing("N");
      sd.update();
    } else if (set.size() == 0) {
      ft.setID(NoUtil.getMaxID("FullTextID"));
      ft.setRelaText("-1");
      ft.setType("Article");
      ft.setName("全站索引-" + SiteUtil.getName(ft.getSiteID()));
      ft.setCode("AllArticle");
      ft.setAddUser("SYS");
      ft.setAddTime(new Date());

      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setAddTime(new Date());
      sd.setAddUser("SYS");
      sd.setCronExpression("*/3 * * * *");
      sd.setID(NoUtil.getMaxID("ScheduleID"));
      sd.setIsUsing("Y");
      sd.setPlanType("Period");
      sd.setTypeCode("IndexMaintenance");
      sd.setStartTime(new Date());
      sd.setSourceID(ft.getID());

      Transaction tran = new Transaction();
      tran.add(ft, OperateType.INSERT);
      tran.add(sd, OperateType.INSERT);
      tran.commit();
    } else {
      ft = set.get(0);
      long sourceID = set.get(0).getID();
      ZDScheduleSchema sd = new ZDScheduleSchema();
      sd.setSourceID(sourceID);
      ZDScheduleSet sdSet = sd.query();
      if (sdSet.size() == 0) {
        sd.setAddTime(new Date());
        sd.setAddUser("SYS");
        sd.setCronExpression("*/3 * * * *");
        sd.setID(NoUtil.getMaxID("ScheduleID"));
        sd.setIsUsing("Y");
        sd.setPlanType("Period");
        sd.setTypeCode("IndexMaintenance");
        sd.setStartTime(new Date());
        sd.setSourceID(ft.getID());
        sd.insert();
      }
    }
  }