// GET: Taxonomy public ActionResult CategoriesList() { var catRootItem = _db.GetItem("/sitecore/content/xferData/Blog/Categories"); var catList = getListOfItemNames(catRootItem); return(View(catList)); }
// Product Symbols #region Create Item private Item CreateItem(string rootItempath, string templateItempath, string itemName, Dictionary <string, string> fieldsToUpdate, bool addVersion, Item defaultLanguageItem, string lang, string postid, string posttype) { Item newItem = null; // The SecurityDisabler overrides the current security model, allowing you // to access the item without any security. It's like the user being an administrator using (new Sitecore.SecurityModel.SecurityDisabler()) { // Get the master database Sitecore.Data.Database master = Sitecore.Data.Database.GetDatabase("master"); // Get the template to base the new item on TemplateItem template = master.GetItem(templateItempath); // Get the place in the site tree where the new item must be inserted Item parentItem = master.GetItem(rootItempath); if (addVersion == false) { newItem = CreateDefaultLanguageItem(itemName + postid, fieldsToUpdate, newItem, template, parentItem); } if (newItem == null) { newItem = defaultLanguageItem; } newItem = AddLanguageVersionItem(posttype, itemName, fieldsToUpdate, template, newItem, master, lang, postid); } return(newItem); }
protected void btnGetPersonalization_ServerClick(object sender, EventArgs e) { var data = new List <PersonalizationData>(); Sitecore.Data.Database master = Sitecore.Data.Database.GetDatabase("master"); var startItem = master.GetItem("/sitecore/content"); DeviceItem device = master.Resources.Devices["Default"]; foreach (var item in startItem.Axes.GetDescendants()) { PersonalizationData details = new PersonalizationData(); Sitecore.Data.Fields.LayoutField layoutField = item.Fields["__renderings"]; List <Sitecore.Layouts.RenderingReference> renderings = layoutField.GetReferences(device) != null?layoutField.GetReferences(device).ToList() : null; if (renderings != null) { Sitecore.Data.Fields.LayoutField finalLayoutField = item.Fields["__final renderings"]; List <Sitecore.Layouts.RenderingReference> finalRenderings = finalLayoutField.GetReferences(device) != null?finalLayoutField.GetReferences(device).ToList() : null; if (finalRenderings != null) { renderings.AddRange(finalRenderings); var renderingsWithPersonalization = renderings.Where(r => r.Settings.Rules.Count > 0).ToList(); details.ItemName = item.Name; details.RederingDetails = new List <RenderingDetails>(); if (details.ItemName != null && renderingsWithPersonalization != null && renderingsWithPersonalization.Count > 0) { foreach (var rendering in renderingsWithPersonalization) { RenderingDetails renderingDetail = new RenderingDetails(); renderingDetail.RenderingID = master.GetItem(rendering.RenderingID).Paths.FullPath.ToString(); renderingDetail.RenderingName = master.GetItem(rendering.RenderingID).Name; details.RederingDetails.Add(renderingDetail); } } } data.Add(details); } data = data.Where(x => x.RederingDetails.Count() > 0).ToList(); } personalizedData.Text = ""; if (data.Count > 0) { foreach (var finalData in data) { personalizedData.Text += "Item Name : <strong>" + finalData.ItemName + "</strong></br>"; personalizedData.Text += "Renderings with Personalizations defined : </br>"; foreach (var renderingData in finalData.RederingDetails) { personalizedData.Text += "Rendering - Path -" + renderingData.RenderingID + "</br>"; } personalizedData.Text += "</br>"; } } else { personalizedData.Text += "No renderings with Personalization found"; } }
public virtual void CreateItem(Registration registration) { Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master"); var eventItemName = StringHelpers.CleanEventName(registration.Event.Name); Item eventItem = masterDB.GetItem($"{eventsPath}{eventItemName}"); if (eventItem == null) { return; } var teamTemplate = masterDB.GetTemplate(_teamTemplate); using (new Sitecore.SecurityModel.SecurityDisabler()) { var teamItemName = StringHelpers.CleanTeamName(registration.Team.TeamName); //No dupes pls. if (masterDB.GetItem($"{eventsPath}{eventItemName}/{teamItemName}") != null) { teamItemName = StringHelpers.CleanTeamName($"{System.Guid.NewGuid().ToString()}_{teamItemName}"); } Item teamItem = eventItem.Add(teamItemName, teamTemplate); if (teamItem != null) { teamItem.Editing.BeginEdit(); teamItem["Team Name"] = registration.Team.TeamName; teamItem["Slogan"] = registration.Team.Slogan; teamItem["Repository Name"] = registration.Team.RepositoryName; teamItem["Repository Url"] = registration.Team.RepositoryUrl; teamItem.Fields[Sitecore.FieldIDs.Workflow].Value = _workflowID; IWorkflow wf = masterDB.WorkflowProvider.GetWorkflow(_workflowID); wf.Start(teamItem); teamItem.Editing.EndEdit(); } var memberTemplate = masterDB.GetTemplate(_participantTemplate); foreach (Participant member in registration.Team.Members) { var participantItemName = StringHelpers.CleanParticipantName(member.Name); Item participantItem = teamItem.Add(participantItemName, memberTemplate); participantItem.Editing.BeginEdit(); participantItem["Participant Name"] = member.Name; participantItem["Email"] = member.Email; participantItem["Github"] = member.Github; participantItem["LinkedIn"] = member.LinkedIn; participantItem["Slack"] = member.Slack; participantItem["Twitter"] = member.Twitter; participantItem["Location"] = member.Location; participantItem.Editing.EndEdit(); } } }
private void CreateProfileData(string profile, List <KeyValuePair <string, string> > profileDataList) { // The SecurityDisabler is required which will overrides the current security model, allowing the code // to access the item without any security. using (new Sitecore.SecurityModel.SecurityDisabler()) { Item newItem = null; // Get the master database Sitecore.Data.Database master = Sitecore.Data.Database.GetDatabase("master"); // Get the template for which you need to create item TemplateItem template = master.GetItem("/sitecore/templates/SCEBTemplates/Forms/ContactProfileData"); // Get the place in the site tree where the new item must be inserted Item parentItem = master.GetItem("/sitecore/content/EmployeeBenefits/ContactProfiles/ProfileData"); try { var dataCount = 0; if (parentItem.HasChildren) { dataCount = parentItem.Children.Count; } // Assign values to the fields of the new item foreach (var profileData in profileDataList) { dataCount = dataCount + 1; // Add the item to the site tree newItem = parentItem.Add("ProfileData" + Convert.ToString(dataCount), template); // Set the new item in editing mode // Fields can only be updated when in editing mode // (It's like the begin transaction on a database) newItem.Editing.BeginEdit(); newItem.Fields["ProfileDataId"].Value = Convert.ToString(dataCount);; newItem.Fields["ContactProfile"].Value = profile; newItem.Fields["ProfileField"].Value = profileData.Key; newItem.Fields["ProfileValue"].Value = profileData.Value; newItem.Fields["IsActive"].Value = Convert.ToString(1); // End editing will write the new values back to the Sitecore // database (It's like commit transaction of a database) newItem.Editing.EndEdit(); } } catch (System.Exception ex) { // Log the message on any failure to sitecore log Sitecore.Diagnostics.Log.Error("Could not update item " + newItem.Paths.FullPath + ": " + ex.Message, this); // Cancel the edit (not really needed, as Sitecore automatically aborts // the transaction on exceptions, but it wont hurt your code) newItem.Editing.CancelEdit(); } } }
// GET: Home public ActionResult Index() { Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("master"); var Item = db.GetItem("/sitecore/content/Home"); return(View()); }
public static List <KeyValuePair <string, string> > GetItemValuesByIdAndVersion(string Ciid, string version, Sitecore.Data.Database database) { var itemVersion = new Sitecore.Data.Version(version); var language = Language.Parse(ContextExtension.CurrentLanguageCode); return(GetItemFieldValuesFromTemplate(database.GetItem(Ciid, language, itemVersion), database)); }
public object ComputeFieldValue(IIndexable indexable) { var indexItem = indexable as SitecoreIndexableItem; if (indexItem?.Item == null) { return(null); } string date = null; Item item = indexItem.Item; if (Context.Site == null) { Context.SetActiveSite("shell"); } if (item.TemplateID.Equals(Templates.EventPage.ID)) { Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master"); Item eventItem = master.GetItem(item.Fields[Templates.EventPage.Fields.Event].Value); date = eventItem.Fields[Templates.Event.Fields.EventStart].Value; } return(date); }
protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { if (!Sitecore.Web.UI.Sheer.SheerResponse.CheckModified()) { return; } if (args.IsPostBack) { Sitecore.Web.UI.Sheer.SheerResponse.Confirm(Sitecore.Globalization.Translate.Text( "Reset {0} to its standard value?", new object[] { args.Parameters["field"] })); args.WaitForPostBack(); } if (!args.HasResult) { return; } if (args.Result != "yes") { return; } Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase(args.Parameters["database"]); Sitecore.Globalization.Language language = Sitecore.Globalization.Language.Parse(args.Parameters["language"]); Sitecore.Data.Version version = Sitecore.Data.Version.Parse(args.Parameters["version"]); Sitecore.Data.Items.Item item = database.GetItem(args.Parameters["id"], language, version); using (new Sitecore.Data.Items.EditContext(item)) { item.Fields[args.Parameters["field"]].Reset(); } }
public override void Process(PipelineStep pipelineStep, PipelineContext pipelineContext) { var logger = pipelineContext.PipelineBatchContext.Logger; var settings = pipelineStep.GetPlugin <PublishContentSettings>(); if (settings == null) { logger.Error( "No Publish Content Settings Detected. " + "(pipeline step: {0})", pipelineStep.Name); return; } Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master"); Sitecore.Data.Database target = Sitecore.Configuration.Factory.GetDatabase(settings.Target); var rootItem = master.GetItem(new Sitecore.Data.ID(settings.RootItem)); logger.Info("About to Start Publish"); Sitecore.Publishing.PublishManager.PublishItem(rootItem, new Sitecore.Data.Database[] { target }, settings.Languages.ToArray(), settings.ChildItems, true, //always smart publish settings.RelatedItems); logger.Info("Publish Started for {0}", rootItem.Name); }
protected void Run() { if (this.MaxVersions < 1) { this.MaxVersions = 10; } if (String.IsNullOrEmpty(this.Database)) { this.Database = "master"; } Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase(this.Database); Sitecore.Diagnostics.Assert.IsNotNull(db, this.Database); if (String.IsNullOrEmpty(this.RootItem)) { this.RootItem = db.GetRootItem().Paths.FullPath; } foreach (Sitecore.Globalization.Language language in db.Languages) { this.Iterate(db.GetItem(this.RootItem, language)); } }
public static Sitecore.Data.Items.Item GetHomeItem( this Sitecore.Sites.SiteContext me, Sitecore.Data.Database database) { Sitecore.Diagnostics.Assert.ArgumentNotNull(database, "database"); return(database.GetItem(me.StartPath)); }
public static Item GetItemByIdAndVersion(string Ciid, string version, Sitecore.Data.Database database) { var itemVersion = new Sitecore.Data.Version(version); var language = Language.Parse(ContextExtension.CurrentLanguageCode); return(database.GetItem(Ciid, language, itemVersion)); }
// retrieve the rules to invoke protected SC.Rules.RuleList <SC.Rules.RuleContext> GetRules( SC.Data.Database db) { // items that define the rules to invoke List <SC.Data.Items.Item> ruleItems = new List <SC.Data.Items.Item>(); // no rules specified to configuration factory; apply all global rules if (this.Rules.Count < 1) { SC.Data.Items.Item ruleRoot = db.GetItem("/sitecore/system/Settings/Rules/Global Item Rules/Rules"); SC.Diagnostics.Assert.IsNotNull(ruleRoot, "ruleRoot"); ruleItems.AddRange(ruleRoot.Children); } else { foreach (string id in this.Rules) { SC.Data.Items.Item ruleItem = db.GetItem(id); SC.Diagnostics.Assert.IsNotNull(ruleItem, id); ruleItems.Add(ruleItem); } } SC.Rules.RuleList <SC.Rules.RuleContext> rules = new SC.Rules.RuleList <SC.Rules.RuleContext>(); rules.Name = "All Global Item Rules"; foreach (SC.Data.Items.Item ruleItem in ruleItems) { string ruleXml = ruleItem["Rule"]; if (String.IsNullOrEmpty(ruleXml) || ruleItem["Disabled"] == "1") { continue; } SC.Rules.RuleList <SC.Rules.RuleContext> parsed = SC.Rules.RuleFactory.ParseRules <SC.Rules.RuleContext>( db, ruleXml); rules.AddRange(parsed.Rules); } return(rules); }
public List <Item> GetGoalItems(string path) { Sitecore.Data.Database context = Sitecore.Configuration.Factory.GetDatabase("master"); var item = context.GetItem(path); var items = item.Children.ToList(); return(items); }
protected override void Render(HtmlTextWriter writer) { string itemId = S.Web.WebUtil.GetQueryString("id"); Assert.IsNotNullOrEmpty(itemId, "itemId"); string dbName = S.Web.WebUtil.GetQueryString("database"); Assert.IsNotNullOrEmpty(dbName, "dbName"); S.Data.Database db = S.Configuration.Factory.GetDatabase(dbName); Assert.IsNotNull(db, "db: " + dbName); S.Data.Items.Item item = db.GetItem(itemId); Assert.IsNotNull(item, "item: " + itemId + " in " + dbName); string value = item["Type"]; Assert.IsNotNullOrEmpty(value, "value: Type of " + item.Paths.FullPath); string name = string.Empty; string dll = string.Empty; int comma = value.IndexOf(','); if (comma >= 0) { name = value.Substring(0, comma).Trim(); dll = value.Substring(comma + 1).Trim(); } Assembly assembly = S.Reflection.ReflectionUtil.LoadAssembly(dll); Assert.IsNotNull(assembly, "assembly: " + dll); Type type = assembly.GetType(name, false, true); if (type == null) { type = assembly.GetType(name + "`1"); } Assert.IsNotNull(type, "Type : " + name); dll = S.IO.FileUtil.MapPath("/bin/" + dll + ".dll"); Assert.IsTrue(File.Exists(dll), "dll.Exists(): " + dll); string tempFile = string.Format( "{0}.{1}.il", type, DateTime.Now.ToString("yyyyMMddTHHmmssffff")); S.IO.TempFolder.EnsureFolder(); tempFile = S.IO.FileUtil.MapPath( S.IO.FileUtil.MakePath(S.IO.TempFolder.Folder, tempFile, '/')); S.Sharedsource.Diagnostics.CommandLineTool clt = new S.Sharedsource.Diagnostics.CommandLineTool( "c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.0A\\bin\\NETFX 4.0 Tools\\x64\\ildasm.exe"); clt.Execute( true /*log*/, "/source /html /linenum /item=" + type + " /out=" + tempFile + " " + dll); // /pubonly Assert.IsTrue(File.Exists(tempFile), "tempFile.Exists(): " + tempFile); this.Response.Output.Write(S.IO.FileUtil.ReadFromFile(tempFile)); this.Response.End(); File.Delete(tempFile); }
// retrieve the versions of the item to process in the relevant language(s) protected SC.Data.Items.Item[] GetVersionsToProcess( SC.Data.Database db, SC.Data.ID id) { // default version of the item in default language SC.Data.Items.Item item = db.GetItem(id); SC.Diagnostics.Assert.IsNotNull(item, "item"); // all versions of the item to process in all languages to process List <SC.Data.Items.Item> versions = new List <SC.Data.Items.Item>(); // languages to process List <SC.Globalization.Language> languages = new List <SC.Globalization.Language>(); if (this.AllLanguages) { languages.AddRange(item.Languages); } else { languages.Add(item.Language); } foreach (SC.Globalization.Language language in languages) { // default version of item in individual language SC.Data.Items.Item languageItem = db.GetItem(id, language); SC.Diagnostics.Assert.IsNotNull(languageItem, "languageItem"); if (this.AllVersions) { versions.AddRange(languageItem.Versions.GetVersions()); } else { versions.Add(languageItem); } } return(versions.ToArray()); }
protected override void OnLoad(EventArgs e) { master = Factory.GetDatabase("master"); if (!Context.ClientPage.IsEvent) { Treeview.SetSelectedItem(master.GetItem(Data.ProjectRootFolder)); } base.OnLoad(e); }
/// <summary> /// /// </summary> /// <param name="args"></param> protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { if (args.IsPostBack) { if ((!String.IsNullOrEmpty(args.Result)) && args.Result != "undefined") { Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase(args.Parameters["database"]); Sitecore.Data.Items.Item item = db.GetItem(args.Parameters["id"], Sitecore.Globalization.Language.Parse(args.Parameters["language"])); } } }
protected void SelectTreeNode() { Item selectionItem = this.Treeview.GetSelectionItem(); if (selectionItem != null) { if (selectionItem.TemplateID != Data.ProjectFolder) { Treeview.SetSelectedItem(master.GetItem(Data.ProjectRootFolder)); } } }
public void OnRemoteEvent(object sender, EventArgs args) { var remoteEventArgs = args as RemoteEventArgs; Log.Info($"Remote event raised: {remoteEventArgs.ItemName}", nameof(RemoteEventHandler)); using (new SecurityDisabler()) { Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master"); Sitecore.Data.Items.Item home = masterDB.GetItem("/sitecore/content/home"); Sitecore.Data.Items.TemplateItem sample = masterDB.Templates[new Sitecore.Data.ID("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}")]; Sitecore.Data.Items.Item myItem = home.Add(remoteEventArgs.ItemName, sample); } }
private void Page_Load(object sender, EventArgs e) { Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master"); Sitecore.Data.Items.Item comments = master.GetItem("/sitecore/content/HaiNguyen/Comments"); // Put user code to initialize the page here var children = comments.Children.Where(x => x.TemplateName == "Comment"); if (children.Any()) { rpComments.DataSource = children; // children; /* Context item's children */; rpComments.DataBind(); } }
public void HowToGetItemFromSitecoreDatabase() { using (new Sitecore.FakeDb.Db { new Sitecore.FakeDb.DbItem("Home") }) { Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase("master"); Xunit.Assert.NotNull(database.GetItem("/sitecore/content/home")); } }
// Access workflow process to get info public void Process(WorkflowPipelineArgs args) { Item currentPost = args.DataItem; string titleField = FieldValidation(currentPost, "Title"); string thumbnailImage = FieldValidation(currentPost, "ThumbnailImage"); string description = FieldValidation(currentPost, "Description"); string content = FieldValidation(currentPost, "Content"); string publishedDate = FieldValidation(currentPost, "PubDate"); // Validate required fields if (IsFieldAvailable(currentPost, "Title") && String.IsNullOrEmpty(titleField) || IsFieldAvailable(currentPost, "ThumbnailImage") && String.IsNullOrEmpty(thumbnailImage) || IsFieldAvailable(currentPost, "Description") && String.IsNullOrEmpty(description) || IsFieldAvailable(currentPost, "Content") && String.IsNullOrEmpty(content)) { Sitecore.Diagnostics.Log.Audit("Blog WP- One of required fields is empty. Stop submitting the request at " + currentPost.Paths.FullPath, this); SheerResponse.Alert("One of required fields is empty"); args.AbortPipeline(); } else { Sitecore.Data.Database webDb = Sitecore.Configuration.Factory.GetDatabase("web"); // if the item has not been published if (currentPost != null && webDb.GetItem(currentPost.ID) == null) { string sitecoreTime = Sitecore.DateUtil.ToIsoDate(DateTime.Now); // Update publish date using (new Sitecore.SecurityModel.SecurityDisabler()) { currentPost.Editing.BeginEdit(); currentPost.Fields["__Display name"].Value = currentPost.DisplayName.Replace("_Draft", ""); // Update pubDate field for RSS Feed currentPost.Fields["pubDate"].Value = sitecoreTime; // Update __Created date field for Bucket Sync currentPost.Fields["__Created"].Value = sitecoreTime; currentPost.Editing.EndEdit(); // Bucket sync BucketManager.Sync(currentPost.Database.GetItem(BlogSettings.ArticleRootPath.ID)); } // Refresh the new post for search index master var tempItem = (SitecoreIndexableItem)currentPost; string searchIndexMaster = BlogSettings.SearchIndexName; Sitecore.ContentSearch.ContentSearchManager.GetIndex(searchIndexMaster).Refresh(tempItem); Sitecore.Diagnostics.Log.Audit("Search Indexing: " + searchIndexMaster, this); } } }
private void SetRight(string strDatabase, string strItem, string strAccount, List <AccessRight> rights) { //Get Access Rules, Set Access Rules try { Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase(strDatabase); Item item = db.GetItem(strItem); AccountType accountType = AccountType.User; Account account = Account.FromName(strAccount, accountType); AccessPermission rightState = AccessPermission.Allow; if (Sitecore.Security.SecurityUtility.IsRole(strAccount)) { accountType = Sitecore.Security.Accounts.AccountType.Role; } AccessRuleCollection accessRules = item.Security.GetAccessRules(); foreach (AccessRight right in rights) { try { accessRules.Helper.RemoveExactMatches(account, right); } catch (Exception ex) { Log.Debug("accessRules.Helper.RemoveExactMatches " + ex.Message.ToString()); } try { accessRules.Helper.AddAccessPermission(account, right, PropagationType.Entity, rightState); accessRules.Helper.AddAccessPermission(account, right, PropagationType.Descendants, rightState); Log.Debug(account.Name.ToString() + " has access right of " + right.Name.ToString() + " for " + strItem); } catch (Exception ex) { Log.Debug("accessRules.Helper.AddAccessPermission " + ex.Message.ToString()); } } item.Security.SetAccessRules(accessRules); } catch (Exception ex) { Log.Debug(ex.Message.ToString()); } }
private string GetColor(string fieldName) { Item pres = SiteConfiguration.GetSiteConfigurationItem(); if (pres != null) { Sitecore.Data.Database d = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database; Item i = d.GetItem(pres[fieldName]); if (i != null) { return(i["Color Value"]); } } return(null); }
public override void Process(PublishItemContext context) { Sitecore.Data.ID itmID = context.ItemId; Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master"); Item item = masterDB.GetItem(itmID); if (item == null) { return; } //string spName = "dbo.AddToPublishLog"; //String ConnectionString = Sitecore.Configuration.Settings.GetConnectionString("custom"); //if (!String.IsNullOrWhiteSpace(ConnectionString)) //{ // using (SqlConnection connection = new SqlConnection(ConnectionString)) // { // using (SqlCommand command = new SqlCommand(spName, connection)) // { // command.CommandType = CommandType.StoredProcedure; // command.Parameters.Add(new SqlParameter("@Site", Sitecore.Context.Site.Name.ToString())); // command.Parameters.Add(new SqlParameter("@ItemID", item.ID.ToString())); // Item produdctGp = GetProductGroup(item); // command.Parameters.Add(new SqlParameter("@ProductGroupItemID", produdctGp == null ? string.Empty : produdctGp.ID.ToString())); // Item productCat = GetProductCategory(item); // command.Parameters.Add(new SqlParameter("@ProductCategoryItemID", productCat == null ? string.Empty : productCat.ID.ToString())); // command.Parameters.Add(new SqlParameter("@Language", String.Empty)); // command.Parameters.Add(new SqlParameter("@Mode", String.Empty)); // command.Parameters.Add(new SqlParameter("@RepublishAll", String.Empty)); // command.Parameters.Add(new SqlParameter("@SourceDatabase", String.Empty)); // command.Parameters.Add(new SqlParameter("@TargetDatabase", String.Empty)); // command.Parameters.Add(new SqlParameter("@RequestedBy", String.Empty)); // connection.Open(); // command.ExecuteNonQuery(); // } // } //} }
public void UpdateEditorialNotes(string itemID, string text) { Sitecore.Data.Database masterDB = Factory.GetDatabase("master"); Item currentItem = masterDB.GetItem(itemID); using (new Sitecore.SecurityModel.SecurityDisabler()) { using (new EditContext(currentItem)) { currentItem.Editing.BeginEdit(); currentItem[IArticleConstants.Editorial_NotesFieldId] = text.StripHtmlTags(); currentItem.Editing.AcceptChanges(); currentItem.Editing.EndEdit(); } } }
public async Task <IHttpActionResult> Profiles(string id) { // todo move to sitecore helper Sitecore.Data.Database db = Sitecore.Context.Database; Item item = db.GetItem(new Sitecore.Data.ID(profilesItem)); var profileKeys = Sitecore.Context.Database.SelectItems(PROFILE_KEYS).Select(el => new { ProfileKeyId = el.ID, ProfileKeyName = el.Name }); // Emulate async work await Task.Delay(50); return(Ok(new { ContextItemId = id, ProfileKeys = profileKeys })); }
public static string GetUpdatePackageVersion(string packageName) { Sitecore.Data.Database coreDB = Sitecore.Configuration.Factory.GetDatabase("core"); using (new SecurityDisabler()) { var normalizedPackageVersion = packageName.Replace(".", ""); var installItem = coreDB.GetItem("/sitecore/system/Packages/Installation history/" + normalizedPackageVersion, Language.Parse("en-GB")); if (installItem == null || installItem.Children.Count == 0) { return(string.Empty); } installItem = installItem.Children.OrderBy(i => i.Name).Last(); return(installItem.Fields["Package version"].Value); } }
public YouTubeStats(string VideoID) { this.videoID = VideoID; master = Factory.GetDatabase("master"); Item settings = master.GetItem(Data.YouTubeSettingsID); if (settings == null) { Log.Error("YouTube Settings not found!", this); return; } else { devKey = settings.Fields[Data.DevKeyFieldID].Value; clientID = settings.Fields[Data.ClientIDFieldID].Value; username = settings.Fields[Data.UserNameFieldID].Value; password = settings.Fields[Data.PasswordFieldID].Value; GetStats(); } }