BB.Caching.Redis.Analytics.BitwiseAnalytics.GetQuarter C# (CSharp) Méthode

GetQuarter() public static méthode

Gets the keys for the months in the quarter covered by the DateTime supplied, creating the data at the key if necessary.
public static GetQuarter ( IDatabase database, string category, string action, System.DateTime dateTime ) : RedisKey
database IDatabase /// The database where the query will be performed. This is passed so that we can reuse the same database to /// perform multiple bitwise operations. Doing this with the same connection will guarantee that performance /// is good. ///
category string /// Typically the object that was interacted with (e.g. button) ///
action string /// The type of interaction (e.g. click) ///
dateTime System.DateTime /// The DateTime. ///
Résultat RedisKey
        public static RedisKey GetQuarter(IDatabase database, string category, string action, DateTime dateTime)
        {
            // get the key
            string quarter = BitwiseAnalytics.DateTimeUtil.QuarterNumber(dateTime);
            RedisKey key = EventKey(category, action, quarter);

            // return it if there's already data for this quarter
            bool quarterExists = BitwiseAnalytics.Exists(database, key);
            if (quarterExists)
            {
                return key;
            }

            // no data for the month, so we need to create it from the days
            string[] monthsInQuarter = BitwiseAnalytics.DateTimeUtil.MonthsInQuarter(dateTime);

            // make sure each day exists
            foreach (string month in monthsInQuarter)
            {
                GetMonth(database, category, action, DateTime.ParseExact(month, "yyyyMM", CultureInfo.InvariantCulture));
            }

            // combine the days to form one month
            BitwiseAnalytics.BitwiseOr(
                database,
                key,
                monthsInQuarter.Select(x => EventKey(category, action, x)).ToArray());

            return key;
        }