public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm) { try { var srcProfile = _srcModel.Profile as IDiskProfile; var destProfile = _destDirModel.Profile as IDiskProfile; var progress = pm.ContainsKey("Progress") ? pm["Progress"] as IProgress <TransferProgress> : NullTransferProgress.Instance; var destMapping = (_destDirModel.Profile as IDiskProfile).DiskIO.Mapper[_destDirModel]; var srcMapping = (_srcModel.Profile as IDiskProfile).DiskIO.Mapper[_srcModel]; string destName = PathFE.GetFileName(srcMapping.IOPath); string destFullName = destProfile.Path.Combine(_destDirModel.FullPath, destName); //PathFE.Combine(destMapping.IOPath, destName); if (_srcModel.IsDirectory) { Func <IEntryModel, bool> filter = em => !em.IsDirectory || (em is SzsRootModel); Func <IEntryModel, bool> lookupFilter = em => em.IsDirectory && !(em is SzsRootModel); return(WPFScriptCommands.List(_srcModel, filter, lookupFilter, true, ems => new SimpleScriptCommandAsync("BatchTransfer", pd => transferAsync(pm, ems, progress, new NotifyChangedCommand(_destDirModel.Profile, destFullName, _srcModel.Profile, _srcModel.FullPath, Defines.ChangeType.Changed))))); } else { return(IOScriptCommands.DiskTransfer(_srcModel, _destDirModel, _removeOriginal)); } return(ResultCommand.NoError); } catch (Exception ex) { return(ResultCommand.Error(ex)); } }
public static IScriptCommand TransferChild(IEntryModel srcModel, IEntryModel destDirModel, Func <IEntryModel, bool> filterFunc = null, bool recrusive = false, IScriptCommand nextCommand = null) { return(WPFScriptCommands.List(srcModel, filterFunc, null, recrusive, ems => WPFScriptCommands.ReportProgress(TransferProgress.IncrementTotalEntries(ems.Length), ScriptCommands.ForEach(ems, em => ScriptCommands.RunInSequence( IOScriptCommands.Transfer(em, destDirModel), WPFScriptCommands.ReportProgress(TransferProgress.IncrementProcessedEntries())), nextCommand)))); }
public static IScriptCommand ParseOrCreateArchive(IDiskProfile profile, string path, Func <IEntryModel, IScriptCommand> thenFunc) { string type = profile.Path.GetExtension(path).ToLower(); byte[] bytes = SevenZipWrapper.GetArchiveBytes(type); if (bytes == null) { return(ResultCommand.Error(new ArgumentException(type + " is not recognized type."))); } return(WPFScriptCommands.ParseOrCreatePath(profile, path, false, em => WPFScriptCommands.WriteBytes(em, bytes, thenFunc))); }
public static IScriptCommand CreateArchive(IEntryModel entryModel, string name, bool renameIfExists, Func <IEntryModel, IScriptCommand> thenFunc) { string type = entryModel.Profile.Path.GetExtension(name).ToLower(); byte[] bytes = SevenZipWrapper.GetArchiveBytes(type); if (bytes == null) { return(ResultCommand.Error(new ArgumentException(type + " is not recognized type."))); } return(WPFScriptCommands.CreatePath(entryModel, name, false, renameIfExists, em => WPFScriptCommands.WriteBytes(em, bytes, thenFunc))); }
public static IScriptCommand ParseOrCreatePath(IDiskProfile profile, string path, bool isFolder, Func <IEntryModel, IScriptCommand> thenFunc) { return(WPFScriptCommands.ParsePath(new[] { profile }, path, thenFunc, WPFScriptCommands.CreatePath(profile, path, isFolder, false, thenFunc))); }