示例#1
0
        public void DifferentFileVersions()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                WebDAV.Version v1530 = versions.First(v => v.Name == "1530");
                WebDAV.Version v1531 = versions.First(v => v.Name == "1531");

                var client1530 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1530);

                var client1531 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1531);

                WebDAV.Directory root1530 = client1530.Root;
                WebDAV.Directory root1531 = client1531.Root;

                WebDAV.File file1530 = root1530.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs") as WebDAV.File;
                WebDAV.File file1531 = root1531.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs") as WebDAV.File;

                using (MemoryStream ms1530 = new MemoryStream())
                {
                    using (MemoryStream ms1531 = new MemoryStream())
                    {
                        file1530.GetContent(ms1530);
                        file1531.GetContent(ms1531);

                        Assert.AreNotEqual(ms1530.Length, ms1531.Length);
                    }
                }
            }
        }
示例#2
0
        public void GetVersionedFiles()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                WebDAV.Version v1530 = versions.First(v => v.Name == "1530");
                WebDAV.Version v1531 = versions.First(v => v.Name == "1531");

                using (var fs = new SVNFileSystem("NFX-SVN"))
                {
                    var session = fs.StartSession(CONN_PARAMS);

                    session.Version = v1530;
                    var    file1530    = session["trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs"] as FileSystemFile;
                    string content1530 = file1530.ReadAllText();

                    session.Version = v1531;
                    var    file1531    = session["trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs"] as FileSystemFile;
                    string content1531 = file1531.ReadAllText();

                    Assert.AreNotEqual(content1530, content1531);
                }
            }
        }
        /// <summary>
        /// Tries to fetch a given path and refreshes the views.
        /// </summary>
        /// <param name="path"></param>
        private void FetchStructure(string path)
        {
            _board = (Storyboard)Resources["DropFileListFadeOut"] as Storyboard;

            if (_dropFileListFadeOutCompleted == null)
            {
                _dropFileListFadeOutCompleted = new EventHandler(delegate
                {
                    _context.Files.Clear();
                    _collector.Raise(_dropFileListFadeOutCompleted);
                });
                _board.Completed += _dropFileListFadeOutCompleted;
            }

            _result = null;
            _board.Begin();
            _collector.WaitFor(_dropFileListFadeOutCompleted);
            _collector.WaitFor("FileListReceived");

            _collector.Complete = () =>
            {
                FetchStructureCompleteHandler(_result);
                Dispatcher.BeginInvoke(() =>
                {
                    ((Storyboard)Resources["DropFileListFadeIn"] as Storyboard).Begin();
                });
            };

            if (_workingAccount != null)
            {
                var dav = new WebDAV(_workingAccount.GetUri(), _workingAccount.GetCredentials());
                dav.StartRequest(DAVRequestHeader.CreateListing(path), DAVRequestBody.CreateAllPropertiesListing(), null, FetchStructureComplete);
            }
        }
示例#4
0
        public static void GetVersions()
        {
            InitCONSTS();

            foreach (var v in WebDAV.GetVersions(ROOT, UNAME, UPSW))
            {
                Console.WriteLine(v);
            }
        }
示例#5
0
        public static void NavigatePath()
        {
            InitCONSTS();

            WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

            WebDAV.Directory root = client.Root;

            WebDAV.Directory nested = root.NavigatePath("/trunk/Source/NFX/") as WebDAV.Directory;
        }
示例#6
0
        public void GetHeadRootVersion()
        {
            using (new AzosApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Version lastVersion = client.GetHeadRootVersion();
                Aver.IsNotNull(lastVersion);
            }
        }
示例#7
0
        public void GetHeadRootVersion()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Version lastVersion = client.GetHeadRootVersion();
                Assert.IsNotNull(lastVersion);
            }
        }
        private void Button_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Account account = (DataContext as AccountDataContext).CurrentAccount;
            // Some Web DAV Test
            var dav_request = DAVRequestHeader.CreateListing(account.WebDAVPath);

            dav_request.Headers[Header.Depth] = HeaderAttribute.MethodDepth.ApplyInfinityNoRoot;
            var dav = new WebDAV(account.GetUri(), account.GetCredentials());

            dav.StartRequest(dav_request, DAVRequestBody.CreateAllPropertiesListing(), null, DAVResult);
        }
