예제 #1
0
        /// <summary>
        /// Loads current TargetedCOntent COnfiguration and populates RuleSets.
        /// </summary>
        /// <returns></returns>
        private TargetedContentData LoadTargetConfigurationData()
        {
            //if (TargetConfigurationId == 0)
            //{
            //    if (Session[Page.ClientID + "_TargetConfigurationId"] != null)
            //    {
            //        long targetId = 0;
            //        long.TryParse(Session[Page.ClientID + "_TargetConfigurationId"].ToString(), out targetId);
            //        TargetConfigurationId = targetId;
            //    }
            //}

            if (_targetedContent == null)
            {
                _targetedContent = GetTargetConfiguration(TargetConfigurationId);
            }

            if (_targetedContent != null)
            {
                if (Rulesets == null)
                {
                    Rulesets = new List<string>();
                }

                if (RulesetNames == null)
                {
                    RulesetNames = new List<string>();
                }

                Rulesets.Clear();
                RulesetNames.Clear();
                _targetedContent.Segments.ForEach(delegate(SegmentData p)
                {
                    Rulesets.Add(p.ToJson());
                    RulesetNames.Add(p.Name);
                });
            }

            return _targetedContent;
        }
예제 #2
0
        /// <summary>
        /// Gets the persona definition for the supplied ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private TargetedContentData GetTargetConfiguration(long targetContentId)
        {
            TargetedContentData tc = null;

            if (targetContentId > 0)
            {
                tc = TargetContentManager.GetItem(targetContentId);
            }
            if (tc == null)
            {
                //New target Content Data
                tc = new TargetedContentData();
                SegmentData p = new SegmentData() { };

                tc.PageData = new PageData();//PageData.Restore(pageXml);
                tc.PageData.Zones = new List<DropZoneData>();
                tc.PageData.Zones.Add(new DropZoneData());
                tc.PageData.Zones[0].Columns = new List<ColumnDataSerialize>();
            }

            return tc;
        }
예제 #3
0
        /// <summary>
        /// Loads TargetContent Property based on legact widget properties
        /// </summary>
        private void LoadLegacyWidget()
        {
            //this is an upgraded version of the widget.
            //Load New TargetContent data object from legacy properties

            _targetedContent = new TargetedContentData();
            SegmentData p = new SegmentData() { };

            _targetedContent.PageData = new PageData();
            _targetedContent.PageData.Zones = new List<DropZoneData>();
            _targetedContent.PageData.Zones.Add(new DropZoneData());
            _targetedContent.PageData.Zones[0].Columns = new List<ColumnDataSerialize>();
            SynchTargetConfiguration();

            for (int index = 0; index < Rulesets.Count; index++)
            {
                List<Rule> rules = Ektron.Newtonsoft.Json.JsonConvert.DeserializeObject<List<Rule>>(Rulesets[index]);
                if (rules == null)
                {
                    rules = new List<Rule>();
                }

                SegmentData segment = new SegmentData() { Name = RulesetNames[index] };
                segment.Rules = rules;
                _targetedContent.Segments.Add(segment);
            }
        }
예제 #4
0
        /// <summary>
        /// Saves the supplied TargetedContent Configuration.
        /// </summary>
        /// <param name="targetConfiguration"></param>
        public void SaveConfiguration(TargetedContentData targetConfiguration)
        {
            //update TargetedContentConfiguration properties with current widget configuration
            targetConfiguration.PageData.Zones[0].Columns = Ektron.Cms.PageBuilder.ColumnData.ConvertToColumnDataSerializeList(_currentColumns);

            //get list of child column Ids
            List<Guid> columnIdList = new List<Guid>();
            _currentColumns.ForEach(c => columnIdList.Add(c.Guid));

            //Get all widgets  that targeted content uses.
            Ektron.Cms.PageBuilder.PageBuilder pb = this.Page as Ektron.Cms.PageBuilder.PageBuilder;
            targetConfiguration.PageData.Widgets = pb.Pagedata.Widgets.FindAll(w => columnIdList.Contains(w.ColumnGuid));

            //remove targetcontent widgets from pagebuilder page.
            //they wil be added at runtime when the targeted content configuration is loaded.
            //targetConfiguration.PageData.Widgets.ForEach(w => pb.Pagedata.Widgets.Remove(w));

            if (targetConfiguration.Id == 0)
            {
                Criteria<TargetedContentProperty> criteria = new Criteria<TargetedContentProperty>();
                criteria.AddFilter(TargetedContentProperty.Name, CriteriaFilterOperator.Contains, targetConfiguration.Name);
                List<TargetedContentData> list = TargetContentManager.GetList(criteria);

                if (list.Count > 0)
                {
                    targetConfiguration.Name = string.Format("{0}({1})", targetConfiguration.Name, list.Count);
                }

                TargetContentManager.Add(targetConfiguration);
            }
            else
            {
                TargetContentManager.Update(targetConfiguration);
            }

            TargetConfigurationId = targetConfiguration.Id;
        }