private string GetImagesStorageDirectory(Guid imageFileId) { var root = Path.Combine(_tempDirectory, "pages"); var path = DirectoryProvider.GetStoragePath(imageFileId, root); return(path); }
// implementation /// <summary> /// Enumerate child data folders in a parent data folder /// </summary> /// <param name="parentFolder"> /// A folder in a tree whose children to enumerate. /// </param> /// <param name="level"> /// The level number of folders being enumerated, according to the current depth (not an index in <see cref="_levelTraits"/>) /// </param> /// <returns></returns> private List <IRepoFileContainerDescriptor> EnumerateChildren(IRepoFileContainerDescriptor parentFolder, int level) { Check.Require(level >= Constants.DataFolderLevelLeaf && level < LevelCount); ICalendarHistoricalFolderTraits traits = GetLevelTraits(level); string parentAbsolutePath = GetAbsolutePath(parentFolder); IEnumerable <string> allDirPaths = DirectoryProvider.EnumerateDirectories(parentAbsolutePath, traits.NameMask); List <IRepoFileContainerDescriptor> retval = new List <IRepoFileContainerDescriptor>(); foreach (string name in allDirPaths.Select((p) => DirectoryProvider.GetLastPathComponent(p))) { CalendarHistoricalFolderInternalDescriptor internalDesc = traits.GetDescriptor(parentFolder, name); if (null != internalDesc) { IRepoFileContainerDescriptor descr = GetDescriptor(parentFolder, internalDesc); retval.Add(descr); } else { _log.WarnFormat("Data folder name {0}/{1} is malformed, ignoring", parentFolder == null ? "" : parentFolder.RelativePath, name); } } return(retval); }
void OnFolderPopulate(FolderNode node) { Controller.EnsureDefaults(); DirectoryInfo directoryInfo = Controller.ResolveFileManagerItemInfo(node.ValuePath).Directory; if (!directoryInfo.Exists) { return; } DirectoryProvider provider = new DirectoryProvider(directoryInfo, SortMode.Name, SortDirection.Ascending); foreach (DirectoryInfo dir in provider.GetFileSystemInfos(DirectoryProvider.FileSystemInfosFilter.Directories)) { FileViewItem item = new FileViewItem(dir, this); if (!ShowHiddenFilesAndFolders && item.Hidden) { continue; } FolderNode treeNode = new FolderNode(this); node.ChildNodes.Add(treeNode); treeNode.Text = dir.Name; treeNode.Hidden = item.Hidden; treeNode.ImageUrl = Controller.GetFolderSmallImage(dir); if (_fileView != null) { treeNode.NavigateUrl = "javascript:WFM_" + _fileView.ClientID + ".Navigate(\"" + treeNode.ValuePath + "\");"; } } }
protected override void RenderContents(HtmlTextWriter writer) { if (DesignMode) { return; } var directoryInfo = GetCurrentDirectory().Directory; var render = FileViewRender.GetRender(this); var provider = new DirectoryProvider(directoryInfo, Sort, SortDirection, SearchTerm); render.RenderBeginList(writer); foreach (FileSystemInfo fsi in provider.GetFileSystemInfos()) { var item = new FileViewItem(directoryInfo, fsi, this); if (!ShowHiddenFilesAndFolders && item.Hidden) { continue; } render.RenderItem(writer, item); } render.RenderEndList(writer); RenderInitScript(writer); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var authSettings = Configuration.GetSection("AuthSettings").Get <AuthSettings>(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { #if (DEBUG) options.RequireHttpsMetadata = false; #endif options.TokenValidationParameters = new TokenValidationParameters { // укзывает, будет ли валидироваться издатель при валидации токена ValidateIssuer = true, // строка, представляющая издателя ValidIssuer = authSettings.Issuer, // будет ли валидироваться потребитель токена ValidateAudience = false, // установка потребителя токена ValidAudience = authSettings.GetAudience(), // будет ли валидироваться время существования ValidateLifetime = true, // установка ключа безопасности IssuerSigningKey = authSettings.GetSymmetricSecurityKey(), // валидация ключа безопасности ValidateIssuerSigningKey = true, // ClockSkew = authSettings.GetClockCrew() }; }); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); //services.AddDistributedMemoryCache(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.Configure <AuthSettings>(Configuration.GetSection("AuthSettings")); services.Configure <ServerSettings>(Configuration.GetSection("PilotServer")); services.Configure <AppSettings>(Configuration.GetSection("AppSettings")); services.AddSingleton <IConnectionService, ConnectionService>(); services.AddSingleton <IRemoteServiceFactory, RemoteServiceFactory>(); services.AddSingleton <IContextService, ContextService>(); services.AddSingleton <IIdleSessionTimeoutProvider, IdleSessionTimeoutProvider>(); services.AddScoped <IDocumentConverterFactory, DocumentConverterFactory>(); services.AddScoped <IDocumentRender, DocumentRender.DocumentRender>(); services.AddScoped <IFileSaver, FileSaver>(); services.AddScoped <IFilesStorage, FilesStorage>(); services.AddScoped <IFilesOperationService, FilesOperationService>(); services.AddScoped <IFileStorageDirectoryProvider, FileStorageDirectoryProvider>(); services.AddScoped <IFileDownloadService, FileDownloadService>(); services.AddSingleton <IFileStorageProvider>(new FileStorageProvider(DirectoryProvider.GetTempPath())); }
private string GetThumbnailPath(Guid imageFileId) { var root = Path.Combine(_tempDirectory, "thumbs"); var thumbnailPath = DirectoryProvider.GetStoragePath(imageFileId, root); var filename = Path.Combine(thumbnailPath, "thumb.png"); return(filename); }
public void GetMyDocumentsDirectoryPath_CorrectILocalizedNames_ReturnsCorrectPath() { DirectoryProvider directoryProvider = new DirectoryProvider(Mock.Of <ILocalizedNames>()); string myDocumentsPath = directoryProvider.GetMyDocumentsDirectoryPath(); string expectedMyDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); Assert.That(myDocumentsPath, Is.EqualTo(expectedMyDocumentsPath)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); // TODO Should be lazy, and reload sometimes. Directory = new DirectoryProvider(); }
public void GetApplicationDirectoryPath_NullApplicationName_ReturnsMyDocumentsPath() { DirectoryProvider directoryProvider = new DirectoryProvider(Mock.Of <ILocalizedNames>()); string applicationDirectoryPath = directoryProvider.GetApplicationDirectoryPath(); string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); Assert.That(applicationDirectoryPath, Is.EqualTo(myDocumentsPath)); }
private string SaveFile(byte[] content) { var tempDirectory = DirectoryProvider.GetCurrentTempDirectory(); var xpsFilename = Path.Combine(tempDirectory, Guid.NewGuid() + ".xps"); using (var fileStream = File.Create(xpsFilename)) fileStream.Write(content, 0, content.Length); return(xpsFilename); }
public IActionResult FileInfo([FromQuery] string path) { if (path == null) { return(StatusCode(400)); } //get infos about file ViewBag.Info = DirectoryProvider.GetFileInfo(path); return(View()); }
public string GetImagesStorageDirectory(Guid imageFileId) { var root = Path.Combine(_tempDirectory, "pages"); var path = DirectoryProvider.GetStoragePath(imageFileId, root); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return(path); }
public void GetApplicationDirectoryPath_CorrectILocalizedNames_ReturnsCorrectPath() { string applicationDirectoryName = "Attendance List Generator"; ILocalizedNames localizedNames = Mock.Of <ILocalizedNames>(l => l.ApplicationDirectoryName == applicationDirectoryName); DirectoryProvider directoryProvider = new DirectoryProvider(localizedNames); string applicationDirectoryPath = directoryProvider.GetApplicationDirectoryPath(); string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string expectedResult = myDocumentsPath + "\\Attendance List Generator"; Assert.That(applicationDirectoryPath, Is.EqualTo(expectedResult)); }
public void ReturnFalse_When_FolderExists() { // Arrange var fixture = new Fixture(); string newFolder = Path.Combine(Path.GetTempPath(), fixture.Create <string>()); var directoryProvider = new DirectoryProvider(); // Act bool doesFolderExists = directoryProvider.DoesDirectoryExists(newFolder); // Assert Assert.That(doesFolderExists, Is.False); }
public IActionResult FileList([FromQuery] string path) { if (path == null) { ViewBag.Files = DirectoryProvider.GetDrives(); } else { ViewBag.Parent = DirectoryProvider.GetParentPath(path); ViewBag.Files = DirectoryProvider.GetFilesInDirectory(path); } return(View()); }
public void ReturnTrue_When_FolderExists() { // Arrange string newFolder = DirectoryFactory.CreateTestDirectory(); var directoryProvider = new DirectoryProvider(); // Act bool doesFolderExists = directoryProvider.DoesDirectoryExists(newFolder); // Assert Assert.That(doesFolderExists, Is.True); // Clean-up Directory.Delete(newFolder); }
public void ReturnCorrectFilePaths() { // Arrange string newFolder = DirectoryFactory.CreateTestDirectory(); string firstFile = FileFactory.CreateTestFile(newFolder, null, string.Empty); string secondFile = FileFactory.CreateTestFile(newFolder, null, string.Empty); var expectedCollection = new[] { firstFile, secondFile }; var directoryProvider = new DirectoryProvider(); // Act var files = directoryProvider.GetFiles(newFolder); // Assert Assert.That(files, Is.EquivalentTo(expectedCollection)); }
public void DirectoryCreatedSuccessfully() { // Arrange var directoryProvider = new DirectoryProvider(); string newFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); // Act directoryProvider.CreateDirectory(newFolder); // Assert Assert.That(Directory.Exists(newFolder), Is.True); // Clean-up Directory.Delete(newFolder); }
private void CreateApplicationDirectories() { LocalizedNames localizedNames = new LocalizedNames(); DirectoryProvider directoryProvider = new DirectoryProvider(localizedNames); if (!Directory.Exists(directoryProvider.GetApplicationDirectoryPath())) { Directory.CreateDirectory(directoryProvider.GetApplicationDirectoryPath()); } if (!Directory.Exists(directoryProvider.GetDocumentsDirectoryPath())) { Directory.CreateDirectory(directoryProvider.GetDocumentsDirectoryPath()); } }
public async override Task <int> Execute(InstallProjectTaskArguments arguments, string[] args) { // todo: finish this. return(1); DirectoryInfo moduleDirectory = arguments.ModuleDirectory != null ? new DirectoryInfo(Path.GetFullPath(arguments.ModuleDirectory)) : PathUtility.GetDefaultModulePath(); (FileInfo Project, FileInfo Module) = DirectoryProvider.GetProjectFiles(DirectoryProvider.WorkingDirectory); if (!Project.Exists || !Module.Exists) { throw new FileNotFoundException("Unable to find project file or module.json."); } var artifactsDirectory = DirectoryProvider.WorkingDirectory .CreateSubdirectory("bin") .CreateSubdirectory("module") .CreateSubdirectory(Path.GetFileNameWithoutExtension(Project.Name)); Console.WriteLine($"Installing {artifactsDirectory.Name}..."); if (!DirectoryProvider.IsModuleDirectory(artifactsDirectory)) { throw new InvalidDataException( "Error! No valid module.json or contents found. Check for JSON errors or missing file. "); } var moduleFile = DirectoryProvider.GetModule(artifactsDirectory); ModuleDefinition module; try { module = JsonConvert.DeserializeObject <ModuleDefinition>(File.ReadAllText(moduleFile?.FullName)); } catch { throw new InvalidDataException( "Error! No valid module.json found. Check for JSON errors or missing file."); } var installer = new ProjectInstaller(module, artifactsDirectory); Console.WriteLine($"Installed to {await installer.CopyModuleFiles(moduleDirectory, arguments.NoTreeShaking)}"); return(0); }
public void Execute() { using (var backupManager = new BackupDirectoryManager(_rootFolder, _backupFolder)) { backupManager.CreateBackupDirectory(); var backedUpFileRegistry = new BackedUpFilesRegistry(backupManager); var folderNamesProvider = new DirectoryProvider(backupManager.BackupRoot); var cleaner = new DuplicateCleaner( new UniqueFilesRegistry(), backedUpFileRegistry, new FileProvider(), folderNamesProvider); cleaner.Clean(_rootFolder); } }
protected override void RenderContents(HtmlTextWriter writer) { if (DesignMode) { return; } DirectoryInfo directoryInfo = GetCurrentDirectory().Directory; FileViewRender render = FileViewRender.GetRender(this); DirectoryProvider provider = new DirectoryProvider(directoryInfo, Sort, SortDirection); render.RenderBeginList(writer); //FileViewItem upDirectory = new FileViewUpDirectoryItem(directoryInfo.Parent, this); //render.RenderItem(output, upDirectory); //if (ShowInGroups) { // GroupInfo [] groups = provider.GetGroups (); // foreach (GroupInfo group in groups) { // render.RenderBeginGroup (writer, group); // foreach (FileSystemInfo fsi in provider.GetFileSystemInfos (group)) { // FileViewItem item = new FileViewItem (fsi, this); // render.RenderItem (writer, item); // } // render.RenderEndGroup (writer, group); // } //} //else { foreach (FileSystemInfo fsi in provider.GetFileSystemInfos()) { FileViewItem item = new FileViewItem(fsi, this); if (!ShowHiddenFilesAndFolders && item.Hidden) { continue; } render.RenderItem(writer, item); } //} render.RenderEndList(writer); RenderInitScript(writer); }
private void Generate() { IList <IPerson> people = GetPeopleList(); // Generate data DaysOffData daysOff = new DaysOffData(Year); AttendanceListData listData = new AttendanceListData(daysOff, people, Month, Year); // Create document generator LocalizedNames localizedNames = new LocalizedNames(); AttendanceListDocumentGenerator documentGenerator = new AttendanceListDocumentGenerator(listData, localizedNames); // Set document generator settings documentGenerator.EnableColors = EnableColors; documentGenerator.EnableHolidaysTexts = EnableHolidaysTexts; documentGenerator.EnableSundaysTexts = EnableSundaysTexts; documentGenerator.EnableTableStretching = EnableTableStretching; // Generate a document Document document = documentGenerator.GenerateDocument(); // Get directory path and filename DirectoryProvider directoryProvider = new DirectoryProvider(localizedNames); FilenameGenerator filenameGenerator = new FilenameGenerator(localizedNames, _dateTimeProvider); string path = directoryProvider.GetDocumentsDirectoryPath(); string filename = filenameGenerator.GeneratePdfDocumentFilename(listData); // Save document FileSaver fileSaver = new FileSaver(); fileSaver.SavePdfDocument(document, path, filename); // And open it FileOpener fileOpener = new FileOpener(); fileOpener.OpenFile(path, filename); SerializeSettings(directoryProvider, filenameGenerator, fileSaver); }
private Settings DeserializeSettings() { try { LocalizedNames localizedNames = new LocalizedNames(); DirectoryProvider directoryProvider = new DirectoryProvider(localizedNames); FilenameGenerator filenameGenerator = new FilenameGenerator(localizedNames, _dateTimeProvider); string applicationDirectory = directoryProvider.GetApplicationDirectoryPath(); string settingsFilename = filenameGenerator.GenerateJsonSettingsFilename(); FileReader fileReader = new FileReader(); string json = fileReader.ReadJsonFile(applicationDirectory, settingsFilename); SettingsSerializer serializer = new SettingsSerializer(); return(serializer.Deserialize(json)); } catch (Exception) { return(null); } }
public void Given_downloaded_directory() { var provider = new DirectoryProvider(); _resultModules = provider.ToList(); }
public InstallCommand(DirectoryProvider directoryProvider, ShellProcessFactory processFactory, PlatformInformationArbiter platformInformation) { _directoryProvider = directoryProvider; _processFactory = processFactory; _platformInformation = platformInformation; }
public SearchIndexEngine() { _directory = DirectoryProvider.CreateDocumentIndex(); _analyzer = new WhitespaceAnalyzer(AppLuceneVersion); }
public void Foo() { var filter = SearchFilter.Equality(DirectoryProperty.SamAccountName.ToString(), "16696763"); var provider = new DirectoryProvider(); var user = provider.FindOne(AdsPath.Parse("LDAP://DC=sigma,DC=sbrf,DC=ru"), filter); }
public IHttpActionResult GetDirectory(string path) { DirectoryProvider provider = new DirectoryProvider(); return(Ok(provider.GetDirectoryList(path))); }
public FileManagerController() { directoryProvider = new DirectoryProvider(); contentInitializer = new ContentInitializer(contentFolderRoot, foldersToCopy, prettyName); }
public ModulesController() { _provider = HomeApplication.Directory; }