コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        /// <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);
                }
            }
        }