public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IEntryModel entryModel = pm.GetValue <IEntryModel>(EntryKey);

            if (entryModel == null)
            {
                return(ResultCommand.Error(new ArgumentException(EntryKey + " is not found or not IEntryModel")));
            }

            IDiskProfile profile = entryModel.Profile as IDiskProfile;

            if (profile == null)
            {
                return(ResultCommand.Error(new NotSupportedException(EntryKey + "'s Profile is not IDiskProfile")));
            }

            using (var stream = await profile.DiskIO.OpenStreamAsync(entryModel, Access, pm.CancellationToken))
            {
                ParameterDic pmClone = pm.Clone();
                pmClone.SetValue(StreamKey, stream);
                logger.Debug(String.Format("{0} = Stream of {1}", StreamKey, EntryKey));
                await ScriptRunner.RunScriptAsync(pmClone, NextCommand);
            }

            if (Access == FileAccess.ReadWrite || Access == FileAccess.Write)
            {
                return(CoreScriptCommands.NotifyEntryChangedProfile(ChangeType.Changed, null, EntryKey, ThenCommand));
            }
            else
            {
                return(ThenCommand);
            }
        }
Exemple #2
0
        public static IScriptCommand DiskDelete(string entryKey, bool notifyChange,
                                                IScriptCommand nextCommand = null)
        {
            if (notifyChange)
            {
                nextCommand = CoreScriptCommands.NotifyEntryChangedProfile(ChangeType.Deleted, null, entryKey, nextCommand);
            }

            return(new DiskDelete()
            {
                EntryKey = entryKey,
                NextCommand = (ScriptCommandBase)nextCommand
            });
        }