/// <summary> /// Install Checked Entries. /// </summary> /// <param name="vm">The vm<see cref="ZipArchiveViewModel"/>.</param> /// <param name="path">The path<see cref="string"/>.</param> /// <param name="overwrite">The overwrite<see cref="bool"/>.</param> /// <returns>The <see cref="IEnumerable{string}"/>.</returns> public static IEnumerable <string> InstallCheckedEntries(this ZipArchiveViewModel vm, string path, bool overwrite = false) { if (vm.SelectedDirectory is ZipArchiveEntryViewModel zvm) { foreach (var item in zvm.InstallCheckedEntries(path, overwrite)) { yield return(item); } yield break; } if (overwrite == false) { Debug.Assert(vm.AreAnyCheckedEntriesInstalled(path) == false); } var installedFolders = new List <Tuple <int, string, DateTime> >(); foreach (var entry in vm.SortedEntries.Values.Where(e => e.WillInstall)) { var zentry = entry as ZipArchiveEntryViewModel; zentry.InstallEntry(path, overwrite); if (zentry.IsDirectory) { yield return(entry.Name); var newpath = Path.Combine(path, entry.Name); zentry.InstallEntries(newpath, overwrite); } } }
/// <summary> /// Initializes a new instance of the <see cref="ZipArchiveWindow"/> class. /// </summary> /// <param name="zfr">The zfr<see cref="Core.ViewModels.ZipFileViewModel"/>.</param> public ZipArchiveWindow(Core.ViewModels.ZipFileViewModel zfr) { InitializeComponent(); WpfHelper.PositionChildWindow(this); IArchiveViewModel archive; if (zfr.Filename.ToLower().EndsWith(".7z")) { archive = new SevenZipArchiveViewModel(zfr.Filename, zfr.FilePath, zfr.PackageId); } else { archive = new ZipArchiveViewModel(zfr.Filename, zfr.FilePath, zfr.PackageId); } view.DataContext = archive; }
// POST api/values public IHttpActionResult Post([FromBody] ZipArchiveViewModel zipvm) { try { string retVal = ""; SecurityManager secMgr = new SecurityManager(); string decText = secMgr.Decrypt(zipvm.ArchiveHirachy); ZipArchive z = new ZipArchive() { ArchiveHirachy = decText, ArchiveName = zipvm.ArchiveName, SavedFileName = zipvm.SavedFileName, SavedDateTime = DateTime.Now }; ZipArchiveManager mgr = new ZipArchiveManager(); bool res = mgr.SaveZipArchive(z); if (res) { retVal = "Successfully Uploaded."; return(Ok <string>(retVal)); } else { retVal = "File Upload Failed."; return(BadRequest(retVal)); } } catch (Exception ex) { log.Error(ex.Message, ex); return(BadRequest(ex.Message)); } }