コード例 #1
0
        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();
        }
コード例 #2
0
        private void UpdateMonthlyRequests()
        {
            string url = null;

            try
            {
                url = context.Request.Url.ToString();
            }
            catch (NullReferenceException) { }

            if (url != null)
            {
                // Get the data.
                RequestUrlData data = service.GetRequestUrlData(context);
                if (data != null)
                {
                    // Find the row for the currently requested URL.
                    RequestUrlData.TRequestUrlRow row = null;
                    foreach (RequestUrlData.TRequestUrlRow r in data.TRequestUrl.Rows)
                    {
                        if (string.Compare(r.Url, url, true, CultureInfo.InvariantCulture) == 0)
                        {
                            row = r;
                            row.RequestCount = row.RequestCount + 1;
                            break;
                        }
                    }

                    // If the currently requested URL was not found, it must be added to the data.
                    if (null == row)
                    {
                        row              = data.TRequestUrl.NewTRequestUrlRow();
                        row.Url          = url;
                        row.RequestCount = 1;
                        data.TRequestUrl.Rows.Add(row);
                    }

                    // Save the data.
                    service.SaveRequestUrlData(context, data);
                }
            }
        }