/// <summary>
        /// 添加新文件夹时的具体添加操作
        /// 在这里应该可以实现递归添加
        /// </summary>
        /// <param name="folderModel"></param>
        /// <param name="folderList"></param>
        /// <returns></returns>
        public async Task <FolderList> OpenAsync(FolderModel folderModel, FolderList folderList)
        {
            if (folderModel == null)
            {
                return(folderList);
            }
            if (folderModel.IsDeleteVisibility == Visibility.Collapsed)
            {
                // 如果是添加新文件夹的按钮
                var folderPicker = new FolderPicker();
                folderPicker.FileTypeFilter.Add("*");
                folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                var folder = await folderPicker.PickSingleFolderAsync();

                if (folder == null)
                {
                    return(folderList);
                }
                var accessToken = StorageApplicationPermissions.FutureAccessList.Add(folder);
                folderModel = new FolderModel
                {
                    FolderPath  = folder.Path,
                    AccessToken = accessToken
                };
                folderList = Add(folderModel, folderList);
            }
            else
            {
                var folder = await _folderModelService.GetFolder(folderModel.AccessToken);

                await Launcher.LaunchFolderAsync(folder);
            }
            return(folderList);
        }
        public void CurrentAdviseGroup_ReturnsFolderAdviseGroup()
        {
            // Arrange

            var adviseGroup = new AdviseGroupModel
            {
                Id   = new ItemId("Advise Group Id"),
                Name = "Advise Group Name",
            };

            var folder = new FolderModel
            {
                AdviseGroup = adviseGroup,
            };

            var target = new FolderAdviseGroupHolder(folder);

            // Act

            var currentAdviseGroup = target.CurrentAdviseGroup;

            // Assert

            currentAdviseGroup.Should().Be(adviseGroup);
        }
예제 #3
0
        public EDiscoveryManagerPathModel GetNotSharedYetPath(FolderModel folder)
        {
            // We need to get the staged count, as it will allow us to A. determine if we're going to show the not shared yet folder,
            // and B. a cound on the not shared yet folder.
            var stagedCount         = EDiscoveryUtility.GetStagedCount(folder);
            var notSharedIdentifier = new PathIdentifier(folder.Identifier, EDiscoveryUtility.E_DISCOVERY_NOT_SHARED_PATH_KEY);

            var processor = new PathProcessor(folder.Identifier);

            processor.Read(folder, skipFolderPaths: true, pathReader: f => {
                if (f.ShareState() != EDiscoveryShareState.Staged)
                {
                    return(null);
                }

                var sharePath = f.MetaEDiscoveryPathIdentifierRead();

                if (sharePath != null)
                {
                    return(notSharedIdentifier.CreateChild(sharePath.PathKey));
                }

                return(null);
            });

            return(new EDiscoveryManagerPathModel()
            {
                Identifier = notSharedIdentifier,
                Icons = new string[] { EDiscoveryUtility.EDISCOVERY_FOLDER_COLOR_STYLE },
                Name = $"Not Shared Yet ({stagedCount.ToString()})",
                FullPath = "eDiscovery/Not Shared Yet",
                AllowedOperations = null,
                Paths = processor[notSharedIdentifier]?.Paths
            });
        }
예제 #4
0
        public void AddSubfolder_IfSubfolderWithSameNameAlreadyExists_ThrowsInvalidOperationException()
        {
            // Arrange

            var target = new FolderModel();

            target.AddSubfolder(new FolderModel {
                Name = "Subfolder 1"
            });
            target.AddSubfolder(new FolderModel {
                Name = "Subfolder 2"
            });
            target.AddSubfolder(new FolderModel {
                Name = "Subfolder 3"
            });

            // Act

            var call = () => target.AddSubfolder(new FolderModel {
                Name = "Subfolder 2"
            });

            // Assert

            call.Should().Throw <InvalidOperationException>().WithMessage("Cannot add subfolder with duplicated name: 'Subfolder 2'");
        }
