コード例 #1
0
        private static void CreateFolderRecursive(Dictionary<string, string> dic, string ParentRef, Folder FolderRef)
        {
            if (FolderRef.HasChildren)
            {
                var folders = ekFolderAPI.GetChildFolders(FolderRef);
                if (folders.Any())
                {
                    string newRef;
                    foreach (var folder in folders)
                    {
                        Console.WriteLine("Creating folder '{0}' as a child of '{1}'", folder.Name, FolderRef.Name);
                        newRef = epFolderAPI.CreateFolder(folder.Name, ParentRef);
                        CreateFolderRecursive(dic, newRef, folder);
                    }
                }
            }

            List<ImageFile> assets = ekAssetAPI.GetImageAssets(FolderRef);
            if (assets.Any())
            {
                string type;
                string ext;
                foreach (var asset in assets)
                {
                    ext = asset.SourceFileUrl.Substring(asset.SourceFileUrl.LastIndexOf('.'));
                    if (string.IsNullOrEmpty(ext))
                    {
                        Console.WriteLine("Content Type not found for files of type '{0}'. File with Ektron ID {1} not uploaded.", ext, asset.SourceContentId);
                    }
                    if (!dic.ContainsKey(ext))
                    {
                        type = epAPI.GetContentTypeForExtension(ext);
                        dic.Add(ext, type);
                    }
                    Console.WriteLine("Uploading file with ID = {0} and Name = '{1}'.", asset.SourceContentId, asset.Name);
                    string result = epAPI.CreateContent(dic[ext], ParentRef, asset);
                    if (string.IsNullOrEmpty(result))
                    {
                        Console.WriteLine("ERROR! File not uploaded!");
                        if (asset.BinaryData.Data.Length > 1000000)
                        {
                            Console.WriteLine("File is too large for the API to consume.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Success!");
                    }
                    Console.WriteLine();
                }
            }
        }
コード例 #2
0
        private static Folder DirSearch(string path)
        {
            var directoryInfo = new DirectoryInfo(path);
            if (!Directory.Exists(path) || IsDirectoryEmpty(path))
            {
                return null;
            }

            var directories = directoryInfo.GetDirectories();
            var files = directoryInfo.GetFiles();

            var folder = new Folder()
            {
                Name = path,
                Files = new File[files.Length],
                ChildFolders = new Folder[directories.Length]
            };

            for (var i = 0; i < folder.ChildFolders.Length; i++)
            {
                folder.ChildFolders[i] = new Folder();
            }

            for (var i = 0; i < folder.Files.Length; i++)
            {
                folder.Files[i] = new File();
            }

            try
            {
                for (var i = 0; i < files.Length; i++)
                {
                    folder.Files[i].Name = files[i].Name;

                    // File size is in Kilobytes(KB)
                    folder.Files[i].Size = int.Parse((files[i].Length / 1024).ToString());
                }

                for (var i = 0; i < directories.Length; i++)
                {
                    folder.ChildFolders[i] = DirSearch(directories[i].FullName);
                }

                return folder;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return null;
        }
コード例 #3
0
        public Folder GetItem(long FolderID, int LanguageID)
        {
            Folder result = new Folder();

            int origLang = CommonAPI.FolderInstance.ContentLanguage;
            CommonAPI.FolderInstance.ContentLanguage = LanguageID;
            var sourceData = CommonAPI.FolderInstance.GetItem(FolderID, true);
            CommonAPI.FolderInstance.ContentLanguage = origLang;

            if (sourceData != null)
            {
                result = sourceData.ToGenericFolder(LanguageID);
            }

            return result;
        }
コード例 #4
0
        public List<ImageFile> GetLibraryImages(Folder FolderRef)
        {
            var criteria = GetLibraryCriteria();
            criteria.AddFilter(Ektron.Cms.Common.LibraryProperty.ParentId, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, FolderRef.Id);
            var rawImageList = CommonAPI.LibraryInstance.GetList(criteria);
            if (criteria.PagingInfo.TotalPages > 1)
            {
                for (int i = 2; i <= criteria.PagingInfo.TotalPages; i++)
                {
                    criteria.PagingInfo.CurrentPage = i;
                    rawImageList.AddRange(CommonAPI.LibraryInstance.GetList(criteria));
                }
            }

            if (rawImageList.Any())
                return (from i in rawImageList
                        select i.ToImageFile()).ToList();
            return new List<ImageFile>();
        }
コード例 #5
0
ファイル: MainModel.cs プロジェクト: Monabr/FS_Explorer
        public void DriversSelectionChanged(object x)
        {
            TreeOfFolders.Clear();
            try
            {
                foreach (DirectoryInfo dir in new DirectoryInfo(x.ToString()).GetDirectories().OrderBy(y => y.Name).ToArray())
                {
                    ShellObject  shellFolder = ShellObject.FromParsingName(dir.FullName.ToString());
                    BitmapSource shellThumb  = shellFolder.Thumbnail.SmallBitmapSource;

                    Folder folder = new Folder
                    {
                        Name     = dir.ToString(),
                        Icon     = shellThumb,
                        FullName = dir.FullName,
                    };
                    try
                    {
                        folder.CountOfFolders = new DirectoryInfo(dir.FullName).GetDirectories().Length.ToString();
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        folder.CountOfFolders = "Отказано в доступе";
                    }

                    try
                    {
                        folder.CountOfFiles = new DirectoryInfo(dir.FullName).GetFiles().Length.ToString();
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        folder.CountOfFiles = "Отказано в доступе";
                    }

                    try
                    {
                        folder.CreationTime = dir.CreationTime.ToString(CultureInfo.InvariantCulture);
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                    }

                    folder.Children.Add(new Folder
                    {
                        Name     = "*",
                        Icon     = null,
                        FullName = dir.FullName
                    });

                    TreeOfFolders.Add(folder);
                }


                foreach (FileInfo file in new DirectoryInfo(x.ToString()).GetFiles().OrderBy(y => y.Name).ToArray())
                {
                    Icon icon =
                        (System.Drawing.Icon)System.Drawing.Icon.ExtractAssociatedIcon(file.FullName.ToString());


                    if (file.Extension.ToLower() == ".jpg" || file.Extension.ToLower() == ".jpeg" || file.Extension.ToLower() == ".bmp" || file.Extension.ToLower() == ".png")
                    {
                        TreeOfFolders.Add(
                            new CustomImage
                        {
                            Name         = file.ToString(),
                            Icon         = icon.ToImageSource(),
                            FullName     = file.FullName.ToString(),
                            Size         = ByteSize.FromBytes(file.Length).ToString(),
                            CreationTime = file.CreationTime.ToString(CultureInfo.InvariantCulture)
                        }
                            );
                    }
                    else
                    {
                        TreeOfFolders.Add(
                            new CustomFile
                        {
                            Name         = file.ToString(),
                            Icon         = icon.ToImageSource(),
                            FullName     = file.FullName.ToString(),
                            Size         = ByteSize.FromBytes(file.Length).ToString(),
                            CreationTime = file.CreationTime.ToString(CultureInfo.InvariantCulture)
                        }
                            );
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(@ex.Message);
            }
        }
コード例 #6
0
ファイル: MainModel.cs プロジェクト: Monabr/FS_Explorer
 public void OpenSelected(Folder arg)
 {
     Process.Start(arg.FullName);
 }
コード例 #7
0
ファイル: MainModel.cs プロジェクト: Monabr/FS_Explorer
 public void ExpandChildrenSelected(Folder arg)
 {
     arg.IsExpanded = true;
     arg.GetChildren();
     arg.ExpandChildren();
 }
コード例 #8
0
 public List<ImageFile> GetImageAssets(Folder FolderRef)
 {
     var images = libAPI.GetLibraryImages(FolderRef);
     return images;
 }
コード例 #9
0
 public List <Folder> GetChildFolders(Models.Folder FolderRef)
 {
     return(FolderAPI.GetList(FolderRef.Id, FolderRef.LanguageId));
 }