示例#9
0
        internal SVNFileSystemSession(SVNFileSystem fs, IFileSystemHandle handle, SVNFileSystemSessionConnectParams cParams)
            : base(fs, handle, cParams)
        {
            m_ServerURL = cParams.ServerURL;

              var cred = cParams.User.Credentials as IDPasswordCredentials;

              if (cred == null)
              m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs);
              else
            m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs, cred.ID, cred.Password);
        }
示例#10
0
        public void EscapeFile()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                var f  = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN/Esc Folder+/Escape.txt") as WebDAV.File;
                var ms = new MemoryStream();
                f.GetContent(ms);
                var s = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);
                Console.WriteLine(s);
                Assert.AreEqual("Escape file+content", s);
            }
        }
示例#11
0
        public static void List()
        {
            InitCONSTS();

            WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

            WebDAV.Directory root = client.Root;

            var children = root.Children;

            foreach (var item in children)
            {
                Console.WriteLine(item.Name);
            }
        }
示例#12
0
        public void ContentType()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            var file1 = root.NavigatePath("/trunk/Source/NFX/LICENSE.txt");
            var file2 = root.NavigatePath("/trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/flags/ad.png");

            Assert.AreEqual(0, string.Compare("text/xml; charset=\"utf-8\"", file1.ContentType, true));
            Assert.AreEqual(0, string.Compare("application/octet-stream", file2.ContentType, true));
              }
        }
示例#13
0
        public void ContentType()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                var file1 = root.NavigatePath("/trunk/Source/NFX/LICENSE.txt");
                var file2 = root.NavigatePath("/trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/flags/ad.png");

                Assert.AreEqual(0, string.Compare("text/xml; charset=\"utf-8\"", file1.ContentType, true));
                Assert.AreEqual(0, string.Compare("application/octet-stream", file2.ContentType, true));
            }
        }
示例#14
0
        public void NonExistingItem()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                var children = root.Children;

                var nonexistingChild = root[children.OrderBy(c => c.Name.Length).First().Name + "_"];

                Assert.IsNull(nonexistingChild);
            }
        }
示例#15
0
        public static void FileContent()
        {
            InitCONSTS();

            WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

            WebDAV.Directory root = client.Root;

            WebDAV.File file = root.Children.First(c => c is WebDAV.File) as WebDAV.File;

            using (MemoryStream ms = new MemoryStream())
            {
                file.GetContent(ms);
            }
        }
示例#16
0
        public void FileContent()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.File file = root.Children.First(c => c is WebDAV.File) as WebDAV.File;

                using (MemoryStream ms = new MemoryStream())
                {
                    file.GetContent(ms);
                    Assert.Greater(ms.Length, 0);
                }
            }
        }
示例#17
0
        public void FileContent()
        {
            using (new AzosApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.File file = root.Children.First(c => c is WebDAV.File) as WebDAV.File;

                using (MemoryStream ms = new MemoryStream())
                {
                    file.GetContent(ms);
                    Aver.IsTrue(ms.Length > 0);
                }
            }
        }
示例#18
0
        public void GetVersions()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                Assert.IsNotNull(versions);
                Assert.Greater(versions.Count(), 0);

                WebDAV.Version v1 = versions.First();

                Assert.IsNotNull(v1);
                Assert.IsNotNullOrEmpty(v1.Creator);
                Assert.IsNotNullOrEmpty(v1.Comment);
                Assert.AreEqual("1", v1.Name);
                Assert.Greater(v1.Date, DateTime.MinValue);
            }
        }
示例#19
0
        public void GetVersions()
        {
            using (new AzosApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                Aver.IsNotNull(versions);
                Aver.IsTrue(versions.Count() > 0);

                WebDAV.Version v1 = versions.First();

                Aver.IsNotNull(v1);
                Aver.IsTrue(v1.Creator.IsNotNullOrEmpty());
                Aver.IsTrue(v1.Comment.IsNotNullOrEmpty());
                Aver.AreEqual("1", v1.Name);
                Aver.IsTrue(v1.Date > DateTime.MinValue);
            }
        }
示例#20
0
        public void EscapeDir()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                {
                    var d = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN") as WebDAV.Directory;
                    Assert.IsNotNull(d.Children.FirstOrDefault(c => c.Name == "Esc Folder+"));
                }

                {
                    var d = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN/Esc Folder+") as WebDAV.Directory;
                    Assert.IsNotNull(d);
                    Assert.AreEqual("Esc Folder+", d.Name);
                }
            }
        }
