sql 检索具有挂起更改的Umbraco文档列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 检索具有挂起更改的Umbraco文档列表相关的知识,希望对你有一定的参考价值。

SELECT umbracoNode.id,
       published.versionId AS publishedVersion,
       latest.versionId AS newestVersion
FROM (umbracoNode
      LEFT JOIN umbracoNode parent ON parent.parentID = umbracoNode.id
      INNER JOIN cmsContent content ON content.nodeId = umbracoNode.id
      LEFT JOIN cmsContentType contenttype ON contenttype.nodeId = content.contentType
      LEFT JOIN
        (SELECT nodeId,
                versionId
         FROM cmsDocument
         WHERE published = 1
         GROUP BY nodeId,
                  versionId) AS published ON umbracoNode.id = published.nodeId
      LEFT JOIN
        (SELECT nodeId,
                versionId
         FROM cmsDocument
         WHERE newest = 1
         GROUP BY nodeId,
                  versionId) AS latest ON umbracoNode.id = latest.nodeId)
WHERE published.versionId != latest.versionId
DECLARE @NodeId INT 
DECLARE my_cursor CURSOR local static read_only forward_only FOR 
  SELECT DISTINCT nodeid 
  FROM   cmsdocument 

OPEN my_cursor 

FETCH next FROM my_cursor INTO @NodeId 

WHILE @@FETCH_STATUS = 0 
  BEGIN 
      DECLARE @published DATETIME 
      DECLARE @newest DATETIME 

      SELECT @published = versiondate 
      FROM   cmscontentversion 
      WHERE  versionid = (SELECT TOP(1) versionid 
                          FROM   cmsdocument 
                          WHERE  nodeid = @NodeId 
                          ORDER  BY updatedate DESC) 

      SELECT TOP(1) @newest = updatedate 
      FROM   cmsdocument 
      WHERE  nodeid = @NodeId 
             AND published = 0 
      ORDER  BY updatedate DESC 

      IF @published IS NOT NULL AND @newest IS NOT NULL 
        BEGIN 
            DECLARE @difference INT 

            SET @difference = Datediff(second, @published, @newest) 

            IF @difference > 2 
              PRINT @NodeId 
        END 

      FETCH next FROM my_cursor INTO @NodeId 
  END 

CLOSE my_cursor 

DEALLOCATE my_cursor 

以上是关于sql 检索具有挂起更改的Umbraco文档列表的主要内容,如果未能解决你的问题,请参考以下文章

sql 按Umbraco中的文档类型删除所有节点

sql 按Umbraco中的文档类型删除所有节点

手动更改数据库后,Umbraco 友好 URL 不起作用

在 Umbraco 中使用实体框架或任何其他 ORM

sql Umbraco部门包 - 将相同的部门节点权限复制到另一个部门。 #umbraco #sql

Umbraco列表分页