protected void FilterPoliciesToCurrentFlows(SortableCollection <UserAccessPolicy> policies, ICollection <string> flowNames) { if (CollectionUtils.IsNullOrEmpty(policies)) { return; } for (int i = policies.Count - 1; i >= 0; --i) { UserAccessPolicy policy = policies[i]; if (policy.PolicyType == ServiceRequestAuthorizationType.Flow) { if (!CollectionUtils.Contains(flowNames, policy.TypeQualifier, StringComparison.InvariantCultureIgnoreCase)) { policies.RemoveAt(i); } } } }
private void initLast24HourChart() { string cacheKey = "15B642D6-FB16-4027-989C-6F40FA821A73"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (cacheWrapper == null) { //LOAD VIEWS SortableCollection <KeyValuePair <int, int> > viewsByHour = PageViewDataSource.GetViewsByHour(true, DateTime.UtcNow.AddHours(-24)); //RESULTS ARE SORTED FROM 0 (MIDNIGHT) TO 23 (11PM) int thisHour = LocaleHelper.LocalNow.Hour; //SHIFT SO IT GOES FOR PAST 24 HOURS for (int i = 0; i <= thisHour; i++) { KeyValuePair <int, int> tempCount = viewsByHour[0]; viewsByHour.RemoveAt(0); viewsByHour.Add(tempCount); } //CREATE CHART Last24HoursChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(Last24HoursChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); Last24HoursChart.Series["Views"].Points.Add(point); } Last24HoursChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(viewsByHour); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { SortableCollection <KeyValuePair <int, int> > viewsByHour = (SortableCollection <KeyValuePair <int, int> >)cacheWrapper.CacheValue; //CREATE CHART Last24HoursChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(Last24HoursChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); Last24HoursChart.Series["Views"].Points.Add(point); } Last24HoursChart.DataBind(); } Last24HoursChart.ChartAreas[0].AxisX.Interval = 1; }
private void initHourChart() { string cacheKey = "59A0ABAC-9204-49ab-A333-85340024E802"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (cacheWrapper == null) { //LOAD VIEWS SortableCollection <KeyValuePair <int, int> > viewsByHour = PageViewDataSource.GetViewsByHour(true); //RESULTS ARE SORTED FROM 0 (MIDNIGHT) TO 23 (11PM) //SHIFT SO IT GOES FROM 6AM TO 5AM INSTEAD for (int i = 0; i < 6; i++) { KeyValuePair <int, int> tempCount = viewsByHour[0]; viewsByHour.RemoveAt(0); viewsByHour.Add(tempCount); } //CREATE CHART ViewsByHourChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(ViewsByHourChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); ViewsByHourChart.Series["Views"].Points.Add(point); } ViewsByHourChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(viewsByHour); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { //USE CACHED VALUES SortableCollection <KeyValuePair <int, int> > viewsByHour = (SortableCollection <KeyValuePair <int, int> >)cacheWrapper.CacheValue; //CREATE CHART ViewsByHourChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(ViewsByHourChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); ViewsByHourChart.Series["Views"].Points.Add(point); } ViewsByHourChart.DataBind(); } ViewsByHourChart.ChartAreas[0].AxisX.Interval = 1; }