/// <summary>
/// Purges a dataset, which means the dataset and all its versions will be physically removed from the database.
/// </summary>
/// <param name="id">the identifier of the dataset to be purged.</param>
/// <remarks>This operation is not revocerable.</remarks>
/// <returns></returns>
public ActionResult Purge(long id)
{
ViewBag.Title = PresentationModel.GetViewTitleForTenant("Purge", this.Session.GetTenant());
bool itsFine = false;
DatasetManager dm = new DatasetManager();
try
{
if (dm.PurgeDataset(id))
{
itsFine = true;
}
}
catch (Exception ex)
{
try // give it another try
{
if (dm.PurgeDataset(id, true))
{
itsFine = true;
}
}
catch (Exception exx)
{
ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be purged. Details: {1}, see also: {2}", id, exx.Message, ex.Message));
}
}
if (itsFine)
{
try
{
PermissionManager pm = new PermissionManager();
pm.DeleteDataPermissionsByEntity(1, id);
}
catch
{
ViewData.ModelState.AddModelError("", string.Format("Dataset {0} was purged, but its permissions were not altered. You need to remove them manually from the data permission management.", id));
}
try
{
ISearchProvider provider = IoCFactory.Container.ResolveForSession<ISearchProvider>() as ISearchProvider;
provider?.UpdateSingleDatasetIndex(id, IndexingAction.DELETE);
}
catch
{
ViewData.ModelState.AddModelError("", string.Format("Dataset {0} was purged, but it is still indexed for searching. You need to reindex the search via the managemnet console.", id));
}
}
return View();
}