示例#21
0
        public void DirectoryChildren()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                var children = root.Children;

                Assert.IsNotNull(children);
                Assert.AreEqual(3, children.Count());
                Assert.IsTrue(children.Any(c => c.Name == "trunk"));

                var firstChild = children.First();
                Assert.AreEqual(root, firstChild.Parent);
            }
        }
示例#22
0
        public void NavigatePathFile()
        {
            using (new AzosApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.File nested = root.NavigatePath("/trunk/Source/Azos/LICENSE.txt") as WebDAV.File;

                Aver.IsNotNull(nested);
                Aver.AreEqual("LICENSE.txt", nested.Name);

                using (MemoryStream s = new MemoryStream())
                {
                    nested.GetContent(s);
                    Aver.IsTrue(s.Length > 0);
                }
            }
        }
示例#23
0
        public void NavigatePathFile()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.File nested = root.NavigatePath("/trunk/Source/NFX/LICENSE.txt") as WebDAV.File;

                Assert.IsNotNull(nested);
                Assert.AreEqual("LICENSE.txt", nested.Name);

                using (MemoryStream s = new MemoryStream())
                {
                    nested.GetContent(s);
                    Assert.Greater(s.Length, 0);
                }
            }
        }
示例#24
0
        public void FailedFastTimeout()
        {
            var conf = LACONF.AsLaconicConfig();

            using (var app = new NFX.ApplicationModel.ServiceBaseApplication(new string[] {}, conf))
            {
                try
                {
                    var client = new WebDAV(SVN_ROOT, 1, SVN_UNAME, SVN_UPSW);

                    WebDAV.Directory root = client.Root;
                    var children          = root.Children;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToMessageWithType());
                    throw;
                }
            }
        }
示例#25
0
        public void NavigatePathFolder()
        {
            using (new AzosApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.Directory nested = root.NavigatePath("/trunk/Source/Azos") as WebDAV.Directory;

                Aver.IsNotNull(nested);
                Aver.AreEqual("Azos", nested.Name);
                Aver.AreEqual("/trunk/Source/Azos", nested.Path);

                Aver.AreEqual("Source", nested.Parent.Name);
                Aver.AreEqual("/trunk/Source", nested.Parent.Path);

                Aver.AreEqual("trunk", nested.Parent.Parent.Name);
                Aver.AreEqual("/trunk", nested.Parent.Parent.Path);
            }
        }
示例#26
0
        public void NavigatePathFolder()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                WebDAV.Directory nested = root.NavigatePath("/trunk/Source/NFX") as WebDAV.Directory;

                Assert.IsNotNull(nested);
                Assert.AreEqual("NFX", nested.Name);
                Assert.AreEqual("/trunk/Source/NFX", nested.Path);

                Assert.AreEqual("Source", nested.Parent.Name);
                Assert.AreEqual("/trunk/Source", nested.Parent.Path);

                Assert.AreEqual("trunk", nested.Parent.Parent.Name);
                Assert.AreEqual("/trunk", nested.Parent.Parent.Path);
            }
        }
示例#27
0
        public void GetManyFiles()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                var d = client.Root.NavigatePath("trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/flags") as WebDAV.Directory;

                var stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                foreach (WebDAV.File f in d.Children)
                {
                    MemoryStream ms = new MemoryStream();
                    f.GetContent(ms);

                    Console.WriteLine("{0} done".Args(f.Name));
                }
                stopwatch.Stop();

                Console.WriteLine(stopwatch.Elapsed);
            }
        }
示例#28
0
        public void DifferentDirectoryVersions()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            IList<WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

            WebDAV.Version v1513 = versions.First(v => v.Name == "1513");
            WebDAV.Version v1523 = versions.First(v => v.Name == "1523");

            var client1513 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1513);

            var client1523 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1523);

            WebDAV.Directory root1513 = client1513.Root;
            WebDAV.Directory root1523 = client1523.Root;

            WebDAV.Directory nested1513 = root1513.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem") as WebDAV.Directory;
            WebDAV.Directory nested1523 = root1523.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem") as WebDAV.Directory;

            Assert.IsNull(nested1513["SVN"]);
            Assert.IsNotNull(nested1523["SVN"]);
              }
        }
示例#29
0
        public void DifferentDirectoryVersions()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                WebDAV.Version v1513 = versions.First(v => v.Name == "1513");
                WebDAV.Version v1523 = versions.First(v => v.Name == "1523");

                var client1513 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1513);

                var client1523 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1523);

                WebDAV.Directory root1513 = client1513.Root;
                WebDAV.Directory root1523 = client1523.Root;

                WebDAV.Directory nested1513 = root1513.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem") as WebDAV.Directory;
                WebDAV.Directory nested1523 = root1523.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem") as WebDAV.Directory;

                Assert.IsNull(nested1513["SVN"]);
                Assert.IsNotNull(nested1523["SVN"]);
            }
        }
