• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

b1f6c1c4 / ProfessionalAccounting / 297

19 Feb 2023 04:15AM UTC coverage: 36.498% (+0.5%) from 35.998%
297

push

appveyor

b1f6c1c4
fix coupling bug

9985 of 27358 relevant lines covered (36.5%)

716.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.17
/AccountingServer.BLL/Parsing/QueryParser.Proxy.Distributed.cs
1
/* Copyright (C) 2020-2023 b1f6c1c4
2
 *
3
 * This file is part of ProfessionalAccounting.
4
 *
5
 * ProfessionalAccounting is free software: you can redistribute it and/or
6
 * modify it under the terms of the GNU Affero General Public License as
7
 * published by the Free Software Foundation, version 3.
8
 *
9
 * ProfessionalAccounting is distributed in the hope that it will be useful, but
10
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License
12
 * for more details.
13
 *
14
 * You should have received a copy of the GNU Affero General Public License
15
 * along with ProfessionalAccounting.  If not, see
16
 * <https://www.gnu.org/licenses/>.
17
 */
18

19
using System;
20
using System.Collections.Generic;
21
using System.Diagnostics.CodeAnalysis;
22
using AccountingServer.BLL.Util;
23
using AccountingServer.Entities;
24

25
namespace AccountingServer.BLL.Parsing;
26

27
internal partial class QueryParser
28
{
29
    public partial class DistributedQAtomContext : IClientDependable, IDistributedQueryAtom
30
    {
31
        public Client Client { private get; set; }
32

33
        /// <inheritdoc />
34
        public IDistributed Filter
35
            => new MyDistributedFilter
293✔
36
                {
37
                    ID = Guid() != null ? System.Guid.Parse(Guid().GetText()) : null,
38
                    User = (UserSpec()?.GetText()).ParseUserSpec(Client ?? new()), // workaround IsDangerous
39
                    Name = RegexString()?.GetText().Dequotation().Replace(@"\/", "/"),
40
                    Remark = PercentQuotedString()?.GetText().Dequotation(),
41
                };
42

43
        /// <inheritdoc />
44
        public DateFilter Range
45
            => rangeCore().Assign(Client)?.Range ?? DateFilter.Unconstrained;
50✔
46

47
        /// <inheritdoc />
48
        public T Accept<T>(IQueryVisitor<IDistributedQueryAtom, T> visitor) => visitor.Visit(this);
61✔
49

50
        /// <summary>
51
        ///     分期过滤器
52
        /// </summary>
53
        [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local")]
54
        private sealed class MyDistributedFilter : IDistributed
55
        {
56
            /// <inheritdoc />
57
            public Guid? ID { get; init; }
58

59
            /// <inheritdoc />
60
            public string User { get; init; }
61

62
            /// <inheritdoc />
63
            public string Name { get; init; }
64

65
            /// <inheritdoc />
66
            public DateTime? Date { get; set; }
67

68
            /// <inheritdoc />
69
            public double? Value { get; set; }
70

71
            /// <inheritdoc />
72
            public string Remark { get; init; }
73

74
            /// <inheritdoc />
75
            public IEnumerable<IDistributedItem> TheSchedule { get; set; }
76
        }
77
    }
78

79
    public partial class DistributedQContext : IClientDependable, IQueryAry<IDistributedQueryAtom>
80
    {
81
        public Client Client { private get; set; }
82

83
        /// <inheritdoc />
84
        public OperatorType Operator
85
            => Op switch
×
86
                {
87
                    null => OperatorType.None,
78✔
88
                    { Text: var x } when distributedQ() == null => x switch
×
89
                        {
90
                            "+" => OperatorType.Identity,
2✔
91
                            "-" => OperatorType.Complement,
2✔
92
                            _ => throw new MemberAccessException("表达式错误"),
×
93
                        },
94
                    { Text: var x } => x switch
12✔
95
                        {
96
                            "+" => OperatorType.Union,
8✔
97
                            "-" => OperatorType.Subtract,
4✔
98
                            _ => throw new MemberAccessException("表达式错误"),
×
99
                        },
100
                };
101

102
        /// <inheritdoc />
103
        public IQueryCompounded<IDistributedQueryAtom> Filter1
104
            => (IQueryCompounded<IDistributedQueryAtom>)distributedQ().Assign(Client) ?? distributedQ1().Assign(Client);
92✔
105

106
        /// <inheritdoc />
107
        public IQueryCompounded<IDistributedQueryAtom> Filter2
108
            => distributedQ1().Assign(Client);
6✔
109

110
        /// <inheritdoc />
111
        public T Accept<T>(IQueryVisitor<IDistributedQueryAtom, T> visitor) => visitor.Visit(this);
94✔
112
    }
113

114
    public partial class DistributedQ1Context : IClientDependable, IQueryAry<IDistributedQueryAtom>
115
    {
116
        public Client Client { private get; set; }
117

118
        /// <inheritdoc />
119
        public OperatorType Operator => Op == null ? OperatorType.None : OperatorType.Intersect;
88✔
120

121
        /// <inheritdoc />
122
        public IQueryCompounded<IDistributedQueryAtom> Filter1
123
            => distributedQ0().Assign(Client);
88✔
124

125
        /// <inheritdoc />
126
        public IQueryCompounded<IDistributedQueryAtom> Filter2
127
            => distributedQ1().Assign(Client);
2✔
128

129
        /// <inheritdoc />
130
        public T Accept<T>(IQueryVisitor<IDistributedQueryAtom, T> visitor) => visitor.Visit(this);
88✔
131
    }
132

133
    public partial class DistributedQ0Context : IClientDependable, IQueryAry<IDistributedQueryAtom>
134
    {
135
        public Client Client { private get; set; }
136

137
        /// <inheritdoc />
138
        public OperatorType Operator => OperatorType.None;
88✔
139

140
        /// <inheritdoc />
141
        public IQueryCompounded<IDistributedQueryAtom> Filter1
142
            => (IQueryCompounded<IDistributedQueryAtom>)distributedQAtom().Assign(Client) ??
88✔
143
                distributedQ().Assign(Client);
144

145
        /// <inheritdoc />
146
        public IQueryCompounded<IDistributedQueryAtom> Filter2 => null;
×
147

148
        /// <inheritdoc />
149
        public T Accept<T>(IQueryVisitor<IDistributedQueryAtom, T> visitor) => visitor.Visit(this);
88✔
150
    }
151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc