Esempio n. 1
0
        protected LinkedList <string> RolloverSimulation(LinkedList <string> files, string formatPattern, bool deleteLatestFile)
        {
            LinkedList <string>     fileList = files;
            RolloverFilenameBuilder fnb      = new RolloverFilenameBuilder(formatPattern);

            fnb.SetFileName(fileList.Last.Value);
            fnb.Index = fnb.Index + fileList.Count;
            string newFileName = fnb.BuildFileName();

            fileList.AddFirst(newFileName);
            LinkedList <string> .Enumerator enumerator     = fileList.GetEnumerator();
            LinkedList <string> .Enumerator nextEnumerator = fileList.GetEnumerator();
            nextEnumerator.MoveNext(); // move on 2nd entry
            enumerator.MoveNext();
            while (nextEnumerator.MoveNext())
            {
                File.Move(nextEnumerator.Current, enumerator.Current);
                enumerator.MoveNext();
            }
            CreateFile(null, nextEnumerator.Current);
            if (deleteLatestFile)
            {
                File.Delete(fileList.First.Value);
                fileList.RemoveFirst();
            }
            return(fileList);
        }
 protected LinkedList<string> RolloverSimulation(LinkedList<string> files, string formatPattern, bool deleteLatestFile)
 {
   LinkedList<string> fileList = files;
   RolloverFilenameBuilder fnb = new RolloverFilenameBuilder(formatPattern);
   fnb.SetFileName(fileList.Last.Value);
   fnb.Index = fnb.Index + fileList.Count;
   string newFileName = fnb.BuildFileName();
   fileList.AddFirst(newFileName);
   LinkedList<string>.Enumerator enumerator = fileList.GetEnumerator();
   LinkedList<string>.Enumerator nextEnumerator = fileList.GetEnumerator();
   nextEnumerator.MoveNext();    // move on 2nd entry
   enumerator.MoveNext();
   while (nextEnumerator.MoveNext())
   {
     File.Move(nextEnumerator.Current, enumerator.Current);
     enumerator.MoveNext();
   }
   CreateFile(null, nextEnumerator.Current);
   if (deleteLatestFile)
   {
     File.Delete(fileList.First.Value);
     fileList.RemoveFirst();
   }
   return fileList;
 }
Esempio n. 3
0
 public void testFilenameHiddenZero3()
 {
   RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("engine$J.log");
   fnb.SetFileName("engine1.log");
   string name = fnb.BuildFileName();
   Assert.AreEqual("engine1.log", name);
   fnb.Index = fnb.Index - 1;
   name = fnb.BuildFileName();
   Assert.AreEqual("engine.log", name);
 }
Esempio n. 4
0
 public void testFilename3()
 {
   RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*_$I.log");
   fnb.SetFileName("engine_0.log");
   string name = fnb.BuildFileName();
   Assert.AreEqual("engine_0.log", name);
   fnb.Index = fnb.Index + 1;
   name = fnb.BuildFileName();
   Assert.AreEqual("engine_1.log", name);
 }
Esempio n. 5
0
 public void testFilename2()
 {
   RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*$D(yyyy-MM-dd).log");
   fnb.SetFileName("engine_2010-06-12.log");
   string name = fnb.BuildFileName();
   Assert.AreEqual("engine_2010-06-12.log", name);
   fnb.Index = fnb.Index + 1;
   name = fnb.BuildFileName();
   Assert.AreEqual("engine_2010-06-12.log", name);
 }
Esempio n. 6
0
        public void testFilenameHiddenZero3()
        {
            RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("engine$J.log");

            fnb.SetFileName("engine1.log");
            string name = fnb.BuildFileName();

            Assert.AreEqual("engine1.log", name);
            fnb.Index = fnb.Index - 1;
            name      = fnb.BuildFileName();
            Assert.AreEqual("engine.log", name);
        }
Esempio n. 7
0
        public void testFilename3()
        {
            RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*_$I.log");

            fnb.SetFileName("engine_0.log");
            string name = fnb.BuildFileName();

            Assert.AreEqual("engine_0.log", name);
            fnb.Index = fnb.Index + 1;
            name      = fnb.BuildFileName();
            Assert.AreEqual("engine_1.log", name);
        }
Esempio n. 8
0
        public void testFilename2()
        {
            RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*$D(yyyy-MM-dd).log");

            fnb.SetFileName("engine_2010-06-12.log");
            string name = fnb.BuildFileName();

            Assert.AreEqual("engine_2010-06-12.log", name);
            fnb.Index = fnb.Index + 1;
            name      = fnb.BuildFileName();
            Assert.AreEqual("engine_2010-06-12.log", name);
        }
Esempio n. 9
0
 public void testFilenameHiddenZero()
 {
   RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*.log$J(.)");
   fnb.SetFileName("engine.log");
   string name = fnb.BuildFileName();
   Assert.AreEqual("engine.log", name);
   fnb.Index = fnb.Index + 1;
   name = fnb.BuildFileName();
   Assert.AreEqual("engine.log.1", name);
   fnb.Index = fnb.Index + 1;
   name = fnb.BuildFileName();
   Assert.AreEqual("engine.log.2", name);
 }
Esempio n. 10
0
        public void testFilenameHiddenZero()
        {
            RolloverFilenameBuilder fnb = new RolloverFilenameBuilder("*.log$J(.)");

            fnb.SetFileName("engine.log");
            string name = fnb.BuildFileName();

            Assert.AreEqual("engine.log", name);
            fnb.Index = fnb.Index + 1;
            name      = fnb.BuildFileName();
            Assert.AreEqual("engine.log.1", name);
            fnb.Index = fnb.Index + 1;
            name      = fnb.BuildFileName();
            Assert.AreEqual("engine.log.2", name);
        }