private void ReportChildTreeDeletions(Data.Items.Item parentItem, List <XmlNode> manifestItems, Sitecore.Data.Database scDataBase, ManifestReportDataBase manifestReportDatabase)
        {
            var items = parentItem.GetChildren();

            items.ForEach(item =>
            {
                if (!manifestItems.Any(manifestItem => NormalizeGuid(manifestItem.Attributes["Id"].Value) == NormalizeGuid(item.ID.Guid)))
                {
                    manifestReportDatabase.Items.Add(new ManifestReportItem()
                    {
                        FullPath   = item.Paths.FullPath,
                        Id         = NormalizeGuid(item.ID.Guid),
                        UpdateType = "DEL"
                    });

                    logger.Info("[DELETE] " + item.Paths.FullPath + " " + NormalizeGuid(item.ID.Guid));
                    // report all decendants as deleted, as we know these are not kept.
                    ReportChildTreeDeletionsAsDeleted(item, manifestItems, scDataBase, manifestReportDatabase);
                }
                else
                {
                    // check any child nodes recursivly.
                    ReportChildTreeDeletions(item, manifestItems, scDataBase, manifestReportDatabase);
                }
            });
        }
Example #2
0
        public IEnumerable <MapPoint> GetAll(Data.Items.Item contextItem)
        {
            if (contextItem == null)
            {
                throw new ArgumentNullException(nameof(contextItem));
            }
            if (contextItem.DescendsFrom(Templates.MapPoint.ID))
            {
                return(new List <MapPoint>
                {
                    new MapPoint(contextItem)
                });
            }
            if (!contextItem.DescendsFrom(Templates.MapPointsFolder.ID))
            {
                throw new ArgumentException("Item must derive from MapPointsFolder or MapPoint", nameof(contextItem));
            }

            var searchService = this.searchServiceRepository.Get(new Foundation.Indexing.Models.SearchSettingsBase {
                Templates = new[] { Templates.MapPoint.ID }
            });

            searchService.Settings.Root = contextItem;

            return(searchService.FindAll().Results.Select(x => new MapPoint(x.Item)));
        }
 private static PublishOptions Options(Data.Items.Item rootItem, Database source, Database target, Language lang, PublishMode publishMode)
 {
     return(new PublishOptions(source, target, publishMode, lang, DateTime.Now)
     {
         RootItem = rootItem, Deep = true
     });
 }
        public void GetAll_WrongItemPassed_ShouldThrowException([Content] Data.Items.Item item)
        {
            var    repository = new MapPointRepository();
            Action a          = () => repository.GetAll(item);

            a.ShouldThrow <ArgumentException>();
        }
 public void ResolveItem([CanBeNull] Data.Items.Item sectionItem)
 {
     if (Item == null && sectionItem != null)
     {
         Item = sectionItem.Children[TemplateField.Name];
     }
 }
        public void GetAll_WrongItemPassed_ShouldThrowException([FakeDb.AutoFixture.Content] Data.Items.Item item, [Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
        {
            var    repository = new MapPointRepository(searchServiceRepository);
            Action a          = () => repository.GetAll(item);

            a.ShouldThrow <ArgumentException>();
        }
Example #7
0
        private static OutputMap CreateOutputMap(Data.Items.Item item, OutputMap parentMap)
        {
            var outputMap = new OutputMap();

            outputMap.ParentMap = parentMap;
            var outputMapCustomItem = new OutputMapTemplateItem(item);

            outputMap.TemplateId     = outputMapCustomItem.TargetTemplate.ID;
            outputMap.NameInputField = outputMapCustomItem.ItemNameField.Name;
            var fieldsCollection =
                item.Children.FirstOrDefault(c => c.InheritsFrom(OutputFieldCollectionItem.TemplateId));

            if (fieldsCollection != null)
            {
                foreach (var field in fieldsCollection.Children.Where(c => c.InheritsFrom(OutputFieldItem.TemplateId)))
                {
                    var fieldCustomItem = new OutputFieldItem(field);
                    outputMap.Fields.Add(new OutputField
                    {
                        SourceColumn    = fieldCustomItem.InputField.Name,
                        TargetFieldName = fieldCustomItem.Name
                    });
                }
            }
            if (!outputMap.Fields.Any())
            {
                outputMap.Fields.Add(new OutputField
                {
                    SourceColumn    = outputMap.NameInputField,
                    TargetFieldName = ""
                });
            }
            if (parentMap != null &&
                !outputMap.Fields.Any(f => f.SourceColumn == parentMap.NameInputField))
            {
                outputMap.Fields.Add(new OutputField
                {
                    SourceColumn    = parentMap.NameInputField,
                    TargetFieldName = ""
                });
            }

            var childMapItems = item.Children.Where(c => c.InheritsFrom(OutputMapTemplateItem.TemplateId));

            if (childMapItems != null &&
                childMapItems.Any())
            {
                foreach (var childMapItem in childMapItems)
                {
                    outputMap.ChildMaps.Add(CreateOutputMap(childMapItem, outputMap));
                }
            }

            return(outputMap);
        }
Example #8
0
        public override string GetItemUrl(Data.Items.Item item, UrlOptions options)
        {
            if (item != null)
            {
                return(BucketManager.IsItemContainedWithinBucket(item, Context.Database)
                           ? item.ShortUrl()
                           : base.GetItemUrl(item, options));
            }

            return(string.Empty);
        }
Example #9
0
 public Doctor(Data.Items.Item item)
 {
     Name       = item[Templates.Person.Fields.Name];
     Title      = item[Templates.Person.Fields.Title];
     Picture    = item[Templates.Person.Fields.Picture];
     Summary    = item[Templates.Person.Fields.Summary];
     Surname    = item[Templates.Person.Fields.Surname];
     Specialist = item[Templates.Doctor.Fields.Specialist];
     Activities = item[Templates.Doctor.Fields.Activities];
     Hospital   = item[Templates.Doctor.Fields.Hospital];
     ItemURL    = item.GetUrl();
 }
        private AnalyticsModel GetModel()
        {
            var item            = RenderingContext.Current.ContextItem;
            var credValue       = item.Fields["GoogleAnalytics_Credential_File"].GetValue(true);
            var viewId          = item.Fields["GoogleAnalytics_Analytics_ViewId"].GetValue(true);
            var applicationName = item.Fields["GoogleAnalytics_App_Name"].GetValue(true);
            var title           = item.Fields["GoogleAnalytics_Title"].GetValue(true);


            Data.Items.Item referencedDimensionItem = GetSelectedItemFromDroplistField(item, "GoogleAnalytics_Dimension");
            var             dimension = "";

            if (referencedDimensionItem != null)
            {
                dimension = referencedDimensionItem.Fields["Value"].GetValue(true);
            }

            Data.Items.Item referencedMetricsItem = GetSelectedItemFromDroplistField(item, "GoogleAnalytics_Metrics");
            var             metrics = "";
            var             alias   = "";

            if (referencedMetricsItem != null)
            {
                metrics = referencedMetricsItem.Fields["Expression"].GetValue(true);
                alias   = referencedMetricsItem.Fields["Alias"].GetValue(true);
            }

            Data.Items.Item referencedPeriodItem = GetSelectedItemFromDroplistField(item, "GoogleAnalytics_ReportPeriod");
            var             period = 0;

            if (referencedPeriodItem != null)
            {
                period = int.Parse(referencedPeriodItem.Fields["PeriodValue"].GetValue(true));
            }


            var credString = credValue;
            var credObject = JsonConvert.DeserializeObject <PersonalServiceAccountCred>(credValue);

            return(new AnalyticsModel
            {
                ApplicationName = applicationName,
                CredStr = credString,
                Credentials = credObject,
                ViewId = viewId,
                Title = title,
                Dimension = dimension,
                Metrics = metrics,
                Alias = alias,
                Period = period
            });
        }
        private string GetChartName()
        {
            var item = RenderingContext.Current.ContextItem;

            Data.Items.Item chartType  = GetSelectedItemFromDroplistField(item, "GoogleAnalytics_Charts");
            var             chartValue = "";

            if (chartType != null)
            {
                chartValue = chartType.Fields["Value"].GetValue(true);
            }
            return(chartValue);
        }
        private Data.Items.Item GetSelectedItemFromDroplistField(Data.Items.Item item, string fieldName)
        {
            Data.Fields.Field field = item.Fields[fieldName];
            if (field == null || string.IsNullOrEmpty(field.Value))
            {
                return(null);
            }

            var fieldSource      = field.Source ?? string.Empty;
            var selectedItemPath = fieldSource.TrimEnd('/') + "/" + field.Value;

            return(item.Database.GetItem(selectedItemPath));
        }
Example #13
0
        public void ResolveItem([CanBeNull] Data.Items.Item templateItem)
        {
            if (Item == null && templateItem != null)
            {
                Item = templateItem.Children[TemplateSection.Name];
            }

            if (Item == null)
            {
                return;
            }

            foreach (var field in Fields)
            {
                field.ResolveItem(Item);
            }
        }
        private void ReportChildTreeDeletionsAsDeleted(Data.Items.Item parentItem, List <XmlNode> manifestItems, Sitecore.Data.Database scDataBase, ManifestReportDataBase manifestReportDatabase)
        {
            var items = parentItem.GetChildren();

            items.ForEach(item =>
            {
                manifestReportDatabase.Items.Add(new ManifestReportItem()
                {
                    FullPath   = item.Paths.FullPath,
                    Id         = NormalizeGuid(item.ID.Guid),
                    UpdateType = "DEL"
                });

                logger.Info("[DELETE] " + item.Name + " " + NormalizeGuid(item.ID.Guid));
                ReportChildTreeDeletionsAsDeleted(item, manifestItems, scDataBase, manifestReportDatabase);
            });
        }
        public static void PublishItemSmart(Data.Items.Item rootItem, Database source, Database target, Language lang, BaseDataMap map, ref LevelLogger logger)
        {
            var publishFullLogger = logger.CreateLevelLogger();

            if (rootItem == null)
            {
                publishFullLogger.AddError("RootItem cannot be [null]", "RootItem cannot be [null]");
                return;
            }
            try
            {
                ItemPublisher(Options(rootItem, source, target, lang, PublishMode.Smart)).Publish();
            }
            catch (Exception ex)
            {
                publishFullLogger.AddError("PublishItemSmart of item failed with exception.", String.Format("PublishItemSmart of item {0} failed. Exception: {1}", rootItem.ID, map.GetExceptionDebugInfo(ex)));
            }
        }
Example #16
0
        public IEnumerable <MapPoint> GetAll(Data.Items.Item contextItem)
        {
            if (contextItem == null)
            {
                throw new ArgumentNullException(nameof(contextItem));
            }
            if (contextItem.IsDerived(Templates.MapPoint.ID))
            {
                return(new List <MapPoint> {
                    new MapPoint(contextItem)
                });
            }
            if (!contextItem.IsDerived(Templates.MapPointsFolder.ID))
            {
                throw new ArgumentException("Item must derive from MapPointsFolder or MapPoint", nameof(contextItem));
            }

            var searchService = searchServiceRepository.Get();

            searchService.Settings.Root = contextItem;

            return(searchService.FindAll().Results.Select(x => new MapPoint(x.Item)));
        }
        protected override AccessResult GetItemAccess(Data.Items.Item item, Account account, AccessRight accessRight, PropagationType propagationType)
        {
            var result = base.GetItemAccess(item, account, accessRight, propagationType);

            if (result.IsNull() || result.Permission != AccessPermission.Allow)
            {
                return(result);
            }

            if (accessRight.Name != BucketRights.MakeABucket)
            {
                return(result);
            }

            var right = accessRight as BucketAccessRight;

            if (right.IsNotNull())
            {
                result = this.GetItemAccess(item, account, right);
            }

            return(result);
        }
Example #18
0
        protected override void AddAllFields(Lucene.Net.Documents.Document document, Data.Items.Item item, bool versionSpecific)
        {
            base.AddAllFields(document, item, versionSpecific);

            if (item != null && document != null)
            {
#if SC70
                var fieldAnalysis = Field.Index.ANALYZED;
#else
                var fieldAnalysis = Field.Index.TOKENIZED;
#endif

                // Sitecore 6.2 does not include template
                document.Add(new Field(Constants.Index.Fields.Template, TransformValue(item.TemplateID), Field.Store.NO, fieldAnalysis));

                // Add multilist fields
                foreach (var fieldName in m_multilistFields)
                {
                    if (item.Fields[fieldName] != null)
                    {
                        document.Add(new Field(fieldName, TransformMultilistValue(item.Fields[fieldName]), Field.Store.YES, fieldAnalysis));
                    }
                }

                // Add additional fields
                foreach (var fieldName in m_dataFieldNames)
                {
                    if (item.Fields[fieldName] != null)
                    {
                        document.Add(new Field(fieldName, TransformCSV(item.Fields[fieldName].Value), Field.Store.YES, fieldAnalysis));
                    }
                }

                // Add modified language code to deal with dash in region specific languages
                document.Add(new Field(Constants.Index.Fields.Language, TransformLanguageCode(item.Language.Name), Field.Store.NO, fieldAnalysis));
            }
        }
        protected virtual AccessResult GetItemAccess(Data.Items.Item item, Account account, BucketAccessRight right)
        {
            var ex = new AccessExplanation("This item can be a bucket");

            return(new AccessResult(AccessPermission.Allow, ex));
        }
Example #20
0
 public MapPoint(Data.Items.Item item)
 {
     this.Name     = item[Templates.MapPoint.Fields.MapPointName];
     this.Address  = item[Templates.MapPoint.Fields.MapPointAddress];
     this.Location = item[Templates.MapPoint.Fields.MapPointLocation];
 }
Example #21
0
        public IEnumerable <Data.Items.Item> filterItem360(IEnumerable <Data.Items.Item> items, string _penawaran, string _category, string _keyword, Sitecore.Data.Items.Item dataSourceItem)
        {
            if (_penawaran.ToLower() == dataSourceItem.ID.ToString().ToLower())
            {
                _penawaran = string.Empty;
            }

            if (string.IsNullOrEmpty(_penawaran) && String.IsNullOrEmpty(_category))
            {
                IEnumerable <Sitecore.Data.Items.Item> ItemProductsPromotion = dataSourceItem.Children.Where(x => x.Template.ID == Sitecore.Feature.Library.Templates.CategoryPromotion.ID);

                List <string> listIValueItemCategory = new List <string>();
                List <string> listProductPromotionID = new List <string>();
                foreach (Sitecore.Data.Items.Item selectItemProductPromotion in ItemProductsPromotion)
                {
                    string idItemCategory = selectItemProductPromotion.Fields[Sitecore.Feature.Library.Templates.CategoryPromotion.Fields.Category].Value;
                    Sitecore.Data.Items.Item iValueItemCategory = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(idItemCategory));
                    listIValueItemCategory.Add(iValueItemCategory.ID.ToString().ToLower());

                    foreach (Sitecore.Data.Items.Item productPromotionList in selectItemProductPromotion.Children.Where(x => x.TemplateID == Sitecore.Feature.Library.Templates.ProductPromotion.ID))
                    {
                        Sitecore.Data.Fields.MultilistField getProductPromotionList = productPromotionList.Fields[Sitecore.Feature.Library.Templates.ProductPromotion.Fields.Product];
                        foreach (string productPromotionID in getProductPromotionList.GetItems().Select(x => x.ID.ToString().ToLower()))
                        {
                            listProductPromotionID.Add(productPromotionID);
                        }
                    }
                }

                if (listIValueItemCategory.Count > 0)
                {
                    items = items.Where(x => listIValueItemCategory.Any(y => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductCategory].Value.ToLower().Contains(y)));
                }

                if (listProductPromotionID.Distinct().Count() > 0)
                {
                    items = items.Where(x => listProductPromotionID.Distinct().Any(y => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductItem].Value.ToLower().Contains(y)));
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(_penawaran))
                {
                    Data.Items.Item          ItemPenawaran      = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(_penawaran));
                    string                   idItemCategory     = ItemPenawaran.Fields[Sitecore.Feature.Library.Templates.CategoryPromotion.Fields.Category].Value;
                    Sitecore.Data.Items.Item iValueItemCategory = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(idItemCategory));
                    items = items.Where(x => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductCategory].Value.Contains(iValueItemCategory.ID.ToString()));
                }

                if (!String.IsNullOrEmpty(_category))
                {
                    Data.Items.Item ItemCategory = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(_category));
                    items = items.Where(x => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductItem].Value.Contains(ItemCategory.ID.ToString()));
                }
                else
                {
                    Data.Items.Item ItemPenawaran = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(_penawaran));
                    if (ItemPenawaran.Children.Where(x => x.TemplateID == Sitecore.Feature.Library.Templates.ProductPromotion.ID).Count() > 0)
                    {
                        Sitecore.Data.Items.Item CategoryItem = ItemPenawaran.Children.Where(x => x.TemplateID == Sitecore.Feature.Library.Templates.ProductPromotion.ID).FirstOrDefault();
                        if (CategoryItem != null)
                        {
                            Sitecore.Data.Fields.MultilistField SelectedProductCategory = CategoryItem.Fields[Sitecore.Feature.Library.Templates.ProductPromotion.Fields.Product];
                            if (SelectedProductCategory.GetItems().Count() > 0)
                            {
                                string[] idCategories = SelectedProductCategory.GetItems().Select(x => x.ID.ToString().ToLower()).ToArray();
                                items = items.Where(x => idCategories.Where(y => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductItem].Value.ToLower().Contains(y.ToLower())).Any());
                            }
                        }
                    }
                }

                if (!String.IsNullOrEmpty(_keyword))
                {
                    //IEnumerable<Data.Items.Item> locItem = new Data.Items.Item[] { };
                    List <Data.Items.Item> oList = new List <Data.Items.Item>();

                    //items = items.Where(x => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductLocation].Value.ToLower().Contains(_keyword.ToLower()));
                    foreach (Data.Items.Item loc in items)
                    {
                        string locIds = loc.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.ProductLocation].Value;

                        foreach (string locId in locIds.Split('|'))
                        {
                            try {
                                Data.Items.Item locItem = Sitecore.Context.Database.GetItem(new Data.ID(locId));
                                if (locItem.DisplayName.ToLower() == _keyword.ToLower())
                                {
                                    oList.Add(loc);
                                }
                            } catch (Exception) { }
                        }
                    }

                    items = oList.AsEnumerable <Data.Items.Item>();
                }
            }

            items = items.Where(x => x.Fields[Sitecore.Feature.Library.Templates.PromotionPageCreditCard.Fields.Layout].Value.ToLower().Contains(dataSourceItem.ID.ToString().ToLower()));

            return(items);
        }
        public void GetMapPoints_ItemIdPassed_PointsReturnedFormRepo(IMapPointRepository mapPointRepository, Db db, MapPoint[] points, [FakeDb.AutoFixture.Content] Data.Items.Item item)
        {
            mapPointRepository.GetAll(null).ReturnsForAnyArgs(points);

            var controller   = new MapsController(mapPointRepository);
            var actualPoints = controller.GetMapPoints(item.ID.Guid).Data as IEnumerable <MapPoint>;

            actualPoints.ShouldBeEquivalentTo(points);
        }
        public void GetMapPoints_ItemIdPassed_ShouldCallRepositoryWithItem(IMapPointRepository mapPointRepository, [FakeDb.AutoFixture.Content] Data.Items.Item item)
        {
            var controller = new MapsController(mapPointRepository);

            controller.GetMapPoints(item.ID.Guid);
            mapPointRepository.GetAll(item).ReceivedWithAnyArgs(1);
        }
Example #24
0
        private static string BuildIdListValue(IImportOptions importOptions, string value, Data.Items.Item item)
        {
            StringBuilder builder = new StringBuilder();

            if (item != null)
            {
                builder.AppendFormat("|{0}", item.ID);
            }
            else
            {
                if (importOptions.InvalidLinkHandling == InvalidLinkHandling.SetBroken)
                {
                    builder.AppendFormat("|{0}", value);
                }
                else if (importOptions.InvalidLinkHandling == InvalidLinkHandling.SetEmpty)
                {
                    builder.Append("|");
                }
            }
            return(builder.ToString());
        }
Example #25
0
 public BucketSecurityManager(Data.Items.Item item)
 {
     this.ContextItem = item;
 }