예제 #5
0
 public StoryTestFolder(Configuration configuration, FolderModel theFolderModel)
     : this(configuration,
            configuration.GetItem <Settings>().InputFolder,
            configuration.GetItem <Settings>().OutputFolder, null, theFolderModel, null)
 {
     myReport = new Report(OutputPath);
 }
        protected override void LoadPage(object target, string source, IDictionary <string, object> sourceData, IDictionary <string, object> uiProperties, bool navigateForward)
        {
            this.Application.NavigatingForward = navigateForward;
            if (navigateForward)
            {
                if (breadcrumbs.Count == 0)
                {
                    breadcrumbs.Add(Config.Instance.InitialBreadcrumbName);
                }
                else if ((uiProperties != null) && (uiProperties.ContainsKey("Item")))
                {
                    Item itm = (Item)uiProperties["Item"];
                    breadcrumbs.Add(itm.Name);
                }
                else if ((uiProperties != null) && (uiProperties.ContainsKey("Folder")))
                {
                    FolderModel folder = (FolderModel)uiProperties["Folder"];
                    breadcrumbs.Add(folder.Name);
                }
                else
                {
                    breadcrumbs.Add("");
                }
            }
            else if (breadcrumbs.Count > 0)
            {
                breadcrumbs.RemoveAt(breadcrumbs.Count - 1);
            }

            base.LoadPage(target, source, sourceData, uiProperties, navigateForward);
        }
        private void FillExternalCollection()
        {
            ExternalCollection.Clear();
            InnerCollection.Clear();
            var externalFolder = new FolderModel {
                FullPath = FolderSizeCounterTests.ExternalFolderName, Name = "externalFolder"
            };
            var testFile1 = new FileModel {
                FullPath = externalFolder.FullPath + @"\testFile1", Name = "testFile1", Size = 1000
            };

            ExternalCollection.Add(testFile1);
            var testFile2 = new FileModel {
                FullPath = externalFolder.FullPath + @"\testFile2", Name = "testFile2", Size = 1000
            };

            ExternalCollection.Add(testFile2);
            var innerFolder = new FolderModel {
                FullPath = externalFolder.FullPath + @"\" + FolderSizeCounterTests.InnerFolderName, Name = "innerFolder"
            };

            ExternalCollection.Add(innerFolder);
            var testFile3 = new FileModel {
                FullPath = innerFolder.FullPath + @"\testFile3", Name = "testFile3", Size = 1000
            };

            InnerCollection.Add(testFile3);
            var testFile4 = new FileModel {
                FullPath = innerFolder.FullPath + @"\testFile4", Name = "testFile4", Size = 1000
            };

            InnerCollection.Add(testFile4);
        }
예제 #8
0
        public ActionResult EditFolder(FolderModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var newPath = Path.Combine(Path.GetDirectoryName(model.Path), model.Name);
                    if (!string.Equals(model.Path, newPath, StringComparison.OrdinalIgnoreCase))
                    {
                        var folder = MediaService.GetRootFolderAbsolutePath(CurrentSiteId);
                        System.IO.Directory.Move(Path.Combine(folder, model.Path), Path.Combine(folder, newPath));
                    }

                    ShowSuccess(MessageResource.UpdateSuccess);

                    return(RedirectToIndex());
                }
                catch
                {
                    ShowError(MessageResource.UpdateFailed);
                }
            }

            return(View(model));
        }
예제 #9
0
        public async Task DeleteEmptyFolder(FolderModel folder, CancellationToken cancellationToken)
        {
            if (folder.HasContent)
            {
                throw new InvalidOperationException($"Can not delete non-empty folder '{folder.Name}'");
            }

            logger.LogInformation($"Deleting folder '{folder.Name}' ...");

            await storageRepository.DeleteFolder(folder, cancellationToken);

            var hasAdviseGroup = folder.AdviseGroup != null;

            if (hasAdviseGroup)
            {
                // We erase advise group so that it could be deleted when no references left.
                folder.AdviseGroup = null;
            }

            folder.DeleteDate = clock.Now;
            await foldersRepository.UpdateFolder(folder, cancellationToken);

            if (hasAdviseGroup)
            {
                await adviseGroupService.DeleteOrphanAdviseGroups(cancellationToken);
            }

            logger.LogInformation($"The folder '{folder.Name}' was deleted successfully");
        }
예제 #10
0
        public void WriteFolderModel(FolderModel folder, string outFolderPath)
        {
            if (folder == null)
            {
                return;
            }
            var basePath = $"{outFolderPath}/{folder.Name}";

            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            if (folder.FileModels.Any())
            {
                foreach (var file in folder.FileModels)
                {
                    var filePath = $"{basePath}/{file.Name}";
                    File.WriteAllBytes(filePath, file.DataBytes);
                }
            }
            if (folder.SubFolderModels.Any())
            {
                foreach (var subFolder in folder.SubFolderModels)
                {
                    WriteFolderModel(subFolder, basePath);
                }
            }
        }
예제 #11
0
        private FolderModel uploadfolderInit(string bucket, string parentKey, string dir)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(dir);

            FolderModel folderModel = new FolderModel();

            folderModel.objListAll = new List <FileModel>();
            folderModel.Size       = 0;
            folderModel.bucketName = bucket;
            folderModel.key        = parentKey + dirInfo.Name + "/";
            folderModel.initial();

            FileInfo[] fileInfos = dirInfo.GetFiles();
            foreach (FileInfo fileInfo in fileInfos)
            {
                folderModel.objListAll.Add(new FileModel()
                {
                    bucketName = folderModel.bucketName, key = folderModel.key + fileInfo.Name, localPath = fileInfo.FullName
                });
                folderModel.Size += fileInfo.Length;
            }

            DirectoryInfo[] sonDirInfos = dirInfo.GetDirectories();
            foreach (DirectoryInfo sonDirInfo in sonDirInfos)
            {
                FolderModel model = uploadfolderInit(bucket, folderModel.key, sonDirInfo.FullName);
                folderModel.objListAll.AddRange(model.objListAll);
                folderModel.Size += model.Size;
            }

            return(folderModel);
        }
        public async Task LoadDirectoryFoldersAsync(string path)
        {
            string[] directories;
            try
            {
                directories = Directory.GetDirectories(path);
            }
            catch (Exception)
            {
                directories = new string[0];
                //throw new Exception(e.Message);
            }
            
            CurrentDirectoryContent.Clear();
            int foldersCount = 0;
            foreach (string folderPath in directories)
            {
                var folder = new FolderModel();
                
                await Task.Run(() => CreateFolderModel(folderPath, folder));
                //CreateFolderModel(folderPath, folder);
                CurrentDirectoryContent.Add(folder);
                foldersCount++;
//                if (foldersCount % 100 == 0)
//                {
//                    await Task.Delay(10); // give time for UI to response
//                }
            }
        }
예제 #13
0
        private FolderModel CreateFolder(string name, string description)
        {
            var rf = new FolderModel()
            {
                Name = name, Description = description
            };
            var nf = new FolderModel();

            rf.Folders.Add(nf);
            nf.Name        = "my stuff";
            nf.Description = "contains all that is well";
            rf.Folders.Add(nf);
            nf.Name        = "my stuff 2";
            nf.Description = "contains all that is well 2";
            var ne = new EntryModel
            {
                ContentType = ContentType.Webpage,
                Description = "hi mom",
                Name        = "private stuff",
                IconUri     = new Uri("https://www.facebook.com/favicon.ico")
            };

            rf.Entries.Add(ne);
            ne = new EntryModel
            {
                ContentType = ContentType.Webpage,
                Description = "hi mom 2",
                Name        = "private stuff 2",
                IconUri     = new Uri("https://www.facebook.com/favicon.ico")
            };
            rf.Entries.Add(ne);
            return(rf);
        }
        /// <summary>
        /// Gets the child folders of the specified item ID.
        /// </summary>
        /// <param name="id">The ID of the parent item.</param>
        /// <returns>The child folders of the specified item ID.</returns>
        internal async Task <ICollection <ItemModel> > GetFolders(FolderModel folder, bool recursive = false)
        {
            string           id      = folder.Id;
            List <ItemModel> results = new List <ItemModel>();

            IEnumerable <DriveItem> items;

            var expandString = "thumbnails, children($expand=thumbnails)";

            // If id isn't set, get the OneDrive root's photos and folders. Otherwise, get those for the specified item ID.
            // Also retrieve the thumbnails for each item if using a consumer client.
            var itemRequest = this._graphClient.Me.Drive.Items[id].Request().Expand(expandString);

            var item = await itemRequest.GetAsync();

            items = item.Children == null ?
                    new List <DriveItem>() :
                    item.Children.CurrentPage.Where(child => child.Folder != null);

            foreach (var child in items)
            {
                results.Add(new ItemModel(child, folder));

                if (recursive)
                {
                    results.AddRange(await GetFolders(new FolderModel(child.Id, child.Name, folder)));
                }
            }

            return(results);
        }
예제 #15
0
        public void Read(FolderModel folder, bool skipFiles = false, bool skipFolderPaths = false, Func <FileModel, PathIdentifier> pathReader = null)
        {
            if (pathReader == null)
            {
                pathReader = APIModelExtensions.MetaPathIdentifierRead;
            }

            if (!skipFolderPaths)
            {
                Add(folder.Read("_paths", defaultValue: new List <string>())
                    .Select(p => new PathIdentifier(this.FolderIdentifier, p))
                    .ToList());
            }

            if (!skipFiles)
            {
                // find any paths mentioned on folders
                foreach (var file in folder.Files.Rows)
                {
                    var pathIdentifier = pathReader(file);
                    if (pathIdentifier != null)
                    {
                        Add(pathIdentifier);
                    }
                }
            }

            Process();
        }
        public static void DecontainerizeDirectoryFiles(FolderModel masterModel, string folderPath, ContainerizationSettingsModel settingsModel, bool includeSubFolders)
        {
            foreach (var filePath in Directory.GetFiles(folderPath).Where(x => Path.GetExtension(x).Equals(settingsModel.Extension)))
            {
                ContainerHelper.DecontainerizeFile(filePath, settingsModel.Password);

                var fileModel = folderPath.Equals(masterModel.Uri)
                    ? masterModel.FileModels.FirstOrDefault(x => x.Secured.Equals(filePath))
                    : GetFileModel(masterModel, file => file.Secured.Equals(filePath));

                var newPath = FileGeneratorHelper.GetValidFileNameForDirectory(
                    GetDirectoryPath(filePath),
                    Path.GetFileNameWithoutExtension(filePath),
                    fileModel != null ? Path.GetExtension(fileModel.File) : string.Empty);

                File.Move(filePath, newPath);
            }

            if (!includeSubFolders)
            {
                return;
            }

            foreach (var subFolderPath in Directory.GetDirectories(folderPath))
            {
                DecontainerizeDirectoryFiles(masterModel, subFolderPath, settingsModel, true);
            }
        }
