public RequestUrlData GetRequestUrlData(HttpContext context, DateTime dateTime) { if (null == context) throw new ArgumentNullException("context"); RequestUrlData data = null; try { // Create the directory if it doesn't already exist. if (!Directory.Exists(Path.Combine(Statistic.GetStatisticsPath(context), "Requests"))) Directory.CreateDirectory(Path.Combine(Statistic.GetStatisticsPath(context), "Requests")); lock (lockObject) { string fileName = Path.Combine(Statistic.GetStatisticsPath(context), @"Requests\Requests_{0}_{1}.xml"); fileName = string.Format(CultureInfo.InvariantCulture, fileName, dateTime.Year, dateTime.Month); // Try to get the login statistics data from the cache. // If the data is not in the cache, try to load the file. // At last, if the file doesn't exist, create a new data object. object obj = context.Cache.Get(fileName); if ((null != obj) && obj.GetType().Equals(typeof(RequestUrlData))) { data = (RequestUrlData)obj; } else if (File.Exists(fileName)) { data = new RequestUrlData(); data.ReadXml(fileName); } else { data = new RequestUrlData(); } } } catch (UnauthorizedAccessException ex) { HandleNoAccessException(Statistic.GetStatisticsPath(context), ex); } catch (SecurityException ex) { HandleNoAccessException(Statistic.GetStatisticsPath(context), ex); } catch (Exception ex) { HandleException(Statistic.GetStatisticsPath(context), ex); } return data; }