コード例 #1
0
        public void Run(CancellationToken token)
        {
            Dir = string.IsNullOrEmpty(Dir)
                ? baseDir
                : FilePath.FilePath.Expand(Dir);

            if (!Directory.Exists(Dir))
            {
                throw new DirectoryNotFoundException(Dir);
            }

            var dbs = Directory.GetFiles(Dir, "*.sqlite");

            if (!dbs.Any())
            {
                throw new AriesException($"{Dir}以下にDbがありませんでした。");
            }
            foreach (var db in dbs)
            {
                token.ThrowIfCancellationRequested();

                var repo = new ReadOnlyRepository(Path.Combine(baseDir, db));
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"Path: {db}");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(repo.GetParameter());

                Console.WriteLine("---------------------------------------------------------------------");
            }
        }
コード例 #2
0
ファイル: Libra.cs プロジェクト: xztaityozx/ptolemy
        /// <summary>
        /// requestに従って数え上げる
        /// </summary>
        /// <returns>Expression,結果のペアリスト</returns>
        public Tuple <string, long>[] Run(LibraRequest request)
        {
            try {
                var delegates = request.BuildFilter();
                var signals   = request.SignalList;

                if (!signals.Any())
                {
                    throw new LibraException("Conditions have no signals");
                }

                var db = new ReadOnlyRepository(request.SqliteFile);
                log.Info("----Parameter Info----");
                Console.WriteLine(db.GetParameter());
                log.Info("----------------------");

                using var bar = new ProgressBar(
                          (int)(request.IsSplitWithSeed ? (request.SeedEnd - request.SeedStart + 1) : request.Sweeps.Times),
                          "Ptolemy.Libra", new ProgressBarOptions {
                    ForegroundColor     = ConsoleColor.DarkYellow, BackgroundCharacter = '-',
                    ProgressCharacter   = '>', CollapseWhenFinished = true, BackgroundColor = ConsoleColor.Gray,
                    ForegroundColorDone = ConsoleColor.Green
                });
                db.IntervalEvent += () => bar.Tick();


                var result = request.IsSplitWithSeed switch {
                    true => db.Aggregate(token, signals, delegates,
                                         Range(request.SeedStart, request.SeedEnd).ToList(),
                                         request.Sweeps.Size,
                                         request.Sweeps.Start,
                                         LibraRequest.GetKey),
                    false => db.Aggregate(token, signals,
                                          delegates,
                                          request.SeedStart,
                                          request.Sweeps.Section().ToList(),
                                          LibraRequest.GetKey)
                };

                return(request.ExpressionNameList.Zip(result, Tuple.Create).ToArray());
            }
            catch (LibraException) {
                throw;
            }
            catch (Exception e) {
                throw new LibraException($"Unknown error has occured\n\t-->{e}");
            }
        }