AI OnAI Off
Hi,
Maybe inside you Scheduled Job execute method you could use something like (I didn't test it):
IEnumerable<PageData> pagesToMove = LoadAllOutdatedEvents();
// save old URLs
var oldUrls = new Dictionary<int, string>();
foreach (var pageData in pagesToMove)
{
oldUrls[pageData.PageLink.ID] = pageData.LinkURL;
}
// job - moves outdated events (your current code)
// ....
// ...
// save redirects
var customRedirectCollection = CustomRedirectHandler.Current.CustomRedirects;
foreach (var pageData in pagesToMove)
{
var pageWithNewUrl = contentRepository.Get<PageData>(pageData.PageLink.ToReferenceWithoutVersion());
customRedirectCollection.Add(new CustomRedirect( oldUrls[pageData.PageLink.ID], pageWithNewUrl.LinkURL ));
}
CustomRedirectHandler.Current.SaveCustomRedirects(customRedirectCollection);
I am using a scheduled job that moves outdated events to a folder called "Past events". After the event have been moved, I want to change the events page url from its old one to the new so it matches the hierarchy of its new location. For this, I am using a custom redirect gadget called BVN.404Handler.
if(Configuration.Logging == LoggerMode.On && Upgrader.Valid) { Logger.LogRequest(urlNotFound, referer); }The line of code above only logs a suggestion of the old url and the new one. Since this is a scheduled job that moves pages based on their endDate value i need to make the redirect gadget register the url mappings automatically. With the current solution, a user needs to manually open the gadget and confirm the mapping by pasting the newurl (known referrers) value into the textfield and pressing "Add".
This is what it looks like:
Is this possible to achieve with the current version of this gadget?
Or do anyone know a possible workaround for achieving this?
Thanks in advance