예제 #17
0
 protected virtual void VisitFolder(FolderModel folderModel)
 {
     foreach (var child in folderModel.Children)
     {
         VisitProjectItem(child);
     }
 }
예제 #18
0
        public void DeleteFolder(Guid folderId, Guid userId)
        {
            FolderModel folderModel = _unitOfWork.FolderRepository.Get(folderId);

            if (folderModel == null)
            {
                throw new Exception();
            }

            if (folderModel.OwnerId != userId)
            {
                throw new Exception();
            }

            List <FileModel> files = _unitOfWork.FileRepository.Find(p => p.ParentId == folderId).ToList();

            foreach (FileModel file in files)
            {
                _fileService.DeleteFile(file.Id, userId);
            }

            List <FolderModel> folders = _unitOfWork.FolderRepository.Find(p => p.ParentId == folderId).ToList();

            foreach (FolderModel folder in folders)
            {
                DeleteFolder(folder.Id, userId);
            }

            _unitOfWork.FolderRepository.Delete(folderId);
            _unitOfWork.Save();
        }
예제 #19
0
        private async Task uploadFolderInCurrentFolder(string Path)
        {
            FolderModel folderModel = null;

            try
            {
                folderModel           = uploadfolderInit(currentFolder.bucketName, currentFolder.key, Path);
                folderModel.localPath = Path;

                events.Publish(new TaskEvent(folderModel, TaskEventType.UPLOADING));
                //events.Publish(new TaskAddNumEvent(1));
                //folderModel.startTimer();
                //await createFolders(folderModel, Path);
                //await uploadFolder(folderModel);
                //events.Publish(new TaskEvent(folderModel, TaskEventType.UPLOADCOMPELETED));
            }
            catch (Exception ex)
            {
                //if (ex is System.Threading.Tasks.TaskCanceledException)
                //{
                //    events.Publish(new TaskEvent(folderModel, TaskEventType.UPLOADCANCEL));
                //    folderListModel.deleteFolder(folderModel.bucketName, folderModel.key);
                //}
            }
        }
        /// <summary>
        /// Open file using open dialog.
        /// </summary>
        public void OpeFile()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Binary file (.bin)|*.bin";

            bool?result = dialog.ShowDialog();

            if (result == true)
            {
                string filename = dialog.FileName;
                try
                {
                    _folder = _serializeClient.DeserializeFolderModel(filename);
                    var treeItem = Mapper.Map <TreeViewItemModel>(_folder);
                    Filename = filename;

                    TreeViewItemModels.Clear();
                    TreeViewItemModels.Add(treeItem);
                }
                catch (Exception ex)
                {
                    _logger.Error(ex);
                }
            }
        }
예제 #21
0
        public List <User> GetUsersHaveFolderPermission(Guid folderId, Guid ownerId, PermissionType permission)
        {
            UserModel userModel = _unitOfWork.UserRepository.Get(ownerId);

            if (userModel == null)
            {
                throw new Exception();
            }

            FolderModel folderModel = _unitOfWork.FolderRepository.Get(folderId);

            if (folderModel == null)
            {
                throw new Exception();
            }

            if (folderModel.OwnerId != ownerId)
            {
                throw new Exception();
            }

            List <FolderPermissionModel> folderPermissions = _unitOfWork.FolderPermissionRepository
                                                             .Find(p => p.FolderId == folderId && p.Value == permission)
                                                             .ToList();

            List <User> users = new List <User>();

            foreach (FolderPermissionModel folderPermission in folderPermissions)
            {
                UserModel user = _unitOfWork.UserRepository.Get(folderPermission.UserId);
                users.Add(user);
            }

            return(users);
        }
        internal async Task MoveItem(ItemModel item, FolderModel destination)
        {
            // TODO: How does move work in the Graph SDK?
            var request = new HttpRequestMessage(HttpMethod.Patch, "https://graph.microsoft.com/v1.0/me/drive/items/" + item.Id);

            await _graphClient.AuthenticationProvider.AuthenticateRequestAsync(request);

            request.Content = new StringContent(
                JsonConvert.SerializeObject(new
            {
                parentReference = new
                {
                    id = destination.Id
                },
            }),
                Encoding.UTF8, "application/json");

            var response = await Client.SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine("Copy failed: " + response.StatusCode);
            }

            var responseBody = await response.Content.ReadAsStringAsync();

            Console.WriteLine(responseBody);
        }