示例#30
0
        public void ItemProperties()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

                WebDAV.Directory root = client.Root;

                Assert.Greater(root.Version.AsInt(), 0);
                Assert.Greater(root.CreationDate, DateTime.MinValue);
                Assert.Greater(root.LastModificationDate, DateTime.MinValue);

                var maxVersionChild = root.Children.OrderByDescending(c => c.Version).First();

                Console.WriteLine("First Child: " + maxVersionChild);

                Assert.Greater(maxVersionChild.Version.AsInt(), 0);
                Assert.Greater(maxVersionChild.CreationDate, DateTime.MinValue);
                Assert.Greater(maxVersionChild.LastModificationDate, DateTime.MinValue);

                Assert.AreEqual(root.Version, maxVersionChild.Version);
            }
        }
示例#31
0
        public void GetVersionedFiles()
        {
            using (new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
            {
                IList <WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

                WebDAV.Version v192 = versions.First(v => v.Name == "192");
                WebDAV.Version v110 = versions.First(v => v.Name == "110");

                var fs = FS.Instances["NFX-SVN"];
                using (var session = fs.StartSession())
                {
                    session.Version = v192;
                    var    file192     = session["trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/script/wv.js"] as FileSystemFile;
                    string content1530 = file192.ReadAllText();

                    session.Version = v110;
                    var    file110     = session["trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/script/wv.js"] as FileSystemFile;
                    string content1531 = file110.ReadAllText();

                    Assert.AreNotEqual(content1530, content1531);
                }
            }
        }
示例#32
0
 public SVNFSH(WebDAV.Item item)
 {
     Item = item;
 }
示例#33
0
        private void StartRequest()
        {
            var dav = new WebDAV(_workingAccount.GetUri(), _workingAccount.GetCredentials());

            dav.StartRequest(DAVRequestHeader.CreateListing(_workingPath), DAVRequestBody.CreateAllPropertiesListing(), null, FetchStructureComplete);
        }
示例#34
0
        public void FailedFastTimeout()
        {
            var conf = LACONF.AsLaconicConfig();

              using (var app = new NFX.ApplicationModel.ServiceBaseApplication(new string[] {}, conf))
              {
            try
            {
              var client = new WebDAV(SVN_ROOT, 1, SVN_UNAME, SVN_UPSW);

              WebDAV.Directory root = client.Root;
              var children = root.Children;
            }
            catch (Exception ex)
            {
              Console.WriteLine(ex.ToMessageWithType());
              throw;
            }
              }
        }
示例#35
0
        public void FileContent()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            WebDAV.File file = root.Children.First(c => c is WebDAV.File) as WebDAV.File;

            using (MemoryStream ms = new MemoryStream())
            {
              file.GetContent(ms);
              Assert.Greater(ms.Length, 0);
            }
              }
        }
示例#36
0
        public void GetHeadRootVersion()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Version lastVersion = client.GetHeadRootVersion();
            Assert.IsNotNull(lastVersion);
              }
        }
示例#37
0
        public static void List()
        {
            InitCONSTS();

              WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

              WebDAV.Directory root = client.Root;

              var children = root.Children;

              foreach (var item in children)
              {
            Console.WriteLine( item.Name);
              }
        }
示例#38
0
        public void ItemProperties()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            Assert.Greater(root.Version.AsInt(), 0);
            Assert.Greater(root.CreationDate, DateTime.MinValue);
            Assert.Greater(root.LastModificationDate, DateTime.MinValue);

            var maxVersionChild = root.Children.OrderByDescending(c => c.Version).First();

            Console.WriteLine("First Child: " + maxVersionChild);

            Assert.Greater(maxVersionChild.Version.AsInt(), 0);
            Assert.Greater(maxVersionChild.CreationDate, DateTime.MinValue);
            Assert.Greater(maxVersionChild.LastModificationDate, DateTime.MinValue);

            Assert.AreEqual(root.Version, maxVersionChild.Version);
              }
        }
示例#39
0
        private ulong GetDirectorySize(WebDAV.Directory dir)
        {
            if (dir == null) return 0;

            ulong size = 0;

            foreach (var child in dir.Children)
            {
              var childDir = child as WebDAV.Directory;
              if (childDir != null)
            size += GetDirectorySize(childDir);

              var childFile = child as WebDAV.File;
              if (childFile != null)
            size += childFile.Size;
            }

            return size;
        }
