SkippedNumbersReportQueries.xml
6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="utf-8"?>
<queries>
<query key="Documents">
<mssql><![CDATA[SELECT
documents.RegistrationDate,
documents.RegistrationNumber,
case when documents.NumberOnFormat is null then 1 else documents.NumberOnFormat end NumberOnFormat,
case when documents.CanRead is null then 1 else documents.CanRead end CanRead,
case when documents.InCorrectOrder is null then 1 else documents.InCorrectOrder end InCorrectOrder,
documents.RegistrationState,
documents.DocumentRegister,
documents.DocumentId,
documents.DocumentName,
documents.Note as Note,
documents.HyperLink,
documents.OrdinalNumber,
documents.SortOrder
FROM
(
SELECT
doc.RegDate_Docflow_Sungero AS RegistrationDate,
doc.RegNumber_Docflow_Sungero AS RegistrationNumber,
availableDocs.NumberOnFormat AS NumberOnFormat,
availableDocs.CanRead AS CanRead,
availableDocs.InCorrectOrder AS InCorrectOrder,
doc.Note_Docflow_Sungero AS Note,
doc.RegState_Docflow_Sungero AS RegistrationState,
doc.DocRegister_Docflow_Sungero AS DocumentRegister,
doc.Id as DocumentId,
doc.Name as DocumentName,
REPLACE(REPLACE(@hyperlinkMask,'DocGUID',doc.Discriminator),'DocId', doc.Id) as HyperLink,
CONVERT(varchar(max), doc.Index_Docflow_Sungero) AS OrdinalNumber,
doc.Index_Docflow_Sungero as SortOrder
FROM
Sungero_Content_EDoc doc
JOIN
Sungero_Reports_SkipNum_Rights availableDocs
ON availableDocs.Id = doc.Id
WHERE
availableDocs.ReportSessionId = @ReportSessionId
UNION
SELECT
NULL AS RegistrationDate,
[RegistrationNumber] AS RegistrationNumber,
NULL AS NumberOnFormat,
NULL AS CanRead,
NULL AS InCorrectOrder,
NULL AS Note,
NULL AS RegistrationState,
NULL AS DocumentRegister,
NULL AS Id,
NULL AS Name,
NULL AS HyperLink,
[OrdinalNumber] AS OrdinalNumber,
[Index] as SortOrder
FROM
Sungero_Reports_SkipNum_Skips
WHERE
ReportSessionId = @ReportSessionId
)
AS documents
ORDER BY
[SortOrder] DESC]]></mssql>
<postgres><![CDATA[SELECT
documents.RegistrationDate,
documents.RegistrationNumber,
case when documents.NumberOnFormat is null then 'true' else documents.NumberOnFormat end as NumberOnFormat,
case when documents.CanRead is null then 'true' else documents.CanRead end as CanRead,
case when documents.InCorrectOrder is null then 'true' else documents.InCorrectOrder end as InCorrectOrder,
documents.RegistrationState,
documents.DocumentRegister,
documents.DocumentId,
documents.DocumentName,
documents.Note as Note,
documents.HyperLink,
documents.OrdinalNumber,
documents.SortOrder
FROM
(
SELECT
doc.RegDate_Docflow_Sungero AS RegistrationDate,
doc.RegNumber_Docflow_Sungero AS RegistrationNumber,
availableDocs.NumberOnFormat AS NumberOnFormat,
availableDocs.CanRead AS CanRead,
availableDocs.InCorrectOrder AS InCorrectOrder,
doc.Note_Docflow_Sungero AS Note,
doc.RegState_Docflow_Sungero AS RegistrationState,
doc.DocRegister_Docflow_Sungero AS DocumentRegister,
doc.Id as DocumentId,
doc.Name as DocumentName,
replace(replace(@hyperlinkMask,'DocGUID', cast(doc.Discriminator as text)),'DocId', cast(doc.Id as text)) as HyperLink,
cast(doc.Index_Docflow_Sungero as text) AS OrdinalNumber,
doc.Index_Docflow_Sungero as SortOrder
FROM
Sungero_Content_EDoc doc
JOIN
Sungero_Reports_SkipNum_Rights availableDocs
ON availableDocs.Id = doc.Id
WHERE
availableDocs.ReportSessionId = @ReportSessionId
UNION
SELECT
NULL AS RegistrationDate,
RegistrationNumber AS RegistrationNumber,
NULL AS NumberOnFormat,
NULL AS CanRead,
NULL AS InCorrectOrder,
NULL AS Note,
NULL AS RegistrationState,
NULL AS DocumentRegister,
NULL AS Id,
NULL AS Name,
NULL AS HyperLink,
OrdinalNumber AS OrdinalNumber,
Index AS SortOrder
FROM
Sungero_Reports_SkipNum_Skips
WHERE
ReportSessionId = @ReportSessionId
)
AS documents
ORDER BY
SortOrder DESC]]></postgres>
</query>
<query key="SkippedIndexes">
<mssql><![CDATA[CREATE TABLE {0} (
RegistrationNumber varchar(MAX),
OrdinalNumber varchar(MAX) NOT NULL,
[Index] int NOT NULL,
ReportSessionId varchar(256) NOT NULL )]]></mssql>
<postgres><![CDATA[CREATE TABLE {0} (
RegistrationNumber citext,
OrdinalNumber citext NOT NULL,
Index int NOT NULL,
ReportSessionId citext NOT NULL)]]></postgres>
</query>
<query key="AvaliableDocuments">
<mssql><![CDATA[CREATE TABLE {0} (
[Id] [int] NOT NULL,
[NumberOnFormat] [bit] NOT NULL DEFAULT(1),
[CanRead] [bit] NOT NULL DEFAULT(1),
[InCorrectOrder] [bit] NOT NULL DEFAULT(1),
[ReportSessionId] varchar(256) NULL)]]></mssql>
<postgres><![CDATA[CREATE TABLE {0} (
Id int NOT NULL,
NumberOnFormat boolean NOT NULL DEFAULT TRUE,
CanRead boolean NOT NULL DEFAULT TRUE,
InCorrectOrder boolean NOT NULL DEFAULT TRUE,
ReportSessionId citext NULL)]]></postgres>
</query>
<query key="GetSkippedIndexes">
<default><![CDATA[WITH skippedIndexdt as
(
select
ROW_Number() OVER(ORDER By t.indx) AS rowNumber,
t.indx
from
(
SELECT
Index_Docflow_Sungero as indx
FROM
Sungero_Content_EDoc
WHERE
DocRegister_Docflow_Sungero = {0} and
Index_Docflow_Sungero > {1} and
Index_Docflow_Sungero < {2} and
(not '{3}' = 'True' or BusinessUnit_Docflow_Sungero = {4}) and
(not '{5}' = 'True' or Department_Docflow_Sungero = {6}) and
(not '{7}' = 'True' or LeadDocument_Docflow_Sungero = {8}) and
(not '{9}' = 'True' or (RegDate_Docflow_Sungero >= '{10}' and RegDate_Docflow_Sungero <= '{11}'))
union
(select {1})
union
(select {2})
) as t
)
select
t1.indx-1 as endInterval,
t2.indx+1 as startInterval
from skippedIndexdt as t1
inner join skippedIndexdt as t2
on t1.rowNumber = t2.rowNumber + 1 and t1.indx - t2.indx > 1]]></default>
</query>
</queries>