public async Task <IActionResult> Delete([FromQuery] List <Guid> id) { if (id == null) { return(BadRequest("id == null")); } List <Guid> delId = new List <Guid>(); foreach (Guid i in id) { SubDirectory f = await _context.SubDirectories.FirstOrDefaultAsync(l => l.Id == i); if (f != null) { delId.Add(f.Id); _context.SubDirectories.Remove(f); var pathDir = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", f.Id.ToString()); if (Directory.Exists(pathDir)) { Directory.Delete(pathDir, true); } } } await _context.SaveChangesAsync(); return(Ok(delId)); }
/// <summary> /// Reset the contents of the directory and allow them to be fetched again /// </summary> public void ResetCachedInfo() { Info = new DirectoryInfo(Info.FullName); Dictionary <string, DirectoryItem> PrevDirectories = Directories; if (PrevDirectories != null) { foreach (DirectoryItem SubDirectory in PrevDirectories.Values) { SubDirectory.ResetCachedInfo(); } Directories = null; } Dictionary <string, FileItem> PrevFiles = Files; if (PrevFiles != null) { foreach (FileItem File in PrevFiles.Values) { File.ResetCachedInfo(); } Files = null; } }
public ActionResult EditDirectory(int id) { SubDirectory subdirectory = db.SubDirectories.Find(id); ViewBag.Number = new SelectList(subdirectory.TopDirectory.SubDirectories.OrderBy(a => a.Number).ToList(), "Number", "Name", subdirectory.Number); return(View(subdirectory)); }
public ActionResult EditDirectory(SubDirectory subdirectory) { var topDir = db.SubDirectories.Find(subdirectory.SubDirectoryId); if (subdirectory.Number == 0 || ModelState.IsValid) { var d = db.SubDirectories.Find(subdirectory.Id); if (subdirectory.Number != d.Number) { foreach (var dir in topDir.SubDirectories) { if (dir.Number > subdirectory.Number) { dir.Number++; } } subdirectory.Number++; } subdirectory.LastUpdate = DateTime.Now; db.Entry(d).CurrentValues.SetValues(subdirectory); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Number = new SelectList(topDir.SubDirectories.OrderBy(a => a.Number).ToList(), "Number", "Name", subdirectory.Number); return(View(subdirectory)); }
public IActionResult SubDirectory(int id) { var categories = _context.SuperCategoryMappingCategories .Where(x => x.SuperCategoryId == id) .Include(x => x.Category) .ToList(); var subDirectories = new List <SubDirectory>(); foreach (var category in categories) { var subCategories = _context.SubCategories.Where(x => x.CategoryId == category.CategoryId).ToList(); SubDirectory subDirectory = new SubDirectory { Id = category.CategoryId, Name = category.Category.Name, Items = subCategories.Select(x => new Item { Id = x.Id, Name = x.Name }).ToList() }; subDirectories.Add(subDirectory); } return(PartialView("SubDirectory", subDirectories)); }
private void ButtonUp_Click(object sender, RoutedEventArgs e) { Button cmd = sender as Button; if (cmd.Tag.ToString() == "Directory") { if (cmd.DataContext is SubDirectory) { SubDirectory moveUp = (SubDirectory)cmd.DataContext; int i = currentScript.SubDirectories.IndexOf(moveUp); if (i > 0) { currentScript.SubDirectories.Move(i, i - 1); } } } else if (cmd.Tag.ToString() == "Prompt") { Prompt moveUp = (Prompt)cmd.DataContext; int i = currentScript.Prompts.IndexOf(moveUp); if (i > 0) { currentScript.Prompts.Move(i, i - 1); } } }
public SubDirectory AddSubDirectory(Site site, string subDirectoryName) { var subDirectory = _subDirectoryRepository.GetAll().FirstOrDefault(x => x.Name == subDirectoryName && x.SiteId == site.Id); if (subDirectory == null) { // Then we need to add (first time been) subDirectory = new SubDirectory() { SiteId = site.Id, Name = subDirectoryName, Timestamp = DateTime.Now }; _subDirectoryRepository.Add(subDirectory); // Return if saved if (Convert.ToBoolean(_subDirectoryRepository.Save())) { return(subDirectory); } // Didnt save, return null return(null); } // Return existing return(subDirectory); }
public async Task <IActionResult> PostSubDirectory([FromBody] SubDirectoryViewModel model) { SubDirectory k = await _context.SubDirectories .FirstOrDefaultAsync(l => l.Name == model.Name && l.DirectoryInformationId == model.DirectoryId); if (k != null) { return(BadRequest("Папка з такою назвою уже існує")); } SubDirectory directory = new SubDirectory() { Name = model.Name, DirectoryInformationId = model.DirectoryId }; var d = _context.SubDirectories.Add(directory); await _context.SaveChangesAsync(); var pathDir = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", d.Entity.Id.ToString()); if (!Directory.Exists(pathDir)) { Directory.CreateDirectory(pathDir); } return(Ok(d.Entity)); }
static void CleanImagesRecursiveDirectory(string SourcePath) { //Recurse sub directories foreach (string SubDirectory in Directory.GetDirectories(SourcePath)) { String SubDirectoryUpper = SubDirectory.ToUpper(); //Exclude archive,css, defaultwebtemplate and image folders from processing if (!(SubDirectoryUpper.EndsWith("\\INCLUDE") || SubDirectoryUpper.EndsWith("\\JAVASCRIPT") || SubDirectoryUpper.EndsWith("\\IMAGES") || SubDirectoryUpper.EndsWith("\\ATTACHMENTS") || SubDirectoryUpper.EndsWith("\\CSS") || SubDirectoryUpper.EndsWith("\\TEMPLATES"))) { CleanImagesRecursiveDirectory(SubDirectory); } else if (SubDirectoryUpper.EndsWith("\\IMAGES")) { //Image folder check for child directories foreach (string LanguageImageFolder in Directory.GetDirectories(SubDirectory)) { //For each file check bytes against parent directories files. foreach (string LangImageFileName in Directory.GetFiles(LanguageImageFolder)) { string INTFileName = Path.Combine(SubDirectory, Path.GetFileName(LangImageFileName)); if (File.Exists(INTFileName) && CommonUnrealFunctions.ByteEquals(File.ReadAllBytes(LangImageFileName), File.ReadAllBytes(INTFileName))) { log.Info(Language.Message("DeletingDuplicatedImage", LangImageFileName)); CommonUnrealFunctions.SetFileAttributeForReplace(new FileInfo(LangImageFileName)); File.Delete(LangImageFileName); } } } } } }
private void ButtonMinus_Click(object sender, RoutedEventArgs e) { Button cmd = sender as Button; if (cmd.Tag.ToString() == "Directory") { if (currentScript.SubDirectories.Count() > 0) { currentScript.SubDirectories.RemoveAt(currentScript.SubDirectories.Count() - 1); if (cmd.DataContext is SubDirectory) { SubDirectory deleteme = (SubDirectory)cmd.DataContext; currentScript.SubDirectories.Remove(deleteme); } } } else if (cmd.Tag.ToString() == "Prompt") { if (currentScript.Prompts.Count() > 0) { currentScript.Prompts.RemoveAt(currentScript.Prompts.Count() - 1); if (cmd.DataContext is SubDirectory) { Prompt deleteme = (Prompt)cmd.DataContext; currentScript.Prompts.Remove(deleteme); } } } }
public IActionResult SuperCategoyList(int id, string supercategoryname) { var categories = _context.SuperCategoryMappingCategories .Where(x => x.SuperCategoryId == id) .Include(x => x.Category) .ToList(); var subDirectories = new List <SubDirectory>(); foreach (var category in categories) { var subCategories = _context.SubCategories.Where(x => x.CategoryId == category.CategoryId).ToList(); SubDirectory subDirectory = new SubDirectory { Id = category.CategoryId, Name = category.Category.Name, Items = subCategories.Select(x => new Item { Id = x.Id, Name = x.Name }).ToList() }; subDirectories.Add(subDirectory); } ViewBag.Supercategory = supercategoryname; ViewBag.SupercategoryId = id; return(View(subDirectories)); }
private void ButtonMore_Click(object sender, RoutedEventArgs e) { Button cmd = (Button)sender; if (cmd.Tag.ToString() == "Directory") { if (cmd.DataContext is SubDirectory) { SubDirectory currentSubDirectory = (SubDirectory)cmd.DataContext; SubSubDirectories popUp = new SubSubDirectories(currentSubDirectory); //popUp.Owner = this.Parent; //popUp.WindowStartupLocation = WindowStartupLocation.CenterOwner; popUp.ShowDialog(); } } else if (cmd.Tag.ToString() == "Prompt") { if (cmd.DataContext is Prompt) { Prompt currentPrompt = (Prompt)cmd.DataContext; PromptSettings popUp = new PromptSettings(currentPrompt); //popUp.Owner = this.Parent; //popUp.WindowStartupLocation = WindowStartupLocation.CenterOwner; popUp.ShowDialog(); } } }
private void ButtonDown_Click(object sender, RoutedEventArgs e) { Button cmd = sender as Button; if (cmd.Tag.ToString() == "Directory") { if (cmd.DataContext is SubDirectory) { SubDirectory moveDown = (SubDirectory)cmd.DataContext; int i = currentScript.SubDirectories.IndexOf(moveDown); if (i < currentScript.SubDirectories.Count() && currentScript.SubDirectories.Count() != 0) { currentScript.SubDirectories.Move(i, i + 1); } } } else if (cmd.Tag.ToString() == "Prompt") { if (cmd.DataContext is Prompt) { Prompt moveDown = (Prompt)cmd.DataContext; int i = currentScript.Prompts.IndexOf(moveDown); if (i < currentScript.Prompts.Count() && currentScript.Prompts.Count() != 0) { currentScript.Prompts.Move(i, i + 1); } } } }
/// <summary> /// Append the contents of this directory and subdirectories to a list /// </summary> /// <param name="Files">List to append to</param> public void AppendFiles(List <StreamFileInfo> Files) { foreach (StreamDirectoryInfo SubDirectory in NameToSubDirectory.Values) { SubDirectory.AppendFiles(Files); } Files.AddRange(NameToFile.Values); }
public ActionResult DeleteDirectoryConfirmed(int id) { SubDirectory subdirectory = db.SubDirectories.Find(id); db.SubDirectories.Remove(subdirectory); db.SaveChanges(); return(RedirectToAction("Index")); }
private void ButtonPlus_Click(object sender, RoutedEventArgs e) { ObservableCollection <SubDirectory> SampleSub = new ObservableCollection <SubDirectory>(); SampleSub.Add(new SubDirectory("Directory 1", 1, null, "Change Text Here")); SampleSub.Add(new SubDirectory("Directory 1", 1, null, "Change Text Here")); SubDirectory newSubDirectory = new SubDirectory("Change Text Here", (currentSetting.SubDirectories.Count()) % 2, SampleSub, null); currentSetting.SubDirectories.Add(newSubDirectory); }
/// <summary> /// Copies a directory to another location /// </summary> /// <param name="Source">Source directory</param> /// <param name="Destination">Destination directory</param> /// <param name="Recursive">Should the copy be recursive</param> /// <param name="Options">Options used in copying</param> /// <returns>The DirectoryInfo for the destination info</returns> public static DirectoryInfo CopyTo(this DirectoryInfo Source, string Destination, bool Recursive = true, CopyOptions Options = CopyOptions.CopyAlways) { if (Source == null) { throw new ArgumentNullException("Source"); } if (!Source.Exists) { throw new DirectoryNotFoundException("Source directory " + Source.FullName + " not found."); } if (string.IsNullOrEmpty(Destination)) { throw new ArgumentNullException("Destination"); } DirectoryInfo DestinationInfo = new DirectoryInfo(Destination); DestinationInfo.Create(); foreach (FileInfo TempFile in Source.EnumerateFiles()) { if (Options == CopyOptions.CopyAlways) { TempFile.CopyTo(Path.Combine(DestinationInfo.FullName, TempFile.Name), true); } else if (Options == CopyOptions.CopyIfNewer) { if (File.Exists(Path.Combine(DestinationInfo.FullName, TempFile.Name))) { FileInfo FileInfo = new FileInfo(Path.Combine(DestinationInfo.FullName, TempFile.Name)); if (FileInfo.LastWriteTime.CompareTo(TempFile.LastWriteTime) < 0) { TempFile.CopyTo(Path.Combine(DestinationInfo.FullName, TempFile.Name), true); } } else { TempFile.CopyTo(Path.Combine(DestinationInfo.FullName, TempFile.Name), true); } } else if (Options == CopyOptions.DoNotOverwrite) { TempFile.CopyTo(Path.Combine(DestinationInfo.FullName, TempFile.Name), false); } } if (Recursive) { foreach (DirectoryInfo SubDirectory in Source.EnumerateDirectories()) { SubDirectory.CopyTo(Path.Combine(DestinationInfo.FullName, SubDirectory.Name), Recursive, Options); } } return(new DirectoryInfo(Destination)); }
private void ButtonMore_Click(object sender, RoutedEventArgs e) { Button cmd = (Button)sender; if (cmd.DataContext is SubDirectory) { SubDirectory currentSubDirectory = (SubDirectory)cmd.DataContext; SubSubDirectories popUp = new SubSubDirectories(currentSubDirectory); //popUp.Owner = this.Parent; //popUp.WindowStartupLocation = WindowStartupLocation.CenterOwner; popUp.ShowDialog(); } }
private void ButtonMinus_Click(object sender, RoutedEventArgs e) { if (currentSetting.SubDirectories.Count() > 0) { currentSetting.SubDirectories.RemoveAt(currentSetting.SubDirectories.Count() - 1); Button cmd = (Button)sender; if (cmd.DataContext is SubDirectory) { SubDirectory deleteme = (SubDirectory)cmd.DataContext; currentSetting.SubDirectories.Remove(deleteme); } } }
private void ButtonDown_Click(object sender, RoutedEventArgs e) { Button cmd = (Button)sender; if (cmd.DataContext is SubDirectory) { SubDirectory moveDown = (SubDirectory)cmd.DataContext; int i = currentSetting.SubDirectories.IndexOf(moveDown); if (i < currentSetting.SubDirectories.Count() && currentSetting.SubDirectories.Count() != 0) { currentSetting.SubDirectories.Move(i, i + 1); } } }
private void ButtonUp_Click(object sender, RoutedEventArgs e) { Button cmd = (Button)sender; if (cmd.DataContext is SubDirectory) { SubDirectory moveUp = (SubDirectory)cmd.DataContext; int i = currentSetting.SubDirectories.IndexOf(moveUp); if (i > 0) { currentSetting.SubDirectories.Move(i, i - 1); } } }
/// <summary> /// Scans a plugin parent directory, adding tasks for subdirectories /// </summary> /// <param name="Directory">The directory which may contain plugin directories</param> static void ScanPluginFolder(DirectoryItem Directory) { foreach (DirectoryItem SubDirectory in Directory.EnumerateDirectories()) { if (SubDirectory.EnumerateFiles().Any(x => x.HasExtension(".uplugin"))) { Enqueue(() => ScanDirectoryTree(DirectoryItem.Combine(SubDirectory, "Source"))); } else { Enqueue(() => ScanPluginFolder(SubDirectory)); } } }
/// <summary> /// Copies the directory to the specified parent directory /// </summary> /// <param name="directory">Directory to copy to</param> /// <param name="options">Copy options</param> /// <returns></returns> public async Task <IDirectory> CopyToAsync(IDirectory directory, CopyOptions options = CopyOptions.CopyAlways) { if (InternalDirectory is null || directory is null || string.IsNullOrEmpty(directory.FullName)) { return(this); } directory.Create(); List <Task> Tasks = new List <Task>(); foreach (var TempFile in EnumerateFiles()) { switch (options) { case CopyOptions.CopyAlways: Tasks.Add(TempFile.CopyToAsync(directory, true)); break; case CopyOptions.CopyIfNewer: if (new FileInfo(directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), Credentials).Exists) { var FileInfo = new FileInfo(directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), Credentials); if (FileInfo.Modified.CompareTo(TempFile.Modified) < 0) { Tasks.Add(TempFile.CopyToAsync(directory, true)); } } else { Tasks.Add(TempFile.CopyToAsync(directory, true)); } break; case CopyOptions.DoNotOverwrite: Tasks.Add(TempFile.CopyToAsync(directory, true)); break; } } await Task.WhenAll(Tasks).ConfigureAwait(false); Tasks.Clear(); foreach (var SubDirectory in EnumerateDirectories()) { Tasks.Add(SubDirectory.CopyToAsync(new DirectoryInfo(directory.FullName + "\\" + SubDirectory.Name.Replace("/", "").Replace("\\", ""), Credentials), options)); } await Task.WhenAll(Tasks).ConfigureAwait(false); return(directory); }
public void Write(BinaryWriter Writer) { Writer.Write(NameToFile.Count); foreach (WorkspaceFileInfo File in NameToFile.Values) { File.Write(Writer); } Writer.Write(NameToSubDirectory.Count); foreach (WorkspaceDirectoryInfo SubDirectory in NameToSubDirectory.Values) { Writer.Write(SubDirectory.Name); SubDirectory.Write(Writer); } }
/// <summary> /// Writes the contents of this stream to disk /// </summary> /// <param name="Writer">Writer to serialize to</param> public void Write(BinaryWriter Writer) { Writer.Write(Name); Writer.Write(NameToFile.Count); foreach (StreamFileInfo File in NameToFile.Values) { File.Write(Writer); } Writer.Write(NameToSubDirectory.Count); foreach (StreamDirectoryInfo SubDirectory in NameToSubDirectory.Values) { SubDirectory.Write(Writer); } }
private void ButtonPlus_Click(object sender, RoutedEventArgs e) { Button cmd = sender as Button; if (cmd.Tag.ToString() == "Directory") { ObservableCollection <SubDirectory> SampleSub = new ObservableCollection <SubDirectory>(); SampleSub.Add(new SubDirectory("Directory 1", 1, null, "Change Text Here")); SampleSub.Add(new SubDirectory("Directory 1", 1, null, "Change Text Here")); SubDirectory newSubDirectory = new SubDirectory("Change Text Here", (currentScript.SubDirectories.Count()) % 2, SampleSub, null); currentScript.SubDirectories.Add(newSubDirectory); } else if (cmd.Tag.ToString() == "Prompt") { currentScript.Prompts.Add(new Prompt()); } }
public async Task <IActionResult> GetById(Guid?id) { if (id == null) { return(BadRequest("id == null")); } SubDirectory d = await _context.SubDirectories.Include(l => l.Files) .FirstOrDefaultAsync(l => l.Id == id); if (d == null) { return(NotFound()); } return(Ok(d)); }
public ActionResult CreateDirectory(int topDirId) { if (topDirId <= 1) { var root = db.SubDirectories.FirstOrDefault(); topDirId = root.Id; } var dir = new SubDirectory { SubDirectoryId = topDirId, LastUpdate = DateTime.Now, }; var topDir = db.SubDirectories.Find(topDirId); ViewBag.Number = new SelectList(topDir.SubDirectories.OrderBy(a => a.Number).ToList(), "Number", "Name"); return(View(dir)); }
/// <summary> /// Copies the directory to the specified parent directory /// </summary> /// <param name="directory">Directory to copy to</param> /// <param name="options">Copy options</param> /// <returns>Returns the new directory</returns> public virtual IDirectory CopyTo(IDirectory directory, CopyOptions options = CopyOptions.CopyAlways) { if (InternalDirectory is null || directory is null || string.IsNullOrEmpty(directory.FullName)) { return(this); } directory.Create(); foreach (var TempFile in EnumerateFiles()) { switch (options) { case CopyOptions.CopyAlways: TempFile.CopyTo(directory, true); break; case CopyOptions.CopyIfNewer: if (new FileInfo(directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), Credentials).Exists) { var FileInfo = new FileInfo(directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), Credentials); if (FileInfo.Modified.CompareTo(TempFile.Modified) < 0) { TempFile.CopyTo(directory, true); } } else { TempFile.CopyTo(directory, true); } break; case CopyOptions.DoNotOverwrite: TempFile.CopyTo(directory, false); break; } } foreach (var SubDirectory in EnumerateDirectories()) { SubDirectory.CopyTo(new DirectoryInfo(directory.FullName + "\\" + SubDirectory.Name.Replace("/", "").Replace("\\", ""), Credentials), options); } return(directory); }
/// <summary> /// Copies the directory to the specified parent directory /// </summary> /// <param name="Directory">Directory to copy to</param> /// <param name="Options">Copy options</param> /// <returns>Returns the new directory</returns> public virtual IDirectory CopyTo(IDirectory Directory, CopyOptions Options = CopyOptions.CopyAlways) { if (InternalDirectory == null || Directory == null) { return(this); } Directory.Create(); foreach (IFile TempFile in EnumerateFiles()) { switch (Options) { case CopyOptions.CopyAlways: TempFile.CopyTo(Directory, true); break; case CopyOptions.CopyIfNewer: if (new FileInfo(Directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), UserName, Password, Domain).Exists) { var FileInfo = new FileInfo(Directory.FullName + "\\" + TempFile.Name.Replace("/", "").Replace("\\", ""), UserName, Password, Domain); if (FileInfo.Modified.CompareTo(TempFile.Modified) < 0) { TempFile.CopyTo(Directory, true); } } else { TempFile.CopyTo(Directory, true); } break; case CopyOptions.DoNotOverwrite: TempFile.CopyTo(Directory, false); break; } } foreach (IDirectory SubDirectory in EnumerateDirectories()) { SubDirectory.CopyTo(new DirectoryInfo(Directory.FullName + "\\" + SubDirectory.Name.Replace("/", "").Replace("\\", ""), UserName, Password, Domain), Options); } return(Directory); }