/// <summary> /// Deletes the chapter pages. /// Deletes Audit Trail, Story Board, Comments, Narrative and document /// for the selected page. /// </summary> /// <param name="siteURL">The site URL.</param> /// <param name="chapterPageID">The chapter page ID.</param> /// <param name="connectionType">Type of the connection.</param> /// <param name="listName">Name of the list.</param> /// <param name="auditListName">Name of the audit list.</param> public void DeleteChapterPages(string siteURL, int chapterPageID, string connectionType, string listName, string auditListName) { string strCamlQuery = string.Empty; string strPageType = string.Empty; DataTable dtResultTable; objCommonDAL = new CommonDAL(); /// Get the Page type from "DWB Chapter Pages Mapping" list /// Based on the connection type delete the document. strCamlQuery = string.Format(@" <Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq></Where>", chapterPageID.ToString()); dtResultTable = objCommonDAL.ReadList(siteURL, listName, strCamlQuery, "<FieldRef Name='ID' /><FieldRef Name='Connection_Type' />"); if (dtResultTable != null && dtResultTable.Rows.Count > 0) { strPageType = Convert.ToString(dtResultTable.Rows[0]["Connection_Type"]); dtResultTable.Dispose(); } /// Delete documents for the selected page if (!string.IsNullOrEmpty(strPageType)) { switch (strPageType) { case DWBTYPE2PAGE: { objCommonDAL.DeleteDocument(siteURL,PUBLISHEDDOCUMENTLIST,string.Format(CHAPTERPAGEDOCUMNETCAMEQUERY,chapterPageID.ToString())); break; } case DWBTYPE3PAGE: { objCommonDAL.DeleteDocument(siteURL, USERDEFINEDDOCUMENTLIST, string.Format(CHAPTERPAGEDOCUMNETCAMEQUERY, chapterPageID.ToString())); break; } default: break; } } strCamlQuery = string.Empty; /// CAML query for DWB Comments. strCamlQuery = string.Format(@"<Where><Eq><FieldRef Name='Page_ID' /><Value Type='Number'>{0}</Value></Eq></Where> ", chapterPageID.ToString()); /// Delete Comments objCommonDAL.DeleteListItem(siteURL, DWBCOMMENT, strCamlQuery); /// Delete Narrative objCommonDAL.DeleteListItem(siteURL, DWBNARRATIVES, strCamlQuery); /// Delete StoryBoard objCommonDAL.DeleteListItem(siteURL, DWBSTORYBOARD, strCamlQuery); /// Delete Audit Trail objCommonDAL.DeleteAuditTrail(siteURL, auditListName, string.Format(AUDITHISTORYCAMLQUERY, chapterPageID.ToString())); /// Delete Chapter Page objCommonDAL.DeleteListItemById(siteURL, listName, chapterPageID); }