Message 1 of 1
Possible bug or strange behavior: Recursion in DocumentService.GetFileDeleteRestrictionsByMasterId
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello again š
also described in the Recycle Bin idea threat, when I want to check of other Restrictions in the DocumentService.DeleteFileEvents Event I programmed myself, it wents into a recursion. Below a excerpt from my code without the fix.
If you don“t remove the event, it will call itself again and again.
using Autodesk.Connectivity.Extensibility.Framework;
using Autodesk.Connectivity.WebServices;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MyVaultExtensions {
public class MyVaultRestrictions : IWebServiceExtension {
public void OnLoad() {
DocumentService.DeleteFileEvents.GetRestrictions += new EventHandler<DeleteFileCommandEventArgs>(DeleteFileEvents_GetRestrictions);
}
private void DeleteFileEvents_GetRestrictions(object sender, DeleteFileCommandEventArgs e) {
var ds = (DocumentService)sender;
// Check if Vault or other restrictions are found for the file, if so, don“t do anything
var res = documentService.GetFileDeleteRestrictionsByMasterId(eventArgs.FileMasterIds.FirstOrDefault(), eventArgs.FolderId); // here he runs forever now
/* the rest of your code will never be executed */
}
}
}
The fix is to remove the Event for the time of the check
private void DeleteFileEvents_GetRestrictions(object sender, DeleteFileCommandEventArgs e) {
var ds = (DocumentService)sender;
// Check if Vault or other restrictions are found for the file, if so, don“t do anything
var res = documentService.GetFileDeleteRestrictionsByMasterId(eventArgs.FileMasterIds.FirstOrDefault(), eventArgs.FolderId); // here he runs forever now
/* the rest of your code will never be executed */
}
I would rather not have to do such hacks, but I trust Vault that the restrictions from i.e. LifeCycles are working and my code should not run.
Any other suggestions?
Best regards
Thomas