Do you want to store more information than is displayed in the Report for expired pages?
I want to store at least the page ID so I can determine what pages expired at any time.
Maybe I don't understand exactly what you want, but if you only want a list of pages that are expired, you can view that report in the "Report viewer" which lists the follwowing for each expired page: Page Name (with a link to the page), Publication Date, Publication Stopped, Last Changed, Changed By, Language, Page Type.
You can use the API to go through all pages and compare StopPublish date to todays date OR you can run sql cmd netReportExpiredPages (which is the code used by Report center):
public PageReferenceCollection GetPagesExpired(PageReference rootPage, DateTime startDate, DateTime endDate, string publishedByName, ReportDB.SortColumn sortColumn, SortDirection sortDirection, int pageSize, int pageNumber, int langID, out int totalRows) { PageReferenceCollection pageReferences = new PageReferenceCollection(); int resultTotalRows = 0; base.Database.Execute(delegate { IDbCommand dbCommand = this.CreateCommand("netReportExpiredPages"); dbCommand.Parameters.Add(this.CreateParameter("PageID", rootPage.ID)); dbCommand.Parameters.Add(this.CreateDateParameter("StartDate", startDate)); dbCommand.Parameters.Add(this.CreateDateParameter("StopDate", endDate)); dbCommand.Parameters.Add(this.CreateParameter("Language", langID)); dbCommand.Parameters.Add(this.CreateParameter("PublishedByName", publishedByName)); dbCommand.Parameters.Add(this.CreateParameter("PageSize", pageSize)); dbCommand.Parameters.Add(this.CreateParameter("PageNumber", pageNumber)); dbCommand.Parameters.Add(this.CreateParameter("SortColumn", sortColumn.ToString())); dbCommand.Parameters.Add(this.CreateParameter("SortDescending", (sortDirection == SortDirection.Descending) ? 1 : 0)); using (IDataReader dataReader = dbCommand.ExecuteReader()) { while (dataReader.Read()) { if (resultTotalRows == 0) { resultTotalRows = Convert.ToInt32(dataReader.GetValue(3)); } if (dataReader.IsDBNull(1)) { pageReferences.Add(new PageReference(dataReader.GetInt32(0))); } else { pageReferences.Add(new PageReference(dataReader.GetInt32(0), dataReader.GetInt32(1))); } } } }); totalRows = resultTotalRows; return pageReferences; }
Thank you for the piece of code, but is there an event that is raised when the page has expired?
Something like event EventHandler<ContentEventArgs> PublishedContent that occurs when you published the page.
There is as far as I know no specific event. Although it is in fact a PublishedContent event. But I don't think the event is triggered by automatic expiring of pages, but I could be wrong.
If it is, you could check for Published Status of your PageData I guess and do whatever you need to do with it.
Hi,
I need to store data about expired pages in the DDS. So I don't have to do a search to get them.
How to determine that the page has expired and at the time of expiration to save data in the DDS?
Maybe an event occurs?