예제 #23
0
        /// <summary>
        /// Creates folder.
        /// </summary>
        /// <param name="createFolderModel">The create folder model.</param>
        public FolderModel CreateFolder(CreateFolderModel createFolderModel)
        {
            Guard.ArgumentNotNull(createFolderModel, nameof(createFolderModel));

            if (string.IsNullOrWhiteSpace(createFolderModel.FolderName))
            {
                throw new FolderNameIsNotSpecifiedException("Cannot create folder. The name was not specified.");
            }

            var folderModel = new FolderModel
            {
                Id           = Guid.NewGuid(),
                Name         = createFolderModel.FolderName,
                CreatedDate  = DateTime.Now,
                LastModified = DateTime.Now
            };

            folderModel.Fields = this.fieldService.CreateSystemFieldsForFolder(folderModel.Id);

            // Associate the fields with the folder.
            foreach (var field in folderModel.Fields)
            {
                field.Folder = folderModel;
            }

            var folderEntity        = Mapper.Map <FolderEntity>(folderModel);
            var createdFolderEntity = this.folderRepository.CreateFolder(folderEntity);
            var createdFolderModel  = Mapper.Map <FolderModel>(createdFolderEntity);

            return(createdFolderModel);
        }
예제 #24
0
        public async Task LoadAvailableDiscsForAdviseSet_IfDiscBelongsToAnotherFolder_DoesNotAddSuchDiscsToList()
        {
            // Arrange

            var adviseSet = new AdviseSetModel {
                Id = new ItemId("1")
            };

            var discs = new[]
            {
                new DiscModel {
                    Id = new ItemId("1"), TreeTitle = "Disc 1", AdviseSetInfo = new AdviseSetInfo(adviseSet, 1)
                },
                new DiscModel {
                    Id = new ItemId("2"), TreeTitle = "Disc 2"
                },
                new DiscModel {
                    Id = new ItemId("3"), TreeTitle = "Disc 3"
                },
            };

            var folder1 = new FolderModel {
                Id = new ItemId("0"), Name = "<ROOT"
            };
            var folder2 = new FolderModel {
                Id = new ItemId("1"), Name = "Folder 1"
            };
            var folder3 = new FolderModel {
                Id = new ItemId("2"), Name = "Folder 2"
            };

            folder1.AddSubfolders(folder2);
            folder2.AddSubfolders(folder3);
            folder2.AddDiscs(discs[0], discs[2]);
            folder3.AddDiscs(discs[1]);

            var adviseSetDiscs = new[]
            {
                discs[0],
            };

            var mocker = new AutoMocker();
            var target = mocker.CreateInstance <AvailableDiscsViewModel>();

            await target.LoadDiscs(discs, CancellationToken.None);

            // Act

            target.LoadAvailableDiscsForAdviseSet(adviseSetDiscs);

            // Assert

            var expectedAvailableDiscs = new[]
            {
                new AvailableDiscViewModel(discs[2], "/Folder 1/Disc 3"),
            };

            target.AvailableDiscs.Should().BeEquivalentTo(expectedAvailableDiscs, x => x.WithStrictOrdering());
        }
예제 #25
0
        public async void searchOperate(string text)
        {
            ProgressVisible = true;
            if (text != "")
            {
                FolderModel searchFolder;
                if (currentFolder != null)
                {
                    searchFolder        = currentFolder;
                    backUpCurrentFolder = currentFolder;
                }
                else
                {
                    searchFolder = backUpCurrentFolder;
                }

                FolderModel folderModel = new FolderModel();
                folderModel.folderList = new List <FolderModel>();
                folderModel.objList    = new List <FileModel>();

                List <ObjectListing> listObjectListing = await folderListModel.getObjectListing(searchFolder.bucketName, searchFolder.key);

                foreach (ObjectListing objectlisting in listObjectListing)
                {
                    foreach (OssObjectSummary ossObj in objectlisting.ObjectSummaries)
                    {
                        if (ossObj.Key.EndsWith("/"))
                        {
                            if (FolderModel.lastName(ossObj.Key).Contains(text))
                            {
                                FolderModel folder = new FolderModel()
                                {
                                    bucketName = ossObj.BucketName, key = ossObj.Key
                                };
                                folder.initial();
                                folderModel.folderList.Add(folder);
                            }
                        }
                        else
                        {
                            if (FileModel.lastName(ossObj.Key).Contains(text))
                            {
                                FileModel fileModel = new FileModel()
                                {
                                    bucketName = ossObj.BucketName, key = ossObj.Key, Size = ossObj.Size
                                };
                                fileModel.modifyTime = ossObj.LastModified;
                                fileModel.initial();
                                folderModel.objList.Add(fileModel);
                            }
                        }
                    }
                }
                currentFolder = null;

                refreshObjectList(folderModel);
                ProgressVisible = false;
            }
        }
예제 #26
0
 public StoryTestFolder(Memory memory, string theInputPath, string theOutputPath, string theSelection, FolderModel theFolderModel, StoryTestFolder theParentFolder) {
     this.memory = memory;
     Name = theInputPath;
     OutputPath = theOutputPath;
     myFolderModel = theFolderModel;
     myParent = theParentFolder;
     mySelection = theSelection;
 }
예제 #27
0
        public static void MetaExternalUserListUpsert(this FolderModel folder, ExternalUser externalUser, string metadataKeyLocation)
        {
            var externalUsers = folder.MetaExternalUserListRead(metadataKeyLocation);

            externalUsers.RemoveAll(r => r.Email?.ToLower() == externalUser.Email?.ToLower());
            externalUsers.Add(externalUser);
            folder.MetaExternalUserListWrite(externalUsers, metadataKeyLocation);
        }