示例#40
0
        public void NavigatePathFolder()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            WebDAV.Directory nested = root.NavigatePath("/trunk/Source/NFX") as WebDAV.Directory;

            Assert.IsNotNull(nested);
            Assert.AreEqual("NFX", nested.Name);
            Assert.AreEqual("/trunk/Source/NFX", nested.Path);

            Assert.AreEqual("Source", nested.Parent.Name);
            Assert.AreEqual("/trunk/Source", nested.Parent.Path);

            Assert.AreEqual("trunk", nested.Parent.Parent.Name);
            Assert.AreEqual("/trunk", nested.Parent.Parent.Path);
              }
        }
示例#41
0
        public void NonExistingItem()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            var children = root.Children;

            var nonexistingChild = root[children.OrderBy(c => c.Name.Length).First().Name + "_"];

            Assert.IsNull(nonexistingChild);
              }
        }
示例#42
0
        private void OnHTTPResponse(IAsyncResult result)
        {
            AsyncHttpResponse state = (AsyncHttpResponse)result.AsyncState;
            var success             = false;

            try
            {
                state.Request.EndGetResponse(result);
                success = true;
            }
            catch (WebException)
            {
                if (state.AssociatedAccount.Protocol == "https")
                {
                    // try to fetch certificate
                    try
                    {
                        var tls = new TLSHandshake();
                        tls.SetServerNameExtension(state.AssociatedAccount.Hostname);
                        var socket = new StreamSocket();
                        socket.Connect(state.AssociatedAccount.Hostname, state.AssociatedAccount.GetPort(true));
                        socket.Write(tls.CreateClientHello());

                        DateTime startTime = DateTime.Now;
                        while (true)
                        {
                            var data = socket.Read();
                            if (data.Length > 0)
                            {
                                var cert = tls.FindPacket(data, TLSHandshake.TLS_HANDSHAKE_CERTIFICATE);
                                if (cert.Length > 0)
                                {
                                    var details = tls.GetCertificateDetails(cert);
                                    if (details.Count > 0)
                                    {
                                        var certDetails = details[0];
                                        if (certDetails.ContainsKey("CN"))
                                        {
                                            Dispatcher.BeginInvoke(() =>
                                            {
                                                MessageBox.Show("EditAccountPage_Connection_Rejected".Translate(state.AssociatedAccount.Hostname, certDetails["CN"], certDetails["ValidAfter"], certDetails["ValidTo"]), "EditAccountPage_Connection_Rejected_Caption".Translate(), MessageBoxButton.OK);
                                                _overlay.Hide();
                                            });
                                            return;
                                        }
                                    }
                                    break;
                                }
                            }

                            if (DateTime.Now.Subtract(startTime).TotalSeconds > 5)
                            {
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // Host not reachable, no SSL host or TLS version not supported
                    }
                }
            }
            catch (Exception)
            {
                // HTTPWebRequest has failed
            }

            if (success)
            {
                // Testing DAV
                //TODO: Add your additional connection test statement here
                // To complete the test all fragments must have been fired.
                EventCollector collector = new EventCollector()
                {
                    Complete = () =>
                    {
                        OnConnectTestComplete(success, state.AssociatedAccount);
                    }
                };
                collector.WaitFor(state.AssociatedAccount.WebDAVPath);
                collector.WaitFor(state.AssociatedAccount.CalDAVPath);

                // define paths to test
                Queue <string> pathsToTest = new Queue <string>();
                pathsToTest.Enqueue(state.AssociatedAccount.WebDAVPath);
                pathsToTest.Enqueue(state.AssociatedAccount.CalDAVPath);

                // create master instance
                WebDAV davTest = new WebDAV(state.AssociatedAccount.GetUri(), state.AssociatedAccount.GetCredentials());

                // call tests
                while (pathsToTest.Count > 0)
                {
                    var path = pathsToTest.Dequeue();
                    davTest.StartRequest(DAVRequestHeader.CreateListing(path), path, (requestResult, userObj) =>
                    {
                        if (requestResult.Status != ServerStatus.MultiStatus)
                        {
                            // all other states are fail states
                            success = false;
                            Dispatcher.BeginInvoke(() =>
                            {
                                MessageBox.Show("EditAccountPage_CheckingConnection_DAVTestFailed".Translate(userObj, requestResult.StatusText), "Error_Caption".Translate(), MessageBoxButton.OK);
                            });
                        }
                        collector.Raise(userObj);
                    });
                }
            }
            else
            {
                OnConnectTestComplete(success, state.AssociatedAccount);
            }
        }
示例#43
0
        public void EscapeFile()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            var f = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN/Esc Folder+/Escape.txt") as WebDAV.File;
            var ms = new MemoryStream();
            f.GetContent(ms);
            var s = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);
            Console.WriteLine(s);
            Assert.AreEqual("Escape file+content", s);
              }
        }
