private void LoadRequestData() { RequestStatisticService service = (RequestStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(RequestStatisticService)); RequestSummaryData data = service.GetRequestSummaryData(Context); //data.TRequestSummary.DefaultView.Sort = "Month DESC"; List <RequestSummaryEntry> entries = new List <RequestSummaryEntry>(); // Max. number of months to display will be set to 12 (1 year). int monthCount = data.TRequestSummary.Rows.Count > 12 ? 12 : data.TRequestSummary.Rows.Count; for (int monthIndex = 0; monthIndex < monthCount; ++monthIndex) { RequestSummaryData.TRequestSummaryRow row = (RequestSummaryData.TRequestSummaryRow)data.TRequestSummary.Rows[(data.TRequestSummary.Rows.Count - 1) - monthIndex]; RequestSummaryEntry entry = new RequestSummaryEntry(); entry.Month = row.Month; entry.RequestsPerDay = GetRequestsPerDay(row.Month, row.RequestCount); entry.VisitsPerDay = GetVisitsPerDay(row.Month, row.VisitsCount); entry.TotalRequests = row.RequestCount; entry.TotalVisits = row.VisitsCount; entries.Add(entry); } repeaterOverview.DataSource = entries; repeaterOverview.DataBind(); // Show the error message, if an error is occured in the service. Exception ex = service.ConsumeLastException(); if (ex != null) { _errorMsg.Visible = true; _errorMsg.Text = ex.Message; } }
protected void Session_Start(Object sender, EventArgs e) { // If its not the LifeguardData.aspx file, then register the Session Start as a Visit. if (0 != string.Compare(Request.AppRelativeCurrentExecutionFilePath, "~/LifeguardData.aspx", true)) { RequestStatisticService service = (RequestStatisticService)Statistic.GetService(typeof(RequestStatisticService)); service.AddVisit(Context); } }
private void LoadSummaryData() { // Use ConfigAgent to get the month to view. ConfigAgent configAgent = ((IStateProcessor)Parent).ConfigAgent; RequestStatisticService service = (RequestStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(RequestStatisticService)); RequestUrlData urlData = service.GetRequestUrlData(Context, configAgent.Month); RequestSummaryData summaryData = service.GetRequestSummaryData(Context); // Contains all entries for the summary table. List <RequestSummaryEntry> entries = new List <RequestSummaryEntry>(); // Calculate total requests of this month. double totalRequests = 0.0; foreach (RequestUrlData.TRequestUrlRow row in urlData.TRequestUrl.Rows) { totalRequests += row.RequestCount; } DataRow[] rows = summaryData.TRequestSummary.Select("Month = " + configAgent.Month.ToString(@"#MM\/dd\/yyyy#")); double totalVisits = 0.0; if (rows.Length > 0) { RequestSummaryData.TRequestSummaryRow row = (RequestSummaryData.TRequestSummaryRow)rows[0]; totalVisits = row.VisitsCount; } // Get the number of days. int dayCount = 1; DateTime now = DateTime.Now; if ((now.Year == configAgent.Month.Year) && (now.Month == configAgent.Month.Month)) { // Current month, so we use the days since 1st of this month. dayCount = now.Day; } else { dayCount = DateTime.DaysInMonth(configAgent.Month.Year, configAgent.Month.Month); } entries.Add(new RequestSummaryEntry(Language.GetText(Portal.API.Module.GetModuleControl(this), "sumRequests"), totalRequests)); entries.Add(new RequestSummaryEntry(Language.GetText(Portal.API.Module.GetModuleControl(this), "sumVisits"), totalVisits)); //entries.Add(new RequestSummaryEntry("", 0.0)); entries.Add(new RequestSummaryEntry(Language.GetText(Portal.API.Module.GetModuleControl(this), "requestsPerDay"), totalRequests / (double)dayCount)); entries.Add(new RequestSummaryEntry(Language.GetText(Portal.API.Module.GetModuleControl(this), "visitsPerDay"), totalVisits / (double)dayCount)); repeaterSummary.DataSource = entries; repeaterSummary.DataBind(); labelMonthlySummary.Text = string.Format(Language.GetText(Portal.API.Module.GetModuleControl(this), "monthlyStatisticTitle"), configAgent.Month.ToString("MMMM"), configAgent.Month.ToString("yyyy")); }
private void LoadRequestData() { // Use ConfigAgent to get the month to view. ConfigAgent configAgent = ((IStateProcessor)Parent).ConfigAgent; RequestStatisticService service = (RequestStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(RequestStatisticService)); RequestUrlData data = service.GetRequestUrlData(Context, configAgent.Month); data.TRequestUrl.DefaultView.Sort = data.TRequestUrl.RequestCountColumn.ColumnName + " DESC"; // Calculate the total logged requests. int totalRequests = 0; foreach (RequestUrlData.TRequestUrlRow row in data.TRequestUrl.Rows) { totalRequests += row.RequestCount; } List <RequestUrlEntry> entries = new List <RequestUrlEntry>(); int rank = 1; foreach (DataRowView rv in data.TRequestUrl.DefaultView) { RequestUrlData.TRequestUrlRow row = (RequestUrlData.TRequestUrlRow)rv.Row; RequestUrlEntry entry = new RequestUrlEntry(); entry.Rank = rank++; entry.RequestCount = row.RequestCount; entry.Percentage = (double)row.RequestCount / (double)totalRequests; entry.Url = row.Url; entry.Url = entry.Url.Substring(entry.Url.IndexOf('/') + 1); entry.Url = entry.Url.Substring(entry.Url.IndexOf('/') + 1); entry.Url = entry.Url.Substring(entry.Url.IndexOf('/')); entries.Add(entry); if (rank > 30) { break; } } labelMonthlyRequests.Text = string.Format(Language.GetText(Portal.API.Module.GetModuleControl(this), "monthlyRequestsTitle"), rank - 1, data.TRequestUrl.Rows.Count); repeaterTopUrls.DataSource = entries; repeaterTopUrls.DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { // Set the CSS-Path. cssLink.Href = Portal.Helper.CssPath; Control TabContent = null; // Depending on current mode, load the Content Control. if (Request["Edit"] == "Tab") { // Try to load the Tab in Edit Mode. Portal.PortalDefinition.Tab EditTab = Helper.GetEditTab(Request["TabRef"]); if (EditTab != null) { Tab TabCtrl = (Tab)LoadControl("Modules/AdminPortal/Tab.ascx"); TabCtrl.LoadData(EditTab); TabContent = TabCtrl; } else { // No Access. TabContent = null; } } if (TabContent == null) { // Load Tab in View Mode. TabContent = LoadControl("PortalTab.ascx"); // Add request to the statistics. if (!IsPostBack) { RequestStatisticService service = (RequestStatisticService)Portal.API.Statistics.Statistic.GetService(typeof(RequestStatisticService)); if (null != service) { service.AddRequest(Context); } } } TabContent.ID = "Content"; ContentPlace.Controls.Add(TabContent); // Set the name of the website if available try { string title = System.Configuration.ConfigurationManager.AppSettings["Title"]; if (!string.IsNullOrEmpty(title)) { this.Title = HttpUtility.HtmlEncode(title); } else { this.Title = "Personal .NET Portal"; } } catch (System.Configuration.ConfigurationErrorsException) { } catch (ArgumentNullException) { } catch (FormatException) { } // Set the portal footer visible depending on the web config settings. try { PortalFooter.Visible = Boolean.Parse(System.Configuration.ConfigurationManager.AppSettings["UsePortalFooter"]); } catch (System.Configuration.ConfigurationErrorsException) { } catch (ArgumentNullException) { } catch (FormatException) { } // Set the favicon visible if the file exists. try { string faviconPath = System.Configuration.ConfigurationManager.AppSettings["FavIconPath"]; favicon.Href = faviconPath; favicon.Visible = !string.IsNullOrEmpty(faviconPath); } catch (System.Configuration.ConfigurationErrorsException) { } try { string description = System.Configuration.ConfigurationManager.AppSettings["Description"]; metaDescription.Content = description; metaDescription.Visible = !string.IsNullOrEmpty(description); } catch (System.Configuration.ConfigurationErrorsException) { } try { string author = System.Configuration.ConfigurationManager.AppSettings["Author"]; metaAuthor.Content = author; metaAuthor.Visible = !string.IsNullOrEmpty(author); } catch (System.Configuration.ConfigurationErrorsException) { } try { string keywords = System.Configuration.ConfigurationManager.AppSettings["Keywords"]; metaKeywords.Content = keywords; metaKeywords.Visible = !string.IsNullOrEmpty(keywords); } catch (System.Configuration.ConfigurationErrorsException) { } try { string robots = System.Configuration.ConfigurationManager.AppSettings["Robots"]; metaRobots.Content = robots; metaRobots.Visible = !string.IsNullOrEmpty(robots); } catch (System.Configuration.ConfigurationErrorsException) { } // Disable browser cache if the user is authenticated. if (User.Identity.IsAuthenticated) { bool preventBrowserCache = false; bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["PreventBrowserCache"], out preventBrowserCache); if (preventBrowserCache) { Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); } } }
public RequestWorker(RequestStatisticService service, HttpContext context) : base(context) { this.service = service; }