public void UnignoreRedirect(string oldUrl, int siteId) { // Get hold of the datastore DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); //find object with matching property "OldUrl" var urlEncode = HttpUtility.UrlEncode(oldUrl); if (urlEncode != null) { var savedUrl = urlEncode.ToLower().Replace("%2f", "/"); var filters = new Dictionary <string, object> { { OldUrlPropertyName, savedUrl.ToLower() }, { SiteIdPropertyName, siteId } }; CustomRedirect match = store.Find <CustomRedirect>(filters).SingleOrDefault(); if (match != null) { // log request to database - if logging is turned on. if (Configuration.Configuration.Logging == LoggerMode.On) { store.Delete(match); // Safe logging RequestLogger.Instance.LogRequest(savedUrl, string.Empty, siteId); } } } }
public void SaveCustomRedirect(CustomRedirect currentCustomRedirect) { // Get hold of the datastore DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); //check if there is an exisiting object with matching property "OldUrl" Dictionary <string, object> filter = new Dictionary <string, object> { { OldUrlPropertyName, currentCustomRedirect.OldUrl.ToLower() }, { SiteIdPropertyName, currentCustomRedirect.SiteId } }; CustomRedirect match = store.Find <CustomRedirect>(filter).SingleOrDefault(); if (match == null) { //check if there is an exisiting object with "NewUrl" set to this property "OldUrl", and change that one instead filter = new Dictionary <string, object> { { NewUrlPropertyName, currentCustomRedirect.OldUrl.ToLower() }, { SiteIdPropertyName, currentCustomRedirect.SiteId } }; match = store.Find <CustomRedirect>(filter).SingleOrDefault(); } //if there is a match, replace the value. if (match != null) { store.Save(currentCustomRedirect, match.Id); } else { store.Save(currentCustomRedirect); } }
// GET: CommentUserBlock public override ActionResult Index(CommentUserBlock currentBlock) { EPiServerProfile currentUser = EPiServerProfile.Current; var model = new CommentUserViewModel { Body = currentBlock.Body, User = currentUser.UserName }; //PageHelper => get current page /* * DynamicDataStore store = DynamicDataStoreFactory.Instance.CreateStore("People", typeof(Person)); * Identity id = store.Save(p); */ var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <EPiServer.Web.Routing.IPageRouteHelper>(); var pageReference = pageRouteHelper.PageLink; var id = pageReference.ID; PersonWithIDynamicData newPerson = new PersonWithIDynamicData { Name = Guid.NewGuid().ToString(), CreatedDate = DateTime.Now }; DynamicDataStore store = DynamicDataStoreFactory.Instance.CreateStore("Comment", typeof(PersonWithIDynamicData)); var loadedPerson = store.LoadAll <PersonWithIDynamicData>(); //var id = store.Save(newPerson); return(PartialView(model)); }
public static StoreMetadata Metadata(this DynamicDataStore store) { return(new StoreMetadata { Name = store.Name, Columns = store.StoreDefinition.ActiveMappings }); }
/// <summary> /// Find all CustomRedirect objects which has a OldUrl og NewUrl that contains the search word. /// </summary> /// <param name="searchWord"></param> /// <param name="siteId"></param> /// <returns></returns> public List <CustomRedirect> SearchCustomRedirects(string searchWord, int siteId) { DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); var customRedirects = from s in store.Items <CustomRedirect>() where s.SiteId.Equals(siteId) && (s.NewUrl.Contains(searchWord) || s.OldUrl.Contains(searchWord)) select s; return(customRedirects.ToList()); }
public EnvironmentSynchronizationStore() { _store = DynamicDataStoreFactory.Instance.GetStore(typeof(EnvironmentSynchronizationStamp)); if (_store == null) { _store = DynamicDataStoreFactory.Instance.CreateStore(typeof(EnvironmentSynchronizationStamp)); Logger.Information("Create data store for 'EnvironmentSynchronizationStamp'."); } }
public static void RemovePersistedValuesFor(this DynamicDataStore store, string pluginId) { var existingBags = store.FindAsPropertyBag("PluginId", pluginId); foreach (var existingBag in existingBags) { store.Delete(existingBag); } }
/// <summary> /// Find all CustomRedirect objects which has a OldUrl og NewUrl that contains the search word. /// </summary> /// <param name="searchWord"></param> /// <returns></returns> public List <CustomRedirect> SearchCustomRedirects(string searchWord) { DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); var CustomRedirects = from s in store.Items <CustomRedirect>() where s.NewUrl.Contains(searchWord) || s.OldUrl.Contains(searchWord) select s; return(CustomRedirects != null?CustomRedirects.ToList() : null); }
public static StayUpToDateData GetByEmail(string email) { if (string.IsNullOrEmpty(email)) { return(null); } DynamicDataStore store = GetStore(); return(store.Items <StayUpToDateData>().FirstOrDefault(x => x.Email == email)); }
internal static void RemoveProcessedQueueItems(System.Collections.ObjectModel.Collection <Identity> ids) { using (DynamicDataStore dynamicDataStore = SearchSettings.GetDynamicDataStore()) { foreach (Identity current in ids) { dynamicDataStore.Delete(current); } } }
public static void PersistValuesFor(this DynamicDataStore store, string pluginId, IEnumerable <Control> controls, Func <Control, object> controlvalue) { store.Save( new ScheduledJobParameters { PluginId = pluginId, PersistedValues = controls .ToDictionary(c => c.ID, controlvalue) }); }
/// <summary> /// Delete all CustomRedirect objects /// </summary> public void DeleteAllCustomRedirects() { // In order to avoid a database timeout, we delete the items one by one. DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); foreach (CustomRedirect redirect in GetCustomRedirects(false)) { store.Delete(redirect); } }
public List <CustomRedirect> GetIgnoredRedirect(int siteId) { DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); var customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) where s.State.Equals(State.Ignored) & s.SiteId.Equals(siteId) select s; return(customRedirects.ToList()); }
public List <CustomRedirect> GetDeletedRedirect() { DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); var deletedRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) where s.State.Equals(State.Deleted) select s; return(deletedRedirects.ToList()); }
private EmployeeSettingsModel RetrieveSettings(DynamicDataStore store) { EmployeeSettingsModel model = null; if (store != null) { model = store.LoadAll <EmployeeSettingsModel>().First(); } return(model); }
public static void SaveAll <T>(this DynamicDataStore store, T[] entries) where T : class { if (entries == null) { return; } foreach (var entry in entries) { store.Save(entry); } }
public Webhook GetWebhook(Guid id, DynamicDataStore storeIn = null) { var store = storeIn ?? _dataStoreFactory.CreateStore(typeof(Webhook)); var item = store.Items <Webhook>().FirstOrDefault(x => x.Id.ExternalId.Equals(id)); if (storeIn == null) { store.Dispose(); } return(item); }
private EmployeeSettingsModel RetrieveSettings(DynamicDataStore store) { EmployeeSettingsModel model = null; if (store != null) { model = store.LoadAll<EmployeeSettingsModel>().First(); } return model; }
public int DeleteAllIgnoredRedirects() { // In order to avoid a database timeout, we delete the items one by one. DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); var ignoredRedirects = GetIgnoredRedirect(); foreach (CustomRedirect redirect in ignoredRedirects) { store.Delete(redirect); } return(ignoredRedirects.Count()); }
private void UnregisterRedirectDynamicStoreCacheHandlers() { if (!CacheConfiguration.Service.IsAllRedirectsCacheEnabled && !CacheConfiguration.Service.IsUrlRedirectCacheEnabled) { return; } var redirectRuleDynamicDataStoreName = DynamicDataStoreFactory.Instance.GetStoreNameForType(typeof(RedirectRule)); DynamicDataStore.UnregisterDeletedAllEventHandler(redirectRuleDynamicDataStoreName, HandleClearCache); DynamicDataStore.UnregisterItemDeletedEventHandler(redirectRuleDynamicDataStoreName, HandleClearCache); DynamicDataStore.UnregisterItemSavedEventHandler(redirectRuleDynamicDataStoreName, HandleClearCache); }
/// <summary> /// Delete CustomObject object from Data Store that has given "OldUrl" property /// </summary> /// <param name="currentCustomRedirect"></param> public void DeleteCustomRedirect(string oldUrl) { // Get hold of the datastore DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); //find object with matching property "OldUrl" CustomRedirect match = store.Find <CustomRedirect>(OLD_URL_PROPERTY_NAME, oldUrl.ToLower()).SingleOrDefault(); if (match != null) { store.Delete(match); } }
private void FillCustomTablePageViewStoreForType(Type storeType) { DynamicDataStore store = storeType.GetOrCreateStore(); for (int i = 0; i < RowsInTableCount; i++) { store.Save(new CustomTablePageViewsData { PageId = i, ViewsAmount = i }); } }
private void FillFakeDataStore() { DynamicDataStore store = _fakeDataStoreType.GetOrCreateStore(); for (int i = 0; i < RowsInTableCount; i++) { store.Save(new FakeData { FakeInt = i, FakeString = i.ToString() }); } }
public QueueManager(DynamicDataStoreFactory dynamicDataStoreFactory, IHandler handler) { if (dynamicDataStoreFactory == null) throw new ArgumentNullException("dynamicDataStoreFactory"); if (handler == null) throw new ArgumentNullException("handler"); _dynamicDataStoreFactory = dynamicDataStoreFactory; _handler = handler; _queueStore = _dynamicDataStoreFactory .GetStore(typeof (QueueItem)); _errorQueueStore = _dynamicDataStoreFactory .GetStore(typeof(ErrorQueueItem)); }
public Guid Save(CommandMetaData commandMetaData) { DynamicDataStore store = this._changeApprovalDynamicDataStoreFactory.GetStore("EPiServer.ChangeApproval.Core.Internal.CommandMetaData"); if (store == null) { return(Guid.Empty); } lock (_lock) { var identity = store.Save(commandMetaData); return(identity == null ? Guid.Empty : identity.ExternalId); } }
public bool SaveSettings(EmployeeSettingsModel data) { DynamicDataStore store = DynamicDataStoreFactory.Instance.GetStore(StoreName); if (store == null) { store = DynamicDataStoreFactory.Instance.CreateStore(StoreName, typeof(EmployeeSettingsModel)); } else { store.DeleteAll(); } Identity id = store.Save(data); return(id.ExternalId != Guid.Empty); }
public void SaveCustomRedirect(CustomRedirect currentCustomRedirect) { // Get hold of the datastore DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); //check if there is an exisiting object with matching property "OldUrl" CustomRedirect match = store.Find <CustomRedirect>(OLD_URL_PROPERTY_NAME, currentCustomRedirect.OldUrl.ToLower()).SingleOrDefault(); //if there is a match, replace the value. if (match != null) { store.Save(currentCustomRedirect, match.Id); } else { store.Save(currentCustomRedirect); } }
private void ContentSecurityRepository_ContentSecuritySaving(object sender, ContentSecurityCancellableEventArgs e) { var entry = new SecurityLogEntry { Id = Identity.NewIdentity(Guid.NewGuid()), ContentLink = e.ContentLink, ContentName = contentLoader.Get <IContent>(e.ContentLink).Name, SecuritySaveType = e.SecuritySaveType, Entries = e.ContentSecurityDescriptor.Entries.Select(ace => ACE.ConvertFrom(ace)).ToArray(), IsInherited = e.ContentSecurityDescriptor.IsInherited, ModifiedBy = HttpContext.Current.User.Identity.Name, Modified = DateTime.Now }; DynamicDataStore store = DynamicDataStoreFactory.Instance .CreateStore("SecurityLogEntry", typeof(SecurityLogEntry)); store.Save(entry); }
/// <summary> /// Returns a list of all CustomRedirect objects in the Dynamic Data Store. /// </summary> /// <returns></returns> public List <CustomRedirect> GetCustomRedirects(bool excludeIgnored) { // IEnumerable<CustomRedirect> customRedirects = null; DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); IEnumerable <CustomRedirect> customRedirects; if (excludeIgnored) { customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) where s.State.Equals((int)State.Saved) select s; } else { customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) select s; } return(customRedirects != null?customRedirects.ToList() : null); }
/// <summary> /// Delete CustomObject object from Data Store that has given "OldUrl" property /// </summary> /// <param name="oldUrl"></param> /// <param name="siteId"></param> public void DeleteCustomRedirect(string oldUrl, int siteId) { // Get hold of the datastore DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); //find object with matching property "OldUrl" var urlEncode = HttpUtility.UrlEncode(oldUrl); if (urlEncode != null) { var savedUrl = urlEncode.ToLower().Replace("%2f", "/"); var filters = new Dictionary <string, object> { { OldUrlPropertyName, savedUrl.ToLower() }, { SiteIdPropertyName, siteId } }; CustomRedirect match = store.Find <CustomRedirect>(filters).SingleOrDefault(); if (match != null) { store.Delete(match); } } }
/// <summary> /// Returns a list of all CustomRedirect objects in the Dynamic Data Store. /// </summary> /// <returns></returns> public List <CustomRedirect> GetCustomRedirects(bool excludeIgnored, int siteId) { DynamicDataStore store = DataStoreFactory.GetStore(typeof(CustomRedirect)); IEnumerable <CustomRedirect> customRedirects; if (excludeIgnored) { customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) where s.State.Equals((int)State.Saved) & s.SiteId == siteId select s; } else { customRedirects = from s in store.Items <CustomRedirect>().OrderBy(cr => cr.OldUrl) where s.SiteId == siteId select s; } if (customRedirects.Any()) { return(customRedirects.ToList()); } return(new List <CustomRedirect>()); }
public DynamicDataStoreRatingRepository(RatingCalculator ratingCalculator, DynamicDataStoreFactory dynamicDataStoreFactory) { this.ratingCalculator = ratingCalculator; this.ratingStore = dynamicDataStoreFactory.GetStore(typeof(PageRating)); }
public static Dictionary <string, object> LoadPersistedValuesFor(this DynamicDataStore store, string pluginId) { var parameters = store.LoadAll <ScheduledJobParameters>().SingleOrDefault(p => p.PluginId == pluginId); return(parameters != null ? parameters.PersistedValues : new Dictionary <string, object>()); }
public PageObjectRatingRepository(RatingCalculator ratingCalculator, PageObjectManagerFactory pageObjectManagerFactory, DynamicDataStoreFactory dynamicDataStoreFactory) { this.ratingCalculator = ratingCalculator; this.pageObjectManagerFactory = pageObjectManagerFactory; this.ratingStore = dynamicDataStoreFactory.GetStore(typeof(PageRating)); }
public ReplaceableStorageProvider() { _replaceableStore = DynamicDataStoreFactory.Instance.GetStore(typeof(Replaceable)); }
public PageObjectCommentRepository(PageObjectManagerFactory pageObjectManagerFactory, DynamicDataStoreFactory dynamicDataStoreFactory) { this.pageObjectManagerFactory = pageObjectManagerFactory; this.commentStore = dynamicDataStoreFactory.GetStore(typeof(PageComment)); }