示例#44
0
        public void GetManyFiles()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            var d = client.Root.NavigatePath("trunk/Source/NFX.Wave/Templatization/StockContent/Embedded/flags") as WebDAV.Directory;

            var stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            foreach (WebDAV.File f in d.Children)
            {
              MemoryStream ms = new MemoryStream();
              f.GetContent(ms);

              Console.WriteLine("{0} done".Args(f.Name));
            }
            stopwatch.Stop();

            Console.WriteLine(stopwatch.Elapsed);
              }
        }
示例#45
0
        public void NavigatePathFile()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            WebDAV.File nested = root.NavigatePath("/trunk/Source/NFX/LICENSE.txt") as WebDAV.File;

            Assert.IsNotNull(nested);
            Assert.AreEqual("LICENSE.txt", nested.Name);

            using (MemoryStream s = new MemoryStream())
            {
              nested.GetContent(s);
              Assert.Greater(s.Length, 0);
            }
              }
        }
示例#46
0
        public void EscapeDir()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            {
              var d = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN") as WebDAV.Directory;
              Assert.IsNotNull(d.Children.FirstOrDefault(c => c.Name == "Esc Folder+"));
            }

            {
              var d = client.Root.NavigatePath("trunk/Source/Testing/NUnit/NFX.NUnit.Integration/IO/FileSystem/SVN/Esc Folder+") as WebDAV.Directory;
              Assert.IsNotNull(d);
              Assert.AreEqual("Esc Folder+", d.Name);
            }
              }
        }
示例#47
0
        public static void FileContent()
        {
            InitCONSTS();

              WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

              WebDAV.Directory root = client.Root;

              WebDAV.File file = root.Children.First(c => c is WebDAV.File) as WebDAV.File;

              using(MemoryStream ms = new MemoryStream())
            {
            file.GetContent(ms);
              }
        }
示例#48
0
        public void DifferentFileVersions()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            IList<WebDAV.Version> versions = WebDAV.GetVersions(SVN_ROOT, SVN_UNAME, SVN_UPSW).ToList();

            WebDAV.Version v1530 = versions.First(v => v.Name == "1530");
            WebDAV.Version v1531 = versions.First(v => v.Name == "1531");

            var client1530 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1530);

            var client1531 = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW, version: v1531);

            WebDAV.Directory root1530 = client1530.Root;
            WebDAV.Directory root1531 = client1531.Root;

            WebDAV.File file1530 = root1530.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs") as WebDAV.File;
            WebDAV.File file1531 = root1531.NavigatePath("trunk/Source/NFX.Web/IO/FileSystem/SVN/WebDAV.cs") as WebDAV.File;

            using (MemoryStream ms1530 = new MemoryStream())
            {
              using (MemoryStream ms1531 = new MemoryStream())
              {
            file1530.GetContent(ms1530);
            file1531.GetContent(ms1531);

            Assert.AreNotEqual(ms1530.Length, ms1531.Length);
              }
            }
              }
        }
示例#49
0
        public static void NavigatePath()
        {
            InitCONSTS();

              WebDAV client = new WebDAV(ROOT, 0, UNAME, UPSW);

              WebDAV.Directory root = client.Root;

              WebDAV.Directory nested = root.NavigatePath("/trunk/Source/NFX/") as WebDAV.Directory;
        }
示例#50
0
        public void DirectoryChildren()
        {
            using(new NFX.ApplicationModel.ServiceBaseApplication(null, LACONF.AsLaconicConfig()))
              {
            var client = new WebDAV(SVN_ROOT, 0, SVN_UNAME, SVN_UPSW);

            WebDAV.Directory root = client.Root;

            var children = root.Children;

            Assert.IsNotNull(children);
            Assert.AreEqual(3, children.Count());
            Assert.IsTrue(children.Any(c => c.Name == "trunk"));

            var firstChild = children.First();
            Assert.AreEqual(root, firstChild.Parent);
              }
        }