예제 #1
0
        public void DeleteFolder(string organizationId, string folder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            string rootPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, folder);

            DirectoryInfo treeRoot = new DirectoryInfo(rootPath);

            if (treeRoot.Exists)
            {
                DirectoryInfo[] dirs = treeRoot.GetDirectories();
                while (dirs.Length > 0)
                {
                    foreach (DirectoryInfo dir in dirs)
                        DeleteFolder(organizationId,
                            folder != string.Empty ? string.Format("{0}\\{1}", folder, dir.Name) : dir.Name,
                            webDavSetting);

                    dirs = treeRoot.GetDirectories();
                }

                // DELETE THE FILES UNDER THE CURRENT ROOT
                string[] files = Directory.GetFiles(treeRoot.FullName);
                foreach (string file in files)
                {
                    File.SetAttributes(file, FileAttributes.Normal);
                    File.Delete(file);
                }

                IWebDav webdav = new WebDav(webDavSetting);

                webdav.DeleteAllWebDavRules(organizationId, folder);

                Directory.Delete(treeRoot.FullName, true);
            }
        }
예제 #2
0
        public SystemFile RenameFolder(string organizationId, string originalFolder, string newFolder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            var oldPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, originalFolder);
            var newPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, newFolder);

            FileUtils.MoveFile(oldPath, newPath);

            IWebDav webdav = new WebDav(webDavSetting);

            //deleting old folder rules
            webdav.DeleteAllWebDavRules(organizationId, originalFolder);

            return GetFolder(organizationId, newFolder, webDavSetting);
        }
예제 #3
0
        public bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting,
            WebDavFolderRule[] rules)
        {
            var users = new List<UserPermission>();

            foreach (var rule in rules)
            {
                foreach (var user in rule.Users)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = user,
                        Read = rule.Read,
                        Write = rule.Write
                    });
                }

                foreach (var role in rule.Roles)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = role,
                        Read = rule.Read,
                        Write = rule.Write
                    });
                }
            }

            var webDavSetting = GetWebDavSetting(setting);

            string path = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                organizationId, folder);

            SecurityUtils.ResetNtfsPermissions(path);

            // 06.09.2015 [email protected]
            // Problem: Serversettings for the Method 'GrantGroupNtfsPermission' is an Default Object, but we need the real Object
            // for the real Settings, to determine Objects from AD
            // Fix: Give the Helper-Class SecurityUtils the real ServerSettings-Object
            // SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, new RemoteServerSettings(), null, null);
            SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, ServerSettings, "*", "*");

            IWebDav webdav = new WebDav(webDavSetting);

            return webdav.SetFolderWebDavRules(organizationId, folder, rules);
        }
예제 #4
0
        public WebDavFolderRule[] GetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            IWebDav webdav = new WebDav(webDavSetting);

            return webdav.GetFolderWebDavRules(organizationId, folder);
        }