Example #1
0
        private bool IsNeedContinue(TrackerEvent evnt)
        {
            var split = evnt.Name.Split('.');

            if (split.Length == 1)
            {
                if (ignores.Contains(split[0]) || ignores.Contains(evnt.Name))
                {
                    return(true);
                }
            }
            else
            {
                if (ignores.Contains(split[0]) || ignores.Contains(split[1]) || ignores.Contains(evnt.Name))
                {
                    return(true);
                }
            }

            foreach (var ignore in ignores)
            {
                if (evnt.FullName.Contains(ignore))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        private void Delete_Check(TrackerEvent evnt, List <TrackerEvent> notDefinedEventList, List <TrackerEvent> returnList)
        {
            //if file was created and can be opened
            var createdFiles = returnList.FindAll(itm => itm.Name == evnt.Name && itm.EventName == TrackerEvents.Created);

            if (createdFiles.Count != 0)
            {
                //todo: do any with many(if this can be)
                createdFiles[0].OldName     = evnt.Name;
                createdFiles[0].OldFullName = evnt.FullName;
                createdFiles[0].EventName   = TrackerEvents.Moved;
                return;
            }
            //if file was created and can't be opened
            createdFiles = notDefinedEventList.FindAll(itm => itm.Name.Equals(evnt.Name) && itm.EventName == TrackerEvents.Created);
            if (createdFiles.Count != 0)
            {
                //todo: do any with many(if this can be)
                var item = createdFiles[0];
                returnList.Add(new TrackerEvent(evnt.Name, evnt.Name, item.FullName, evnt.FullName, TrackerEvents.Moved));
                notDefinedEventList.RemoveAll(itm => createdFiles.Contains(itm));
                return;
            }

            returnList.Add(evnt);
        }
Example #3
0
        private void Change_Check(TrackerEvent evnt, List <TrackerEvent> notDefinedEventList, List <TrackerEvent> returnList)
        {
            if (!File.Exists(evnt.FullName))
            {
                //change folder(skip)
                return;
            }

            var item = notDefinedEventList.Find(itm => itm.FullName == evnt.FullName);

            if (item != null)
            {
                //was changed created file
                if (item.EventName == TrackerEvents.Created)
                {
                    bool isOpenend = IsCanOpen(evnt.FullName);
                    if (isOpenend)
                    {
                        returnList.Add(item);
                        notDefinedEventList.Remove(item);
                    }
                }
                return;
            }
            if (returnList.Find(itm => itm.FullName == evnt.FullName) != null)
            {
                //was changed created or deleted file(skip)
                return;
            }

            notDefinedEventList.Add(evnt);
        }
Example #4
0
        private void CreateDir_Check(TrackerEvent evnt, List <TrackerEvent> notDefinedEventList, List <TrackerEvent> returnList)
        {
            var deletedFiles = notDefinedEventList.FindAll(itm => itm.Name == evnt.Name && itm.EventName == TrackerEvents.DeletedDir);

            //if before create event was delete event with same name
            //then it was moved a littel file
            if (deletedFiles.Count != 0)
            {
                //todo: need check on same files
                var item = deletedFiles[0];
                returnList.Add(new TrackerEvent(evnt.Name, evnt.Name, evnt.FullName, item.FullName, TrackerEvents.MovedDir));
                notDefinedEventList.RemoveAll(itm => deletedFiles.Contains(itm));

                return;
            }

            deletedFiles = returnList.FindAll(itm => itm.Name == evnt.Name && itm.EventName == TrackerEvents.DeletedDir);

            if (deletedFiles.Count != 0)
            {
                //todo: need check on same files
                var item = deletedFiles[0];
                returnList.Add(new TrackerEvent(evnt.Name, evnt.Name, evnt.FullName, item.FullName, TrackerEvents.MovedDir));
                returnList.RemoveAll(itm => deletedFiles.Contains(itm));

                return;
            }

            returnList.Add(evnt);
        }
Example #5
0
        public void RemoveAll()
        {
            lock (objLock) {
                RemoveRange(TrackerEvent.ToList());
                RemoveRange(TrackerEventInfo.ToList());

                SaveChanges();
            }
        }
Example #6
0
        private void GetContentFromFile(FileInfo fi, TrackerEvent item)
        {
            using (var fsRead = fi.OpenRead())
            {
                var buffer = new byte[fsRead.Length];
                int readed;

                readed       = fsRead.Read(buffer, 0, buffer.Length);
                item.Content = buffer;
            }
        }
Example #7
0
        private void NormalizePath(TrackerEvent evnt)
        {
            int indexOfLastSlesh;

            indexOfLastSlesh = evnt.FullName.LastIndexOf('\\');
            evnt.Name        = evnt.FullName.Substring(indexOfLastSlesh + 1);

            if (evnt.EventName == TrackerEvents.Renamed)
            {
                indexOfLastSlesh = evnt.OldFullName.LastIndexOf('\\');
                evnt.OldName     = evnt.OldFullName.Substring(indexOfLastSlesh + 1);
            }
        }
Example #8
0
        public void AddDirEvent(TrackerEvent trackerEvent)
        {
            TrackerEventInfo dirEvent = new TrackerEventInfo()
            {
                IsContentInTrackerEvent = true,
                TrackerEvent            = trackerEvent,
            };

            lock (objLock)
            {
                TrackerEventInfo.Add(dirEvent);
                SaveChanges();
            }
        }
Example #9
0
        private void Create_Check(TrackerEvent evnt, List <TrackerEvent> notDefinedEventList, List <TrackerEvent> returnList)
        {
            var deletedFiles = notDefinedEventList.FindAll(itm => itm.Name == evnt.Name && itm.EventName == TrackerEvents.Deleted);

            //if before create event was delete event with same name
            //then it was moved a littel file
            if (deletedFiles.Count != 0)
            {
                //todo: need check on same files
                var item = deletedFiles[0];
                returnList.Add(new TrackerEvent(evnt.Name, evnt.Name, evnt.FullName, item.FullName, TrackerEvents.Moved));
                notDefinedEventList.RemoveAll(itm => deletedFiles.Contains(itm));

                return;
            }

            deletedFiles = returnList.FindAll(itm => itm.Name == evnt.Name && itm.EventName == TrackerEvents.Deleted);

            if (deletedFiles.Count != 0)
            {
                //todo: need check on same files
                var item = deletedFiles[0];
                returnList.Add(new TrackerEvent(evnt.Name, evnt.Name, evnt.FullName, item.FullName, TrackerEvents.Moved));
                returnList.RemoveAll(itm => deletedFiles.Contains(itm));

                return;
            }

            //if dont was any events with this file
            //try open his
            bool isOpenend = IsCanOpen(evnt.FullName);

            //if cant open, then file size big
            if (isOpenend)
            {
                returnList.Add(evnt);
            }
            else
            {
                notDefinedEventList.Add(evnt);
            }
            return;
        }
Example #10
0
 public TrackerEvent(TrackerEvent evnt) : this(evnt.Name, evnt.OldName, evnt.FullName, evnt.OldFullName, evnt.EventName)
 {
 }