public void AddSiteLog()
        {
            try
            {
                SiteLogInfo objSiteLog;
                SiteLogController 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

                            DataProvider.Instance().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)
            {
            }
        }
Beispiel #2
0
        public void AddSiteLog()
        {
            try
            {
                SiteLogInfo       objSiteLog;
                SiteLogController 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

                        DataProvider.Instance().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)
            {
            }
        }
 private 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];
         if (portal.SiteLogHistory > 0)
         {
             var purgeDate = DateTime.Now.AddDays(-(portal.SiteLogHistory));
             siteLogController.DeleteSiteLog(purgeDate, portal.PortalID);
         }
     }
 }
Beispiel #4
0
        private 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];
                if (portal.SiteLogHistory > 0)
                {
                    var purgeDate = DateTime.Now.AddDays(-(portal.SiteLogHistory));
                    siteLogController.DeleteSiteLog(purgeDate, portal.PortalID);
                }
            }
        }
Beispiel #5
0
 private void DoPurgeSiteLog()
 {
     var objSiteLog = new SiteLogController();
     var objPortals = new PortalController();
     ArrayList arrPortals = objPortals.GetPortals();
     PortalInfo objPortal;
     DateTime PurgeDate;
     int intIndex;
     for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
     {
         objPortal = (PortalInfo) arrPortals[intIndex];
         if (objPortal.SiteLogHistory > 0)
         {
             PurgeDate = DateTime.Now.AddDays(-(objPortal.SiteLogHistory));
             objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
         }
     }
 }
Beispiel #6
0
        private void DoPurgeSiteLog()
        {
            var        objSiteLog = new SiteLogController();
            var        objPortals = new PortalController();
            ArrayList  arrPortals = objPortals.GetPortals();
            PortalInfo objPortal;
            DateTime   PurgeDate;
            int        intIndex;

            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                if (objPortal.SiteLogHistory > 0)
                {
                    PurgeDate = DateTime.Now.AddDays(-(objPortal.SiteLogHistory));
                    objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
                }
            }
        }
        private void PurgeSiteLog_Renamed()
        {
            SiteLogController objSiteLog = new SiteLogController();

            PortalController objPortals = new PortalController();
            ArrayList arrPortals = objPortals.GetPortals();
            PortalInfo objPortal;
            DateTime PurgeDate;

            int intIndex;
            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                if (objPortal.SiteLogHistory > 0)
                {
                    PurgeDate = DateAndTime.DateAdd(DateInterval.Day, -(objPortal.SiteLogHistory), DateTime.Now);
                    objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
                }
            }
        }
Beispiel #8
0
        private void PurgeSiteLog_Renamed()
        {
            SiteLogController objSiteLog = new SiteLogController();

            PortalController objPortals = new PortalController();
            ArrayList        arrPortals = objPortals.GetPortals();
            PortalInfo       objPortal;
            DateTime         PurgeDate;

            int intIndex;

            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                if (objPortal.SiteLogHistory > 0)
                {
                    PurgeDate = DateAndTime.DateAdd(DateInterval.Day, -(objPortal.SiteLogHistory), DateTime.Now);
                    objSiteLog.DeleteSiteLog(PurgeDate, objPortal.PortalID);
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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");
                        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 = "";
                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.GetCurrentUserInfo();
                objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, urlReferrer, Request.Url.ToString(),
                                       Request.UserAgent, Request.UserHostAddress, Request.UserHostName,
                                       PortalSettings.ActiveTab.TabID, affiliateId, intSiteLogBuffer,
                                       strSiteLogStorage);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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();
            }
        }
        /// <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 );
            }
        }