/// <summary> /// Gets the number of views for the item given by ID. /// </summary> /// <param name="itemId">The ID of the item to get the views for.</param> /// <returns>The number of views for the item.</returns> protected virtual long GetItemViews(ID itemId) { var query = new ItemVisitsQuery(this.ReportDataProvider) { ItemId = itemId }; query.Execute(); return(query.Visits); }
/// <summary> /// Gets the number of views for the item given by ID. /// </summary> /// <param name="itemId">The ID of the item to get the views for.</param> /// <returns>The number of views for the item.</returns> protected virtual long GetItemViews(ID itemId) { #if FEATURE_XDB var query = new ItemVisitsQuery(this.ReportDataProvider) { ItemId = itemId }; query.Execute(); return(query.Visits); #elif FEATURE_DMS var queryId = itemId.ToString().Replace("{", string.Empty).Replace("}", string.Empty); var sql = "SELECT COUNT(ItemId) as Visits FROM {{0}}Pages{{1}} WHERE {{0}}ItemId{{1}} = '{0}'".FormatWith(queryId); return(DataAdapterManager.ReportingSql.ReadOne(sql, reader => DataAdapterManager.ReportingSql.GetLong(0, reader))); #endif }