コード例 #1
0
ファイル: PurgeSiteLog.cs プロジェクト: DLFergrd/Dnn.SiteLog
 private static void DoPurgeSiteLog()
 {
     var siteLogController = new SiteLogController();
     var portals = PortalController.Instance.GetPortals();
     for (var index = 0; index <= portals.Count - 1; index++)
     {
         var portal = (PortalInfo) portals[index];
         var siteLogHistory = PortalController.GetPortalSettingAsInteger("SiteLogHistory", portal.PortalID, 0);
         var purgeDate = DateTime.Now.AddDays(-(siteLogHistory));
         siteLogController.DeleteSiteLog(purgeDate, portal.PortalID);
     }
 }
コード例 #2
0
        private static void DoPurgeSiteLog()
        {
            var siteLogController = new SiteLogController();
            var portals           = PortalController.Instance.GetPortals();

            for (var index = 0; index <= portals.Count - 1; index++)
            {
                var portal         = (PortalInfo)portals[index];
                var siteLogHistory = PortalController.GetPortalSettingAsInteger("SiteLogHistory", portal.PortalID, 0);
                var purgeDate      = DateTime.Now.AddDays(-(siteLogHistory));
                siteLogController.DeleteSiteLog(purgeDate, portal.PortalID);
            }
        }
コード例 #3
0
        public void AddSiteLog()
        {
            try
            {
                SiteLogInfo objSiteLog;
                var objSiteLogs = new SiteLogController();

				//iterate through buffered sitelog items and insert into database
                int intIndex;
                for (intIndex = 0; intIndex <= SiteLog.Count - 1; intIndex++)
                {
                    objSiteLog = (SiteLogInfo) SiteLog[intIndex];
                    switch (SiteLogStorage)
                    {
                        case "D": //database
                            _dataService.AddSiteLog(objSiteLog.DateTime,
                                                               objSiteLog.PortalId,
                                                               objSiteLog.UserId,
                                                               objSiteLog.Referrer,
                                                               objSiteLog.URL,
                                                               objSiteLog.UserAgent,
                                                               objSiteLog.UserHostAddress,
                                                               objSiteLog.UserHostName,
                                                               objSiteLog.TabId,
                                                               objSiteLog.AffiliateId);
                            break;
                        case "F": //file system
                            objSiteLogs.W3CExtendedLog(objSiteLog.DateTime,
                                                       objSiteLog.PortalId,
                                                       objSiteLog.UserId,
                                                       objSiteLog.Referrer,
                                                       objSiteLog.URL,
                                                       objSiteLog.UserAgent,
                                                       objSiteLog.UserHostAddress,
                                                       objSiteLog.UserHostName,
                                                       objSiteLog.TabId,
                                                       objSiteLog.AffiliateId);
                            break;
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

            }
        }
コード例 #4
0
        public void AddSiteLog()
        {
            try
            {
                SiteLogInfo objSiteLog;
                var         objSiteLogs = new SiteLogController();

                //iterate through buffered sitelog items and insert into database
                int intIndex;
                for (intIndex = 0; intIndex <= SiteLog.Count - 1; intIndex++)
                {
                    objSiteLog = (SiteLogInfo)SiteLog[intIndex];
                    switch (SiteLogStorage)
                    {
                    case "D":     //database
                        _dataService.AddSiteLog(objSiteLog.DateTime,
                                                objSiteLog.PortalId,
                                                objSiteLog.UserId,
                                                objSiteLog.Referrer,
                                                objSiteLog.URL,
                                                objSiteLog.UserAgent,
                                                objSiteLog.UserHostAddress,
                                                objSiteLog.UserHostName,
                                                objSiteLog.TabId,
                                                objSiteLog.AffiliateId);
                        break;

                    case "F":     //file system
                        objSiteLogs.W3CExtendedLog(objSiteLog.DateTime,
                                                   objSiteLog.PortalId,
                                                   objSiteLog.UserId,
                                                   objSiteLog.Referrer,
                                                   objSiteLog.URL,
                                                   objSiteLog.UserAgent,
                                                   objSiteLog.UserHostAddress,
                                                   objSiteLog.UserHostName,
                                                   objSiteLog.TabId,
                                                   objSiteLog.AffiliateId);
                        break;
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
            }
        }
コード例 #5
0
ファイル: SiteLogModule.cs プロジェクト: DLFergrd/Dnn.SiteLog
        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);
            }
        }
コード例 #6
0
ファイル: SiteLog.ascx.cs プロジェクト: DLFergrd/Dnn.SiteLog
		/// -----------------------------------------------------------------------------
        /// <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;
            }
        }