Esempio n. 1
0
        public override PipelineProcessorResponseValue ProcessRequest()
        {
            var itemTitle = RequestContext.Argument;

            if (ItemUtil.IsItemNameValid(itemTitle))
            {
                var currentItem = RequestContext.Item;
                var currentBlog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(currentItem);
                if (currentBlog != null)
                {
                    var  template = new TemplateID(currentBlog.BlogSettings.EntryTemplateID);
                    Item newItem  = ItemManager.AddFromTemplate(itemTitle, template, currentBlog);

                    return(new PipelineProcessorResponseValue
                    {
                        Value = new
                        {
                            itemId = newItem.ID.Guid
                        }
                    });
                }
            }
            return(new PipelineProcessorResponseValue
            {
                Value = null
            });
        }
Esempio n. 2
0
        public override void Execute(CommandContext context)
        {
            Assert.IsNotNull(context, "context");
            Assert.IsNotNull(context.Parameters["id"], "id");

            string   contextDbName = Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronContextDB);
            Database contextDb     = Factory.GetDatabase(contextDbName);

            Item scriptItem = contextDb.GetItem(new ID(context.Parameters["id"]));

            if (scriptItem != null && scriptItem.TemplateID == SitecronConstants.Templates.SitecronJobTemplateID)
            {
                string newItemName = ItemUtil.ProposeValidItemName(string.Concat("Execute Now ", scriptItem.Name, DateTime.Now.ToString(" yyyyMMddHHmmss")));

                Item autoFolderItem = contextDb.GetItem(new ID(SitecronConstants.ItemIds.AutoFolderID));
                if (autoFolderItem != null)
                {
                    Item newScriptItem = scriptItem.CopyTo(autoFolderItem, newItemName);

                    double addExecutionSeconds = 20;
                    if (!Double.TryParse(Settings.GetSetting(SitecronConstants.SettingsNames.SiteCronExecuteNowSeconds), out addExecutionSeconds))
                    {
                        addExecutionSeconds = 20;
                    }

                    using (new EditContext(newScriptItem, Sitecore.SecurityModel.SecurityCheck.Disable))
                    {
                        DateTime executeTime = DateTime.Now.AddSeconds(addExecutionSeconds);
                        newScriptItem[SitecronConstants.FieldNames.CronExpression]        = string.Format("{0} {1} {2} 1/1 * ? * ", executeTime.ToString("ss"), executeTime.ToString("mm"), executeTime.ToString("HH"));
                        newScriptItem[SitecronConstants.FieldNames.ArchiveAfterExecution] = "1";
                        newScriptItem[SitecronConstants.FieldNames.Disable] = "0";
                    }
                }
            }
        }
        protected override void ApplyVariation(CustomizeRenderingArgs args, ComponentTestContext context)
        {
            // Begin copied from sitecore
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(context, "context");
            ComponentTestRunner componentTestRunner = new ComponentTestRunner();

            try
            {
                componentTestRunner.Run(context);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                string    str       = (ItemUtil.IsNull(context.Component.RenderingID) ? string.Empty : context.Component.RenderingID.ToString());
                string    str1      = (args.PageContext.Item != null ? args.PageContext.Item.ID.ToString() : string.Empty);
                Log.Warn("Failed to execute MV testing on component with id \"{0}\". Item ID:\"{1}\"".FormatWith(new object[] { str, str1 }), exception, this);
            }
            RenderingReference renderingReference = context.Components.FirstOrDefault <RenderingReference>((RenderingReference c) => c.UniqueId == context.Component.UniqueId);

            if (renderingReference == null)
            {
                args.Renderer = new EmptyRenderer();
                return;
            }
            this.ApplyChanges(args.Rendering, renderingReference);
            // End copied from sitecore

            // Apply Parameters Too
            TransferRenderingParameters(args.Rendering, renderingReference);
        }
