Skip to content

Instantly share code, notes, and snippets.

@ivanbuzyka
Created September 25, 2014 07:45
Show Gist options
  • Save ivanbuzyka/7f9e9818fdac48332ac9 to your computer and use it in GitHub Desktop.
Save ivanbuzyka/7f9e9818fdac48332ac9 to your computer and use it in GitHub Desktop.
namespace Sitecore.TestProject.Analytics.Data.Filters
{
using Sitecore.Analytics;
using Sitecore.Analytics.Data.Filters.Filters;
using Sitecore.Diagnostics;
/// <summary>
/// WherePageEventTextLike: filter class
/// </summary>
public class WherePageEventTextLike : FilterBase
{
/// <summary>
/// Gets or sets Text.
/// </summary>
public string Text { get; set; }
/// <summary>
/// ApplyFilter: method for applying filter
/// </summary>
/// <param name="sqlCommand" /> /// The sql command.
public override void ApplyFilter(Sitecore.Analytics.Data.Filters.SqlCommand sqlCommand)
{
Assert.ArgumentNotNull(sqlCommand, "sqlCommand");
sqlCommand.AddWhereClause("Browser", AnalyticsManager.FormatCommandText("{0}PageEvent{1}.{0}Text{1}") + " LIKE '" + string.Format("%{0}%", EscapeQuote(Text)) + "'", this.Except);
}
/// <summary>
/// IsApplicable: method checks whether the filter is applicable
/// </summary>
/// <param name="sqlCommand" /> /// The sql command.
/// <returns>
/// Bool value
/// </returns>
public override bool IsApplicable(Sitecore.Analytics.Data.Filters.SqlCommand sqlCommand)
{
Assert.ArgumentNotNull(sqlCommand, "sqlCommand");
// We are using "Browser" placeholder for our filter
return sqlCommand.HasPlaceholder("Browser");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment