添加项目文件。

This commit is contained in:
Zel
2025-01-22 23:31:03 +08:00
parent 1b8ba6771f
commit 2ae76476fb
894 changed files with 774558 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
UPDATE
Profile
SET
AccountName = @StandinName,
Navigation = @Navigation,
Biography = 'Deleted account.',
Avatar = null,
ModifiedDate = @ModifiedDate
WHERE
UserId = @UserId

View File

@@ -0,0 +1,21 @@
--Remove the previous page file revision attachment, if any.
DELETE FROM PageRevisionAttachment
WHERE
PageId = @PageId
AND PageFileId = @PageFileId
AND FileRevision = @PreviousFileRevision
AND PageRevision = @PageRevision;
--Associate the file revision record with the page revision.
INSERT INTO PageRevisionAttachment
(
PageId,
PageFileId,
FileRevision,
PageRevision
)
SELECT
@PageId,
@PageFileId,
@FileRevision,
@PageRevision;

View File

@@ -0,0 +1,26 @@
INSERT INTO Page
(
Name,
Namespace,
Description,
Navigation,
Revision,
CreatedByUserId,
CreatedDate,
ModifiedByUserId,
ModifiedDate
)
VALUES
(
@Name,
@Namespace,
@Description,
@Navigation,
1,
@CreatedByUserId,
@CreatedDate,
@ModifiedByUserId,
@ModifiedDate
);
SELECT last_insert_rowid();

View File

@@ -0,0 +1,15 @@
INSERT INTO Profile
(
UserId,
AccountName,
Navigation,
CreatedDate,
ModifiedDate
)
SELECT
@UserId,
@AccountName,
@Navigation,
@CreatedDate,
@ModifiedDate

View File

@@ -0,0 +1,2 @@
DELETE FROM EmojiCategory WHERE EmojiId = @Id;
DELETE FROM Emoji WHERE Id = @Id;

View File

@@ -0,0 +1,4 @@
DELETE FROM
MenuItem
WHERE
Id = @Id

View File

@@ -0,0 +1,6 @@
DELETE FROM
PageComment
WHERE
PageId = @PageId
AND Id = @CommentId

View File

@@ -0,0 +1,7 @@
DELETE FROM
PageComment
WHERE
PageId = @PageId
AND UserId = @UserId
AND Id = @CommentId

View File

@@ -0,0 +1 @@
DELETE FROM [CompilationStatistics] WHERE PageId = @PageId;

View File

@@ -0,0 +1,23 @@
DELETE FROM PageRevisionAttachment
WHERE EXISTS (
SELECT 1
FROM PageFile AS PF
INNER JOIN Page AS P
ON P.Id = PF.PageId
INNER JOIN PageRevision AS PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment AS PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
INNER JOIN PageFileRevision AS PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PRA.FileRevision
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PR.Revision = @PageRevision
AND PageRevisionAttachment.PageId = P.Id
AND PageRevisionAttachment.PageFileId = PF.Id
AND PageRevisionAttachment.PageRevision = PR.Revision
);

View File

@@ -0,0 +1,6 @@
SELECT
1
FROM
AspNetUsers
WHERE
Email = @EmailAddress

View File

@@ -0,0 +1,7 @@
SELECT
1
FROM
Profile
WHERE
Navigation = @Navigation
LIMIT 1

View File

@@ -0,0 +1 @@
PRAGMA foreign_key_check;

View File

@@ -0,0 +1,28 @@
SELECT
U.UserId,
U.Avatar,
ANU.Email as EmailAddress,
U.AccountName,
U.Navigation,
U.Biography,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'firstname') as FirstName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'lastname') as LastName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'theme') as Theme,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
ANU.EmailConfirmed
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
U.Navigation = @Navigation

View File

@@ -0,0 +1,28 @@
SELECT
U.UserId,
U.Avatar,
ANU.Email as EmailAddress,
U.AccountName,
U.Navigation,
U.Biography,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'firstname') as FirstName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'lastname') as LastName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'theme') as Theme,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
ANU.EmailConfirmed
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
U.UserId = @UserId

View File

@@ -0,0 +1,46 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
DeletedUser.AccountName as DeletedByUserName,
DM.DeletedDate,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
WHERE
P.Id IN (SELECT PID.Value FROM TempPageIds as PID)
) as PaginationPageCount
FROM
[Page] as P
INNER JOIN DeletionMeta as DM
ON DM.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
LEFT OUTER JOIN users_db.Profile as DeletedUser
ON DeletedUser.UserId = DM.DeletedByUserID
WHERE
P.Id IN (SELECT PID.Value FROM TempPageIds as PID)
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Page=P.[Name]
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,42 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
DeletedUser.AccountName as DeletedByUserName,
DM.DeletedDate,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
) as PaginationPageCount
FROM
[Page] as P
INNER JOIN DeletionMeta as DM
ON DM.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
LEFT OUTER JOIN users_db.Profile as DeletedUser
ON DeletedUser.UserId = DM.DeletedByUserID
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Page=P.[Name]
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,9 @@
SELECT
[Id],
[Name],
MimeType,
'%%' || lower([Name]) || '%%' as [Shortcut]
FROM
Emoji
ORDER BY
[Name]

View File

