예제 #1
0
    /// <inheritdoc />
    public override async IAsyncEnumerable <string> Execute(string expr, Session session)
    {
        Template temp = null;

        if (ParsingF.Token(ref expr, true, t => (temp = GetTemplate(t)) != null) == null)
        {
            throw new ArgumentException("找不到模板", nameof(expr));
        }

        var regex    = new Regex(@"^[A-Za-z]{3}$");
        var currency =
            Parsing.Token(ref expr, false, regex.IsMatch)?.ToUpperInvariant()
            ?? BaseCurrency.Now;

        DateFilter the;

        if (string.IsNullOrWhiteSpace(expr))
        {
            the = DateRange(temp.Day, session.Client.Today);
        }
        else
        {
            the = ParsingF.Range(ref expr, session.Client) ?? throw new ArgumentException("语法错误", nameof(expr));
            ParsingF.Eof(expr);
        }

        yield return((await DoInquiry(the, temp, currency, session)).Item1);
    }
예제 #2
0
        /// <inheritdoc />
        public override IQueryResult Execute(string expr, IEntitiesSerializer serializer)
        {
            Template temp = null;

            if (ParsingF.Token(ref expr, true, t => (temp = GetTemplate(t)) != null) == null)
            {
                throw new ArgumentException("找不到模板", nameof(expr));
            }

            var regex    = new Regex(@"^[A-Za-z]{3}$");
            var currency =
                Parsing.Token(ref expr, false, regex.IsMatch)?.ToUpperInvariant()
                ?? BaseCurrency.Now;

            DateFilter the;

            if (string.IsNullOrWhiteSpace(expr))
            {
                the = DateRange(temp.Day);
            }
            else
            {
                the = ParsingF.Range(ref expr) ?? throw new ArgumentException("语法错误", nameof(expr));
                ParsingF.Eof(expr);
            }

            return(DoInquiry(the, temp, out _, currency, serializer));
        }