public FileSystemEvent(FileSystemEventType eventType, string oldFileName, string newFileName, DateTime eventDate)
 {
     this.eventType = eventType;
     this.oldFileName = oldFileName;
     this.newFileName = newFileName;
     this.eventDate = eventDate;
 }
Esempio n. 2
0
            /// <summary>
            /// Initializes a new instance of the PathEventItem class.
            /// </summary>
            /// <param name="info">The <see cref="SerializationInfo"/> to load data from..</param>
            /// <param name="context">The source <see cref="StreamingContext"/> for this serialization.</param>
            public PathEventItem(SerializationInfo info, StreamingContext context)
            {
                if (info == null)
                {
                    throw new ArgumentNullException("info", "info cannot be null.");
                }

                this.publishEventArgs = (FileSystemEventArgs)info.GetValue("publishEventArgs", typeof(FileSystemEventArgs));
                this.publishEventType = (FileSystemEventType)Enum.ToObject(typeof(FileSystemEventType), info.GetInt32("publishEventType"));
                this.lastRaised       = info.GetDateTime("lastRaised");
                this.raisedCount      = info.GetInt32("raisedCount");
            }
Esempio n. 3
0
        /// <summary>
        /// Enqueues and possibly throttles an event for raising.
        /// </summary>
        /// <param name="path">The path that raised the original event.</param>
        /// <param name="eventType">The type of the original event that was raised.</param>
        /// <param name="e">The arguments passed when the original event was raised.</param>
        private void EnqueueEvent(string path, FileSystemEventType eventType, FileSystemEventArgs e)
        {
            DateTime now = DateTime.Now;
            string   key = this.Mode == FileSystemWatcherMode.Directory ? this.Path : path;

            lock (this.locker)
            {
                if (!this.pathEvents.ContainsKey(key))
                {
                    this.pathEvents[key] = new PathEventItem();
                }

                PathEventItem item = this.pathEvents[key];
                item.PublishEventArgs = e;
                item.PublishEventType = eventType;
                item.LastRaised       = now;
                item.RaisedCount++;
            }
        }
            /// <summary>
            /// Initializes a new instance of the PathEventItem class.
            /// </summary>
            /// <param name="info">The <see cref="SerializationInfo"/> to load data from..</param>
            /// <param name="context">The source <see cref="StreamingContext"/> for this serialization.</param>
            public PathEventItem(SerializationInfo info, StreamingContext context)
            {
                if (info == null)
                {
                    throw new ArgumentNullException("info", "info cannot be null.");
                }

                this.publishEventArgs = (FileSystemEventArgs)info.GetValue("publishEventArgs", typeof(FileSystemEventArgs));
                this.publishEventType = (FileSystemEventType)Enum.ToObject(typeof(FileSystemEventType), info.GetInt32("publishEventType"));
                this.lastRaised = info.GetDateTime("lastRaised");
                this.raisedCount = info.GetInt32("raisedCount");
            }
        /// <summary>
        /// Enqueues and possibly throttles an event for raising.
        /// </summary>
        /// <param name="path">The path that raised the original event.</param>
        /// <param name="eventType">The type of the original event that was raised.</param>
        /// <param name="e">The arguments passed when the original event was raised.</param>
        private void EnqueueEvent(string path, FileSystemEventType eventType, FileSystemEventArgs e)
        {
            DateTime now = DateTime.Now;
            string key = this.Mode == FileSystemWatcherMode.Directory ? this.Path : path;

            lock (this.locker)
            {
                if (!this.pathEvents.ContainsKey(key))
                {
                    this.pathEvents[key] = new PathEventItem();
                }

                PathEventItem item = this.pathEvents[key];
                item.PublishEventArgs = e;
                item.PublishEventType = eventType;
                item.LastRaised = now;
                item.RaisedCount++;
            }
        }
        private void RegisterEvent(FileSystemEventType eventType, string oldFullPath, string newFullPath, Guid traceGuid)
        {
            try
            {
                QueryParameterSet parameters = new QueryParameterSet();
                parameters.Add("@FolderTraceGUID", traceGuid.ToString());
                parameters.Add("@FileSystemEventType", (int)eventType);
                parameters.Add("@FileSystemEventDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                parameters.Add("@FileSystemEventOldName", oldFullPath);
                parameters.Add("@FileSystemEventNewName", newFullPath);
                DataProvider.Database.Query(eventInsertQueryText, parameters, false);

                if (eventType != FileSystemEventType.Renamed)
                {
                    EventLogger.RecordEvent(Constants.NTServiceEventSource, LogEventType.Information, string.Format("{0}: {1}", eventType, newFullPath));
                }
                else
                {
                    EventLogger.RecordEvent(Constants.NTServiceEventSource, LogEventType.Information, string.Format("{0}: {1} to {2}", eventType, oldFullPath, newFullPath));
                }
            }
            catch (Exception ex)
            {
                EventLogger.RecordException(Constants.NTServiceEventSource, ex, "Failed to register event: ");
            }
        }
 /// <summary>
 /// Instantiate a new FileSystemEventArgsExt
 /// </summary>
 /// <param name="changeType"></param>
 /// <param name="directory"></param>
 /// <param name="name"></param>
 /// <param name="fileSystemEventType"></param>
 public TopshelfFileSystemEventArgs(WatcherChangeTypes changeType, string directory, string name, FileSystemEventType fileSystemEventType)
     : base(changeType, directory, name)
 {
     FileSystemEventType = fileSystemEventType;
 }
 /// <summary>
 /// Instantiate a new FileSystemEventArgsExt
 /// </summary>
 /// <param name="changeType"></param>
 /// <param name="directory"></param>
 /// <param name="name"></param>
 /// <param name="fileSystemEventType"></param>
 public TopshelfFileSystemEventArgs(WatcherChangeTypes changeType, string directory, string name, FileSystemEventType fileSystemEventType)
     : base(changeType, directory, name)
 {
     FileSystemEventType = fileSystemEventType;
 }
 public FileSystemEvent(FileSystemEventType eventType, string newFileName, DateTime eventDate)
     : this(eventType, newFileName, newFileName, eventDate)
 {
 }