@@ -0,0 +1,27 @@
SELECT
E.Id,
E.[Name],
E.MimeType,
'%%' || lower(E.[Name]) || '%%' as Shortcut,
@PageSize as PaginationPageSize,
(
SELECT
(Round(Count(0) / (@PageSize + 0.0) + 0.999))
FROM
Emoji as iE
) as PaginationPageCount
FROM
Emoji as E
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=E.[Name]
MimeType=E.[MimeType]
Shortcut=E.[Name]
*/
--::CONFIG
ORDER BY
E.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,35 @@
SELECT
E.Id,
E.[Name],
E.MimeType,
'%%' || lower(E.[Name]) || '%%' as Shortcut,
@PageSize as PaginationPageSize,
(
SELECT
(Round(Count(0) / (@PageSize + 0.0) + 0.999))
FROM
Emoji as iE
INNER JOIN EmojiCategory as iEC
ON iEC.EmojiId = iE.Id
WHERE
iEC.Id IN (SELECT Value FROM TempEmojiCategoryIds)
) as PaginationPageCount
FROM
Emoji as E
INNER JOIN EmojiCategory as EC
ON EC.EmojiId = E.Id
WHERE
EC.Id IN (SELECT Value FROM TempEmojiCategoryIds)
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=E.[Name]
MimeType=E.[MimeType]
Shortcut=E.[Name]
*/
--::CONFIG
ORDER BY
E.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,28 @@
SELECT
Id,
[Text],
[ExceptionText],
[StackTrace],
[CreatedDate],
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Exception] as P
) as PaginationPageCount
FROM
[Exception]
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Id=Id
CreatedDate=[CreatedDate]
*/
--::CONFIG
ORDER BY
Id
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,19 @@
SELECT
[Id] as [Id],
[Name] as [Name],
[Link] as [Link],
[Ordinal] as [Ordinal]
FROM
[MenuItem]
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Id=Id
Name=Name
Link=Link
Ordinal=Ordinal
*/
--::CONFIG
ORDER BY
[Ordinal]
--::CUSTOM_ORDER_BEGIN

View File

@@ -0,0 +1,43 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
WHERE
P.[Namespace] = @Namespace
) as PaginationPageCount
FROM
[Page] as P
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
WHERE
P.[Namespace] = @Namespace
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=P.[Name]
Revision=P.Revision
ModifiedBy=ModifiedUser.AccountName
ModifiedDate=P.ModifiedDate
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,4 @@
SELECT DISTINCT
[Namespace]
FROM
[Page]

View File

@@ -0,0 +1,27 @@
SELECT
P.[Namespace],
Count(0) as [CountOfPages],
@PageSize as PaginationPageSize,
(
SELECT
Count(DISTINCT P.[Namespace]) / (@PageSize + 0.0)
FROM
[Page] as P
) as PaginationPageCount
FROM
[Page] as P
GROUP BY
[Namespace]
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=P.[Namespace]
Pages=Count(0)
*/
--::CONFIG
ORDER BY
P.[Namespace]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,17 @@
SELECT
P.Id,
P.[Name],
P.[Description],
PR.Body,
PR.Revision,
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
WHERE
PR.Revision = P.Revision

View File

@@ -0,0 +1,38 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
INNER JOIN PageProcessingInstruction as PPI
ON PPI.PageId = P.Id
WHERE
PPI.Instruction = @Instruction
) as PaginationPageCount
FROM
[Page] as P
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
INNER JOIN PageProcessingInstruction as PPI
ON PPI.PageId = P.Id
WHERE
PPI.Instruction = @Instruction
ORDER BY
P.[Name],
P.Id
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,44 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
(SELECT COUNT(0) FROM deletedpagerevisions_db.[PageRevision] WHERE PageId = P.Id) as DeletedRevisionCount,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
WHERE
P.Id IN (SELECT PID.Value FROM TempPageIds as PID)
) as PaginationPageCount
FROM
[Page] as P
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
WHERE
P.Id IN (SELECT PID.Value FROM TempPageIds as PID)
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=p.Name
Revision=P.Revision
ModifiedBy=ModifiedUser.AccountName
ModifiedDate=P.ModifiedDate
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,40 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
(SELECT COUNT(0) FROM deletedpagerevisions_db.[PageRevision] WHERE PageId = P.Id) as DeletedRevisionCount,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
) as PaginationPageCount
FROM
[Page] as P
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=p.Name
Revision=P.Revision
ModifiedBy=ModifiedUser.AccountName
ModifiedDate=P.ModifiedDate
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,62 @@
--This proc is exactly like GetAllUsersPaged except it has no filter on personal infomation so it can be used for public info.
SELECT
U.UserId,
U.AccountName,
U.Navigation,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
Profile as P
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
LEFT OUTER JOIN AspNetUserClaims as UCFirstName
ON UCFirstName.UserId = U.UserId
AND UCFirstName.ClaimType = 'firstname'
LEFT OUTER JOIN AspNetUserClaims as UCLastName
ON UCLastName.UserId = U.UserId
AND UCLastName.ClaimType = 'lastname'
WHERE
@SearchToken IS NULL
OR U.AccountName LIKE '%' || @SearchToken || '%'
OR ANU.Email LIKE '%' || @SearchToken || '%'
OR UCFirstName.ClaimValue LIKE '%' || @SearchToken || '%'
OR UCLastName.ClaimValue LIKE '%' || @SearchToken || '%'
) as PaginationPageCount
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
LEFT OUTER JOIN AspNetUserClaims as UCFirstName
ON UCFirstName.UserId = U.UserId
AND UCFirstName.ClaimType = 'firstname'
LEFT OUTER JOIN AspNetUserClaims as UCLastName
ON UCLastName.UserId = U.UserId
AND UCLastName.ClaimType = 'lastname'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
@SearchToken IS NULL
OR U.AccountName LIKE '%' || @SearchToken || '%'
OR ANU.Email LIKE '%' || @SearchToken || '%'
OR UCFirstName.ClaimValue LIKE '%' || @SearchToken || '%'
OR UCLastName.ClaimValue LIKE '%' || @SearchToken || '%'
ORDER BY
U.AccountName,
U.UserId
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,17 @@
SELECT
Id,
[Name],
[Description]
FROM
[Role]
[MenuItem]
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=Name
Description=Description
*/
--::CONFIG
ORDER BY
[Name]
--::CUSTOM_ORDER_BEGIN

View File

