Пример #1
0
 public NodeSettingNewestOldestFileOrDirectory()
 {
     Newest      = true;
     Files       = false;
     Directories = false;
     DateType    = PathDate.CreationTime;
 }
Пример #2
0
        public void RunNewestOldestPath(bool files, bool dictionaries, PathDate dateType)
        {
            if (Directory.Exists(this.nodeConfig.Details.Path))
            {
                DateTime      newestDateTime = new DateTime();
                string        newestPath     = string.Empty;
                List <string> paths          = new List <string>();

                if (files)
                {
                    paths.AddRange(Directory.GetFiles(this.nodeConfig.Details.Path));
                }
                if (dictionaries)
                {
                    paths.AddRange(Directory.GetDirectories(this.nodeConfig.Details.Path));
                }

                foreach (var path in paths)
                {
                    DateTime?dt = null;
                    if (dateType == PathDate.LastWriteTime)
                    {
                        dt = File.GetLastWriteTime(path);
                    }
                    if (dateType == PathDate.LastAccessTime)
                    {
                        dt = File.GetLastAccessTime(path);
                    }
                    if (dateType == PathDate.CreationTime)
                    {
                        dt = File.GetCreationTime(path);
                    }

                    if (dt != null && dt.Value.Ticks > newestDateTime.Ticks)
                    {
                        newestDateTime = dt.Value;
                        newestPath     = path;
                    }
                }
                if (!string.IsNullOrEmpty(newestPath))
                {
                    Process.Start(newestPath);
                }
            }
            else
            {
                MessageBox.Show("Path is not a folder");
            }
        }
Пример #3
0
    public void getRecordingPath(string _root)
    {
        allVideoFiles.Clear();
        getMostRecentPath(_root);
        if (allVideoFiles.Count == 0)
        {
            if (debugActive)
            {
                Debug.Log("No .mkv files found in root!");
            }
            return;
        }
        PathDate[] pathDates = new PathDate[allVideoFiles.Count];
        for (int i = 0; i < allVideoFiles.Count; i++)
        {
            //Debug.Log("Path " + i.ToString() + ": " + allVideoFiles[i]);
            string path   = (string)allVideoFiles[i];
            string date   = getDateFromFilePath(path);
            string time   = getTimeFromFilePath(path);
            int    year   = int.Parse(date.Remove(4, 4));
            int    month  = int.Parse(date.Remove(0, 4).Remove(2, 2));
            int    day    = int.Parse(date.Remove(0, 6));
            int    hour   = int.Parse(time.Remove(2, 4));
            int    minute = int.Parse(time.Remove(0, 2).Remove(2, 2));
            int    second = int.Parse(time.Remove(0, 4));
            //Debug.Log("Year " + i.ToString() + ": " + year);
            //Debug.Log("Month " + i.ToString() + ": " + month);
            //Debug.Log("Day " + i.ToString() + ": " + day);
            //Debug.Log("Hour " + i.ToString() + ": " + hour);
            //Debug.Log("Minute " + i.ToString() + ": " + minute);
            //Debug.Log("Second " + i.ToString() + ": " + second);
            System.DateTime dateTime = new System.DateTime(year, month, day, hour, minute, second, 0, System.DateTimeKind.Utc);
            pathDates[i].date = dateTime;
            pathDates[i].path = (string)allVideoFiles[i];
        }

        for (int j = 0; j < pathDates.Length - 1; j++)
        {
            // Find the smallest
            int iMin = j;
            // test against elements after j to find the smallest
            for (int i = j + 1; i < pathDates.Length; i++)
            {
                if (pathDates[i].CompareTo(pathDates[iMin]) > 0)
                {
                    iMin = i;
                }
            }

            if (iMin != j)
            {
                PathDate temp = pathDates[iMin];
                pathDates[iMin] = pathDates[j];
                pathDates[j]    = temp;
            }
        }

        mostRecentRecording = new string[(pathDates.Length > maxVideos ? maxVideos : pathDates.Length)];

        for (int i = 0; i < pathDates.Length; i++)
        {
            if (i < mostRecentRecording.Length && i < pathDates.Length)
            {
                mostRecentRecording[i] = pathDates[i].path;
            }
            else
            {
                break;
            }
        }

        flipMostRecentRecordingArray();
    }
Пример #4
0
 public int CompareTo(PathDate _pathDate)
 {
     return(date.CompareTo(_pathDate.date));
 }