Esempio n. 1
0
        public JettisonFile AddFileToJettison(Jettison jettison, string file)
        {
            JettisonFile newFile = new JettisonFile();

            newFile.FullPath = file;
            newFile.DropTime = DateTime.Now;
            jettison.JettisonFiles.Add(newFile);
            SaveDataFile();
            JFLog.Log(LogOperationType.Info, file + " was added");
            return(newFile);
        }
Esempio n. 2
0
        private static void CheckFile(Jettison j, string file)
        {
            DateTime fileDate = File.GetLastAccessTime(file);

            if (j.JettisonFiles == null)
            {
                j.JettisonFiles = new List <JettisonFile>();
            }
            JettisonFile jFile = j.JettisonFiles.Where(x => x.FullPath == file).FirstOrDefault();

            if (jFile == null)
            {
                jFile = dh.AddFileToJettison(j, file);
            }
            fileDate = jFile.DropTime;
            DateTime now    = DateTime.Now;
            TimeSpan span   = now.Subtract(fileDate);
            bool     delete = !j.Recycle;

            // 24 hours
            if (j.MaxLife == 1)
            {
                if (span.TotalHours >= 24)
                {
                    DisposeFile(j, file, delete);
                }
            }

            // 48 hours
            else if (j.MaxLife == 2)
            {
                if (span.TotalHours >= 48)
                {
                    DisposeFile(j, file, delete);
                }
            }

            // 72 hours
            else if (j.MaxLife == 3)
            {
                if (span.TotalHours >= 72)
                {
                    DisposeFile(j, file, delete);
                }
            }

            // custom
            else if (j.MaxLife == 4)
            {
                // seconds
                if (j.CustomLifeDuration == 1)
                {
                    if (span.TotalSeconds >= j.CustomLife)
                    {
                        DisposeFile(j, file, delete);
                    }
                }

                // minutes
                else if (j.CustomLifeDuration == 2)
                {
                    if (span.TotalMinutes >= j.CustomLife)
                    {
                        DisposeFile(j, file, delete);
                    }
                }

                // hours
                else if (j.CustomLifeDuration == 3)
                {
                    if (span.TotalHours >= j.CustomLife)
                    {
                        DisposeFile(j, file, delete);
                    }
                }
            }
        }