@@ -0,0 +1,12 @@
SELECT
[Name],
ClassNavBar,
ClassNavLink,
ClassDropdown,
ClassBranding,
EditorTheme,
DelimitedFiles
FROM
[Theme]
ORDER BY
[Name]

View File

@@ -0,0 +1,29 @@
SELECT
U.UserId,
ANU.Email as EmailAddress,
U.AccountName,
U.Navigation,
UCFirstName.ClaimValue as FirstName,
UCLastName.ClaimValue as LastName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
ANU.EmailConfirmed
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
LEFT OUTER JOIN AspNetUserClaims as UCFirstName
ON UCFirstName.UserId = U.UserId
AND UCFirstName.ClaimType = 'firstname'
LEFT OUTER JOIN AspNetUserClaims as UCLastName
ON UCLastName.UserId = U.UserId
AND UCLastName.ClaimType = 'lastname'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue

View File

@@ -0,0 +1,77 @@
SELECT
U.UserId,
ANU.Email as EmailAddress,
U.AccountName,
U.Navigation,
UCFirstName.ClaimValue as FirstName,
UCLastName.ClaimValue as LastName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
ANU.EmailConfirmed,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
LEFT OUTER JOIN AspNetUserClaims as UCFirstName
ON UCFirstName.UserId = U.UserId
AND UCFirstName.ClaimType = 'firstname'
LEFT OUTER JOIN AspNetUserClaims as UCLastName
ON UCLastName.UserId = U.UserId
AND UCLastName.ClaimType = 'lastname'
WHERE
@SearchToken IS NULL
OR U.AccountName LIKE '%' || @SearchToken || '%'
OR ANU.Email LIKE '%' || @SearchToken || '%'
OR UCFirstName.ClaimValue LIKE '%' || @SearchToken || '%'
OR UCLastName.ClaimValue LIKE '%' || @SearchToken || '%'
) as PaginationPageCount
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
LEFT OUTER JOIN AspNetUserClaims as UCFirstName
ON UCFirstName.UserId = U.UserId
AND UCFirstName.ClaimType = 'firstname'
LEFT OUTER JOIN AspNetUserClaims as UCLastName
ON UCLastName.UserId = U.UserId
AND UCLastName.ClaimType = 'lastname'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
@SearchToken IS NULL
OR U.AccountName LIKE '%' || @SearchToken || '%'
OR ANU.Email LIKE '%' || @SearchToken || '%'
OR UCFirstName.ClaimValue LIKE '%' || @SearchToken || '%'
OR UCLastName.ClaimValue LIKE '%' || @SearchToken || '%'
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Account=U.AccountName
FirstName=UCFirstName.ClaimValue
LastName=UCLastName.ClaimValue
Created=U.CreatedDate
TimeZone=TimeZone
Language=Language
Country=Country
EmailAddress=ANU.Email
*/
--::CONFIG
ORDER BY
U.AccountName
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,15 @@
SELECT
[Extent].[Tag],
Count(DISTINCT [Extent].PageId) as [PageCount]
FROM
PageTag as [Root]
INNER JOIN PageTag as [Interm]
ON [Interm].[Tag] = [Root].[Tag]
AND [Interm].[PageId] = [Root].[PageId]
INNER JOIN PageTag as [Extent]
ON [Extent].[PageId] = [Interm].[PageId]
WHERE
[Root].[Tag] = @Tag
GROUP BY
[Extent].[Tag]
LIMIT 100;

View File

@@ -0,0 +1,18 @@
SELECT
U.UserId,
U.AccountName,
U.Navigation,
U.Biography,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'theme') as Theme,
UCR.ClaimValue as Role
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
U.UserId = @UserId

View File

@@ -0,0 +1,50 @@
SELECT
MAX(P.Name) as Name,
MAX(P.Namespace) as Namespace,
MAX(P.Navigation) as Navigation,
MAX(Stats.CreatedDate) as LatestBuild,
COUNT(0) as Compilations,
AVG(Stats.WikifyTimeMs) as AvgBuildTimeMs,
AVG(Stats.MatchCount) as AvgWikiMatches,
SUM(Stats.ErrorCount) as TotalErrorCount,
AVG(Stats.OutgoingLinkCount) as AvgOutgoingLinkCount,
AVG(Stats.TagCount) as AvgTagCount,
AVG(Stats.BodySize) as AvgRawBodySize,
AVG(Stats.ProcessedBodySize) as AvgWikifiedBodySize,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(DISTINCT P.Id) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
CompilationStatistics as Stats
INNER JOIN pages_db.[Page] as P
ON P.Id = Stats.PageId
) as PaginationPageCount
FROM
CompilationStatistics as Stats
INNER JOIN pages_db.[Page] as P
ON P.Id = Stats.PageId
GROUP BY
Stats.PageId
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Name=MAX(P.Name)
Namespace=MAX(P.Namespace)
Navigation=MAX(P.Navigation)
CreatedDate=MAX(P.CreatedDate)
Compilations=COUNT(0)
AvgBuildTimeMs=AVG(Stats.WikifyTimeMs)
AvgWikiMatches=AVG(Stats.MatchCount)
TotalErrorCount=SUM(Stats.ErrorCount)
AvgOutgoingLinkCount=AVG(Stats.OutgoingLinkCount)
AvgTagCount=AVG(Stats.TagCount)
AvgRawBodySize=AVG(Stats.BodySize)
AvgWikifiedBodySize=AVG(Stats.ProcessedBodySize)
*/
--::CONFIG
ORDER BY
MAX(P.Name) DESC
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize;

View File

@@ -0,0 +1,13 @@
SELECT
CE.[Id] as [Id],
CE.[ConfigurationGroupId] as [ConfigurationGroupId],
CE.[Name] as [Name],
CE.[Value] as [Value],
CE.[IsEncrypted] as [IsEncrypted],
CE.[Description] as [Description]
FROM
[ConfigurationEntry] as CE
INNER JOIN [ConfigurationGroup] as CG
ON CG.Id = CE.ConfigurationGroupId
WHERE
CG.[Name] = @GroupName