예제 #28
0
        public FolderModel GetFirstFolder()
        {
            FolderModel firstFolder = new FolderModel();

            firstFolder = folderM.Folders.FirstOrDefault();

            return(firstFolder);
        }
 private static void Register(IOutputTargetRegistry registry, FolderModel folder)
 {
     registry.RegisterOutputTarget(folder.ToOutputTargetConfig());
     foreach (var child in folder.Folders)
     {
         Register(registry, child);
     }
 }
예제 #30
0
        public FolderModel GetAllFolder()
        {
            var model = new FolderModel();

            model.folders = _photoFolderService.GetAll();

            return(model);
        }
예제 #31
0
 public FolderViewModel(IProviderViewModel provider, FolderModel folder)
 {
     Provider = provider;
     _folder  = folder;
     Children = folder.Children != null && folder.Children.Any()
         ? folder.Children.Select(f => new FolderViewModel(provider, f))
         : Enumerable.Empty <IFolderViewModel>();
 }
예제 #32
0
 public StoryTestFolder(string theInputPath, string theOutputPath, FolderModel theFolderModel, StoryTestFolder theParentFolder, Filters filters)
 {
     FullName      = theInputPath;
     OutputPath    = theOutputPath;
     myFolderModel = theFolderModel;
     myParent      = theParentFolder;
     this.filters  = filters;
 }
예제 #33
0
        StoryTestFolder CreateStoryTestFolder(Memory memory, FolderModel folderModel) {
            var storyTestFolder = new StoryTestFolder(memory, folderModel);

            string tagList = memory.GetItem<Settings>().TagList;
            if (!string.IsNullOrEmpty(tagList))
                storyTestFolder.AddPageFilter(new TagFilter(tagList));

            return storyTestFolder;
        }
예제 #34
0
 public Boolean addFolder(FolderModel folderModel)
 {
     FolderModel parentFolder = GetFolderById(folderModel.ParentFolderId);
     folderModel.PhysicalPath = Helper.CreateNewFolderPath(parentFolder.PhysicalPath+"\\");
     Helper.CreateDirectory(folderModel.PhysicalPath);
     if (folderDAL.CreateFolder(folderModel) > 0)
     {
         return true;
     }
     return false;
 }
예제 #35
0
 public void DeleteFolder(FolderModel folder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Folder dbFolder = ConvertModelToDB(folder);
         context.Folders.Attach(dbFolder);
         context.Folders.DeleteObject(dbFolder);
         context.SaveChanges();
     }
 }
예제 #36
0
        public static bool CreateEpisodeParents(Item item, FolderModel topParent = null)
        {
            var episode = item.BaseItem as Episode;
            if (episode == null) return false;
            //this item loaded out of context (no season/series parent) we need to derive and create them
            var mySeason = episode.Season;
            if (mySeason != null)
            {
                //found season - attach it
                episode.Parent = mySeason;
                //and create a model item for it
                item.PhysicalParent = ItemFactory.Instance.Create(mySeason) as FolderModel;
            }
            //gonna need a series too
            var mySeries = episode.Series;
            if (mySeries != null)
            {
                if (mySeason != null)
                    mySeason.Parent = mySeries;
                else
                    episode.Parent = mySeries;

                if (item.PhysicalParent == null)
                    item.PhysicalParent = ItemFactory.Instance.Create(mySeries) as FolderModel;
                else
                    item.PhysicalParent.PhysicalParent = ItemFactory.Instance.Create(mySeries) as FolderModel;

                if (topParent != null) mySeries.Parent = topParent.Folder;

                //now force the blasted images to load so they will inherit
                var ignoreList = mySeries.BackdropImages;
                ignoreList = mySeason != null ? mySeason.BackdropImages : null;
                ignoreList = episode.BackdropImages;
                var ignore = mySeries.ArtImage;
                ignore = mySeries.PrimaryImage;
                ignore = mySeries.LogoImage;
                ignore = mySeason != null ? mySeason.ArtImage : null;
                ignore = mySeason != null ? mySeason.LogoImage : null;
                ignore = episode.ArtImage;
                ignore = episode.LogoImage;
                return true;
            }
            else
            {
                //something went wrong deriving all this
                return false;
            }

        }
        public async void LoadDirectoryContentAsync(string path)
        {
            _content.Clear();

            string[] directories;
            string[] files;
            try
            {
                directories = Directory.GetDirectories(path);
                files = Directory.GetFiles(path);
            }
            catch (Exception)
            {
                directories = new string[0];
                files = new string[0];
                //throw new Exception(e.Message);
            }

            foreach (var folderPath in directories)
            {
                var folderModel = new FolderModel();
                await Task.Run(() => CreateFolderModel(folderPath, folderModel));

                _content.Add(folderModel);
            }
            
            foreach (var filePath in files)
            {
                //Fixing an odd behaviour. I've got a file: D:\Autorun.inf\lpt1.UsbFix, which I can see in Windows File Explorer,
                //but which I can't delete. It says, this file does not exist anymore.
                //And of course such file causes exception, when trying to calculate its size. So, ignore the case.
                if (!File.Exists(filePath)) continue;

                var fileModel = new FileModel();
                await Task.Run(() => CreateFileModel(filePath, fileModel));
                var extractedIcon = Icon.ExtractAssociatedIcon(filePath);
                if (extractedIcon != null)
                {
                    var iconBitmap = extractedIcon.ToBitmap();
                    var iconBitmapImage = Bitmap2BitmapImage(iconBitmap);
                    fileModel.Icon = iconBitmapImage;
                }
                //CreateFileModelAsync(file, fileModel);
                _content.Add(fileModel);
            }

            //CalculateFileSizeAsync();
        }
