Exemplo n.º 1
0
        /// <summary>
        /// Function that forms a list of statuses compared to a specific DirectoryData data passed.
        /// </summary>
        /// <param name="currentDD">Specific DirectoryData to form a file statuses from.</param>
        /// <returns>LoadedFileStatus list which tells if the file datas read from Fhsks are correct or if its not tell whats wrong with it.</returns>
        public static List <LoadedFileStatus> CheckFileStatusesOfDirectoryData(DirectoryData currentDD)
        {
            List <LoadedFileStatus> result = new List <LoadedFileStatus>();

            foreach (var item in currentDD.Files)
            {
                string currentLocalPath = currentDD.FindFileGetLocalPath(item.RelativePath);
                if (File.Exists(currentLocalPath))
                {
                    FileInfo fi = new FileInfo(currentLocalPath);

                    if (fi.LastWriteTime != item.LastModifiedTime)
                    {
                        result.Add(LoadedFileStatus.Modified);
                    }
                    else
                    {
                        result.Add(LoadedFileStatus.NotTouched);
                    }
                }
                else
                {
                    result.Add(LoadedFileStatus.DoesntExist);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public void TestUpdateDetails()
        {
            using (var mock = AutoMock.GetStrict()) {
                var settings = mock.Mock <ISettings>();
                settings.SetupGet(m => m.DataFilename).Returns("song.xml");

                var fileSystem = mock.Mock <IFileSystem>();
                fileSystem.Setup(m => m.Path.Combine(@"C:\test\bla", "song.xml")).Returns(@"C:\test\bla\song.xml");

                var song = new SongModel {
                    Path = @"C:\test\bla"
                };
                var data = new DirectoryData {
                    Status = DirectoryStatus.SONG, Song = song
                };

                var exporter = mock.Mock <IExporter>();
                exporter.Setup(m => m.Write(@"C:\test\bla\song.xml", data));

                var songService = mock.Create <Song>();

                songService.UpdateDetails(song);

                settings.VerifyGet(m => m.DataFilename, Times.Once);
                fileSystem.Verify(m => m.Path.Combine(@"C:\test\bla", "song.xml"), Times.Once);
                exporter.Verify(m => m.Write(@"C:\test\bla\song.xml", data), Times.Once);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Function that performs synchronization actions based of SyncData parameters and specific SyncExecAccessPermit.
 /// </summary>
 /// <param name="ConflictList">The list of SyncData's which specifies how conflict of the specific file should be solved.</param>
 /// <param name="SourceData">The directory being synchronized.</param>
 /// <param name="TargetData">The comparing directory to be synchronized with.</param>
 public static void SynchronizeConflict(List <SyncData> ConflictList, DirectoryData SourceData, DirectoryData TargetData)
 {
     foreach (var item in ConflictList)
     {
         if (item.SCS.HasFlag(SyncConflictState.DoesntExistInSource))
         {
             if (accessOption.HasFlag(SyncShareAllowanceNonExistnant.ShareToSource))
             {
                 SolveNonExistantFileToOtherDirectory(SourceData, TargetData, item);
             }
         }
         else if (item.SCS.HasFlag(SyncConflictState.DoesntExistInTarget))
         {
             if (accessOption.HasFlag(SyncShareAllowanceNonExistnant.ShareToTarget))
             {
                 SolveNonExistantFileToOtherDirectory(TargetData, SourceData, item);
             }
         }
         else if (item.SCS.HasFlag(SyncConflictState.OlderInSource) || item.SCS.HasFlag(SyncConflictState.NewerInSource) ||
                  item.SCS.HasFlag(SyncConflictState.BiggerInSource) || item.SCS.HasFlag(SyncConflictState.OlderInSource))
         {
             SolveStatedPrioritizedConflict(SourceData, TargetData, item);
         }
     }
 }
        private void WriteCheckIfExists(HttpContext context)
        {
            FS = Engine.Resolve <IFileSystem>();
            var parentDirectory = context.Request["selected"];
            var filenames       = Selection.RequestValueAccessor("filenames");
            var selected        = new Directory(DirectoryData.Virtual(parentDirectory), null);

            if (string.IsNullOrEmpty(parentDirectory) || !Engine.SecurityManager.IsAuthorized(context.User, selected, N2.Security.Permission.Read))
            {
                context.Response.WriteJson(new { Status = "Error", Message = "Not allowed" });
                return;
            }

            if (string.IsNullOrEmpty(filenames))
            {
                context.Response.WriteJson(new { Status = "Error", Message = "No files selected" });
                return;
            }

            var fns = filenames.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            context.Response.WriteJson(
                new
            {
                Status = "Checked",
                Files  = (from fileName in fns
                          let newPath = Url.Combine(context.Request.ApplicationPath + selected.Url, HttpUtility.UrlDecode(fileName))
                                        where FS.FileExists(newPath)
                                        select fileName).ToArray()
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Lists the installed modules.
        /// </summary>
        /// <returns>The installed modules.</returns>
        public override Module[] ListInstalledModules()
        {
            List <Module> list = new List <Module> ();

            string ModulesPath = this.GetModulesRootPath();

            SystemLogger.Log(SystemLogger.Module.PLATFORM, "Listing installed modules under path: " + ModulesPath);

            DirectoryData modulesDirectory = new DirectoryData(ModulesPath);

            if (this.GetFileSystemService().ExistsDirectory(modulesDirectory))
            {
                DirectoryData[] apps = this.GetFileSystemService().ListDirectories(modulesDirectory);
                foreach (DirectoryData app in apps)
                {
                    SystemLogger.Log(SystemLogger.Module.PLATFORM, "directory: " + app.FullName);
                    DirectoryData[] versions = this.GetFileSystemService().ListDirectories(app);

                    foreach (DirectoryData version in versions)
                    {
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "version: " + version.FullName);
                        Module module = new Module();
                        module.Id      = Path.GetFileName(app.FullName);
                        module.Version = this.ParseModuleVersion(Path.GetFileName(version.FullName));
                        list.Add(module);
                    }
                }
            }
            else
            {
                SystemLogger.Log(SystemLogger.Module.PLATFORM, "Modules directory does not exists: " + ModulesPath);
            }

            return(list.ToArray());
        }
Exemplo n.º 6
0
        internal static Items.Directory New(DirectoryData dir, ContentItem parent, IDependencyInjector injector)
        {
            var node = new Directory(dir, parent);

            injector.FulfilDependencies(node);
            return(node);
        }
Exemplo n.º 7
0
        public override DirectoryData Scan(string path, bool logDirectories = false)
        {
            try
            {
                var dir       = new DirectoryInfo(path);
                var dirs      = dir.EnumerateDirectories("*.*").ToList();
                var files     = dir.EnumerateFiles("*.*").ToList();
                var fileTypes = GetFileTypes(files);

                var logDirs = logDirectories ? dirs : null;
                LogDirectoryFiles(logDirs, files);
                _logger.SaveLogs();

                var dirData = new DirectoryData()
                {
                    Directories       = dirs,
                    DirectoryCount    = dirs.Count(),
                    FileCount         = files.Count(),
                    DirectoryFileSize = files.Sum(fi => fi.Length),
                    FileTypes         = fileTypes,
                };
                return(dirData);
            }
            catch (Exception exception)
            {
                _errorLogger.Log(exception, $"An exception occurred attempting to scan {path}.");
                return(new DirectoryData());
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Function that performs action of synchronization based on the corresponding SyncData which has to contain SyncActionState and SyncDirection.
        /// </summary>
        /// <param name="SourceData">The directory being synchronized.</param>
        /// <param name="TargetData">The comparing directory to be synchronized with.</param>
        /// <param name="SD">Corresponding SyncData with parameters to decide what to do with the file.</param>
        private static void SolveStatedPrioritizedConflict(DirectoryData SourceData, DirectoryData TargetData, SyncData SD)
        {
            switch (SD.SAS)
            {
            case SyncActionState.Skip:
                return;

            case SyncActionState.Delete:
                File.Delete(TargetData.FindFileGetLocalPath(SD.FD.RelativePath));
                File.Delete(SourceData.FindFileGetLocalPath(SD.FD.RelativePath));
                break;

            case SyncActionState.Share:
                if (SD.SD != SyncDirection.None)
                {
                    if (SD.SD == SyncDirection.Target)
                    {
                        UpdateExistingFile(TargetData.FindFileGetLocalPath(SD.FD.RelativePath), SourceData.FindFileGetLocalPath(SD.FD.RelativePath));
                    }
                    else if (SD.SD == SyncDirection.Source)
                    {
                        UpdateExistingFile(SourceData.FindFileGetLocalPath(SD.FD.RelativePath), TargetData.FindFileGetLocalPath(SD.FD.RelativePath));
                    }
                }
                break;

            case SyncActionState.Copy:
                break;

            default:
                break;
            }
        }
Exemplo n.º 9
0
        public void UpdateDetails(SongModel song)
        {
            var path = fileSystem.Path.Combine(song.Path, settings.DataFilename);
            var data = new DirectoryData {
                Status = DirectoryStatus.SONG, Song = song
            };

            exporter.Write(path, data);
        }
Exemplo n.º 10
0
        public void DirectoryInfo()
        {
            var d = new DirectoryData(path);

            Assert.AreEqual(d.Directory, parentPath);
            Assert.AreEqual(d.FullFilePath, path);
            Assert.AreEqual <ListingTypeOption>(d.ListingType, ListingTypeOption.Directory);
            Assert.AreEqual(d.Name, "Test");
        }
Exemplo n.º 11
0
        /// <summary>
        /// Function that serialize DirectoryData object to a Fhsks file.
        /// </summary>
        /// <param name="DD">DirectoryData object to be serialized.</param>
        /// <param name="StorageFilePath">Path the serialized data to be written to.</param>
        public static void WriteDirectoryDataToFile(DirectoryData DD, string StorageFilePath)
        {
            if (!Directory.Exists("FHSKS"))
            {
                Directory.CreateDirectory("FHSKS");
            }

            File.WriteAllText(StorageFilePath, JsonConvert.SerializeObject(DD));
        }
Exemplo n.º 12
0
        public static IEnumerable <DirectoryData> GetAllDirectoryInfos(this DirectoryData directoryData)
        {
            yield return(directoryData);

            foreach (var child in directoryData.GetDirectories().SelectMany(GetAllDirectoryInfos))
            {
                yield return(child);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Löscht das Verzeichnis.
        /// </summary>
        public void Delete()
        {
            if (Parent == null)
            {
                throw new InvalidOperationException();
            }

            DirectoryData.Delete(true);
            parent.Detach(this);
        }
Exemplo n.º 14
0
    /// <summary>
    /// Konstruktor.
    /// </summary>
    /// <param name="path">Physikalischer Pfad zu dieser Datei.</param>
    /// <param name="cnfgRow">DataRow welche die Daten dieses Files enthält.</param>
    /// <param name="parent">Das Verzeichnis welche diese Datei enthält.</param>
    public FileWrapper(string path, DirectoryData.FileConfigRow cnfgRow, DirectoryWrapper parent)
    {
      if (null == parent)
        throw new ArgumentNullException("Verzeichnis darf nicht null sein.");
      this.parent = parent;
      this.fileInfo = new FileInfo(path);

      this.fileInfoCfg = cnfgRow;
      this.fileInfoCfg.Name = this.fileInfo.Name;
    }
 /// <summary>
 /// Enumerate directories and files under the project path of |projet|.
 /// </summary>
 private IEnumerable <DirectoryWithFiles> TraverseFileSystem(DirectoryName directoryName, bool isSymLink)
 {
     using (new TimeElapsedLogger($"Traversing directory \"{directoryName.FullPath}\" to collect directory/file names", _cancellationToken)) {
         var directory = new DirectoryData(directoryName, isSymLink);
         var bag       = new ConcurrentBag <DirectoryWithFiles>();
         var task      = TraverseDirectoryAsync(directory, bag, _cancellationToken);
         task.Wait(_cancellationToken);
         return(bag);
     }
 }
Exemplo n.º 16
0
        public Directory(IFileSystem fs, DirectoryData directory, ContentItem parent)
            : base(fs)
        {
            Parent = parent;

            Name = directory.Name;
            Title = directory.Name;
            Updated = directory.Updated;
            Created = directory.Created;
            url = directory.VirtualPath;
        }
Exemplo n.º 17
0
        /// <summary>
        /// GET /rest/db/browse
        /// </summary>
        /// <returns>Version info</returns>
        public DirectoryData GetDbBrowse(String folder)
        {
            IRestResponse res = this.GET("/db/browse?folder=" + folder);

            if (res.ErrorException != null)
            {
                throw new ApiException(res.ErrorMessage);
            }

            return(DirectoryData.DeserializeJson(res.Content));
        }
Exemplo n.º 18
0
        private void TestBtn_Click(object sender, EventArgs e)
        {
            dd1 = new DirectoryData(CurrentPD.SourceDirectoryPath);
            dd2 = new DirectoryData(CurrentPD.TargetDirectoryPath);

            CurrentSession = ConflictSolver.FormConflictFileDataList(dd1, dd2);

            SyncClassifier.ClassifySyncDatas(CurrentSession, CurrentPD.StatementDataString);

            FillTheTable();
        }
Exemplo n.º 19
0
        public List <DirectoryEntry> Directory()
        {
            var databaseEntries = DirectoryData.GetAllEntries();

            return(databaseEntries.Select(dbDirectoryEntry => new DirectoryEntry
            {
                Pkid = dbDirectoryEntry.Pkid,
                Name = dbDirectoryEntry.Name,
                TelephoneNumber = dbDirectoryEntry.TelephoneNumber
            }).ToList());
        }
Exemplo n.º 20
0
        public Directory(DirectoryData directory, ContentItem parent)
        {
            Parent = parent;

            originalName = directory.Name;
            Name         = directory.Name;
            Title        = directory.Name;
            Updated      = directory.Updated;
            Created      = directory.Created;
            localUrl     = N2.Web.Url.ToAbsolute(directory.VirtualPath);
        }
Exemplo n.º 21
0
        public Directory(DirectoryData directory, ContentItem parent)
        {
            Parent = parent;

            originalName = directory.Name;
            Name         = directory.Name;
            Title        = directory.Name;
            Updated      = directory.Updated;
            Created      = directory.Created;
            url          = directory.VirtualPath;
        }
Exemplo n.º 22
0
        public Directory(DirectoryData directory, ContentItem parent)
        {
            Parent = parent;

            originalName = directory.Name;
            Name = directory.Name;
            Title = directory.Name;
            Updated = directory.Updated;
            Created = directory.Created;
            url = directory.VirtualPath;
        }
Exemplo n.º 23
0
        public Directory(DirectoryData directory, ContentItem parent)
        {
            Parent = parent;

            originalName = directory.Name;
            Name = directory.Name;
            Title = directory.Name;
            Updated = directory.Updated;
            Created = directory.Created;
            localUrl = N2.Web.Url.ToAbsolute(directory.VirtualPath);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Erzeugt ein neues Unterverzeichnis.
        /// </summary>
        /// <param name="dirName"></param>
        /// <param name="dirDescription"></param>
        public void CreateSubDir(string dirName, string dirDescription)
        {
            DirectoryInfo newDirInfo = DirectoryData.CreateSubdirectory(dirName);

            // Erzeugen der Wrapper mit der selben Sortierung.
            DirectoryWrapper dirWrapper = new DirectoryWrapper(newDirInfo.FullName, this);

            dirWrapper.Description = dirDescription;
            dirWrapper.SaveData();

            subDirectories = null; // Neu einlesen der Unterverzeichnisse.
        }
Exemplo n.º 25
0
 /// <summary>
 /// Function that removes non-existant files from specified DirectoryData FileData list based on pre-computed LoadedFileStatus list.
 /// </summary>
 /// <param name="lfs">Pre-computed LoadedFileStatus list</param>
 /// <param name="currentDD">Specific DirectoryData to correct.</param>
 public static void RemoveNotExistingFiles(List <LoadedFileStatus> lfs, DirectoryData currentDD)
 {
     for (int i = 0; i < currentDD.Files.Count; i++)
     {
         if (lfs[i] == LoadedFileStatus.DoesntExist)
         {
             lfs.RemoveAt(i);
             currentDD.Files.RemoveAt(i);
             i--;
         }
     }
 }
Exemplo n.º 26
0
 public DirectoryData(DirectoryInfo info, DirectoryData _parent = null, bool storeRelativePath = false, string rootPath = "")
 {
     fullName = info.FullName;
     if (storeRelativePath)
     {
         fullName = fullName.Replace(rootPath + Path.DirectorySeparatorChar.ToString(), "");
     }
     parent = _parent;
     if (parent != null)
     {
         parent.directories.Add(this);
     }
 }
Exemplo n.º 27
0
        public JObject getFolderTree(DirectoryData d)
        {
            BrowseManager browse = new BrowseManager();

            Directory_browse.Models.Directory dir = browse.getFolderTree(d.FullName);

            JObject dirJSON = JObject.FromObject(new
            {
                Dir = dir
            });

            return(dirJSON);
        }
Exemplo n.º 28
0
        private void WriteDirectoryCreate(HttpContext context)
        {
            ValidateTicket(context.Request["ticket"]);
            FS = Engine.Resolve <IFileSystem>();

            var parentDirectory = context.Request["selected"];
            var selected        = new Directory(DirectoryData.Virtual(parentDirectory), null);

            if (string.IsNullOrEmpty(parentDirectory) || !Engine.SecurityManager.IsAuthorized(context.User, selected, N2.Security.Permission.Write))
            {
                context.Response.WriteJson(new { Status = "Error", Message = "Not allowed" });
                return;
            }

            var name = context.Request["name"];

            if (string.IsNullOrWhiteSpace(name))
            {
                context.Response.WriteJson(new { Status = "Error", Message = "Directory name required" });
                return;
            }

            var regex = new Regex("[^a-zA-Z0-9_ ]");

            name = regex.Replace(name, "");
            if (name.Length == 0)
            {
                context.Response.WriteJson(new { Status = "Error", Message = "Directory name required (Special characters are stripped out)" });
                return;
            }

            var newDir = VirtualPathUtility.AppendTrailingSlash(context.Request.ApplicationPath + selected.Url) + name;

            try
            {
                if (FS.DirectoryExists(newDir))
                {
                    context.Response.WriteJson(new { Status = "Exists", Message = "Directory already exists" });
                }
                else
                {
                    FS.CreateDirectory(newDir);
                    context.Response.WriteJson(new { Status = "Ok", Message = "Directory created" });
                }
            }
            catch (Exception e)
            {
                context.Response.WriteJson(new { Status = "Error", Message = "Create directory failed", Detail = e.Message });
            }
        }
Exemplo n.º 29
0
        public void CreateDirectory(string applicationName, string directoryName, string description)
        {
            if (string.IsNullOrWhiteSpace(directoryName))
            {
                throw new SettingsStoreException(Constants.ERROR_DIRECTORY_NO_NAME);
            }

            var application = GetApplicationsData(applicationName).SingleOrDefault();

            if (application == null)
            {
                throw new SettingsNotFoundException(Constants.ERROR_APPLICATION_UNKNOWN);
            }

            if (!Auth.AllowCreateDirectory(applicationName, directoryName))
            {
                throw new SettingsAuthorizationException(AuthorizationScope.Directory, AuthorizationLevel.Create, directoryName, Auth.CurrentIdentity.Id);
            }

            if (DirectoryExists(application, directoryName))
            {
                throw new SettingsDuplicateException(Constants.ERROR_DIRECTORY_ALREADY_EXISTS);
            }

            if (!NameValidator.ValidateName(directoryName))
            {
                throw new SettingsNotFoundException(Constants.ERROR_DIRECTORY_NAME_INVALID);
            }

            DirectoryData directory;

            using (TransactionScope scope = new TransactionScope())
            {
                directory = new DirectoryData();
                directory.ApplicationId = application.Id;
                directory.Name          = directoryName.Trim();
                if (description != null)
                {
                    directory.Description = description.Trim();
                }
                directory.Created = DateTime.Now;

                Store.Context.Directories.Add(directory);
                Store.Save();

                scope.Complete();
            }

            Auth.Invalidate();
        }
Exemplo n.º 30
0
        /// <summary>
        /// Function that checks for existant files that hasnt been detected by reading Fhsks file it because they are new.
        /// </summary>
        /// <param name="lfs">Pre-computed LoadedFileStatus list</param>
        /// <param name="currentDD">Specific DirectoryData to correct.</param>
        public static void AddNewFiles(List <LoadedFileStatus> lfs, DirectoryData currentDD)
        {
            string[] files = Directory.GetFiles(currentDD.RootPath, "*", SearchOption.AllDirectories);

            for (int i = 0; i < files.Length; i++)
            {
                string buff = files[i].Replace(currentDD.RootPath, "");

                if (!currentDD.CheckFileExistanceByRelativePath(buff))
                {
                    currentDD.AddFileData(files[i]);
                    lfs.Add(LoadedFileStatus.NotTouched);
                }
            }
        }
Exemplo n.º 31
0
        private void GetDirectoryData(DirectoryData parentData, string directory, string tabString = "", int currentDepth = 0)
        {
            if (searchDepth != -1 && currentDepth <= searchDepth)
            {
                System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(directory);
                if (dInfo.Exists)
                {
                    DirectoryData dd = new DirectoryData(dInfo, parentData, storeRelativePaths, Directory);
                    pathData.Add(dd);
                    //D.Log(tabString + "DIR: " + directory);
                    DirectoryInfo[] dirs = dInfo.GetDirectories(searchPattern);

                    // filter out any dirs that should be ignored
                    if (ignoreStrings != null)
                    {
                        List <DirectoryInfo> newDirs = new List <DirectoryInfo>();
                        foreach (DirectoryInfo di in dirs)
                        {
                            string path   = di.FullName.Replace(directory + Path.DirectorySeparatorChar.ToString(), "");
                            bool   ignore = false;
                            foreach (string pattern in ignoreStrings)
                            {
                                if (Regex.IsMatch(path, pattern))
                                {
                                    ignore = true;
                                    break;
                                }
                            }
                            if (!ignore)
                            {
                                newDirs.Add(di);
                            }
                        }
                        dirs = newDirs.ToArray();
                    }

                    // recurse through directories
                    foreach (DirectoryInfo di in dirs)
                    {
                        GetDirectoryData(dd, di.FullName, tabString + "\t", currentDepth + 1);
                    }
                }
                else
                {
                    throw new Exception("In GetDirectoryData, but the directory passed (" + directory + ") does not exist!");
                }
            }
        }
        public NSData ProcessDocumentResource(string resourcePath)
        {
            SystemLogger.Log(SystemLogger.Module.PLATFORM, "# IPhoneResourceHandler. Processing document resource path: " + resourcePath);

            // url should be escaped to reach the real filesystem path for the requested file.
            resourcePath = Uri.UnescapeDataString(resourcePath);

            // Getting Root Directory for Files in this platform.
            IFileSystem   fileSystemService = (IFileSystem)IPhoneServiceLocator.GetInstance().GetService("file");
            DirectoryData rootDir           = fileSystemService.GetDirectoryRoot();

            resourcePath = Path.Combine(rootDir.FullName, resourcePath);

            // Get Resources as Binary Data and Write them to the server response
            return(NSData.FromArray(IPhoneUtils.GetInstance().GetResourceAsBinary(resourcePath, false)));
        }
Exemplo n.º 33
0
        private IList <DirectoryEntry> GetDirectoryEntries(DirectoryData directory)
        {
            var path = _project.RootPath.Combine(directory.DirectoryName.RelativePath);

            try {
                return(_fileSystem.GetDirectoryEntries(path));
            }
            catch (Win32Exception e) {
                Logger.LogWarn("Skipping directory \"{0}\": {1} ({2})", path, e.Message, e.NativeErrorCode);
                return(ArrayUtilities.EmptyList <DirectoryEntry> .Instance);
            }
            catch (Exception e) {
                Logger.LogWarn(e, "Skipping directory \"{0}\"", path);
                return(ArrayUtilities.EmptyList <DirectoryEntry> .Instance);
            }
        }
Exemplo n.º 34
0
        private IList <DirectoryData> GetFlatten(DirectoryData data)
        {
            lock (StorageLock)
            {
                var list = new List <DirectoryData>();
                list.Add(data);

                if (data.Children?.Any() ?? false)
                {
                    foreach (var child in data.Children)
                    {
                        list.AddRange(GetFlatten(child));
                    }
                }
                return(list);
            }
        }
Exemplo n.º 35
0
 internal static Items.Directory New(DirectoryData dir, ContentItem parent, IFileSystem fs, ImageSizeCache sizes)
 {
     var node = new Directory(dir, parent);
     node.Set(fs);
     node.Set(sizes);
     return node;
 }
Exemplo n.º 36
0
 public DirectoryData(DirectoryInfo info, DirectoryData _parent = null, bool storeRelativePath = false, string rootPath = "")
 {
     fullName = info.FullName;
     if ( storeRelativePath ) {
     fullName = fullName.Replace( rootPath + Path.DirectorySeparatorChar.ToString(), "" );
     }
     parent = _parent;
     if ( parent != null ) {
        parent.directories.Add( this );
     }
 }
        private bool IsUserInRoleRecursive(string distinguishedUserName, DirectoryData roleEntry)
        {
            if (roleEntry == null)
            {
                return false;
            }

            string[] members;
            if (!roleEntry.TryGetValue(_membersAttribute, out members))
            {
                // The membership attribute does not exists for this item, cannot be a member here
                return false;
            }

            foreach (string distinguishedMemberName in members)
            {
                if (String.Compare(distinguishedMemberName, distinguishedUserName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return true;
                }

                DirectoryData member = this._factory.GetEntry(distinguishedMemberName);
                if (member == null)
                {
                    continue;
                }

                if (member.SchemaClassName == "group")
                {
                    return IsUserInRoleRecursive(distinguishedUserName, member);
                }
            }

            return false;
        }
Exemplo n.º 38
0
    protected void PopulateData(CommunityGroupData cGrp, List<UserData> groupAdmins, DirectoryData[] aCategories)
    {
        int groupAdminCount = 0;
        this.GroupName_TB.Text = cGrp.GroupName;
        this.ShortDescription_TB.Text = cGrp.GroupShortDescription;
        this.Description_TB.Text = cGrp.GroupLongDescription;
        if (cGrp.GroupHidden)
        {
            this.PublicJoinHidden_RB.Checked = true;
        }
        else
        {
            this.PublicJoinYes_RB.Checked = cGrp.GroupEnroll;
            this.PublicJoinNo_RB.Checked = !(cGrp.GroupEnroll);
        }
        this.Location_TB.Text = cGrp.GroupLocation;
        if (groupAdmins.Count == 0)
        {
            ltr_admin_name.Text = cGrp.GroupAdmin.DisplayName.ToString();
        }
        else
        {
            int order = 0;
            for (groupAdminCount = 0; groupAdminCount < groupAdmins.Count; groupAdminCount++)
            {
                if (order != 0)
                    this.ltr_admin_name.Text += ", ";
                if (groupAdmins[groupAdminCount].DisplayName != "")
                    this.ltr_admin_name.Text += groupAdmins[groupAdminCount].DisplayName;
                else
                    this.ltr_admin_name.Text += groupAdmins[groupAdminCount].FirstName;
                order += 1;
            }
        }

        //this.ltr_admin_name.Text=        this.ltr_admin_name.Text.ToString().Remove(this.ltr_admin_name.Text.ToString().LastIndexOf(","), 1);
        this.GroupAvatar_TB.Text = cGrp.GroupImage;
        this.cmd_browse.Attributes.Add("onclick", "javascript:return false;");
        this.cmd_browse.Visible = false;
        this.EnableDistributeToSite_CB.Checked = cGrp.GroupEnableDistributeToSite;
        this.AllowMembersToManageFolders_CB.Checked = cGrp.AllowMembersToManageFolders;

        this.chkEnableDocumentNotifications.Checked = cGrp.EnableDocumentsInNotifications;
        this.chkEnableEmail.Checked = cGrp.EnableGroupEmail;
        this.lblEmailAccountValue.Text = cGrp.EmailAccountName;
        this.lblEmailAddressValue.Text = cGrp.EmailAddress;
        MailServerData mailServer = GetNotificationEmailServer();
        this.lblEmailServerPortValue.Text = mailServer.POPPort.ToString();
        this.lblEmailServerValue.Text = mailServer.POPServer;
        this.chkUseSsl.Checked = mailServer.POPSSL;
        ucEktronGroupEmailSetting.Visible = cGrp.EnableGroupEmail;

        this.ltr_avatarpath.Text = "";
        List<string> cat_list = new List<string>();
        string TaxonomyList = string.Empty;
        if ((aCategories != null) && aCategories.Length > 0)
        {
            for (int i = 0; i <= (aCategories.Length - 1); i++)
            {
                cat_list.Add(("<li>" + aCategories[i].DirectoryPath.Remove(0, 1).Replace("\\", " > ") + "</li>"));
            }
            TaxonomyList = string.Join(string.Empty, cat_list.ToArray());
        }
        else
        {
            TaxonomyList = GetMessage("lbl cgroup no cat");
        }
        ltr_cat.Text += TaxonomyList;
        calendardata = _CalendarApi.GetPublicCalendar(Ektron.Cms.Common.EkEnumeration.WorkSpace.Group, cGrp.GroupId);
        if (calendardata != null)
        {
            this.FeaturesCalendar_CB.Checked = true;
        }
        _doesForumExists = m_refCommunityGroupApi.DoesCommunityGroupForumExists(Ektron.Cms.Common.EkEnumeration.WorkSpace.Group, cGrp.GroupId);
        if (_doesForumExists != 0)
        {
            this.FeaturesForum_CB.Checked = true;
        }

        var todoList = GetGroupTodoList();
        if (todoList != null)
        {
            FeaturesTodo_CB.Enabled = false;
            FeaturesTodo_CB.Checked = true;
        }

        if (this.m_sPageAction == "viewgroup")
        {
            this.GroupName_TB.Enabled = false;
            this.ShortDescription_TB.Enabled = false;
            this.Description_TB.Enabled = false;
            this.PublicJoinYes_RB.Enabled = false;
            this.PublicJoinNo_RB.Enabled = false;
            this.PublicJoinHidden_RB.Enabled  = false;
            this.Location_TB.Enabled = false;
            this.GroupAvatar_TB.Enabled = false;
            this.EnableDistributeToSite_CB.Enabled = false;
            this.AllowMembersToManageFolders_CB.Enabled = false;
            this.FeaturesCalendar_CB.Enabled = false;
            this.FeaturesForum_CB.Enabled = false;
            this.FeaturesTodo_CB.Enabled = false;
        }
        else if (this.m_sPageAction == "addeditgroup")
        {
            if (this.m_refContentApi.IsAdmin() == false)
            {
                this.AllowMembersToManageFolders_CB.Enabled = false;
            }
        }
    }
Exemplo n.º 39
0
 internal static Items.Directory New(DirectoryData dir, ContentItem parent, IDependencyInjector injector)
 {
     var node = new Directory(dir, parent);
     injector.FulfilDependencies(node);
     return node;
 }
        private List<string> GetRolesForUserRecursive(DirectoryData entry)
        {
            var subtree = new List<string>();
            string[] propertyValue;
            if (entry.TryGetValue(_memberOfAttribute, out propertyValue))
            {
                foreach (string role in propertyValue)
                {
                    DirectoryData roleEntry = this._factory.GetEntry(role);
                    if (roleEntry == null || roleEntry.SchemaClassName != "group")
                    {
                        continue;
                    }
                    string[] roleName;
                    if (roleEntry.TryGetValue(this._roleNameAttribute, out roleName))
                    {
                        subtree.Add(roleName[0]);
                    }
                    subtree.AddRange(GetRolesForUserRecursive(roleEntry));
                }
            }

            return subtree;
        }
Exemplo n.º 41
0
        private void GetDirectoryData(DirectoryData parentData, string directory, string tabString = "", int currentDepth = 0)
        {
            if ( searchDepth != -1 && currentDepth <= searchDepth ) {
             System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(directory);
             if ( dInfo.Exists ) {
                DirectoryData dd = new DirectoryData(dInfo, parentData, storeRelativePaths, Directory);
                pathData.Add(dd);
                //D.Log(tabString + "DIR: " + directory);
                DirectoryInfo[] dirs = dInfo.GetDirectories(searchPattern);

                // filter out any dirs that should be ignored
                if ( ignoreStrings != null ) {
                    List<DirectoryInfo> newDirs = new List<DirectoryInfo>();
                    foreach( DirectoryInfo di in dirs ) {
                        string path = di.FullName.Replace(directory + Path.DirectorySeparatorChar.ToString(), "");
                        bool ignore = false;
                        foreach( string pattern in ignoreStrings ) {
                            if ( Regex.IsMatch( path, pattern ) ) {
                                ignore = true;
                                break;
                            }
                        }
                        if ( !ignore ) newDirs.Add(di);
                    }
                    dirs = newDirs.ToArray();
                }

                // recurse through directories
                foreach( DirectoryInfo di in dirs ) {
                   GetDirectoryData( dd, di.FullName, tabString + "\t", currentDepth + 1 );
                }
             }
             else {
                throw new Exception("In GetDirectoryData, but the directory passed (" + directory + ") does not exist!");
             }
              }
        }
Exemplo n.º 42
0
 public FileData(FileSystemObjectProperties properties, DirectoryData parent, long fileSize)
     : base(properties, parent)
 {
     _bytesSize = fileSize;
 }