public ActionResult AddDeletedUrl(string oldUrl) { CheckAccess(); // add redirect to dds with state "deleted" var redirect = new CustomRedirect { OldUrl = oldUrl, NewUrl = string.Empty, State = Convert.ToInt32(RedirectState.Deleted) }; _redirectsService.AddOrUpdate(redirect); CustomRedirectHandler.ClearCache(); // delete rows from DB var dbAccess = DataAccessBaseEx.GetWorker(); dbAccess.DeleteRowsForRequest(oldUrl); // List <CustomRedirect> customRedirectList = GetDeletedUrls(); CustomRedirectHandler.ClearCache(); return(Deleted()); }
public ActionResult MigrateDdsToSql() { CheckAccess(); var ddsRequests = _ddsRedirectRepository.GetAll().ToList(); var count = ddsRequests.Count; foreach (var ddsRequest in ddsRequests) { _redirectsService.AddOrUpdate(new CustomRedirect { State = ddsRequest.State, NewUrl = ddsRequest.NewUrl, OldUrl = ddsRequest.OldUrl, WildCardSkipAppend = ddsRequest.WildCardSkipAppend }); _ddsRedirectRepository.Delete(ddsRequest); } ViewData["information"] = $"Migrated {count} redirects from DDS to SQL"; CustomRedirectHandler.ClearCache(); return(View("Administer")); }
public FileUploadJsonResult ImportRedirects(HttpPostedFileBase xmlfile) { CheckAccess(); if (!IsXml(xmlfile)) { return(new FileUploadJsonResult { Data = new { message = LocalizationService.Current.GetString("/gadget/redirects/invalidxmlfile") } }); } // Read all redirects from xml file RedirectsXmlParser parser = new RedirectsXmlParser(xmlfile.InputStream); // Save all redirects from xml file CustomRedirectCollection redirects = parser.Load(); string message; if (redirects != null || redirects.Count() != 0) { _redirectsService.AddOrUpdate(redirects); CustomRedirectHandler.ClearCache(); message = string.Format(LocalizationService.Current.GetString("/gadget/redirects/importsuccess"), redirects.Count()); } else { message = LocalizationService.Current.GetString("/gadget/redirects/importnone"); } return(new FileUploadJsonResult { Data = new { message = message } }); }
public ActionResult IgnoreRedirect(string oldUrl, int pageNumber, string searchWord, int pageSize) { CheckAccess(); // delete rows from DB var dbAccess = DataAccessBaseEx.GetWorker(); dbAccess.DeleteRowsForRequest(oldUrl); // add redirect to dds with state "ignored" var redirect = new CustomRedirect { OldUrl = oldUrl, NewUrl = string.Empty, State = Convert.ToInt32(RedirectState.Ignored) }; _redirectsService.AddOrUpdate(redirect); CustomRedirectHandler.ClearCache(); List <CustomRedirect> customRedirectList = GetSuggestions(searchWord); string actionInfo = string.Format(LocalizationService.Current.GetString("/gadget/redirects/ignoreredirect"), oldUrl); RedirectIndexViewData viewData = GetRedirectIndexViewData(pageNumber, customRedirectList, actionInfo, searchWord, pageSize, true, true); if (customRedirectList.Count > 0) { viewData.HighestSuggestionValue = customRedirectList.First().NotfoundErrorCount; viewData.LowestSuggestionValue = customRedirectList.Last().NotfoundErrorCount; } return(View("Index", viewData)); }
public void SaveRedirect(string oldUrl, string newUrl, string skipWildCardAppend) { Logger.Debug("Adding redirect: '{0}' -> '{1}'", oldUrl, newUrl); // Get hold of the datastore _redirectsService.AddOrUpdate(new CustomRedirect(oldUrl.Trim(), newUrl.Trim(), skipWildCardAppend == null ? false : true)); CustomRedirectHandler.ClearCache(); }
public ActionResult AddDeletedUrl(string oldUrl) { CheckAccess(); // add redirect to dds with state "deleted" var redirect = new CustomRedirect(); redirect.OldUrl = oldUrl; redirect.State = Convert.ToInt32(DataStoreHandler.State.Deleted); DataStoreHandler dsHandler = new DataStoreHandler(); dsHandler.SaveCustomRedirect(redirect); CustomRedirectHandler.ClearCache(); // delete rows from DB var dbAccess = DataAccessBaseEx.GetWorker(); dbAccess.DeleteRowsForRequest(oldUrl); // List <CustomRedirect> customRedirectList = GetDeletedUrls(); CustomRedirectHandler.ClearCache(); return(Deleted()); }
private static void dataStoreInvalidationEvent_Raised(object sender, EventNotificationEventArgs e) { _log.Debug("dataStoreInvalidationEvent '{2}' handled - raised by '{0}' on '{1}'", e.RaiserId, Environment.MachineName, e.EventId); _log.Debug("Begin: Clearing cache on '{0}'", Environment.MachineName); CustomRedirectHandler.ClearCache(); _log.Debug("End: Clearing cache on '{0}'", Environment.MachineName); }
public ActionResult DeleteAllRedirects() { CheckAccess(); _redirectsService.DeleteAll(); CustomRedirectHandler.ClearCache(); ViewData["information"] = LocalizationService.Current.GetString("/gadget/redirects/redirectsdeleted"); return(View("Administer")); }
public void SaveRedirect(string oldUrl, string newUrl, string skipWildCardAppend) { Logger.Debug("Adding redirect: '{0}' -> '{1}'", oldUrl, newUrl); // Get hold of the datastore DataStoreHandler dsHandler = new DataStoreHandler(); dsHandler.SaveCustomRedirect(new CustomRedirect(oldUrl.Trim(), newUrl.Trim(), skipWildCardAppend == null ? false : true)); CustomRedirectHandler.ClearCache(); }
public ActionResult Delete(string oldUrl, int?pageNumber, string searchWord, int?pageSize) { CheckAccess(); Logger.Debug("Deleting redirect: '{0}'", oldUrl); _redirectsService.DeleteByOldUrl(oldUrl); CustomRedirectHandler.ClearCache(); List <CustomRedirect> customRedirectList = GetData(searchWord); //Make sure that the searchinfo is contained after an item has been deleted - if there is any. return(View("Index", GetRedirectIndexViewData(pageNumber, customRedirectList, GetSearchResultInfo(searchWord, customRedirectList.Count, false), searchWord, pageSize, false, true))); }
public FileUploadJsonResult ImportDeleted(HttpPostedFileBase txtFile) { CheckAccess(); if (!IsTxt(txtFile)) { return(new FileUploadJsonResult { Data = new { message = LocalizationService.Current.GetString("/gadget/redirects/invalidtxtfile") } }); } var redirects = new CustomRedirectCollection(); using (var streamReader = new StreamReader(txtFile.InputStream)) { while (streamReader.Peek() >= 0) { var url = streamReader.ReadLine(); if (!string.IsNullOrEmpty(url)) { redirects.Add(new CustomRedirect { OldUrl = url, NewUrl = string.Empty, State = (int)RedirectState.Deleted }); } } } string message; if (redirects.Count() != 0) { _redirectsService.AddOrUpdate(redirects); CustomRedirectHandler.ClearCache(); message = string.Format(LocalizationService.Current.GetString("/gadget/redirects/importdeletedsuccess"), redirects.Count()); } else { message = LocalizationService.Current.GetString("/gadget/redirects/importnone"); } return(new FileUploadJsonResult { Data = new { message = message } }); }
public ActionResult SaveSuggestion(string oldUrl, string newUrl, string skipWildCardAppend, int?pageNumber, int?pageSize) { CheckAccess(); SaveRedirect(oldUrl, newUrl, skipWildCardAppend); // delete rows from DB var dbAccess = DataAccessBaseEx.GetWorker(); dbAccess.DeleteRowsForRequest(oldUrl); // List <CustomRedirect> customRedirectList = GetSuggestions(null); string actionInfo = string.Format(LocalizationService.Current.GetString("/gadget/redirects/saveredirect"), oldUrl, newUrl); CustomRedirectHandler.ClearCache(); var viewData = GetRedirectIndexViewData(pageNumber, customRedirectList, actionInfo, null, pageSize, true, true); if (customRedirectList.Count > 0) { viewData.HighestSuggestionValue = customRedirectList.First().NotfoundErrorCount; viewData.LowestSuggestionValue = customRedirectList.Last().NotfoundErrorCount; } return(View("Index", viewData)); }