Exemplo n.º 1
0
        public void UpdateFileTimes(Document doc, FileSystemEvent eve)
        {
            // READ Events
            if (doc.DocEvents.Any(i => i.Type == Enums.EventType.Read))
            {
                var recentRead = doc.DocEvents.OrderByDescending(i => i.Time).First(j => j.Type == Enums.EventType.Read);
                if (DateTime.Compare(recentRead.Time, eve.FileInf.LastAccessTime.AddMilliseconds(-eve.FileInf.LastAccessTime.Millisecond)) < 0)
                {
                    // add event to doc
                    doc.DocEvents.Add(new DocEvent() { Type = Enums.EventType.Read, Time = eve.FileInf.LastAccessTime });
                }
            }
            else
            {
                doc.DocEvents.Add(new DocEvent() { Type = Enums.EventType.Read, Time = eve.FileInf.LastAccessTime });
            }

            // WRITE Events
            if (doc.DocEvents.Any(i => i.Type == Enums.EventType.Write))
            {
                var recentWrite = doc.DocEvents.OrderByDescending(i => i.Time).First(j => j.Type == Enums.EventType.Write);
                if (DateTime.Compare(recentWrite.Time, eve.FileInf.LastWriteTime.AddMilliseconds(-eve.FileInf.LastWriteTime.Millisecond)) < 0)
                {
                    // add event to doc
                    doc.DocEvents.Add(new DocEvent() { Type = Enums.EventType.Write, Time = eve.FileInf.LastWriteTime });
                }
            }
            else
            {
                doc.DocEvents.Add(new DocEvent() { Type = Enums.EventType.Write, Time = eve.FileInf.LastWriteTime });
            }
        }
Exemplo n.º 2
0
 public void AddEvent(FileSystemEvent eve)
 {
     _events.Add(eve);
 }
Exemplo n.º 3
0
 public void RestoreFileTimes(FileSystemEvent eve)
 {
     try
     {
         eve.FileInf.LastAccessTime = eve.LastAccess;
         eve.FileInf.LastWriteTime = eve.LastWrite;
         eve.FileInf.CreationTime = eve.CreationTime;
     }
     catch (UnauthorizedAccessException ex)
     {
         // this occurs when the time cannot be written (mostly files in .git?)
     }
 }