-
Notifications
You must be signed in to change notification settings - Fork 14
/
03.00.11.SqlDataProvider
189 lines (159 loc) · 4.42 KB
/
03.00.11.SqlDataProvider
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
186
187
188
/* =====================================================================*/
/***** Initialization Script 03.00.11 *****/
/* =====================================================================*/
/* =====================================================================*/
/* add a Summary field to the grmRepositoryObjects table */
/* =====================================================================*/
IF (SELECT COLUMNPROPERTY( OBJECT_ID('{databaseOwner}{objectQualifier}grmRepositoryObjects'),'Summary','AllowsNull')) IS NULL
alter table {databaseOwner}[{objectQualifier}grmRepositoryObjects] ADD [Summary] NTEXT NULL
GO
/* =====================================================================*/
/* Remove and replace all stored procedures */
/* =====================================================================*/
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}grmAddRepositoryObject]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}[{objectQualifier}grmAddRepositoryObject]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}grmUpdateRepositoryObject]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}[{objectQualifier}grmUpdateRepositoryObject]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}grmUpdateRepositoryRating]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}[{objectQualifier}grmUpdateRepositoryRating]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure {databaseOwner}{objectQualifier}grmAddRepositoryObject
@UserName nvarchar(150),
@ModuleID int,
@Name nvarchar(50),
@Description ntext,
@Author nvarchar(150),
@AuthorEMail nvarchar(150),
@FileSize nvarchar(12),
@PreviewImage nvarchar(150),
@Image nvarchar(150),
@FileName nvarchar(150),
@Approved int,
@ShowEMail int,
@CategoryId nvarchar(50),
@Summary ntext
as
insert into {databaseOwner}{objectQualifier}grmRepositoryObjects (
CreatedByUser,
CreatedDate,
UpdatedByUser,
UpdatedDate,
ModuleID,
[Name],
[Description],
Author,
AuthorEMail,
FileSize,
Downloads,
PreviewImage,
[Image],
[FileName],
Clicks,
RatingVotes,
RatingTotal,
RatingAverage,
Approved,
ShowEMail,
CategoryId,
Summary
)
values (
@UserName,
getdate(),
@UserName,
getdate(),
@ModuleID,
@Name,
@Description,
@Author,
@AuthorEMail,
@FileSize,
0,
@PreviewImage,
@Image,
@FileName,
0,
0,
0,
0,
@Approved,
@ShowEMail,
@CategoryId,
@Summary
)
select SCOPE_IDENTITY()
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure {databaseOwner}{objectQualifier}grmUpdateRepositoryObject
@ItemID int,
@UserName nvarchar(150),
@Name nvarchar(50),
@Description ntext,
@Author nvarchar(150),
@AuthorEMail nvarchar(150),
@FileSize nvarchar(12),
@PreviewImage nvarchar(150),
@Image nvarchar(150),
@FileName nvarchar(150),
@Approved int,
@ShowEMail int,
@CategoryId nvarchar(50),
@Summary ntext
as
update {databaseOwner}{objectQualifier}grmRepositoryObjects
set
UpdatedByUser = @UserName,
UpdatedDate = getdate(),
[Name] = @Name,
[Description] = @Description,
Author = @Author,
AuthorEMail = @AuthorEMail,
FileSize = @FileSize,
PreviewImage = @PreviewImage,
[Image] = @Image,
[FileName] = @FileName,
Approved = @Approved,
ShowEMail = @ShowEMail,
CategoryId = @CategoryId,
Summary = @Summary
where ItemID = @ItemID
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure {databaseOwner}{objectQualifier}grmUpdateRepositoryRating
@ObjectId int,
@Rating int
as
BEGIN
declare @SQL nvarchar(200)
select @SQL = 'update {databaseOwner}{objectQualifier}grmRepositoryObjects set RatingVotes = RatingVotes + 1 where ItemID = ' + convert(varchar,@ObjectId)
EXEC sp_executesql @SQL
select @SQL = 'update {databaseOwner}{objectQualifier}grmRepositoryObjects set RatingTotal = RatingTotal + ' + convert(varchar,@Rating) + ' where ItemID = ' + convert(varchar,@ObjectId)
EXEC sp_executesql @SQL
select @SQL = 'update {databaseOwner}{objectQualifier}grmRepositoryObjects set RatingAverage = RatingTotal / RatingVotes where ItemID = ' + convert(varchar,@ObjectId)
EXEC sp_executesql @SQL
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO