protected void Page_Load(object sender, EventArgs e) { _UserId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); if (!Page.IsPostBack) { IList <PageView> pageViews = PageViewDataSource.LoadForUser(_UserId, 30, 0, "ActivityDate DESC"); ViewsGrid.DataSource = pageViews; ViewsGrid.DataBind(); CompleteHistoryLink.Visible = pageViews.Count > 0; CompleteHistoryLink.NavigateUrl = "~/Admin/Reports/CustomerHistory.aspx?UserId=" + _UserId.ToString(); } }
private void drawChart() { //GET THE TOP 4 BROWSERS BY VIEW SortableCollection <KeyValuePair <string, int> > topBrowsers = PageViewDataSource.GetViewsByBrowser(4, 0, "ViewCount DESC, Browser ASC"); if (topBrowsers.Count > 0) { //FIND OUT HOW MANY VIEWS TOTAL int totalPageViews = PageViewDataSource.CountAll(); int pageViewsCharted = 0; //List<double> viewCounts = new double[topBrowsers.Count]; //string[] browserNames = new string[topBrowsers.Count]; List <int> viewCounts = new List <int>(); List <string> browserNames = new List <string>(); foreach (KeyValuePair <string, int> browserView in topBrowsers) { browserNames.Add(browserView.Key); viewCounts.Add(browserView.Value); pageViewsCharted += browserView.Value; } if (pageViewsCharted < totalPageViews) { //NEED TO ADD AN "OTHER" PIE SLICE browserNames.Add("Other"); viewCounts.Add(totalPageViews - pageViewsCharted); } //BUILD BAR CHART BrowserChart.Series["Browsers"].Points.Clear(); for (int i = 0; i < topBrowsers.Count; i++) { DataPoint point = new DataPoint(BrowserChart.Series["Browsers"]); point.SetValueXY(browserNames[i], new object[] { viewCounts[i] }); BrowserChart.Series["Browsers"].Points.Add(point); } BrowserChart.DataBind(); } else { //NO CATEGORIES HAVE BEEN VIEWED YET OR PAGE TRACKING IS NOT AVAIALBEL this.Controls.Clear(); Panel noViewsPanel = new Panel(); noViewsPanel.CssClass = "emptyData"; Label noViewsMessage = new Label(); noViewsMessage.Text = "No categories have been viewed or page tracking is disabled."; noViewsPanel.Controls.Add(noViewsMessage); this.Controls.Add(noViewsPanel); } }
protected void Page_Load(object sender, System.EventArgs e) { _Settings = AbleContext.Current.Store.Settings; if (!Page.IsPostBack) { TrackPageViews.Checked = _Settings.PageViewTrackingEnabled; HistoryLength.Text = _Settings.PageViewTrackingDays.ToString(); CurrentRecords.Text = PageViewDataSource.CountAll().ToString(); SaveArchive.SelectedIndex = (_Settings.PageViewTrackingSaveArchive ? 1 : 0); SaveArchiveWarningPanel.Visible = (SaveArchive.SelectedIndex == 1); GoogleUrchinId.Text = _Settings.GoogleUrchinId; EnablePageTracking.Checked = _Settings.EnableGoogleAnalyticsPageTracking; EnableEcommerceTracking.Checked = _Settings.EnableGoogleAnalyticsEcommerceTracking; ActivityDateUpdateInterval.Text = _Settings.ActivityDateUpdateInterval.ToString(); } ResponseMessageGA.Visible = false; ResponseMessage.Visible = false; }
protected void ExportByViewsButton_Click(Object sender, EventArgs e) { GenericExportManager <CategoryViewSummary> exportManager = GenericExportManager <CategoryViewSummary> .Instance; GenericExportOptions <CategoryViewSummary> options = new GenericExportOptions <CategoryViewSummary>(); options.CsvFields = new string[] { "CategoryName", "Views" }; SortableCollection <KeyValuePair <ICatalogable, int> > categoryViews = PageViewDataSource.GetViewsByCategory("ViewCount DESC"); // CONVERT TO SUMMARY LIST TO GENERATE CSV IList <CategoryViewSummary> viewsSummay = new List <CategoryViewSummary>(); foreach (KeyValuePair <ICatalogable, int> dataRow in categoryViews) { viewsSummay.Add(new CategoryViewSummary(dataRow.Key.Name, dataRow.Value)); } options.ExportData = viewsSummay; options.FileTag = "POPULAR_CATEGORIES_BY_VIEWS"; exportManager.BeginExport(options); }
protected void ExportByViewsButton_Click(Object sender, EventArgs e) { GenericExportManager <ProductViewSummary> exportManager = GenericExportManager <ProductViewSummary> .Instance; GenericExportOptions <ProductViewSummary> options = new GenericExportOptions <ProductViewSummary>(); options.CsvFields = new string[] { "ProductName", "Views" }; CacheWrapper cacheWrapper = Cache[_ViewsCacheKey] as CacheWrapper; SortableCollection <KeyValuePair <ICatalogable, int> > productViews; Dictionary <string, object> viewsDataWrapper = null; IList <ProductViewSummary> viewsSummay = new List <ProductViewSummary>(); if (cacheWrapper == null) { //GET VIEWS productViews = PageViewDataSource.GetViewsByProduct(50, 0, "ViewCount DESC"); //CACHE THE DATA viewsDataWrapper = new Dictionary <string, object>(); viewsDataWrapper["DataSource"] = productViews; cacheWrapper = new CacheWrapper(viewsDataWrapper); Cache.Remove(_ViewsCacheKey); Cache.Add(_ViewsCacheKey, cacheWrapper, null, DateTime.UtcNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, null); } else { //USE CACHED VALUES viewsDataWrapper = (Dictionary <string, object>)cacheWrapper.CacheValue; productViews = (SortableCollection <KeyValuePair <ICatalogable, int> >)viewsDataWrapper["DataSource"]; } // CONVERT TO SUMMARY LIST TO GENERATE CSV foreach (KeyValuePair <ICatalogable, int> dataRow in productViews) { viewsSummay.Add(new ProductViewSummary(dataRow.Key.Name, dataRow.Value)); } options.ExportData = viewsSummay; options.FileTag = "POPULAR_PRODUCTS_BY_VIEWS"; exportManager.BeginExport(options); }
private void initMonthChart() { string cacheKey = "69F41EE8-327B-401c-BE1A-A2F9208BC257"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (cacheWrapper == null) { //LOAD VIEWS SortableCollection <KeyValuePair <int, int> > viewsByMonth = PageViewDataSource.GetViewsByMonth(true); //CREATE CHART ViewsByMonthChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByMonth.Count; i++) { DataPoint point = new DataPoint(ViewsByMonthChart.Series["Views"]); point.SetValueXY(viewsByMonth[i].Key.ToString(), new object[] { viewsByMonth[i].Value }); ViewsByMonthChart.Series["Views"].Points.Add(point); } ViewsByMonthChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(viewsByMonth); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { //USE CACHED VALUES SortableCollection <KeyValuePair <int, int> > viewsByMonth = (SortableCollection <KeyValuePair <int, int> >)cacheWrapper.CacheValue; //CREATE CHART ViewsByMonthChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByMonth.Count; i++) { DataPoint point = new DataPoint(ViewsByMonthChart.Series["Views"]); point.SetValueXY(viewsByMonth[i].Key.ToString(), new object[] { viewsByMonth[i].Value }); ViewsByMonthChart.Series["Views"].Points.Add(point); } ViewsByMonthChart.DataBind(); } ViewsByMonthChart.ChartAreas[0].AxisX.Interval = 1; }
protected void Page_Load(object sender, EventArgs e) { phCaption.Text = this.Caption; int userId = AbleContext.Current.UserId; if (userId != 0) { IList <Product> products = PageViewDataSource.GetRecentlyViewedProducts(userId, this.MaxItems, 0, "ActivityDate DESC"); if (products.Count > 0) { ProductList.RepeatColumns = Columns; ProductList.DataSource = products; ProductList.DataBind(); } else { phContent.Visible = false; } } else { phContent.Visible = false; } }
private void initViewsChart() { string cacheKey = "242003F5-5A58-44e9-BFB0-C077C6BEDBF2"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; Dictionary <string, object> viewsData; if (cacheWrapper == null) { //GET VIEWS SortableCollection <KeyValuePair <ICatalogable, int> > productViews = PageViewDataSource.GetViewsByProduct(8, 0, "ViewCount DESC"); if (productViews.Count > 0) { //BUILD BAR CHART ViewsChart1.Series["Views"].Points.Clear(); for (int i = 0; i < productViews.Count; i++) { DataPoint point = new DataPoint(ViewsChart1.Series["Views"]); point.SetValueXY(((ICatalogable)productViews[i].Key).Name, new object[] { productViews[i].Value }); ViewsChart1.Series["Views"].Points.Add(point); } ViewsChart1.DataBind(); //BIND THE DATA GRID ViewsGrid.DataSource = productViews; ViewsGrid.DataBind(); //CACHE THE DATA viewsData = new Dictionary <string, object>(); viewsData["DataSource"] = productViews; cacheWrapper = new CacheWrapper(viewsData); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, null); } else { //NO PRODUCTS HAVE BEEN VIEWED YET OR PAGE TRACKING IS DISABLED Control container = ViewsChart1.Parent; container.Controls.Clear(); Panel noViewsPanel = new Panel(); noViewsPanel.CssClass = "emptyData"; Label noViewsMessage = new Label(); noViewsMessage.Text = "No products have been viewed yet or page tracking is disabled."; noViewsPanel.Controls.Add(noViewsMessage); container.Controls.Add(noViewsPanel); // REMOVE VIEWS DATA TAB Tabs.Tabs[3].Visible = false; } } else { //USE CACHED VALUES viewsData = (Dictionary <string, object>)cacheWrapper.CacheValue; SortableCollection <KeyValuePair <ICatalogable, int> > productViews = (SortableCollection <KeyValuePair <ICatalogable, int> >)viewsData["DataSource"]; //BUILD BAR CHART ViewsChart1.Series["Views"].Points.Clear(); for (int i = 0; i < productViews.Count; i++) { DataPoint point = new DataPoint(ViewsChart1.Series["Views"]); point.SetValueXY(((ICatalogable)productViews[i].Key).Name, new object[] { productViews[i].Value }); ViewsChart1.Series["Views"].Points.Add(point); } ViewsChart1.DataBind(); ViewsGrid.DataSource = productViews; ViewsGrid.DataBind(); } }
private void initViewChart(bool forceRefresh) { string cacheKey = "3C26BAC7-1D53-40ef-920B-5BDB705F363B"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (forceRefresh || (cacheWrapper == null)) { SortableCollection <KeyValuePair <ICatalogable, int> > categoryViews = PageViewDataSource.GetViewsByCategory(_Size, 0, "ViewCount DESC"); if (categoryViews.Count > 0) { //BUILD BAR CHART ViewsChart.Series["Views"].Points.Clear(); for (int i = 0; i < categoryViews.Count; i++) { DataPoint point = new DataPoint(ViewsChart.Series["Views"]); point.SetValueXY(categoryViews[i].Key.Name, new object[] { categoryViews[i].Value }); ViewsChart.Series["Views"].Points.Add(point); } ViewsChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(categoryViews); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { //NO CATEGORIES HAVE BEEN VIEWED YET OR PAGE TRACKING IS NOT AVAIALBEL this.Controls.Clear(); Panel noViewsPanel = new Panel(); noViewsPanel.CssClass = "emptyData"; Label noViewsMessage = new Label(); noViewsMessage.Text = "No categories have been viewed or page tracking is disabled."; noViewsPanel.Controls.Add(noViewsMessage); this.Controls.Add(noViewsPanel); } } else { //USE CACHED VALUES SortableCollection <KeyValuePair <ICatalogable, int> > categoryViews = (SortableCollection <KeyValuePair <ICatalogable, int> >)cacheWrapper.CacheValue; //BUILD BAR CHART ViewsChart.Series["Views"].Points.Clear(); for (int i = 0; i < categoryViews.Count; i++) { DataPoint point = new DataPoint(ViewsChart.Series["Views"]); point.SetValueXY(categoryViews[i].Key.Name, new object[] { categoryViews[i].Value }); ViewsChart.Series["Views"].Points.Add(point); } ViewsChart.DataBind(); ViewsGrid.DataSource = categoryViews; ViewsGrid.DataBind(); } DateTime cacheDate = (cacheWrapper != null) ? cacheWrapper.CacheDate : LocaleHelper.LocalNow; CacheDate1.Text = string.Format(CacheDate1.Text, cacheDate); CacheDate2.Text = string.Format(CacheDate2.Text, cacheDate); }
/// <summary> /// Migrates data such as profile settings and basket contents from one user to another. /// </summary> /// <param name="oldUser">The user that provides the source data.</param> /// <param name="newUser">The user to receive the data.</param> /// <param name="includeOrderData">If true, order history and address book are migrated.</param> /// <param name="isNewUserAccount">If true, newUser represents an account just created.</param> public static void Migrate(User oldUser, User newUser, bool includeOrderData, bool isNewUserAccount) { //FAIL MIGRATION IF REQUIRED PARAMETERS MISSING if (oldUser == null) { throw new ArgumentNullException("oldUser"); } if (newUser == null) { throw new ArgumentNullException("newUser"); } //ONLY MIGRATE IF USERID DOES NOT MATCH if (oldUser.UserId != newUser.UserId) { //MIGRATE AFFILIATE SETTINGS if (oldUser.Affiliate != null && oldUser.AffiliateId != newUser.AffiliateId) { // A VALID AFFILIATE WAS SET ON THE OLD USER AND IS NOT THE ONE ASSOCIATED WITH NEW USER // SHOULD WE UPDATE THE USER? StoreSettingCollection settings = Store.GetCachedSettings(); if (isNewUserAccount || settings.AffiliateReferralRule == ReferralRule.NewSignupsOrExistingUsersOverrideAffiliate || (settings.AffiliateReferralRule == ReferralRule.NewSignupsOrExistingUsersNoOverride && newUser.AffiliateId == 0)) { // EITHER A NEW SIGNUP // OR THE RULE IS TO ALWAYS OVERRIDE // OR AN EXISTING USER WITH NO AFFILIATE SET WITH EXISTING USERS NO OVERRIDE OPTION // AFFILIATE SHOULD BE UPDATED FOR THE TARGET USER newUser.AffiliateId = oldUser.AffiliateId; newUser.AffiliateReferralDate = oldUser.AffiliateReferralDate; } // UPDATE USERS WITH NEW AFFILIATE ASSOCIATIONS newUser.Save(); oldUser.AffiliateId = 0; oldUser.AffiliateReferralDate = DateTime.MinValue; oldUser.Save(); } //TRANSFER BASKET IF NEEDED Basket.Transfer(oldUser.UserId, newUser.UserId); Wishlist.Transfer(oldUser.UserId, newUser.UserId); // TRANSFER PAGE VIEW HISTORY PageViewDataSource.UpdateUser(oldUser.UserId, newUser.UserId); //SHOULD WE TRANSFER ORDER DATA? if (includeOrderData) { //REASSIGN ORDERS AND ADDRESSES TO NEW USER OrderDataSource.UpdateUser(oldUser.UserId, newUser.UserId); AddressDataSource.UpdateUser(oldUser.UserId, newUser.UserId); } else if (oldUser.IsAnonymous) { //BUG 7740, ERASE ANY ADDRESS INFO ASSOCIATED WITH ANON ACCOUNT oldUser.Addresses.DeleteAll(); oldUser.PrimaryAddressId = 0; oldUser.Save(); } } }
private void initLast24HourChart() { string cacheKey = "15B642D6-FB16-4027-989C-6F40FA821A73"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (cacheWrapper == null) { //LOAD VIEWS SortableCollection <KeyValuePair <int, int> > viewsByHour = PageViewDataSource.GetViewsByHour(true, DateTime.UtcNow.AddHours(-24)); //RESULTS ARE SORTED FROM 0 (MIDNIGHT) TO 23 (11PM) int thisHour = LocaleHelper.LocalNow.Hour; //SHIFT SO IT GOES FOR PAST 24 HOURS for (int i = 0; i <= thisHour; i++) { KeyValuePair <int, int> tempCount = viewsByHour[0]; viewsByHour.RemoveAt(0); viewsByHour.Add(tempCount); } //CREATE CHART Last24HoursChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(Last24HoursChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); Last24HoursChart.Series["Views"].Points.Add(point); } Last24HoursChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(viewsByHour); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { SortableCollection <KeyValuePair <int, int> > viewsByHour = (SortableCollection <KeyValuePair <int, int> >)cacheWrapper.CacheValue; //CREATE CHART Last24HoursChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(Last24HoursChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); Last24HoursChart.Series["Views"].Points.Add(point); } Last24HoursChart.DataBind(); } Last24HoursChart.ChartAreas[0].AxisX.Interval = 1; }
private void initHourChart() { string cacheKey = "59A0ABAC-9204-49ab-A333-85340024E802"; CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper; if (cacheWrapper == null) { //LOAD VIEWS SortableCollection <KeyValuePair <int, int> > viewsByHour = PageViewDataSource.GetViewsByHour(true); //RESULTS ARE SORTED FROM 0 (MIDNIGHT) TO 23 (11PM) //SHIFT SO IT GOES FROM 6AM TO 5AM INSTEAD for (int i = 0; i < 6; i++) { KeyValuePair <int, int> tempCount = viewsByHour[0]; viewsByHour.RemoveAt(0); viewsByHour.Add(tempCount); } //CREATE CHART ViewsByHourChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(ViewsByHourChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); ViewsByHourChart.Series["Views"].Points.Add(point); } ViewsByHourChart.DataBind(); //CACHE THE DATA cacheWrapper = new CacheWrapper(viewsByHour); Cache.Remove(cacheKey); Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null); } else { //USE CACHED VALUES SortableCollection <KeyValuePair <int, int> > viewsByHour = (SortableCollection <KeyValuePair <int, int> >)cacheWrapper.CacheValue; //CREATE CHART ViewsByHourChart.Series["Views"].Points.Clear(); for (int i = 0; i < viewsByHour.Count; i++) { string dayName; int hour = viewsByHour[i].Key; if (hour == 0) { dayName = "12a"; } else if (hour == 12) { dayName = "12p"; } else if (hour > 12) { hour -= 12; dayName = hour.ToString() + "p"; } else { dayName = hour.ToString() + "a"; } DataPoint point = new DataPoint(ViewsByHourChart.Series["Views"]); point.SetValueXY(dayName, new object[] { viewsByHour[i].Value }); ViewsByHourChart.Series["Views"].Points.Add(point); } ViewsByHourChart.DataBind(); } ViewsByHourChart.ChartAreas[0].AxisX.Interval = 1; }
protected void ClearButton_Click(object sender, EventArgs e) { PageViewDataSource.DeleteAll(); CurrentRecords.Text = PageViewDataSource.CountAll().ToString(); }