DocumentUsageReportQueries.xml
3.53 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
<?xml version="1.0" encoding="utf-8"?>
<queries>
<query key="DataSource">
<mssql><![CDATA[select
emp.Name as Employee,
pos.Name as JobTitle,
dep.Name as Department,
ISNULL(SUM(Created), 0) as Created,
ISNULL(SUM(Updated), 0) as Updated,
ISNULL(SUM(Readed), 0) as Readed
from
Sungero_Core_Recipient emp
left join
(select
Employee,
DocId,
case when ActionType = 'Create' then 1 else 0
end as Created,
case when ActionType = 'Update' then 1 else 0
end as Updated,
case when ActionType = 'Read' then 1 else 0
end as Readed
from
(select
distinct
his.[User] as Employee,
EntityId as DocId,
case
when [Action] = 'Create'
then 'Create'
when [Action] = 'Update' and (Operation = 'UpdateVerBody' or Operation = 'CreateVersion')
then 'Update'
when [Action] = 'Read' and Operation = 'ReadVerBody'
then 'Read'
end as ActionType
from
[dbo].[Sungero_Content_DocHistory] his
where
EntityId <> 0
and his.HistoryDate between @PeriodBegin and @PeriodEnd) hist
) history on
emp.Id = history.Employee
left join Sungero_Company_JobTitle pos on
emp.JobTitle_Company_Sungero = pos.Id
join Sungero_Core_Login logins on
emp.Login = logins.Id
join Sungero_Core_Recipient dep on
emp.Department_Company_Sungero = dep.Id
where
emp.Discriminator = 'b7905516-2be5-4931-961c-cb38d5677565'
and emp.Status = 'Active'
and (@DepartmentId = 0 or emp.Department_Company_Sungero = @DepartmentId)
group by
emp.Name, pos.Name, dep.Name
order by
ISNULL(SUM(Created), 0) + ISNULL(SUM(Updated), 0) + ISNULL(SUM(Readed), 0), dep.Name, emp.Name]]></mssql>
<postgres><![CDATA[select
emp.Name as Employee,
pos.Name as JobTitle,
dep.Name as Department,
COALESCE(SUM(Created), 0) as Created,
COALESCE(SUM(Updated), 0) as Updated,
COALESCE(SUM(Readed), 0) as Readed
from
Sungero_Core_Recipient emp
left join
(select
Employee,
DocId,
case when ActionType = 'Create' then 1 else 0
end as Created,
case when ActionType = 'Update' then 1 else 0
end as Updated,
case when ActionType = 'Read' then 1 else 0
end as Readed
from
(select
distinct
his.User as Employee,
EntityId as DocId,
case
when Action = 'Create'
then 'Create'
when Action = 'Update' and (Operation = 'UpdateVerBody' or Operation = 'CreateVersion')
then 'Update'
when Action = 'Read' and Operation = 'ReadVerBody'
then 'Read'
end as ActionType
from
Sungero_Content_DocHistory his
where
EntityId <> 0
and his.HistoryDate between @PeriodBegin and @PeriodEnd) hist
) history on
emp.Id = history.Employee
left join Sungero_Company_JobTitle pos on
emp.JobTitle_Company_Sungero = pos.Id
join Sungero_Core_Login logins on
emp.Login = logins.Id
join Sungero_Core_Recipient dep on
emp.Department_Company_Sungero = dep.Id
where
emp.Discriminator = 'b7905516-2be5-4931-961c-cb38d5677565'
and emp.Status = 'Active'
and (@DepartmentId = 0 or emp.Department_Company_Sungero = @DepartmentId)
group by
emp.Name, pos.Name, dep.Name
order by
COALESCE(SUM(Created), 0) + COALESCE(SUM(Updated), 0) + COALESCE(SUM(Readed), 0), dep.Name, emp.Name
]]></postgres>
</query>
</queries>