⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useractivityreport.aspx.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using CommunityServer.Reporting;
using CA = ComponentArt.Web.UI;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;
using ResourceManager = CommunityServer.ControlPanel.Components.ResourceManager;

namespace CommunityServer.ControlPanel.Tools.Reports
{
	/// <summary>
	/// Summary description for BlogActivityReport.
	/// </summary>
	public class UserActivityReport : BaseToolsPage
	{
		#region Members

		protected CA.Grid Grid1;
		protected DropDownList PageList;
		protected ResourceLinkButton FilterButton;
		protected Modal Modal1;
		protected ActivityQueryControl UserActivityQueryControl1;
		protected Label countLabel;
		int recordCount = 0;
		string BegReportDate;
		protected CommunityServer.ControlPanel.Controls.ControlPanelSelectedNavigation SelectedNavigation1;
		protected CommunityServer.ControlPanel.Controls.ResourceControl RegionTitle;
		protected CommunityServer.Controls.MPContent DescriptionRegion;
		protected CommunityServer.ControlPanel.Controls.ResourceControl UniqueCount;
		protected CommunityServer.Controls.MPContent TaskRegion;
		protected CommunityServer.Controls.MPContainer MPContainer;
		string EndReportDate;

		protected CommunityServer.Controls.StatusMessage Status;

		#endregion

		override protected void OnInit(EventArgs e)
		{
			if (Telligent.Registration.CommunityServer.IsStandard)
			{
				Grid1.PageIndexChanged += new CA.Grid.PageIndexChangedEventHandler(OnPageIndexChanged);
				Grid1.NeedRebind += new CA.Grid.NeedRebindEventHandler(OnNeedRebind);
				Grid1.NeedDataSource += new CA.Grid.NeedDataSourceEventHandler(OnNeedDataSource);

				this.Load += new EventHandler(this.Page_Load);
			}
			else
			{
				Status.Success = false;
				Status.IsLicenseMessage = true;
				Status.Text = CommunityServer.ControlPanel.Components.ResourceManager.GetString("CP_Tools_UserActivityReport_LicenseNotAvailable");
				Status.Visible = true;
			}

			//Taken from the BaseGridControl Helper function - In the future this page should inherit from that base class
			foreach(CA.GridColumn gc in Grid1.Levels[0].Columns)
			{
				if(gc.Visible)
				{
					gc.SortedDataCellCssClass = "SortedDataCell";
					//Allows for mock resource manager calls in heading text
					//eg HeadingText="ResourceManager.CP_Photos_GridCol_Name"
					if(gc.HeadingText.StartsWith("ResourceManager."))
						gc.HeadingText = ResourceManager.GetString(gc.HeadingText.Replace("ResourceManager.",""));
			
				}
			}

			base.OnInit(e);
		}

		private void Page_Load(object sender, EventArgs e)
		{
			if(!Page.IsPostBack && !this.IsCallBack)
			{
				CSContext context = CSContext.Current;
				if(context.QueryString["csv"] != null && context.QueryString["csv"].ToString() == "1")
					BuildExcelDoc();
				else
					Bind();
			}
		}

		private void Bind()
		{
			UserActivityResultSet uars = BuildReportData();
			Grid1.DataSource = uars.Records;
			this.recordCount = uars.TotalRecords;
			countLabel.Text = recordCount.ToString("#,###");
			Grid1.DataBind();
			Grid1.RecordCount = recordCount; //recordCount;
		}

		private UserActivityResultSet BuildReportData()
		{
			CSContext context = CSContext.Current;
			BegReportDate = "1/1/1900";
			EndReportDate = "1/1/1900";
			int startRecord;
			int endRecord;
			Grid1.PageSize = 20;

			startRecord = (Grid1.CurrentPageIndex * Grid1.PageSize) + 1;
			endRecord = ((Grid1.CurrentPageIndex + 1) * Grid1.PageSize);

			if (Globals.IsDate(context.QueryString["brd"]))
			{
				BegReportDate = context.QueryString["brd"];
				UserActivityQueryControl1.BegSearchReportDatePicker = DateTime.Parse(BegReportDate);
				UserActivityQueryControl1.BegSearchReportDateCalendar = DateTime.Parse(BegReportDate);
			}
			if (Globals.IsDate(context.QueryString["erd"]))
			{
				EndReportDate = context.QueryString["erd"];
				UserActivityQueryControl1.EndSearchReportDatePicker = DateTime.Parse(EndReportDate);
				UserActivityQueryControl1.BegSearchReportDateCalendar = DateTime.Parse(EndReportDate);
			}

			UserActivityResultSet uars = new UserActivityResultSet();
			
			uars = ReportingSqlDataProvider.GetUserActivityResults(startRecord, endRecord, BegReportDate, EndReportDate);

			return uars;
		}

		#region Events
		public void OnPageIndexChanged(object sender, CA.GridPageIndexChangedEventArgs args)
		{
			Grid1.CurrentPageIndex = args.NewIndex;
		}

		public void OnNeedDataSource(object sender, EventArgs oArgs)
		{
			UserActivityResultSet uars = BuildReportData();
			Grid1.DataSource = uars.Records;
			this.recordCount = uars.TotalRecords;
			countLabel.Text = recordCount.ToString();
		}

		public void OnNeedRebind(object sender, EventArgs oArgs)
		{
			Grid1.DataBind();
			Grid1.RecordCount = recordCount;
			countLabel.Text = recordCount.ToString();
		}

		#endregion

		private void InitializeComponent()
		{
		
		}

		private void BuildExcelDoc()
		{
			CSContext context = CSContext.Current;
			BegReportDate = "1/1/1900";
			EndReportDate = "1/1/1900";
			if (Globals.IsDate(context.QueryString["brd"]))
				BegReportDate = context.QueryString["brd"];
			if (Globals.IsDate(context.QueryString["erd"]))
				EndReportDate = context.QueryString["erd"];
			string CSV = "";
			CSV = ReportingSqlDataProvider.GetUserActivitySummaryCSV(0, 0, BegReportDate, EndReportDate);
			Response.ContentType = "Application/x-msexcel";
			Response.AddHeader("content-disposition", "attachment; filename=\"UserActivityReport.csv\"");
			Response.Write(CSV);
			Response.End();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -