/// ----------------------------------------------------------------------------- /// <summary> /// BindData binds the controls to the Data /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/15/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- private void BindData() { var strPortalAlias = Globals.GetPortalDomainName(PortalAlias.HTTPAlias, Request, false); if (strPortalAlias.IndexOf("/") != -1) //child portal { strPortalAlias = strPortalAlias.Substring(0, strPortalAlias.LastIndexOf("/") - 1); } var dtStart = DefaultBeginDate; var dtEnd = DefaultEndDate.Add(new TimeSpan(0, 23, 59, 59)); if(diStartDate.SelectedDate.HasValue) { dtStart = diStartDate.SelectedDate.Value; } if(diEndDate.SelectedDate.HasValue) { dtEnd = diEndDate.SelectedDate.Value.Add(new TimeSpan(0, 23, 59, 59)); } ArrayList arrUsers; var dt = new DataTable(); DataView dv; switch (cboReportType.SelectedItem.Value) { case "10": arrUsers = UserController.GetUsers(PortalId); dt = new DataTable(); dt.Columns.Add(new DataColumn("Full Name", typeof (string))); dt.Columns.Add(new DataColumn("User Name", typeof (string))); dt.Columns.Add(new DataColumn("Date Registered", typeof (DateTime))); foreach (UserInfo objUser in arrUsers) { if (objUser.Membership.CreatedDate >= dtStart && objUser.Membership.CreatedDate <= dtEnd && objUser.IsSuperUser == false) { var dr = dt.NewRow(); dr["Date Registered"] = objUser.Membership.CreatedDate; dr["Full Name"] = objUser.Profile.FullName; dr["User Name"] = objUser.Username; dt.Rows.Add(dr); } } dv = new DataView(dt) {Sort = "Date Registered DESC"}; grdLog.DataSource = dv; grdLog.DataBind(); break; case "11": //User Registrations By Country arrUsers = UserController.GetUsers(PortalId); dt = new DataTable(); dt.Columns.Add(new DataColumn("Full Name", typeof (string))); dt.Columns.Add(new DataColumn("User Name", typeof (string))); dt.Columns.Add(new DataColumn("Country", typeof (string))); foreach (UserInfo objUser in arrUsers) { if (objUser.Membership.CreatedDate >= dtStart && objUser.Membership.CreatedDate <= dtEnd && objUser.IsSuperUser == false) { var dr = dt.NewRow(); dr["Country"] = objUser.Profile.Country; dr["Full Name"] = objUser.Profile.FullName; dr["User Name"] = objUser.Username; dt.Rows.Add(dr); } } dv = new DataView(dt) {Sort = "Country"}; grdLog.DataSource = dv; grdLog.DataBind(); break; default: var objSiteLog = new SiteLogController(); var reader = objSiteLog.GetSiteLog(PortalId, strPortalAlias, Convert.ToInt32(cboReportType.SelectedItem.Value), dtStart, dtEnd); grdLog.DataSource = reader; //we are using a DataReader here because the resultset returned by GetSiteLog varies based on the report type selected and therefore does not conform to a static business object grdLog.DataBind(); reader.Close(); break; } if (grdLog.Items.Count > 0) { lblMessage.Visible = false; grdLog.Visible = true; } else { lblMessage.Visible = true; grdLog.Visible = false; } }
//Log Display //Tasks /// <summary> /// BindData binds the controls to the Data /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/15/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> private void BindData() { string strPortalAlias; strPortalAlias = Globals.GetPortalDomainName( PortalAlias.HTTPAlias, Request, false ); if( strPortalAlias.IndexOf("/") != 0 ) // child portal { strPortalAlias = strPortalAlias.Substring( 0, strPortalAlias.LastIndexOf( "/" ) - 1 ); } string strStartDate = txtStartDate.Text; DateTime dtStart = DateTime.Parse( strStartDate ); if( !String.IsNullOrEmpty(strStartDate) ) { strStartDate = strStartDate + " 00:00"; } string strEndDate = txtEndDate.Text; DateTime dtEnd = DateTime.Parse( strEndDate ); if( !String.IsNullOrEmpty(strEndDate) ) { strEndDate = strEndDate + " 23:59"; } UserController objUsers = new UserController(); UserInfo objUser; if( cboReportType.SelectedItem.Value == "10" ) { //User Registrations By Date ArrayList arrUsers = UserController.GetUsers( PortalId, false ); DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add( new DataColumn( "Full Name", typeof( string ) ) ); dt.Columns.Add( new DataColumn( "User Name", typeof( string ) ) ); dt.Columns.Add( new DataColumn( "Date Registered", typeof( DateTime ) ) ); foreach( UserInfo tempLoopVar_objUser in arrUsers ) { objUser = tempLoopVar_objUser; if( objUser.Membership.CreatedDate >= dtStart && objUser.Membership.CreatedDate <= dtEnd && objUser.IsSuperUser == false ) { dr = dt.NewRow(); dr["Date Registered"] = objUser.Membership.CreatedDate; dr["Full Name"] = objUser.Profile.FullName; dr["User Name"] = objUser.Username; dt.Rows.Add( dr ); } } DataView dv = new DataView( dt ); dv.Sort = "Date Registered DESC"; grdLog.DataSource = dv; grdLog.DataBind(); } else if( cboReportType.SelectedItem.Value == "11" ) { //User Registrations By Country ArrayList arrUsers = UserController.GetUsers( PortalId, false ); DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add( new DataColumn( "Full Name", typeof( string ) ) ); dt.Columns.Add( new DataColumn( "User Name", typeof( string ) ) ); dt.Columns.Add( new DataColumn( "Country", typeof( string ) ) ); foreach( UserInfo tempLoopVar_objUser in arrUsers ) { objUser = tempLoopVar_objUser; if( objUser.Membership.CreatedDate >= dtStart && objUser.Membership.CreatedDate <= dtEnd && objUser.IsSuperUser == false ) { dr = dt.NewRow(); dr["Country"] = objUser.Profile.Country; dr["Full Name"] = objUser.Profile.FullName; dr["User Name"] = objUser.Username; dt.Rows.Add( dr ); } } DataView dv = new DataView( dt ); dv.Sort = "Country"; grdLog.DataSource = dv; grdLog.DataBind(); } else { SiteLogController objSiteLog = new SiteLogController(); IDataReader dr = objSiteLog.GetSiteLog( PortalId, strPortalAlias, Convert.ToInt32( cboReportType.SelectedItem.Value ), Convert.ToDateTime( strStartDate ), Convert.ToDateTime( strEndDate ) ); grdLog.DataSource = dr; // we are using a DataReader here because the resultset returned by GetSiteLog varies based on the report type selected and therefore does not conform to a static business object grdLog.DataBind(); dr.Close(); } }