Ejemplo n.º 1
0
        public void TryInstallDemoContent()
        {
            if (session.Query <NoteWithCategories>().Any())
            {
                return;
            }

            var newNotes = DemoContent.GetNodesWithCategories("Redis", () => null);

            foreach (var newNote in newNotes)
            {
                session.Store(newNote);
            }

            session.SaveChanges();

            var newCategories = DemoContent.GetCategories(() => null);

            foreach (var newCategory in newCategories)
            {
                session.Store(newCategory);
            }

            session.SaveChanges();
        }
        private static void InitializeReferrer(DemoContent demoContent, TrackerData trackerData)
        {
            Uri referrerUri;

            if (!Uri.TryCreate(demoContent.Referrer, UriKind.Absolute, out referrerUri))
            {
                referrerUri = null;
            }
            trackerData.Referrer = referrerUri;
        }
        private static void InitializeIpAddress(DemoContent demoContent, TrackerData trackerData)
        {
            IPAddress address;

            if (!IPAddress.TryParse(demoContent.IpAddress, out address))
            {
                address = null;
            }
            trackerData.IpAddress = address;
        }
Ejemplo n.º 4
0
        public ActionResult DemoContent()
        {
            var item = RenderingContext.Current?.Rendering?.Item ?? RenderingContext.Current?.ContextItem;

            if (item == null || !item.IsDerived(Templates.DemoContent.ID))
            {
                throw new InvalidDataSourceItemException($"Item should be not null and derived from {nameof(Templates.DemoContent)} {Templates.DemoContent.ID} template");
            }

            var demoContent = new DemoContent(item);

            return(this.View("DemoContent", demoContent));
        }
        private static TrackerData CreateTrackerData()
        {
            if (Sitecore.Context.Item == null || !Sitecore.Context.Item.IsDerived(Templates.DemoContent.ID))
            {
                return(null);
            }

            var demoContent = new DemoContent(Sitecore.Context.Item);
            var trackerData = new TrackerData();

            InitializeReferrer(demoContent, trackerData);
            InitializeIpAddress(demoContent, trackerData);
            InitializeGeoData(demoContent, trackerData);
            return(trackerData);
        }
Ejemplo n.º 6
0
        public void TryInstallDemoContent()
        {
            if (notes.Count() > 0)
            {
                return;
            }

            var newNotes = DemoContent.GetNodesWithCategories("MongoDB", () => null);

            notes.InsertBatch(newNotes);

            var newCategories = DemoContent.GetCategories(() => null);

            categories.InsertBatch(newCategories);
        }
Ejemplo n.º 7
0
        public void TryInstallDemoContent()
        {
            using (var notes = redisClient.GetTypedClient <NoteWithCategories>())
            {
                if (redisClient.ContainsKey("urn:notewithcategories:1"))
                {
                    return;
                }

                var newNotes = DemoContent.GetNodesWithCategories("Redis", () => notes.GetNextSequence().AsString());
                notes.StoreAll(newNotes);
            }

            using (var categories = redisClient.GetTypedClient <Category>())
            {
                var newCategories = DemoContent.GetCategories(() => categories.GetNextSequence().AsString());
                categories.StoreAll(newCategories);
            }
        }
 private static void InitializeGeoData(DemoContent demoContent, TrackerData trackerData)
 {
     trackerData.GeoData = demoContent.GeoData;
 }