Esempio n. 4
0
 /// <summary>
 /// </summary>
 /// <param name="parentId"></param>
 /// <param name="cmsItem"></param>
 /// <returns></returns>
 public string CreateNotMappedItem(string parentId, CmsItem cmsItem)
 {
     if (parentId != null)
     {
         using (new SecurityDisabler())
         {
             using (new LanguageSwitcher(cmsItem.Language))
             {
                 var templateItem = ContextDatabase.GetItem("/sitecore/templates/GatherContent/Not Mapped Item");
                 if (templateItem != null)
                 {
                     var template  = ContextDatabase.GetTemplate(new ID(templateItem.ID.Guid));
                     var validName = ItemUtil.ProposeValidItemName(cmsItem.Title);
                     var parent    = ContextDatabase.GetItem(new ID(parentId));
                     if (parent != null)
                     {
                         try
                         {
                             var createdItem = parent.Add(validName, template);
                             return(createdItem.ID.ToString());
                         }
                         catch (Exception)
                         {
                             throw new Exception(string.Format("Item cannot be created: parent='{0}l cmsItem.Title='{1}'", parent.Name, cmsItem.Title));
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="cmsItem"></param>
        /// <returns></returns>
        public string GetItemId(string parentId, CmsItem cmsItem)
        {
            if (parentId == null)
            {
                return(null);
            }

            using (new SecurityDisabler())
            {
                using (new LanguageSwitcher(cmsItem.Language))
                {
                    var validName = ItemUtil.ProposeValidItemName(cmsItem.Title);
                    var parent    = ContextDatabase.GetItem(new ID(parentId));
                    if (parent != null)
                    {
                        var items = parent.Axes.SelectItems(string.Format("./*[@@name='{0}']", validName));
                        if (items != null && items.Any())
                        {
                            return(items.First().ID.ToString());
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// Replace all non-alphanumeric characters with hyphens, ignoring slashes
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private static string Normalize(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(path);
            }

            // Decode the path.
            path = WebUtility.HtmlDecode(path);
            path = MainUtil.DecodeName(path);

            var segments = path.Split(Constants.UrlSeparator, StringSplitOptions.RemoveEmptyEntries);
            var name     = segments?.Length != 0 ? segments.Last() : null;

            if (!string.IsNullOrEmpty(name))
            {
                var replaced = ItemUtil.ProposeValidItemName(name).ToLower();
                path = path.Replace(name, replaced);
            }

            // Replace characters that Sitecore doesn't allow and lower case the rest.
            path = path.Replace(Constants.Blank, Constants.Hyphen);

            return(path);
        }
Esempio n. 7
0
        public override PipelineProcessorResponseValue ProcessRequest()
        {
            var itemTitle = RequestContext.Argument;

            if (ItemUtil.IsItemNameValid(itemTitle ?? string.Empty))
            {
                var currentItem = RequestContext.Item;
                var currentBlog = _blogManager.GetCurrentBlog(currentItem);
                if (currentBlog != null)
                {
                    var templateId = GetTemplateId(currentBlog);
                    var parentItem = GetParentItem(currentBlog);

                    Item newItem = _itemManager.AddFromTemplate(itemTitle, templateId, parentItem);

                    return(new PipelineProcessorResponseValue
                    {
                        Value = new
                        {
                            itemId = newItem.ID.Guid
                        }
                    });
                }
            }
            return(new PipelineProcessorResponseValue
            {
                Value = null
            });
        }
        private Item CreateOrGetProject(string gcProjectId, string gcProjectName)
        {
            var projectItem = GetProject(gcProjectId);

            if (projectItem != null)
            {
                return(projectItem);
            }

            var accountSettings = _accountsRepository.GetAccountSettings();

            var parentItem = GetItem(accountSettings.AccountItemId);

            using (new SecurityDisabler())
            {
                var template        = ContextDatabase.GetTemplate(new ID(Constants.GcProject));
                var validFolderName = ItemUtil.ProposeValidItemName(gcProjectName);
                projectItem = parentItem.Add(validFolderName, template);
                using (new SecurityDisabler())
                {
                    projectItem.Editing.BeginEdit();
                    projectItem.Fields["Id"].Value   = gcProjectId;
                    projectItem.Fields["Name"].Value = gcProjectName;
                    projectItem.Editing.EndEdit();
                }
                CreateProjectFolders(projectItem.ID.ToString());
            }

            return(projectItem);
        }
Esempio n. 9
0
        private static void CreateImportedAuthorsInSitecore(Database master, List <WPAuthor> authors, XBlogAuthors xbAuthors)
        {
            TemplateItem blogAuthorTemplate = master.GetItem(Author.AuthorTemplateId);

            foreach (WPAuthor wpa in authors)
            {
                try
                {
                    string authorsName = ItemUtil.ProposeValidItemName(wpa.Name);

                    Author a = xbAuthors.InnerItem.Add(authorsName, blogAuthorTemplate).CreateAs <Author>();

                    using (new EditContext(a.InnerItem))
                    {
                        a.InnerItem.SetString(Author.AuthorFullNameFieldId, wpa.Name.Replace(".", " "));
                        a.InnerItem.SetString(Author.AuthorEmailAddressFieldId, wpa.Email);
                        a.InnerItem.SetString(Author.CreatorFieldId, wpa.Creator);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("failed to create author: " + wpa.Name + ex.Message, "XB Creator");
                }
            }
        }
Esempio n. 10
0
        public void AddItems(Item parent, IEnumerable <Event> events, TemplateID templateID)
        {
            var  children = parent.GetChildren();
            Item foundItem;

            using (new SecurityDisabler())
            {
                foreach (var currentEvent in events)
                {
                    var name = ItemUtil.ProposeValidItemName(currentEvent.ContentHeading);
                    if (EventExists(children, name, out foundItem))
                    {
                        if (foundItem != null)
                        {
                            UpdateItem(foundItem, currentEvent);
                            UpdateCount++;
                        }
                    }
                    else
                    {
                        AddItem(parent, currentEvent, templateID);
                        AddCount++;
                    }
                }
            }
        }
Esempio n. 11
0
        // Methods
        public new void Execute(CopyItemsArgs args)
        {
            Event.RaiseEvent("item:bucketing:cloning", args, this);
            Assert.ArgumentNotNull(args, "args");
            var items = GetItems(args);

            if (args.IsNotNull())
            {
                var itemId = args.Parameters["destination"];
                if (itemId.IsNotNull())
                {
                    var database = GetDatabase(args);
                    if (database.GetItem(itemId).IsBucketItemCheck())
                    {
                        var list = new ArrayList();
                        foreach (var item3 in from item2 in items
                                 where item2.IsNotNull()
                                 let item = BucketManager.CreateAndReturnDateFolderDestination(database.GetItem(itemId), item2)
                                            let copyOfName = ItemUtil.GetCopyOfName(item, item2.Name)
                                                             select item2.CloneTo(item, copyOfName, true))
                        {
                            list.Add(item3);
                        }

                        args.Copies = list.ToArray(typeof(Item)) as Item[];
                        Event.RaiseEvent("item:bucketing:cloned", args, this);
                        args.AbortPipeline();
                    }
                }
            }
        }
        private void CreateEvents(IEnumerable <Event> events, string parentPath)
        {
            var database   = Factory.GetDatabase("master");
            var parent     = database.GetItem(parentPath);
            var templateId = new TemplateID(new ID("{33AA7A2F-B443-4199-BAB8-F88830CE6501}"));

            using (new SecurityDisabler())
            {
                foreach (var ev in events)
                {
                    var name = ItemUtil.ProposeValidItemName(ev.ContentHeading);
                    var item = parent.Add(name, templateId);
                    using (new EditContext(item))
                    {
                        item["ContentHeading"]       = ev.ContentHeading;
                        item["ContentIntro"]         = ev.ContentIntro;
                        item["Difficulty Level"]     = ev.Difficulty.ToString();
                        item["Duration"]             = ev.Duration.ToString();
                        item["Highlights"]           = ev.Highlights;
                        item["Start Date"]           = DateUtil.ToIsoDate(ev.StartDate);
                        item[FieldIDs.Workflow]      = "{97EE4F91-4053-4F5B-A000-F86CABB14781}";
                        item[FieldIDs.WorkflowState] = "{870CA50B-225D-4481-A839-EB99E83F40E8}";
                    }
                }
            }
        }
Esempio n. 13
0
        private void Repair(UPlayer player, Items item)
        {
            if (item == null)
            {
                return;
            }

            var  playerInv = player.UnturnedPlayer.inventory;
            var  items     = (List <ItemJar>)_itemsField.GetValue(item);
            byte index     = 0;

            items.ForEach(itemJar => {
                item.updateQuality(index, 100);

                playerInv.channel.send("tellUpdateQuality", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] {
                    item.page,
                    playerInv.getIndex(item.page, itemJar.PositionX, itemJar.PositionY),
                    100
                });

                var barrel = ItemUtil.GetWeaponAttachment(itemJar.item, ItemUtil.AttachmentType.BARREL);
                barrel.IfPresent(attach => {
                    attach.Durability = 100;
                    ItemUtil.SetWeaponAttachment(itemJar.item, ItemUtil.AttachmentType.BARREL, attach);
                });
                index++;
            });
        }
Esempio n. 14
0
        public ActionResult Send()
        {
            var rendering  = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull?.Rendering;
            var parameters = rendering?.Parameters;
            var makerKey   = ItemUtil.GetItemById(parameters?[Templates.Parameters.MakerKey])?[Templates.Account.Fields.MakerKey];
            var eventName  = ItemUtil.GetItemById(parameters?[Templates.Parameters.Event])?[Templates.Event.Fields.EventName];
            var threshold  = int.TryParse(parameters?[Templates.Parameters.Threshold], out int num)? num : -1;
            var value1     = parameters?[Templates.Parameters.Value1];
            var value2     = parameters?[Templates.Parameters.Value2];
            var value3     = parameters?[Templates.Parameters.Value3];

            if (threshold > 1)
            {
                var thresholdKey = KeyUtil.MakeKey(
                    $"{nameof(TriggerController)}_{nameof(Send)}_",
                    Sitecore.Context.Item?.ID.ToGuid().ToString(),
                    rendering?.UniqueId
                    );

                if (Threshold.IsMet(threshold, thresholdKey))
                {
                    Ifttt.Trigger(makerKey, eventName, value1, value2, value3);
                    return(Content($"<p>Threshold met, trigger '{eventName}' sent!</p>"));
                }
                else
                {
                    return(Content("<p>Threshold incremented</p>"));
                }
            }

            Ifttt.Trigger(makerKey, eventName, value1, value2, value3);
            return(Content($"<p>Trigger '{eventName}' sent!</p>"));
        }
Esempio n. 15
0
        public virtual string GetPhraseItemPath(string key, Language language, Guid?domainId = null)
        {
            var splittedValue    = key.Split(new[] { ".", "/" }, StringSplitOptions.RemoveEmptyEntries);
            var relativeItemPath = string.Join("/", splittedValue.Select(x => ItemUtil.ProposeValidItemName(x).ToPascalCase()));

            return(this.GetDomainItem(language, domainId).Paths.FullPath + "/" + relativeItemPath);
        }
Esempio n. 16
0
        /// <summary>
        /// Checks if the user has write permissions for the selected language.
        /// </summary>
        /// <param name="language">The language to check permissons on.</param>
        /// <returns>True if the user has write permissons for the language.</returns>
        private bool CanWriteLanguage(Language language)
        {
            if (language == null)
            {
                return(false);
            }

            bool renderLanguage = true;

            if (Settings.CheckSecurityOnLanguages)
            {
                ID languageItemId = LanguageManager.GetLanguageItemId(language, _database);
                if (!ItemUtil.IsNull(languageItemId))
                {
                    Item languageItem = _database.GetItem(languageItemId);
                    if (languageItem == null)
                    {
                        renderLanguage = false;
                    }

                    bool canWriteLanguage = AuthorizationManager.IsAllowed(languageItem, AccessRight.LanguageWrite, Context.User);
                    if (!canWriteLanguage)
                    {
                        renderLanguage = false;
                    }
                }
                else
                {
                    renderLanguage = false;
                }
            }

            return(renderLanguage);
        }
Esempio n. 17
0
 public void createPanels(List <WeaponDefinition> definitions)
 {
     foreach (WeaponDefinition def in definitions)
     {
         addPanel(def.name, def.minimumDamage + " - " + def.maximumDamage, ItemUtil.getRarityColour(def.rarity));
     }
 }
        public ActionResult Index(HttpPostedFileBase file, string parentPath)
        {
            IEnumerable <Event> events = null;
            string message             = null;

            using (var reader = new System.IO.StreamReader(file.InputStream))
            {
                var contents = reader.ReadToEnd();
                try
                {
                    events = JsonConvert.DeserializeObject <IEnumerable <Event> >(contents);
                }
                catch (Exception ex)
                {
                }
            }

            var database   = Sitecore.Configuration.Factory.GetDatabase("master");
            var parentItem = database.GetItem(parentPath);
            var templateID = new TemplateID(new ID("{FB56D476-904B-4BD8-BD45-4C6B31047677}"));

            using (new SecurityDisabler())
            {
                foreach (var ev in events)
                {
                    var  name = ItemUtil.ProposeValidItemName(ev.ContentHeading);
                    Item item = parentItem.Add(name, templateID);
                    item.Editing.BeginEdit();
                    item["ContentHeading"] = ev.ContentHeading;
                    item.Editing.EndEdit();
                }
            }
            return(View());
        }
        public void Process(SitemapGenerateArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            if (!args.IsSiteGroup || args.SitemapSites.Count <= 1)
            {
                return;
            }

            var sitemapindex = new Sitemapindex();

            foreach (var sitemapSite in args.SitemapSites)
            {
                var scheme = sitemapSite.SiteContext.Properties["scheme"] ?? "http";

                var groupUrl = $"{scheme}://{sitemapSite.SiteContext.TargetHostName}";

                var loc = $"{groupUrl}/sitemaps/{ItemUtil.ProposeValidItemName(sitemapSite.SiteContext.Name)}.xml";

                var sitemap = new Sitemap(loc, DateTime.Now);

                sitemapindex.Sitemaps.Add(sitemap);
            }

            Logger.Info($"Generated SiteIndex object for site group: {args.SiteGroupName}");

            var xmlString = sitemapindex.SitemapToXml();

            var indexPath = $"{args.SiteDirectoryAbsolutePath}\\index.xml";

            File.WriteAllText(indexPath, xmlString);
            Logger.Info($"Wrote SiteIndex XML for site group: {args.SiteGroupName}");
        }
Esempio n. 20
0
        public void Start(ClientPipelineArgs args)
        {
            if (args.IsPostBack)
            {
                Database database =
                    Sitecore.Configuration.Factory.GetDatabase(
                        Settings.Instance.ConfigurationDatabase);
                Assert.IsNotNull(database, "configuration database is null");

                Item report = database.GetItem(new Sitecore.Data.ID(Current.Context.ReportItem.Id));

                Assert.IsNotNull(report, "can't find report item");

                Sitecore.Context.ClientPage.SendMessage(this, "ASR.MainForm:updateparameters");

                using (new Sitecore.SecurityModel.SecurityDisabler())
                {
                    Item newItem = ItemUtil.AddFromTemplate(args.Result, "System/ASR/Saved Report", report);
                    using (new EditContext(newItem))
                    {
                        newItem["parameters"]            = Current.Context.ReportItem.SerializeParameters("^", "&");
                        newItem[Sitecore.FieldIDs.Owner] = Sitecore.Context.User.Name;
                    }
                }
            }
            else
            {
                Sitecore.Context.ClientPage.ClientResponse.Input("Enter the name of the new blog entry:",
                                                                 "report name", Sitecore.Configuration.Settings.ItemNameValidation, "'$Input' is not a valid name.",
                                                                 Sitecore.Configuration.Settings.MaxItemNameLength);
                args.WaitForPostBack(true);
            }
        }
        public virtual Item CreateItemFromBranch(ID parentId, ID branchId, string dbName, string itemName, Dictionary <ID, string> fieldNameValues)
        {
            var folder = GetItemById(parentId, dbName);

            if (folder == null)
            {
                return(null);
            }

            Item branchItem = GetItemById(branchId, dbName);

            if (branchItem == null)
            {
                return(null);
            }

            var  validName = ItemUtil.ProposeValidItemName(itemName);
            Item newItem   = folder.Add(validName, (BranchItem)branchItem);

            if (newItem == null)
            {
                return(newItem);
            }

            UpdateFields(newItem, fieldNameValues);

            return(newItem);
        }
Esempio n. 22
0
        public static T Save <T>(this T obj, IGlassBase parent, ISitecoreService service) where T : class, IHasExternalId
        {
            if (obj.HasIDTableEntry())
            {
                if (obj.IsUpdateRequired())
                {
                    //      Any data manipulation can go hear before
                    //      updating the database once again
                    //      This case will never be hit in this sample
                    using (new SecurityDisabler())
                    {
                        service.Save(obj);
                    }
                }
                obj = service.GetItem <T>(obj.GetItemIdFromIDTableEntry().Guid);
            }
            else
            {
                obj.Name = ItemUtil.ProposeValidItemName(obj.Name).ToLower().Replace(" ", "-");
                using (new SecurityDisabler())
                {
                    service.Create(parent, obj);
                }
            }

            return(obj);
        }
        /// <summary>
        /// Update Item
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="accountItem"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public override Item UpdateItem(object entity, Item accountItem, Item item)
        {
            PlayList playList = (PlayList)entity;

            using (new EditContext(item))
            {
                item.Name = ItemUtil.ProposeValidItemName(playList.Name);
                item[FieldIDs.MediaElement.Name]             = playList.Name;
                item[FieldIDs.PlayerList.PlaylistType]       = playList.PlaylistType;
                item[FieldIDs.MediaElement.Id]               = playList.Id;
                item[FieldIDs.MediaElement.ShortDescription] = playList.ShortDescription;
                item[FieldIDs.MediaElement.ReferenceId]      = playList.ReferenceId;
                if (playList.PlayListSearch != null)
                {
                    item[FieldIDs.PlayerList.TagInclusion] =
                        playList.PlayListSearch.TagInclusion.ToString();
                }
                item[FieldIDs.Playlist.CreationDate] = playList.CreationDate.HasValue ?
                                                       playList.CreationDate.ToString() : string.Empty;
                item[FieldIDs.Playlist.LastModifiedDate] = playList.LastModifiedDate.HasValue ?
                                                           playList.CreationDate.ToString() : string.Empty;
                item[FieldIDs.Playlist.Favorite] = playList.Favorite.HasValue ?
                                                   playList.Favorite.Value ? "1" : "0" : string.Empty;
            }
            return(item);
        }
        public void Process(PipelineArgs args)
        {
            Database db = Factory.GetDatabase("master", false);

            if (db == null)
            {
                return;
            }
            Database core = Factory.GetDatabase("core", false);

            if (core == null)
            {
                return;
            }
            EpContext.Tabs = AppDomain.CurrentDomain.GetAssemblies().Where(x => !Constants.BinaryBlacklist.Contains(x.GetName().Name)).SelectMany(GetEpTabs).Select(t => (EpExpressModel)Activator.CreateInstance(t)).ToDictionary(x => x.GetType().AssemblyQualifiedName);
            using (new SecurityDisabler())
            {
                Item tabs      = core.GetItem(Constants.EpTabsFolder);
                Item rendering = core.GetItem(Constants.EpExpressRendering);
                if (rendering == null)
                {
                    Item renderingsContainer = core.GetItem(Constants.ContainersRenderingFolder);
                    rendering = core.DataManager.DataEngine.CreateItem("EpExpress", renderingsContainer,
                                                                       new ID(Constants.EpExpressRenderingTemplate), new ID(Constants.EpExpressRendering));
                    rendering.Editing.BeginEdit();
                    rendering["Method"]   = "Render";
                    rendering["Class"]    = "Sitecore.Feature.EPTab.Handler.EpExpressTabRenderer";
                    rendering["Assembly"] = "Sitecore.Feature.EPTab";
                    rendering.Editing.EndEdit();
                }
                Dictionary <string, Item> foundTabs = new Dictionary <string, Item>();
                foreach (Item tab in tabs.Children)
                {
                    if (tab["Placeholder Name"].StartsWith("epe"))
                    {
                        foundTabs.Add(tab["Placeholder Name"].Substring(3), tab);
                    }
                }

                foreach (string key in EpContext.Tabs.Keys)
                {
                    Item tab;
                    if (foundTabs.ContainsKey(key))
                    {
                        tab = foundTabs[key];
                        foundTabs.Remove(key);
                    }
                    else
                    {
                        tab = tabs.Add(ItemUtil.ProposeValidItemName(key), new TemplateID(new ID(Constants.EpTabTemplate)));
                    }
                    ValidateTab(tab, EpContext.Tabs[key], key);
                }
                foreach (Item old in foundTabs.Values)
                {
                    old.Recycle();
                }
            }
        }
 public override ItemDefinition GetItemDefinition(ID itemId, CallContext context)
 {
     if (Items.ContainsKey(itemId))
     {
         return(new ItemDefinition(itemId, ItemUtil.ProposeValidItemName(Items[itemId].Title.Text), _templateId, ID.Null));
     }
     return(null);
 }
Esempio n. 26
0
        private Item InstallCondition(Item ruleElement, string type, bool accountWatch, string name, string attributeFolder, string attributeType)
        {
            Item condition = ruleElement.Database.DataManager.DataEngine.CreateItem(ItemUtil.ProposeValidItemName(name),
                                                                                    ruleElement, new ID(DemandbaseConstants.RuleCondition), GuidUtility.GetId("demandbaseconditiondefault", name + accountWatch));

            SetCondition($"{(accountWatch ? "Watch List " : "")} " + DefaultAttributeSelector.FormatWith(attributeFolder), attributeType, condition, null, accountWatch, false, "25");
            return(condition);
        }
Esempio n. 27
0
        private Item InstallCondition(DemandbaseAttribute attribute, Item ruleElement, bool accountWatch, string attributeFolderId, string valuesFolderId)
        {
            Item condition = ruleElement.Database.DataManager.DataEngine.CreateItem(ItemUtil.ProposeValidItemName(attribute.Name),
                                                                                    ruleElement, new ID(DemandbaseConstants.RuleCondition), GuidUtility.GetId("demandbasecondition" + attributeFolderId, attribute.Id));

            SetCondition(attribute.Name, attribute.Type, condition, valuesFolderId, accountWatch, attribute.DefaultValues.Any());
            return(condition);
        }
Esempio n. 28
0
        /// <summary>
        /// Builds the name of the schedule in sitecore
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string BuildPublishScheduleName(Item item)
        {
            Guid guid = item != null
                ? item.ID.Guid
                : Guid.NewGuid();

            return(ItemUtil.ProposeValidItemName(string.Format("{0}PublishSchedule", guid)));
        }
Esempio n. 29
0
        public KitItem(ushort id, byte durability, byte amount)
        {
            Id         = id;
            Durability = durability;
            Amount     = amount;

            ItemUtil.GetItem(id).IfPresent(asset => Metadata = asset.getState());
        }
Esempio n. 30
0
        public void setupSecondaryMenu(WeaponDefinition currentDefinition, Action <WeaponDefinition> returnAction)
        {
            setupWeaponMenu(currentDefinition, returnAction);

            Inventory inventory = ItemUtil.getInventory();

            setupWeaponDefinitions(inventory.secondaryWeaponDefinitions);
        }
        static void Main(string[] args)
        {
            var deserializerUtil = new ItemUtil(new SyncItemDeserializer());

            var items = deserializerUtil.Deserialize(@"C:\inetpub\wwwroot\Usergroup\Website\App_Data\serialization\master\sitecore");

            var templates = deserializerUtil.BuildTemplates(items);

            //"".StartsWith("", StringComparison.OrdinalIgnoreCase )
        
        }