Пример #1
0
 public static void RecordTimeline(ITimelineService service, BrowsingHistory browsingHistory)
 {
     if (service.VerifyRationality(browsingHistory))
     {
         service.Insert(browsingHistory);
     }
 }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BrowsingHistroyID,UserName,ProductID,Viewed")] BrowsingHistory browsingHistory)
        {
            if (id != browsingHistory.BrowsingHistroyID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(browsingHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BrowsingHistoryExists(browsingHistory.BrowsingHistroyID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductName", browsingHistory.ProductID);
            return(View(browsingHistory));
        }
Пример #3
0
 public static void RecordTimelineInternal(BrowsingHistory browsingHistory)
 {
     RecordTimeline(BrowsingHistoryAccessor.GlobalLifeTimeScope, browsingHistory);
     if (CheckWindowsVersion())
     {
         RecordTimeline(WindowsUserActivityManager.GlobalLifeTimeScope, browsingHistory);
     }
Пример #4
0
        //To delete the customer recently viewed books
        public ActionResult Delete(int BookId)
        {
            BrowsingHistory history = _db.BrowsingHistory.Where(m => m.BookID == BookId).FirstOrDefault();

            _db.BrowsingHistory.Remove(history);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 private static FavoriteSpotlight FromBrowsingHistory(BrowsingHistory history)
 {
     return(new FavoriteSpotlight
     {
         SpotlightArticleId = history.BrowseObjectId,
         SpotlightThumbnail = history.BrowseObjectThumbnail,
         SpotlightTitle = history.BrowseObjectState
     });
 }
Пример #6
0
        public ReferenceLister(Workspace workspace, Options options,
                               CommandRepository commandRepository)
            : base(workspace, options, commandRepository)
        {
            Items            = new ObservableCollection <ReferenceItem>();
            Title            = PathName = ProtocolPrefix;
            PropertyChanged += ReferenceLister_PropertyChanged;

            History = new BrowsingHistory();
        }
Пример #7
0
 public FileLister(Workspace workspace, Options options,
                   CommandRepository commandRepository)
     : base(workspace, options, commandRepository)
 {
     Title    = "Files";
     History  = new BrowsingHistory();
     _watcher = new FilesystemChangeWatcher(this);
     _watcher.Register();
     _itemProvider = new FileItemProvider(workspace);
     PathChanged  += FileLister_PathChanged;
 }
Пример #8
0
        public void Insert(BrowsingHistory browsingHistory)
        {
            // we can simply consider the browsing histories as a double-ended queue with limited capacity, we will pop the oldest one
            // and insert a new one if the Deque is full
            if (_delegation.Count >= _stackLimit)
            {
                _delegation.Remove(_delegation.Last());
            }

            _delegation.Insert(0, browsingHistory);
        }
Пример #9
0
        public bool VerifyRationality(BrowsingHistory browsingHistory)
        {
            // if current browsing history list has elements
            if (_delegation.Any())
            {
                var prev = _delegation[0];
                // check if the last one in the browsing history list is the same as the one to be insert, return false if so
                if (prev.Type == browsingHistory.Type && prev.BrowseObjectId == browsingHistory.BrowseObjectId)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #10
0
        public ApplicationViewModel()
        {
            RequestFactory = new RestRequestFactory();
            RestClient     = new RestClient("http://164.132.63.49/musicdb/api");
            var jsonSerializer = NewtonsoftJsonSerializer.Default;

            RestClient.AddHandler("application/json", jsonSerializer);
            RestClient.AddHandler("text/json", jsonSerializer);
            RestClient.AddHandler("text/x-json", jsonSerializer);
            RestClient.AddHandler("text/javascript", jsonSerializer);
            RestClient.AddHandler("*+json", jsonSerializer);

            History = new BrowsingHistory(this);
            //dataProvider = new BackendResponseDataProvider();
            //CurrentViewModel = new HomeViewModel(this, dataProvider);
            CurrentViewModel = new LoginViewModel(this, dataProvider);
        }
Пример #11
0
        public void Insert(BrowsingHistory browsingHistory)
        {
            if (delegation.Count >= stackLimit)
            {
                delegation.Remove(delegation.Last());
            }

            if (delegation.Any())
            {
                var prev = delegation[0];
                if (prev.Type == browsingHistory.Type && prev.BrowseObjectId == browsingHistory.BrowseObjectId)
                {
                    return;
                }
            }

            delegation.Insert(0, browsingHistory);
        }
Пример #12
0
        public async void Insert(BrowsingHistory browsingHistory)
        {
            var userActivityChannel = UserActivityChannel.GetDefault();
            var model = await GetPixevalTimelineModel(browsingHistory);

            var userActivity = await userActivityChannel.GetOrCreateUserActivityAsync($"Pixeval-{model.Id}-{DateTime.Now:s}");

            userActivity.VisualElements.DisplayText            = model.Title;
            userActivity.VisualElements.Content                = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(BuildAdaptiveCard(model));
            userActivity.VisualElements.Attribution            = new UserActivityAttribution(_iconUri);
            userActivity.VisualElements.AttributionDisplayText = "Pixeval";
            userActivity.ActivationUri = new Uri(browsingHistory.Type switch
            {
                "illust" => $"pixeval://www.pixiv.net/artworks/{model.Id}",
                "user" => $"pixeval://www.pixiv.net/users/{model.Id}",
                "spotlight" => $"pixeval://www.pixivision.net/en/a/{model.Id}",
                _ => throw new ArgumentException(nameof(browsingHistory.Type))
            });
Пример #13
0
        public async Task Create(int ProductID)
        {
            DateTime        time     = DateTime.Now;
            BrowsingHistory browsing = new BrowsingHistory
            {
                UserName = User.Identity.Name,

                ApplicationUser = _context.ApplicationUser.FirstOrDefault(x => x.UserName == User.Identity.Name),
                //System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                ProductID = ProductID,
                Viewed    = time
            };

            if (ModelState.IsValid)
            {
                _context.BrowsingHistory.Add(browsing);
                await _context.SaveChangesAsync();
            }
        }
Пример #14
0
        // GET: BookInformation
        public ActionResult Details(int?Id)
        {
            Book book = _db.Book.Find(Id);

            if (book.Status > 1 && book.Quantity == 0)
            {
                return(View(book));
            }
            else
            if (User != null && User.Identity.IsAuthenticated == true && User.Role.ToUpper().Equals("CUSTOMER"))
            {
                BrowsingHistory bh = new BrowsingHistory();
                bh.CustomerID = User.CustomerId;
                bh.BookID     = book.Id;
                bh.Date       = DateTime.Now;
                bh.Price      = book.UnitPrice;
                this._db.BrowsingHistory.Add(bh);
                this._db.SaveChanges();
                return(View(book));
            }
            return(View(book));
        }
        public async Task AddPageToWebBrowsingHistory(string username, string userId, string pageUrl, string userAgent)
        {
            try
            {
                BrowsingHistory browsingHistory = new BrowsingHistory()
                {
                    DateTimeServer = DateTime.Now,
                    DateTimeUtc    = DateTime.UtcNow,
                    PageUrl        = pageUrl,
                    UserAgent      = userAgent,
                    UserId         = userId,
                    Username       = username
                };

                unitOfWork.BrowsingHistoryRepository.Create(browsingHistory);
                await unitOfWork.SaveChangesAsync();
            }
            catch (Exception e)
            {
                await LogError("AddPageToWebBrowsingHistory", e);

                Trace.TraceError(string.Format("AddPageToWebBrowsingHistory error: {0}", e.Message));
            }
        }
Пример #16
0
 public bool VerifyRationality(BrowsingHistory browsingHistory)
 {
     return(true);
 }
Пример #17
0
        private void SetSession()
        {
            //CREATE NEW USER SESSION
            //Check if we are loading home page for the first time
            User objUser;

            //Check Session
            if (Session["sess_User_landing"] == null)
            {
                newSession = true;
                 objUser = new User();
            }
            else
            {
                objUser = (User)Session["sess_User_landing"];
            }

            #region //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check gallery preference
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery)))
                {
                    //Store to session
                    objUser.ShowGallery = CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery) == "Y" ? true : false;
                }

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    //Interorgate the request 'Do Not Track' settings.
                    HttpContext objContext = HttpContext.Current;
                    bool headerDoNotTrack = false;

                    if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
                    {
                        headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
                    }

                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }

                //Set Browsing History-User is coming to page for the first time

                string fullQueryString = Request.QueryString.ToString();

                BrowsingHistory browsingHistory = new BrowsingHistory();
                if (!string.IsNullOrEmpty(WebUtil.GetQueryString("_profile")))
                {
                    browsingHistory.LandingProfile = WebUtil.GetQueryString("_profile");
                }
                if (!string.IsNullOrEmpty(WebUtil.GetQueryString("_region")))
                {
                    browsingHistory.LandingRegion = WebUtil.GetQueryString("_region");
                }
                if (!string.IsNullOrEmpty(WebUtil.GetQueryString("_clubId")))
                {
                    browsingHistory.LandingClubID = WebUtil.GetQueryString("_clubId");

                    if (currentItem.InnerItem.TemplateID.ToString() == LandingPageItem.TemplateId)
                    {
                        //Get the enquiry page for this item
                        LandingEnquiryItem enquiryPage = currentItem.InnerItem.Axes.SelectSingleItem(String.Format("descendant::*[@@tid='{0}']", LandingEnquiryItem.TemplateId));

                        //Redirect to the enquiry page
                        Response.Redirect(Sitecore.Links.LinkManager.GetItemUrl(enquiryPage) + "?" + fullQueryString);
                    }
                }

                UrlOptions options = new UrlOptions();

                browsingHistory.LandingPageUrl = Sitecore.Links.LinkManager.GetItemUrl(currentItem);

                objUser.BrowsingHistory = browsingHistory;

                Session["sess_User_landing"] = objUser;

            }
            else
            {
                if (!String.IsNullOrEmpty(WebUtil.GetQueryString("_clubId")) && objUser.BrowsingHistory.LandingClubID != WebUtil.GetQueryString("_clubId"))
                {
                    objUser.BrowsingHistory.LandingClubID = WebUtil.GetQueryString("_clubId");
                }
                if (!String.IsNullOrEmpty(WebUtil.GetQueryString("_profile")) && objUser.BrowsingHistory.LandingProfile != WebUtil.GetQueryString("_profile"))
                {
                    objUser.BrowsingHistory.LandingProfile = WebUtil.GetQueryString("_profile");
                }
                if (!String.IsNullOrEmpty(WebUtil.GetQueryString("_region")) && objUser.BrowsingHistory.LandingRegion != WebUtil.GetQueryString("_region"))
                {
                    objUser.BrowsingHistory.LandingRegion = WebUtil.GetQueryString("_region");
                }

                Session["sess_User_landing"] = objUser;
            }
            #endregion

            //DEFAULT PREFERENCES
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //Save session
            Session["sess_User_landing"] = objUser;
        }
Пример #18
0
 public BrowsingHistoryViewModel(BrowsingHistory history)
 {
     DateTimeUtc = history.DateTimeUtc.ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
     PageUrl     = history.PageUrl;
     UserAgent   = history.UserAgent;
 }