View File

@@ -0,0 +1,13 @@
SELECT
CE.[Id] as [Id],
CE.[ConfigurationGroupId] as [ConfigurationGroupId],
CE.[Name] as [Name],
CE.[Value] as [Value],
CE.[Description] as [Description]
FROM
[ConfigurationEntry] as CE
INNER JOIN [ConfigurationGroup] as CG
ON CG.Id = CE.ConfigurationGroupId
WHERE
CG.[Name] = @GroupName
AND CE.[Name] = @EntryName

View File

@@ -0,0 +1,6 @@
SELECT
Count(0) as Attachments
FROM
PageFile
WHERE
PageId = @PageId

View File

@@ -0,0 +1 @@
SELECT Content FROM CryptoCheck

View File

@@ -0,0 +1,6 @@
SELECT
Revision
FROM
[Page]
WHERE
Id = @PageId

View File

@@ -0,0 +1 @@
PRAGMA page_count;

View File

@@ -0,0 +1 @@
PRAGMA page_size;

View File

@@ -0,0 +1 @@
SELECT SQLITE_VERSION();

View File

@@ -0,0 +1,31 @@
SELECT
P.Id,
P.[Name],
PR.[Description],
PR.Body,
PR.Revision,
P.Revision as MostCurrentRevision,
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
PR.ModifiedByUserId,
PR.ModifiedDate,
DM.DeletedDate,
Createduser.AccountName as CreatedByUserName,
ModifiedUser.AccountName as ModifiedByUserName,
DeletedUser.AccountName as DeletedByUserName
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
AND PR.Revision = P.Revision
INNER JOIN DeletionMeta as DM
ON DM.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = P.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
LEFT OUTER JOIN users_db.Profile as DeletedUser
ON DeletedUser.UserId = DM.DeletedByUserID
WHERE
P.Id = @PageId

View File

@@ -0,0 +1,12 @@
SELECT
T.PageId
FROM
PageToken as T
INNER JOIN TempTokens as TT
ON TT.[value] = T.Token
WHERE
Coalesce(TT.[value], '') <> ''
GROUP BY
T.PageId
HAVING
Count(0) = @TokenCount

View File

@@ -0,0 +1,18 @@
SELECT
PR.PageId as Id,
PR.Name,
PR.[Description],
PR.Revision as Revision,
PR.Body,
DM.DeletedDate,
DeletedUser.AccountName as DeletedByUserName
FROM
[PageRevision] as PR
INNER JOIN DeletionMeta as DM
ON DM.PageId = PR.PageId
AND DM.Revision = PR.Revision
LEFT OUTER JOIN users_db.Profile as DeletedUser
ON DeletedUser.UserId = DM.DeletedByUserID
WHERE
PR.PageId = @PageId
AND PR.Revision = @Revision

View File

@@ -0,0 +1,39 @@
SELECT
PR.PageId as Id,
PR.Name,
PR.[Description],
PR.Revision as Revision,
DM.DeletedDate,
DeletedUser.AccountName as DeletedByUserName,
@PageSize as PaginationPageSize,
(
SELECT
Count(0) / (@PageSize + 0.0)
FROM
[PageRevision] as PR
WHERE
PR.PageId = @PageId
) as PaginationPageCount
FROM
[PageRevision] as PR
INNER JOIN DeletionMeta as DM
ON DM.PageId = PR.PageId
AND DM.Revision = PR.Revision
LEFT OUTER JOIN users_db.Profile as DeletedUser
ON DeletedUser.UserId = DM.DeletedByUserID
WHERE
PR.PageId = @PageId
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Revision=PR.Revision
DeletedDate=DM.DeletedDate
DeletedBy=DeletedUser.AccountName
*/
--::CONFIG
ORDER BY
PR.Revision
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,10 @@
SELECT
E.Id,
E.[Name],
E.MimeType,
'%%' || lower(E.[Name]) || '%%' as Shortcut,
ImageData
FROM
Emoji as E
WHERE
E.[Name] = @Name

View File

@@ -0,0 +1,10 @@
SELECT
Ec.Id,
EC.EmojiId,
EC.Category
FROM
Emoji as E
INNER JOIN EmojiCategory as EC
ON EC.EmojiId = E.Id
WHERE
E.[Name] = @Name

View File

@@ -0,0 +1,22 @@
SELECT
Category,
(
SELECT
Count(0)
FROM
EmojiCategory as iEC
INNER JOIN Emoji as iE
ON iE.Id = iEC.EmojiId
WHERE
iEC.Category = EC.Category
) as EmojiCount
FROM
EmojiCategory as EC
INNER JOIN Emoji as E
ON E.Id = EC.EmojiId
WHERE
E.[Name] NOT LIKE '%' || EC.Category || '%'
GROUP BY
Category
ORDER BY
Category

View File

@@ -0,0 +1,13 @@
SELECT DISTINCT
E.[Id],
E.[Name],
E.MimeType,
'%%' || lower([Name]) || '%%' as [Shortcut]
FROM
Emoji as E
INNER JOIN EmojiCategory as EC
ON EC.EmojiId = E.Id
WHERE
EC.Category = @Category
ORDER BY
E.[Name]

View File

@@ -0,0 +1,27 @@
SELECT
PageId,
SUM([Match]) as [Match],
SUM([Weight]) as [Weight],
SUM([Score]) as [Score]
FROM
(
SELECT
T.PageId,
COUNT(DISTINCT T.Token) / (@TokenCount + 0.0) as [Match],
SUM(T.[Weight] * 1.5) as [Weight],
--Extra weight on score for exact matches:
SUM(T.[Weight] * 1.5) * (COUNT(DISTINCT T.Token) / (@TokenCount + 0.0)) as [Score]
FROM
PageToken as T
INNER JOIN TempSearchTerms as ST
ON ST.Token = T.Token
GROUP BY
T.PageId
) as T
GROUP BY
T.PageId
HAVING
SUM(Score) >= @MinimumMatchScore
ORDER BY
SUM([Score]) DESC
LIMIT 250;

View File

@@ -0,0 +1,10 @@
SELECT
Id,
[Text],
[ExceptionText],
[StackTrace],
[CreatedDate]
FROM
[Exception]
WHERE
Id = @Id

View File

@@ -0,0 +1 @@
SELECT COUNT(0) FROM Exception

View File

@@ -0,0 +1,22 @@
SELECT
CG.Id as [GroupId],
CG.[Name] as [GroupName],
CG.[Description] as [GroupDescription],
CE.[Id] as [EntryId],
CE.[Name] as [EntryName],
CE.[Value] as [EntryValue],
CE.[Description] as [EntryDescription],
CE.IsEncrypted,
CE.IsRequired,
DT.[Name] as DataType
FROM
[ConfigurationEntry] as CE
INNER JOIN [ConfigurationGroup] as CG
ON CG.Id = CE.ConfigurationGroupId
INNER JOIN DataType as DT
ON DT.Id = CE.DataTypeId
ORDER BY
CG.[Name],
CE.[Name]

View File

@@ -0,0 +1,28 @@
SELECT
PageId,
SUM([Match]) as [Match],
SUM([Weight]) as [Weight],
SUM([Score]) as [Score]
FROM
(
SELECT
T.PageId,
COUNT(DISTINCT T.DoubleMetaphone) / (@TokenCount + 0.0) as [Match],
SUM(T.[Weight] * 1.0) as [Weight],
--No weight benefits on score for fuzzy matching weight for exact matches:
(COUNT(DISTINCT T.DoubleMetaphone) / (@TokenCount + 0.0)) as [Score]
FROM
PageToken as T
INNER JOIN TempSearchTerms as ST
ON ST.Token != T.Token
AND ST.DoubleMetaphone = T.DoubleMetaphone
GROUP BY
T.PageId
) as T
GROUP BY
T.PageId
HAVING
SUM(Score) >= @MinimumMatchScore
ORDER BY
SUM([Score]) DESC
LIMIT 250;

View File

@@ -0,0 +1,22 @@
SELECT
P.Id,
P.[Name],
PR.[Description],
PR.Body,
PR.Revision,
P.Revision as MostCurrentRevision,
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
PR.ModifiedByUserId,
PR.ModifiedDate,
MBU.AccountName as ModifiedByUserName
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
AND PR.Revision = P.Revision
LEFT OUTER JOIN users_db.Profile as MBU
ON MBU.UserId = P.ModifiedByUserId
WHERE
P.Id = @PageId

View File

@@ -0,0 +1,20 @@
SELECT
P.Id,
P.[Name],
P.[Namespace],
P.[Description],
P.Navigation,
PR.Revision,
PR.DataHash,
P.Revision as MostCurrentRevision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
WHERE
P.Id = @PageId
AND PR.Revision = COALESCE(@Revision, P.Revision)

View File

@@ -0,0 +1,11 @@
SELECT
[Id] as [Id],
[Name] as [Name],
[Link] as [Link],
[Ordinal] as [Ordinal]
FROM
[MenuItem]
WHERE
Id = @Id
ORDER BY
[Ordinal]

View File

@@ -0,0 +1,35 @@
SELECT
P.Id as SourcePageId,
P.[Name] as SourcePageName,
P.[Navigation] as SourcePageNavigation,
PR.ReferencesPageName as TargetPageName,
PR.ReferencesPageNavigation as TargetPageNavigation,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
PageReference as PR
INNER JOIN [Page] as P
ON P.Id = PR.PageId
WHERE
PR.ReferencesPageId IS NULL
) as PaginationPageCount
FROM
PageReference as PR
INNER JOIN [Page] as P
ON P.Id = PR.PageId
WHERE
PR.ReferencesPageId IS NULL
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
SourcePage=P.[Name]
TargetPage=PR.ReferencesPageName
*/
--::CONFIG
ORDER BY
P.[Name]
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,50 @@
SELECT
PFR.PageFileId,
P.Name as PageName,
P.Namespace,
P.Navigation as PageNavigation,
PF.Name as FileName,
PF.Navigation as FileNavigation,
PFR.Size,
PFR.Revision as FileRevision,
@PageSize as PaginationPageSize,
(
SELECT
(Round(Count(0) / (@PageSize + 0.0) + 0.999))
FROM
PageFileRevision as PFR
INNER JOIN PageFile as PF
ON PF.Id = PFR.PageFileId
INNER JOIN Page as P
ON P.Id = PF.PageId
LEFT OUTER JOIN PageRevisionAttachment as PRA
ON PRA.PageFileId = PFR.PageFileId
AND PRA.FileRevision = PFR.Revision
WHERE
PRA.PageFileId IS NULL
) as PaginationPageCount
FROM
PageFileRevision as PFR
INNER JOIN PageFile as PF
ON PF.Id = PFR.PageFileId
INNER JOIN Page as P
ON P.Id = PF.PageId
LEFT OUTER JOIN PageRevisionAttachment as PRA
ON PRA.PageFileId = PFR.PageFileId
AND PRA.FileRevision = PFR.Revision
WHERE
PRA.PageFileId IS NULL
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Page=P.Name
File=PF.Name
Size=PFR.Size
Revision=PFR.Revision
*/
--::CONFIG
ORDER BY
P.Name
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,32 @@
SELECT
PC.Id,
PC.PageId,
PC.CreatedDate,
PC.UserId,
PC.Body,
U.AccountName as UserName,
U.AccountName as UserNavigation,
P.[Name] as PageName,
@PageSize as PaginationPageSize,
(
SELECT
(Round(Count(0) / (@PageSize + 0.0) + 0.999))
FROM
[Page] as iP
INNER JOIN PageComment as iPC
ON iPC.PageId = iP.Id
WHERE
iP.Navigation = @Navigation
) as PaginationPageCount
FROM
[Page] as P
INNER JOIN PageComment as PC
ON PC.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as U
ON U.UserId = PC.UserId
WHERE
P.Navigation = @Navigation
ORDER BY
PC.CreatedDate DESC
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,20 @@
SELECT
PF.PageId,
PFA.PageFileId,
PFR.Revision,
PFR.ContentType,
PFR.Size,
PFR.DataHash
FROM
PageFile as PF
INNER JOIN Page as P
ON P.Id = PF.PageId
INNER JOIN PageRevisionAttachment as PFA
ON PFA.PageFileId = PF.Id
AND PFA.PageRevision = P.Revision
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PFA.FileRevision
WHERE
PF.PageId = @PageId
AND PF.Navigation = @Navigation

View File

@@ -0,0 +1,20 @@
SELECT
PFR.Revision,
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate],
PFR.[Data] as [Data]
FROM
PageFile as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PFR.Revision = Coalesce(@FileRevision, PF.Revision)

View File

@@ -0,0 +1,46 @@
SELECT
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate],
PFR.[Data]
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
INNER JOIN (
SELECT
PF.Id as PageFileId,
PR.Revision as PageRevision,
MAX(PRA.FileRevision) as LatestAttachedFileRevision
FROM
Page as P
INNER JOIN PageFile as PF
ON PF.PageId = P.Id
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PR.Revision = Coalesce(@PageRevision, P.Revision)
GROUP BY
PF.Id
) as Latest
ON Latest.PageFileId = PF.Id
AND Latest.LatestAttachedFileRevision = PRA.FileRevision
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = Latest.LatestAttachedFileRevision
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PRA.PageRevision = Latest.PageRevision

View File

@@ -0,0 +1,45 @@
SELECT
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate]
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
INNER JOIN (
SELECT
PF.Id as PageFileId,
PR.Revision as PageRevision,
MAX(PRA.FileRevision) as LatestAttachedFileRevision
FROM
Page as P
INNER JOIN PageFile as PF
ON PF.PageId = P.Id
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PR.Revision = Coalesce(@PageRevision, P.Revision)
GROUP BY
PF.Id
) as Latest
ON Latest.PageFileId = PF.Id
AND Latest.LatestAttachedFileRevision = PRA.FileRevision
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = Latest.LatestAttachedFileRevision
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
AND PRA.PageRevision = Latest.PageRevision

View File

@@ -0,0 +1,41 @@
SELECT
PFR.Revision,
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PFR.[CreatedDate] as [CreatedDate],
PFR.Revision as FileRevision,
UP.UserID as CreatedByUserId,
UP.AccountName as CreatedByUserName,
UP.Navigation as CreatedByNavigation,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
PageFile as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
LEFT OUTER JOIN users_db.Profile UP
ON UP.UserId = PFR.CreatedByUserId
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
) as PaginationPageCount
FROM
PageFile as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
LEFT OUTER JOIN users_db.Profile UP
ON UP.UserId = PFR.CreatedByUserId
WHERE
P.Navigation = @PageNavigation
AND PF.Navigation = @FileNavigation
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize;

View File

@@ -0,0 +1,9 @@
SELECT
PF.Id as PageFileId,
PF.PageId,
PF.Revision
FROM
PageFile as PF
WHERE
PF.PageId = @PageId
AND PF.Navigation = @Navigation

View File

@@ -0,0 +1,24 @@
SELECT
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate]
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PRA.FileRevision
WHERE
P.Id = @PageId
AND PF.[Name] = @FileName
AND PR.Revision = Coalesce(@PageRevision, P.Revision)

View File

@@ -0,0 +1,28 @@
SELECT
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate],
PR.Revision as PageRevision,
PFR.Revision as FileRevision,
PF.Navigation as FileNavigation,
P.Navigation as PageNavigation
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
AND PRA.FileRevision = PF.Revision --Latest file revision.
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PRA.FileRevision
WHERE
P.Id = @PageId
AND PR.Revision = P.Revision

View File

@@ -0,0 +1,55 @@
SELECT
PF.[Id] as [Id],
PF.[PageId] as [PageId],
PF.[Name] as [Name],
PFR.[ContentType] as [ContentType],
PFR.[Size] as [Size],
PF.[CreatedDate] as [CreatedDate],
PR.Revision as PageRevision,
PFR.Revision as FileRevision,
PF.Navigation as FileNavigation,
P.Navigation as PageNavigation,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
AND PRA.FileRevision = PF.Revision --Latest file revision.
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PRA.FileRevision
WHERE
P.Navigation = @PageNavigation
AND PR.Revision = Coalesce(@PageRevision, P.Revision)
) as PaginationPageCount
FROM
[PageFile] as PF
INNER JOIN [Page] as P
ON P.Id = PF.PageId
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
INNER JOIN PageRevisionAttachment as PRA
ON PRA.PageId = P.Id
AND PRA.PageFileId = PF.Id
AND PRA.PageRevision = PR.Revision
AND PRA.FileRevision = PF.Revision --Latest file revision.
INNER JOIN PageFileRevision as PFR
ON PFR.PageFileId = PF.Id
AND PFR.Revision = PRA.FileRevision
WHERE
P.Navigation = @PageNavigation
AND PR.Revision = Coalesce(@PageRevision, P.Revision)
ORDER BY
PF.[Name],
PF.Id
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,12 @@
SELECT
T.PageId
FROM
PageToken as T
INNER JOIN TempTokens as TT
ON TT.[value] = T.Token
WHERE
Coalesce(TT.[value], '') <> ''
GROUP BY
T.PageId
HAVING
Count(0) = @TokenCount

View File

@@ -0,0 +1,13 @@
SELECT DISTINCT
P.Id,
P.[Name],
P.[Description],
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
INNER JOIN TempNamespaces as TN
ON TN.[value] = P.[Namespace]

View File

@@ -0,0 +1,14 @@
SELECT
P.Id,
P.[Name],
P.[Description],
P.Navigation,
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
WHERE
P.Navigation = @Navigation

View File

@@ -0,0 +1,15 @@
SELECT DISTINCT
P.Id,
P.[Name],
P.[Description],
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
PageTag as PT
INNER JOIN TempTags AS T
ON T.Value = PT.Tag
INNER JOIN [Page] as P
ON P.Id = PT.PageId

View File

@@ -0,0 +1,6 @@
SELECT
Navigation
FROM
Page
WHERE
Id = @PageId

View File

@@ -0,0 +1,10 @@
SELECT
PR.Revision
FROM
[PageRevision] as PR
WHERE
PR.PageId = @PageId
AND PR.Revision > @Revision
ORDER BY
PR.Revision ASC
LIMIT 1;

View File

@@ -0,0 +1,10 @@
SELECT
PR.Revision
FROM
[PageRevision] as PR
WHERE
PR.PageId = @PageId
AND PR.Revision < @Revision
ORDER BY
PR.Revision DESC
LIMIT 1;

View File

@@ -0,0 +1,7 @@
SELECT
PageId,
Instruction
FROM
PageProcessingInstruction
WHERE
PageId = @PageId

View File

@@ -0,0 +1,18 @@
SELECT
P.Id,
P.[Name],
P.[Description],
PR.Body,
PR.Revision,
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
WHERE
P.Id = @PageId
AND PR.Revision = Coalesce(@Revision, P.Revision)

View File

@@ -0,0 +1,24 @@
SELECT
P.Id,
P.[Name],
PR.[Description],
PR.Body,
PR.Revision,
P.Revision as MostCurrentRevision,
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
PR.ModifiedByUserId,
PR.ModifiedDate,
MBU.AccountName as ModifiedByUserName,
(SELECT COUNT(0) FROM PageRevision AS iPR
WHERE iPR.PageId = P.Id AND iPR.Revision > PR.Revision) as HigherRevisionCount
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as MBU
ON MBU.UserId = P.ModifiedByUserId
WHERE
P.Navigation = @Navigation
AND PR.Revision = COALESCE(@Revision, P.Revision)

View File

@@ -0,0 +1,6 @@
SELECT
Count(0)
FROM
[PageRevision] as PR
WHERE
PR.PageId = @PageId

View File

@@ -0,0 +1,23 @@
SELECT
P.Id,
P.[Name],
P.[Description],
PR.Revision,
P.Navigation,
P.CreatedByUserId,
--Createduser.AccountName as CreatedByUserName,
P.CreatedDate,
PR.ModifiedByUserId,
--ModifiedUser.AccountName as ModifiedByUserName,
PR.ModifiedDate
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
--INNER JOIN [User] as ModifiedUser
-- ON ModifiedUser.Id = PR.ModifiedByUserId
--INNER JOIN [User] as Createduser
-- ON Createduser.Id = P.CreatedByUserId
WHERE
P.Id = @PageId
AND PR.Revision = COALESCE(@Revision, P.Revision)

View File

@@ -0,0 +1,49 @@
SELECT
P.Id as PageId,
PR.[Name],
PR.[Description],
PR.Revision,
P.Revision as HighestRevision,
P.Navigation,
P.CreatedByUserId,
Createduser.AccountName as CreatedByUserName,
P.CreatedDate,
PR.ModifiedByUserId,
ModifiedUser.AccountName as ModifiedByUserName,
PR.ModifiedDate,
(SELECT COUNT(0) FROM PageRevision AS iPR WHERE iPR.PageId = P.Id AND iPR.Revision > PR.Revision) as HigherRevisionCount,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
WHERE
P.Navigation = @Navigation
) as PaginationPageCount
FROM
[Page] as P
INNER JOIN [PageRevision] as PR
ON PR.PageId = P.Id
LEFT OUTER JOIN users_db.Profile as ModifiedUser
ON ModifiedUser.UserId = PR.ModifiedByUserId
LEFT OUTER JOIN users_db.Profile as Createduser
ON Createduser.UserId = P.CreatedByUserId
WHERE
P.Navigation = @Navigation
--CUSTOM_ORDER_BEGIN::
--CONFIG::
/*
Revision=PR.Revision
ModifiedBy=ModifiedUser.AccountName
ModifiedDate=PR.ModifiedDate
Page=PR.[Name]
*/
--::CONFIG
ORDER BY
PR.Revision DESC
--::CUSTOM_ORDER_BEGIN
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,6 @@
SELECT
PT.Tag
FROM
[PageTag] as PT
WHERE
PT.PageId = @PageId

View File

@@ -0,0 +1,7 @@
SELECT
[Avatar] as Bytes,
AvatarContentType as ContentType
FROM
Profile
WHERE
Navigation = @Navigation

View File

@@ -0,0 +1,24 @@
SELECT
U.UserId,
U.EmailAddress,
U.AccountName,
U.Navigation,
U.PasswordHash,
U.FirstName,
U.LastName,
U.TimeZone,
U.Country,
U.[Language],
U.Biography,
U.CreatedDate,
U.ModifiedDate,
U.VerificationCode,
R.[Name] as [Role],
U.EmailConfirmed
FROM
Profile as U
INNER JOIN Role as R
ON R.Id = U.RoleId
WHERE
(U.EmailAddress = @AccountNameOrEmail OR U.AccountName = @AccountNameOrEmail)
AND U.PasswordHash = @PasswordHash

View File

