Example #1
0
        /// <summary>
        /// Creates a zip archive from one file
        /// </summary>
        /// <param name="C">The context</param>
        /// <param name="Flow">The source/target</param>
        public static Option <Link <FilePath> > ZipFile(this IApplicationContext C, Link <FilePath> Flow)
        {
            var cmd    = CreateFileArchive.DefineZipFileCommand(Flow.Source, Flow.Target);
            var result = C.CPS().ExecuteCommand(cmd);

            return(result.IsSome
                ? some(Flow)
                : none <Link <FilePath> >(result.Message));
        }
Example #2
0
        /// <summary>
        /// Creates a zip archive from one file
        /// </summary>
        /// <param name="C">The context</param>
        /// <param name="SrcFile">Path to the file that will be archived</param>
        /// <param name="DstFile">Path to which the archive will be written</param>
        public static Option <Link <FilePath> > ZipFile(this IApplicationContext C, FilePath SrcFile, FilePath DstFile)
        {
            var cmd    = CreateFileArchive.DefineZipFileCommand(SrcFile, DstFile);
            var result = C.CPS().ExecuteCommand(cmd);

            return(result.IsSome
                ? some(new Link <FilePath>(SrcFile, DstFile))
                : none <Link <FilePath> >(result.Message));
        }
Example #3
0
        /// <summary>
        /// Creates a zip archive from the contents of a Folder
        /// </summary>
        /// <param name="C">The context</param>
        /// <param name="SrcFolder">Path to the folder that will be archived</param>
        /// <param name="DstFile">Path to which the archive will be written</param>
        public static Option <FilePath> ZipDir(this IApplicationContext C,
                                               FolderPath SrcFolder, FilePath DstFile)
        {
            var command = CreateFileArchive.DefineZipDirCommand(SrcFolder, DstFile);
            var result  = C.CPS().Execute(command);

            return(result.IsNone()
                ? result.ToNone <FilePath>()
                : new Option <FilePath>(DstFile, ArchivedFolder(SrcFolder, DstFile)));
        }
Example #4
0
    public static IEnumerable <CommandResult <TSpec, TPayload> > ExecuteQueue <TSpec, TPayload>(this IApplicationContext C, int MaxCount = 3, bool Concurrent = false)
        where TSpec : CommandSpec <TSpec, TPayload>, new()
    {
        var executionService = C.CPS().Pattern <TSpec, TPayload>().Require();
        var dispatches       = executionService.Queue.Dispatch(MaxCount);

        while (dispatches.Count != 0)
        {
            var results    = executionService.Executor.Execute(dispatches, Concurrent);
            var completion = C.CPS().ExecStore.Complete(results).OnNone(message => C.Notify(message));
            if (completion)
            {
                foreach (var result in results)
                {
                    yield return(result);
                }
            }
            dispatches = executionService.Queue.Dispatch(MaxCount);
        }
    }
Example #5
0
 public static Option <ReadOnlyList <CommandSubmission <TSpec> > > Enqueue <TSpec, TPayload>(this IApplicationContext C, IEnumerable <TSpec> specs, SystemNode target)
     where TSpec : CommandSpec <TSpec, TPayload>, new()
 => from p in C.CPS().Pattern <TSpec, TPayload>()
 from q in p.Queue.Enqueue(specs, target)
 select q;
Example #6
0
 /// <summary>
 /// Obtains fully-typed command processor
 /// </summary>
 /// <typeparam name="TSpec"></typeparam>
 /// <typeparam name="TPayload"></typeparam>
 /// <param name="C"></param>
 /// <param name="batchSize"></param>
 /// <param name="concurrent"></param>
 /// <returns></returns>
 public static ICommandProcessor <TSpec, TPayload> CommandProcessor <TSpec, TPayload>(this IApplicationContext C, int?batchSize = null, bool?concurrent = null)
     where TSpec : CommandSpec <TSpec, TPayload>, new()
 => new global::CommandProcessor <TSpec, TPayload>(C.CPS(), batchSize, concurrent);
Example #7
0
 /// <summary>
 /// Obtains weakly-typed command processor
 /// </summary>
 /// <param name="C"></param>
 /// <param name="batchSize"></param>
 /// <param name="concurrent"></param>
 /// <returns></returns>
 public static ICommandProcessor CommandProcessor(this IApplicationContext C, int?batchSize = null, bool?concurrent = null)
 => new global::CommandProcessor(C.CPS(), batchSize, concurrent);
Example #8
0
 /// <summary>
 /// Creates a zip archive for each file in a folder
 /// </summary>
 /// <param name="C">The context</param>
 /// <param name="SrcFolder">The folder that contains the files to be archived</param>
 /// <param name="DstFolder">The folder that will receive the archived files</param>
 /// <param name="PLL">Whether operations should be executed concurently</param>
 public static void ZipDirFiles(this IApplicationContext C,
                                FolderPath SrcFolder, FolderPath DstFolder, bool PLL = true)
 => iter(SrcFolder.CreateFileArchiveCommands(DstFolder),
         command => C.Notify(C.CPS().ExecuteCommand(command).Message), PLL);