/// <summary> /// reIndex Document /// </summary> /// <param name="runCleanUp">clean old records</param> /// <param name="toBeIndexed">Array of Strings to be indexed</param> /// <param name="ctx">context</param> /// <param name="AD_Client_ID">id</param> /// <param name="AD_Table_ID">id</param> /// <param name="Record_ID">id</param> /// <param name="CM_WebProject_ID">webproject</param> /// <param name="lastUpdated">date of last update</param> public static void ReIndex(bool runCleanUp, String[] toBeIndexed, Ctx ctx, int AD_Client_ID, int AD_Table_ID, int Record_ID, int CM_WebProject_ID, DateTime?lastUpdated) { Trx trx = Trx.Get("ReIndex_" + AD_Table_ID + "_" + Record_ID); try { if (!runCleanUp) { MIndex.CleanUp(trx, AD_Client_ID, AD_Table_ID, Record_ID); } for (int i = 0; i < toBeIndexed.Length; i++) { MIndex.RunIndex(toBeIndexed[i], ctx, trx, AD_Table_ID, Record_ID, CM_WebProject_ID, lastUpdated); } trx.Commit(); //DataBase.DB.Commit (true, trx); } catch { try { //DataBase.DB.Rollback(true, trx); trx.Rollback(); } catch { } } }
protected override bool BeforeDelete() { // Clean own index MIndex.CleanUp(Get_Trx(), GetAD_Client_ID(), Get_Table_ID(), Get_ID()); // Clean ElementIndex MContainerElement[] theseElements = GetAllElements(); if (theseElements != null) { for (int i = 0; i < theseElements.Length; i++) { theseElements[i].Delete(false); } } // StringBuilder sb = new StringBuilder("DELETE FROM AD_TreeNodeCMC ") .Append(" WHERE Node_ID=").Append(Get_ID()).Append( " AND AD_Tree_ID=").Append(GetAD_Tree_ID()); int no = DataBase.DB.ExecuteQuery(sb.ToString(), null, Get_TrxName()); if (no > 0) { log.Fine("#" + no + " - TreeType=CMC"); } else { log.Warning("#" + no + " - TreeType=CMC"); } return(no > 0); }
} // afterDelete /// <summary> /// reIndex /// </summary> /// <param name="newRecord">new record</param> public void ReIndex(bool newRecord) { if (IsIndexed()) { String [] toBeIndexed = new String[8]; toBeIndexed[0] = this.GetName(); toBeIndexed[1] = this.GetDescription(); toBeIndexed[2] = this.GetRelativeURL(); toBeIndexed[3] = this.GetMeta_Author(); toBeIndexed[4] = this.GetMeta_Copyright(); toBeIndexed[5] = this.GetMeta_Description(); toBeIndexed[6] = this.GetMeta_Keywords(); toBeIndexed[7] = this.GetMeta_Publisher(); MIndex.ReIndex(newRecord, toBeIndexed, GetCtx(), GetAD_Client_ID(), Get_Table_ID(), Get_ID(), GetCM_WebProject_ID(), this.GetUpdated()); MContainerElement[] theseElements = GetAllElements(); if (theseElements != null) { for (int i = 0; i < theseElements.Length; i++) { theseElements[i].ReIndex(false); } } } if (!IsIndexed() && !newRecord) { MIndex.CleanUp(Get_Trx(), GetAD_Client_ID(), Get_Table_ID(), Get_ID()); } } // reIndex
/// <summary> /// After Save. /// </summary> /// <param name="newRecord">new</param> /// <param name="success">success</param> /// <returns>true if inserted</returns> protected override bool AfterSave(bool newRecord, bool success) { if (!success) { return(success); } if (!newRecord) { MIndex.CleanUp(Get_TrxName(), GetAD_Client_ID(), Get_Table_ID(), Get_ID()); } ReIndex(newRecord); return(success); } // afterSave
} // afterSave /// <summary> /// reIndex /// </summary> /// <param name="newRecord">new record</param> public void ReIndex(bool newRecord) { if (GetParent().IsIndexed()) { int CMWebProjectID = 0; if (GetParent() != null) { CMWebProjectID = GetParent().GetCM_WebProject_ID(); } String [] toBeIndexed = new String[3]; toBeIndexed[0] = this.GetName(); toBeIndexed[1] = this.GetDescription(); toBeIndexed[2] = this.GetContentHTML(); MIndex.ReIndex(newRecord, toBeIndexed, GetCtx(), GetAD_Client_ID(), Get_Table_ID(), Get_ID(), CMWebProjectID, this.GetUpdated()); } if (!GetParent().IsIndexed() && !newRecord) { MIndex.CleanUp(Get_TrxName(), GetAD_Client_ID(), Get_Table_ID(), Get_ID()); } } // reIndex