예제 #38
0
 public IList<FolderModel> GetAllSubFolders(FolderModel parentFolder)
 {
     IList<FolderModel> firstLevelSubFolders = GetSubFolders(parentFolder);
     // 遍历子目录
     Stack<FolderModel> foldersToVisit = new Stack<FolderModel>(firstLevelSubFolders);
     while (foldersToVisit.Count != 0)
     {
         FolderModel current = foldersToVisit.Pop();
         current.SubFolders = GetSubFolders(current);
         foreach (FolderModel sub in current.SubFolders)
         {
             foldersToVisit.Push(sub);
         }
     }
     return firstLevelSubFolders;
 }
예제 #39
0
        public XmlResultWriter(string outputFileName, FolderModel theFolderModel) {
            folderModel = theFolderModel;

            var settings = new XmlWriterSettings {Indent = true};

            if ("stdout".Equals(outputFileName))
                writer = XmlWriter.Create(Console.Out, settings);
            else
            {
                file = folderModel.MakeWriter(outputFileName);
                writer = XmlWriter.Create(file, settings);
            }

            writer.WriteStartDocument();
            writer.WriteStartElement("testResults");
        }
예제 #40
0
 public int CreateFolder(FolderModel folder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Folder dbFolder = new Folder
         {
             FolderName = folder.FolderName,
             Description = folder.Description,
             ParentId = folder.ParentFolderId,
             PhysicalPath = folder.PhysicalPath
         };
         context.Folders.AddObject(dbFolder);
         context.SaveChanges();
         return dbFolder.Id;
     }
 }
예제 #41
0
        // 添加部门
        public void CreateDepartment(string deptName, string folderDesc)
        {
            FolderModel deptFolder = new FolderModel
            {
                FolderName = deptName,
                Description = folderDesc,
                ParentFolderId = 0, // 1级目录
                PhysicalPath = Helper.CreateNewFolderPath(@"\") // 1级目录存放在根目录下
            };
            Helper.CreateDirectory(deptFolder.PhysicalPath);    // 创建目录

            int folderId = folderDAL.CreateFolder(deptFolder);

            DepartmentModel dept = new DepartmentModel
            {
                DepartmentName = deptName,
                FolderId = folderId
            };
            departmentDAL.CreateDepartment(dept);
        }
        private void LoadDummyData()
        {
            var folderModel = new FolderModel
            {
                Name = "Folder",
                FullPath = "D:\\Folder",
                ChangedDate = DateTime.Now
            };

            _content.Add(folderModel);

            var fileModel = new FileModel
            {
                Name = "File",
                FullPath = "D:\\File",
                ChangedDate = DateTime.Now,
                Size = 123,
                Extension = ".none"
            };

            _content.Add(fileModel);
        }
예제 #43
0
 public int DeleteFolderCascade(FolderModel folder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         folder.SubFolders = GetAllSubFolders(folder);
         // DFS遍历目录结构
         Stack<FolderModel> folder_to_delete = new Stack<FolderModel>();
         folder_to_delete.Push(folder);
         while (folder_to_delete.Count != 0)
         {
             FolderModel current = folder_to_delete.Pop();
             foreach (FolderModel child in current.SubFolders)
             {
                 folder_to_delete.Push(child);
             }
             Folder dbCurrent = ConvertModelToDB(current);
             context.Folders.Attach(dbCurrent);
             context.Folders.DeleteObject(dbCurrent);
         }
         return context.SaveChanges();
     }
 }
        public void LoadLogicalDrives()
        {
            foreach (string logicalDrive in Directory.GetLogicalDrives())
            {
                var folder = new FolderModel
                {
                    Name = logicalDrive,
                    FullPath = logicalDrive
                };

                CurrentDirectoryContent.Add(folder);

                try
                {
                    var subfoldersCount = Directory.GetDirectories(folder.Name).Length;
                    folder.HasSubfolders = subfoldersCount != 0;
                    folder.IsAccessible = true;
                }
                catch (Exception)
                {
                    folder.IsAccessible = false;
                }
            }
        }
예제 #45
0
 private static int RunShell(string[] arguments, FolderModel model)
 {
     return new Shell(new ConsoleReporter(), model).Run(arguments);
 }