@@ -0,0 +1,44 @@
SELECT
U.UserId,
ANU.Email as EmailAddress,
U.AccountName,
U.Navigation,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'firstname') as FirstName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'lastname') as LastName,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'timezone') as TimeZone,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType = 'language') as Language,
(select UC.ClaimValue from AspNetUserClaims as UC WHERE UC.UserId = U.UserId AND UC.ClaimType LIKE '%/country') as Country,
U.CreatedDate,
U.ModifiedDate,
UCR.ClaimValue as Role,
ANU.EmailConfirmed,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
Profile as P
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
R.Id = @RoleId
) as PaginationPageCount
FROM
Profile as U
INNER JOIN AspNetUsers as ANU
ON ANU.Id = U.UserId
INNER JOIN AspNetUserClaims as UCR
ON UCR.UserId = U.UserId
AND UCR.ClaimType LIKE '%/role'
INNER JOIN Role as R
ON R.Name = UCR.ClaimValue
WHERE
R.Id = @RoleId
ORDER BY
U.AccountName,
U.UserId
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,29 @@
SELECT
P.Id,
P.[Name],
P.[Revision],
P.Navigation,
P.[Description],
@PageSize as PaginationPageSize,
(
SELECT
Round(Count(0) / (@PageSize + 0.0) + 0.999)
FROM
PageReference as PR
INNER JOIN [Page] as P
ON P.Id = PR.PageId
WHERE
PR.ReferencesPageId = @PageId
AND PR.PageId <> PR.ReferencesPageId
) as PaginationPageCount
FROM
PageReference as PR
INNER JOIN [Page] as P
ON P.Id = PR.PageId
WHERE
PR.ReferencesPageId = @PageId
AND PR.PageId <> PR.ReferencesPageId
ORDER BY
P.[Name]
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,8 @@
SELECT
Id,
[Name],
[Description]
FROM
[Role]
WHERE
[Name] = @Name

View File

@@ -0,0 +1,53 @@
SELECT
P.Id,
P.[Name],
P.Navigation,
P.[Description],
P.Revision,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate,
@PageSize as PaginationPageSize,
(
SELECT
CAST((Count(0) + (@PageSize - 1.0)) / @PageSize AS INTEGER)
FROM
Page as P
WHERE
P.Id IN
(
SELECT
PT.PageId
FROM
PageTag as RootTags
LEFT OUTER JOIN PageTag as PT
ON PT.Tag = RootTags.Tag
WHERE
RootTags.PageId = @PageId
GROUP BY
PT.PageId
HAVING
((Count(0) / (SELECT COUNT(0) FROM PageTag as iP WHERE iP.PageId = @PageId)) * 100.0) >= @Similarity
)
) as PaginationPageCount
FROM
Page as P
WHERE
P.Id IN
(
SELECT
PT.PageId
FROM
PageTag as RootTags
LEFT OUTER JOIN PageTag as PT
ON PT.Tag = RootTags.Tag
WHERE
RootTags.PageId = @PageId
GROUP BY
PT.PageId
HAVING
((Count(0) / (SELECT COUNT(0) FROM PageTag as iP WHERE iP.PageId = @PageId)) * 100.0) >= @Similarity
)
LIMIT @PageSize
OFFSET (@PageNumber - 1) * @PageSize

View File

@@ -0,0 +1,6 @@
SELECT
Text
FROM
Words
LIMIT 1
OFFSET @Offset

View File

@@ -0,0 +1,16 @@
SELECT
P.Id,
P.[Name],
P.[Description],
P.[Revision],
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
ORDER BY
P.ModifiedDate DESC,
P.[Name] ASC
LIMIT @TopCount

View File

@@ -0,0 +1,18 @@
SELECT
P.Id,
P.[Name],
P.[Description],
P.[Revision],
P.Navigation,
P.CreatedByUserId,
P.CreatedDate,
P.ModifiedByUserId,
P.ModifiedDate
FROM
[Page] as P
WHERE
P.ModifiedByUserId = @UserId
ORDER BY
P.ModifiedDate DESC,
P.[Name] ASC
LIMIT @TopCount

View File

@@ -0,0 +1,6 @@
SELECT
UserId
FROM
Profile
WHERE
Navigation = @Navigation

View File

@@ -0,0 +1,11 @@
SELECT
(SELECT Count(0) FROM [Page]) as Pages,
(SELECT Count(DISTINCT Namespace) FROM [Page]) as Namespaces,
(SELECT Count(0) FROM [PageReference]) as IntraLinks,
(SELECT Count(0) FROM PageRevision) as PageRevisions,
(SELECT Count(0) FROM PageFile) as PageAttachments,
(SELECT Count(0) FROM PageFileRevision) as PageAttachmentRevisions,
(SELECT Count(0) FROM PageTag) as PageTags,
(SELECT Count(0) FROM PageToken) as PageSearchTokens,
(SELECT Count(0) FROM users_db.Profile) as Profiles,
(SELECT Count(0) FROM users_db.AspNetUsers) as Users

View File

@@ -0,0 +1,9 @@
SELECT
(SELECT Count(0) FROM [PageToken]) as Words,
(SELECT Count(0) FROM [Page]) as Pages,
(SELECT Count(0) FROM [PageTag]) as Tags,
(SELECT Count(0) FROM [User]) as Users,
(SELECT Count(0) FROM [PageRevision]) as PageRevisions,
(SELECT Count(0) FROM [PageFile]) as Attachments,
(SELECT SUM(DATALENGTH(Body)) FROM [PageRevision]) / 1024.0 / 1024.0 as TotalPageSizeMB,
(SELECT SUM(Size) FROM [PageFileRevision]) / 1024.0 / 1024.0 as TotalAttachmentSizeMB

View File

@@ -0,0 +1,4 @@
SELECT
Count(0)
FROM
Words

Some files were not shown because too many files have changed in this diff Show More