Possibly to subscribe to file status changes via events?

Possibly to subscribe to file status changes via events?

Anonymous
Not applicable
818 Views
3 Replies
Message 1 of 4

Possibly to subscribe to file status changes via events?

Anonymous
Not applicable

I want my application to be notified when a file status change occurs ie for example if another user checks out the file.

The events system I've read about seems to rather local, reacting only to changes that occurs on the same machine? And requiring an extension DLL be installed so that it's used by any vault client  on that machine? I'd like to simply be notified by the server that a file status has been updated... Is there a simple way to get this done so that I don't have to do polling?

0 Likes
Accepted solutions (1)
819 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

This is 100% possible, we do it today.  Wait one I will find a code sample.

0 Likes
Message 3 of 4

Anonymous
Not applicable
Accepted solution

It's not particularly simple - it's not HARD, but you will have to write a service and a listener.  

 

In a nutshell, you need a service running somewhere that has a connection to Vault and an instance of the Webservice manager.  You service is going to implement System.ServiceModel.ServiceBase, it's going to get a connection the the WebServiceManager and then pass off to an implementation of System.ServiceModel.ServiceHost .    WebServiceManager is going to toss out the FileEvents and FolderEvents, you just catch them in your particular implementation and do something with them.  Note that your actual implementation doesn't particularly need to live on the server that ADMS is running on, your implementation just needs to live somewhere that it can access the webservice manager. Our particular implementation runs in a tray app on our users workstations, gets a connection, and just listens and does stuff based on the events we have configured.  Here is a sample interface you can reference:

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace VaultInterfaceEntities {
    [ServiceContract]
    public interface IVaultIntercept {
        [OperationContract]
        EventResult FileEvent(string vaultserver, string vaultname, string user, EventType eventtype, InterceptEvent ievent, long[] targetids, long parent);
        [OperationContract]
        EventResult FolderEvent(string vaultserver, string vaultname, string user, EventType eventtype, InterceptEvent ievent, long[] targetids, long parent);
        [OperationContract(IsOneWay = true)]
        void UserEvent(string user, string machine, UserInterceptEvent uevent);
        [OperationContract]
        IEnumerable<Restriction> FindRestrictions(string vaultserver, string vaultname, string user, RestrictionType restrictionType, InterceptEvent ievent, long[] targetids, long parent);
    }
    [DataContract]
    public enum UserInterceptEvent  {
        [EnumMember]
        Connect,
        [EnumMember]
        Disconnect
    }
    [DataContract]
    public enum RestrictionType {
        [EnumMember]
        File,
        [EnumMember]
        Folder
    }
    [DataContract]
    public class Restriction {
        [DataMember]
        public string Id { get; set; }
        [DataMember]
        public string ObjectName { get; set; }
        [DataMember]
        public string Message { get; set; }
    }
    [DataContract]
    public enum EventType {
        [EnumMember]
        Pre,
        [EnumMember]
        Post
    }
    /// <summary>
    /// File and Folder event types
    /// File Event Types:
    ///     most of the file events use the File Master Id but some use the File Id
    /// </summary>
   [DataContract]
    public enum InterceptEvent {
       /// <summary>
        ///File event targetids are File Master Id
       /// </summary>
        [EnumMember]
        Add,
        /// <summary>
        ///File event targetids are File Master Id
        /// </summary>
        [EnumMember]
        Delete,
        /// <summary>
        ///File event targetids are File Id
        /// </summary>
        [EnumMember]
        Acquire,
        /// <summary>
        ///File event targetids are File Master Id
        /// </summary>
        [EnumMember]
        CheckIn,
        /// <summary>
        ///File event targetids are File Id
        /// </summary>
        [EnumMember]
        Checkout,
        /// <summary>
        ///File event targetids are File Master Id
        /// </summary>
        [EnumMember]
        StateChange,
        /// <summary>
        /// File event targetid is File Master Id, parent is the destination folder
        /// </summary>
        [EnumMember]
        Move,
        /// <summary>
        /// File event targetids are the File Id, parent is always 0
        /// </summary>
        [EnumMember]
        Download
    };
   [DataContract]
    public class EventResult {
       [DataMember]
       public bool Success { get; set; }
       [DataMember]
       public string Message { get; set; }
   }
}

 

May not be exactly what you need but hopefully it gets you in the ballpark.   

0 Likes
Message 4 of 4

Anonymous
Not applicable
Thanks a lot!!
I will try it out, it might just be right!