예제 #46
0
 private Folder ConvertModelToDB(FolderModel model)
 {
     return new Folder
     {
         Id = model.Id,
         FolderName = model.FolderName,
         Description = model.Description,
         ParentId = model.ParentFolderId,
         PhysicalPath = model.PhysicalPath
     };
 }
예제 #47
0
 public StoryTestFolder(Configuration configuration, string theInputPath, string theOutputPath, string theSelection, FolderModel theFolderModel, StoryTestFolder theParentFolder)
 {
     this.configuration = configuration;
     Name = theInputPath;
     OutputPath = theOutputPath;
     myFolderModel = theFolderModel;
     myParent = theParentFolder;
     mySelection = theSelection;
 }
예제 #48
0
 public StoryTestFolder(Configuration configuration, FolderModel theFolderModel)
     : this(configuration, 
            configuration.GetItem<Settings>().InputFolder,
            configuration.GetItem<Settings>().OutputFolder, null, theFolderModel, null)
 {
     myReport = new Report(OutputPath);
 }
예제 #49
0
 public void UpdateFolder(FolderModel folder)
 {
     folderDAL.UpdateFolder(folder);
 }
예제 #50
0
 public StoryTestFolder(Memory memory, FolderModel theFolderModel)
     : this(memory, 
            memory.GetItem<Settings>().InputFolder,
            memory.GetItem<Settings>().OutputFolder, null, theFolderModel, null) {
     myReport = new Report(OutputPath);
 }
예제 #51
0
파일: Shell.cs 프로젝트: jediwhale/fitsharp
 public Shell()
 {
     progressReporter = new ConsoleReporter();
     folderModel = new FileSystemModel();
 }
        private void CreateFolderModel(string folderPath, FolderModel folder)
        {
            folder.Name = folderPath.Substring(folderPath.LastIndexOf("\\", StringComparison.Ordinal) + 1);
            folder.FullPath = folderPath;
            folder.ChangedDate = File.GetLastWriteTime(folderPath);

            //folder.Size = GetFolderSize(new DirectoryInfo(folder.FullPath)); //TODO ??? Folder size calculation
        }
예제 #53
0
 public ActionResult doAddFolder()
 {
     FolderModel folderModel = new FolderModel();
     folderModel.FolderName = Request.Form["FolderName"];
     folderModel.Description = Request.Form["Description"];
     folderModel.ParentFolderId = Convert.ToInt32(Request.Form["ParentFolderId"]);
     BLLFolder bllFolder = new BLLFolder();
     if (bllFolder.addFolder(folderModel))
     {
         TempData["successMsg"] = "添加成功。";
     }
     else
     {
         TempData["errorMsg"] = "添加失败。";
     }
     return RedirectToAction("Manager", "User");
 }
예제 #54
0
 public void UpdateFolder(FolderModel folder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Folder dbFolder = ConvertModelToDB(folder);
         context.Folders.AddObject(dbFolder);
         context.ObjectStateManager.ChangeObjectState(dbFolder, EntityState.Modified);
         context.SaveChanges();
     }
 }
예제 #55
0
 private void CreateResultWriter(string fileName, string outputType, FolderModel folders)
 {
     if (string.IsNullOrEmpty(fileName)) return;
     if (outputType == "xml")
         resultWriter = new XmlResultWriter(fileName, folders);
     else
         resultWriter = new TextResultWriter(fileName, folders);
 }
예제 #56
0
파일: Shell.cs 프로젝트: jediwhale/fitsharp
 public Shell(ProgressReporter progressReporter, FolderModel folderModel)
 {
     this.progressReporter = progressReporter;
     this.folderModel = folderModel;
 }
예제 #57
0
 public StoryTestFile(string thePath, StoryTestFolder theFolder, FolderModel theFolderModel)
 {
     myPath = new StoryFileName(thePath);
     myFolder = theFolder;
     myFolderModel = theFolderModel;
 }
        private void CreateFolderModel(string folderPath, FolderModel folder)
        {
            folder.Name = folderPath.Substring(folderPath.LastIndexOf("\\", StringComparison.Ordinal) + 1);
            folder.FullPath = folderPath;

            try
            {
                var subfoldersCount = Directory.GetDirectories(folder.FullPath).Length;
                folder.HasSubfolders = subfoldersCount != 0;
                folder.IsAccessible = true;
            }
                catch (Exception)
            {
                folder.IsAccessible = false;
            }
        }
예제 #59
0
 public TextResultWriter(string outputFileName, FolderModel theFolderModel)
 {
     _writer = "stdout".Equals(outputFileName) ? Console.Out : theFolderModel.MakeWriter(outputFileName);
 }
예제 #60
0
 public IList<FolderModel> GetSubFolders(FolderModel parentFolder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         IList<FolderModel> result = new List<FolderModel>();
         var list = from f in context.Folders
                    where f.ParentId == parentFolder.Id
                    select f;
         foreach (Folder subfolder in list)
         {
             result.Add(ConvertDBToModel(subfolder));
         }
         return result;
     }
 }