Date Rollup API
API function
.NET:
DateTime HushHush.MaskingLogic.SSRS.Mask.DateTimeRollup(DateTime data, string rangesConfiguration, DateTime defaultReplacement, RollupConfigurationFormat format = RollupConfigurationFormat.Xml)
Expected input
data: value to be masked.
rangesConfiguration: proper rollup ranges in XML or CSV format.
defaultReplacement: default replacement for values not covered by rollup ranges.
format: RollupConfigurationFormat.Xml (default) or RollupConfigurationFormat.Csv. Selects whether rangesConfiguration is XML or CSV.
Expected output
Masked DateTime value
Error handling
InvalidOperationException when the rollup configuration is invalid. For XML (“There is an error in XML document”), the details are in the inner exception. For CSV, the message names the row and column of each problem, and ArgumentException is thrown when the configuration is null or empty. An empty XML configuration is not an error: every value gets defaultReplacement. The message does not include the value being masked.
Examples
string rangesXML =
"<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
"<ArrayOfRollupOfDateTime xmlns:xsi=" +
"\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" <RollupOfDateTime>" +
" <Replacement>" +
" <dateTime>2020-10-10T00:00:00</dateTime>" +
" </Replacement>" +
" <Filter type=\"Range\">" +
" <RangeRollupFilterOfDateTime>" +
" <Min>2013-01-01T00:00:00</Min>" +
" <Max>2014-01-01T00:00:00</Max>" +
" </RangeRollupFilterOfDateTime>" +
" </Filter>" +
" <MatchValues />" +
" </RollupOfDateTime>" +
"</ArrayOfRollupOfDateTime>";
HushHush.MaskingLogic.SSRS.Mask.DateTimeRollup(new DateTime(2013, 10, 3), rangesXML, new DateTime(3000, 11, 30)) // DateTime "10/10/2020 00:00:00"
HushHush.MaskingLogic.SSRS.Mask.DateTimeRollup(new DateTime(2017, 10, 3), rangesXML, new DateTime(3000, 11, 30)); // DateTime "11/30/3000 00:00:00"
Note: XML written by earlier versions using the full assembly-qualified type value still loads correctly.
using HushHush.MaskingLogic.Helpers; // for RollupConfigurationFormat
string rangesCsv = "Min,Max,Replacement" + System.Environment.NewLine + "2013-01-01 00:00:00,2014-01-01 00:00:00,2020-10-10 00:00:00";
HushHush.MaskingLogic.SSRS.Mask.DateTimeRollup(new DateTime(2013, 10, 3), rangesCsv, new DateTime(3000, 11, 30), RollupConfigurationFormat.Csv) // DateTime "10/10/2020 00:00:00"
Note: The first row is a header: Min,Max,Replacement. Dates are formatted as yyyy-MM-dd HH:mm:ss. One range per line.
API Reference: Date Rollup
- 1. Date Rollup API
- 1.1 API function
- 1.2 Expected input
- 1.3 Expected output
- 1.4 Error handling
- 1.5 Examples