/// ----------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <remarks> /// - manage affiliates /// - log visit to site /// </remarks> /// <history> /// [sun1] 1/19/2004 Created /// </history> /// ----------------------------------------------------------------------------- private void ManageRequest() { //affiliate processing int affiliateId = -1; if (Request.QueryString["AffiliateId"] != null) { if (Regex.IsMatch(Request.QueryString["AffiliateId"], "^\\d+$")) { affiliateId = Int32.Parse(Request.QueryString["AffiliateId"]); var objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(affiliateId, 1, 0); //save the affiliateid for acquisitions if (Request.Cookies["AffiliateId"] == null) //do not overwrite { var objCookie = new HttpCookie("AffiliateId", affiliateId.ToString("D")) { Expires = DateTime.Now.AddYears(1), Path = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/") }; Response.Cookies.Add(objCookie); } } } //site logging if (PortalSettings.SiteLogHistory != 0) { //get User ID //URL Referrer string urlReferrer = ""; try { if (Request.UrlReferrer != null) { urlReferrer = Request.UrlReferrer.ToString(); } } catch (Exception exc) { Logger.Error(exc); } string strSiteLogStorage = Host.SiteLogStorage; int intSiteLogBuffer = Host.SiteLogBuffer; //log visit var objSiteLogs = new SiteLogController(); UserInfo objUserInfo = UserController.Instance.GetCurrentUserInfo(); objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, urlReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, affiliateId, intSiteLogBuffer, strSiteLogStorage); } }
private void OnBeginRequest(object sender, EventArgs e) { var application = sender as HttpApplication; var context = application.Context; //First check if we are upgrading/installing if (!Initialize.ProcessHttpModule(context.ApplicationInstance.Request, false, false)) { return; } if (SiteLogHistory != 0) { var request = context.Request; //get User ID //affiliate processing var affiliateId = -1; if (request.QueryString["AffiliateId"] != null) { if (Regex.IsMatch(request.QueryString["AffiliateId"], "^\\d+$")) { affiliateId = int.Parse(request.QueryString["AffiliateId"]); } } //URL Referrer string urlReferrer = ""; try { if (request.UrlReferrer != null) { urlReferrer = request.UrlReferrer.ToString(); } } catch (Exception exc) { Logger.Error(exc); } var siteLogStorage = "D"; var siteLogBuffer = 1; var portalId = PortalSettings.Current.PortalId; //log visit var siteLogController = new SiteLogController(); var userInfo = UserController.Instance.GetCurrentUserInfo(); siteLogController.AddSiteLog(portalId, userInfo.UserID, urlReferrer, request.Url.ToString(), request.UserAgent, request.UserHostAddress, request.UserHostName, PortalSettings.Current.ActiveTab.TabID, affiliateId, siteLogBuffer, siteLogStorage); } }
/// <remarks> /// - manage affiliates /// - log visit to site /// </remarks> /// <history> /// [sun1] 1/19/2004 Created /// </history> private void ManageRequest() { // affiliate processing int AffiliateId = -1; if (Request.QueryString["AffiliateId"] != null) { if (Int32.TryParse(Request.QueryString["AffiliateId"], out AffiliateId)) { AffiliateId = int.Parse(Request.QueryString["AffiliateId"]); AffiliateController objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(AffiliateId, 1, 0); // save the affiliateid for acquisitions if (Request.Cookies["AffiliateId"] == null) // do not overwrite { HttpCookie objCookie = new HttpCookie("AffiliateId"); objCookie.Value = AffiliateId.ToString(); objCookie.Expires = DateTime.Now.AddYears(1); // persist cookie for one year Response.Cookies.Add(objCookie); } } } // site logging if (PortalSettings.SiteLogHistory != 0) { // get User ID // URL Referrer string URLReferrer = ""; if (Request.UrlReferrer != null) { URLReferrer = Request.UrlReferrer.ToString(); } string strSiteLogStorage = "D"; if (Convert.ToString(Globals.HostSettings["SiteLogStorage"]) != "") { strSiteLogStorage = Convert.ToString(Globals.HostSettings["SiteLogStorage"]); } int intSiteLogBuffer = 1; if (Convert.ToString(Globals.HostSettings["SiteLogBuffer"]) != "") { intSiteLogBuffer = int.Parse(Convert.ToString(Globals.HostSettings["SiteLogBuffer"])); } // log visit SiteLogController objSiteLogs = new SiteLogController(); UserInfo objUserInfo = UserController.GetCurrentUserInfo(); objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, URLReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, AffiliateId, intSiteLogBuffer, strSiteLogStorage); } }
/// <summary> /// Get Referrers from Sitelog /// </summary> /// <param name="portalId"> /// The Portal ID that is used /// </param> /// <param name="sPortalAlias"> /// The Current Portal Alias /// </param> /// <param name="dtStartDate"> /// Startdate to get Referres from /// </param> /// <param name="dtEndDate"> /// Enddate to get Referres from /// </param> /// <returns> /// Item List with Referrers /// </returns> public static List <ReferrerItems> TagCloudSiteLogInfo( int portalId, string sPortalAlias, DateTime dtStartDate, DateTime dtEndDate) { List <ReferrerItems> siteLogInfoList = new List <ReferrerItems>(); SiteLogController objSiteLog = new SiteLogController(); try { using (IDataReader dr = objSiteLog.GetSiteLog(portalId, sPortalAlias, 4, dtStartDate, dtEndDate)) { try { while (dr.Read()) { ReferrerItems item = new ReferrerItems(); string sReferrer = Convert.ToString(dr["Referrer"]); if (((((!sReferrer.Contains("search?q=") && !sReferrer.Contains("&q=")) && !sReferrer.Contains("bing")) && !sReferrer.Contains(@"Search=")) && !sReferrer.Contains("yahoo")) && !sReferrer.Contains(@"ask.com")) { continue; } item.Referrer = sReferrer; siteLogInfoList.Add(item); } } finally { dr.Close(); dr.Dispose(); } } } catch (Exception /*exc*/) { // Exceptions.LogException(exc); return(siteLogInfoList); } return(siteLogInfoList); }
/// ----------------------------------------------------------------------------- /// <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(); } }