tblLicHistItem.intLicHistItemId AS lintLicHistItemId,
tblLicHistItem.lintLicHistId AS lintLicHistId,
tblLicHistItem.txtSerialNumber AS txtSerialNumber,
tblLicHistItem.lintComputerNodeId AS lintComputerNodeId,
tblNode.txtName AS txtComputer,
tblLicHistItem.lintCancelledByLicHistId AS lintCancelledById,
tblLicHist.dteDate AS dteCancelledDate,
tblUser.txtUser AS txtCancelledByUser
FROM
tblNode RIGHT JOIN ((
tblLicHistItem
LEFT JOIN
tblLicHist
ON tblLicHistItem.lintCancelledByLicHistId = tblLicHist.intLicHistId)
LEFT JOIN
tblUser
ON tblLicHist.lintUserId = tblUser.intUserId)
ON tblNode.intNodeId = tblLicHistItem.lintComputerNodeId
<% End Sub %>
<% Sub vInstHist %>
SELECT
tblInstHist.intInstHistId AS lintInstHistId,
tblInstHist.lintComputerNodeId AS lintComputerNodeId,
tblInstHist.lintProductId AS lintProductId,
tblNode.txtName AS txtComputer,
vProduct.txtName AS txtProduct,
vProduct.lintLangId AS lintLangId,
tblInstHist.dteDate AS dteDate,
tblInstHist.intCount AS intCount,
tblUser.txtName AS txtUser,
tblLicHistItem.txtSerialNumber AS txtSerialNumber,
tblInstHist.txtMemo AS txtMemo
FROM
tblLicHistItem
RIGHT JOIN (
tblUser
RIGHT JOIN (
vProduct
INNER JOIN (
tblInstHist
INNER JOIN
tblNode
ON tblInstHist.lintComputerNodeId = tblNode.intNodeId)
ON vProduct.intProductId = tblInstHist.lintProductId)
ON tblUser.intUserId = tblInstHist.lintUserId)
ON tblLicHistItem.intLicHistItemId = tblInstHist.lintLicHistItemId
WHERE NOT tblNode.bolHidden=<% WriteBool(True) %>
<% End Sub %>
<% Sub vProductComputerBase %>
SELECT
tblInstHist.lintProductId AS lintProductId,
tblInstHist.lintComputerNodeId AS lintComputerNodeId
FROM
vComputer
INNER JOIN (
tblInstHist
INNER JOIN
vProduct
ON tblInstHist.lintProductId=vProduct.intProductId)
ON vComputer.intComputerNodeId=tblInstHist.lintComputerNodeId
WHERE NOT vComputer.bolHidden=<% WriteBool(True) %>
GROUP BY tblInstHist.lintProductId, tblInstHist.lintComputerNodeId
HAVING SUM (tblInstHist.intCount)>0
<% End Sub %>
<% Sub vProductAllComputers %>
SELECT
vProduct.intProductId AS lintProductId,
vComputer.intComputerNodeId AS lintComputerNodeId
FROM vComputer <% If dbt=dbtJet Then %>,<% Else %>CROSS JOIN<% End If %> vProduct
WHERE NOT vComputer.bolHidden=<% WriteBool(True) %>
<% End Sub %>
<% Sub vLic1 %>
SELECT
tblLicHist.lintProductId AS lintProductId,
SUM(tblLicHist.intCountChange) AS intCount,
SUM(tblLicHist.intMultiCountChange) AS intMultiCount
FROM
tblLicHist
INNER JOIN
vProduct
ON tblLicHist.lintProductId=vProduct.intProductId
WHERE tblLicHist.dteDate <= <% WriteNow() %> AND
(tblLicHist.dteDateExpire IS NULL OR <% WriteNow() %> <= tblLicHist.dteDateExpire) AND
NOT EXISTS(
SELECT 1
FROM tblLicHistItem
WHERE tblLicHist.intLicHistId=tblLicHistItem.lintLicHistId AND tblLicHistItem.lintComputerNodeId IS NOT NULL)
GROUP BY tblLicHist.lintProductId
<% End Sub %>
<% Sub vLic2 %>
SELECT
tblLicHist.lintProductId AS lintProductId,
tblLicHistItem.lintComputerNodeId AS lintComputerNodeId
FROM
vComputer
INNER JOIN (
vProduct
INNER JOIN (
tblLicHist
INNER JOIN
tblLicHistItem
ON tblLicHist.intLicHistId=tblLicHistItem.lintLicHistId)
ON vProduct.intProductId=tblLicHist.lintProductId)
ON vComputer.intComputerNodeId=tblLicHistItem.lintComputerNodeId
WHERE NOT vComputer.bolHidden=<% WriteBool(True) %> AND
tblLicHist.dteDate <= <% WriteNow() %> AND (tblLicHist.dteDateExpire IS NULL OR <% WriteNow() %> <= tblLicHist.dteDateExpire) AND
tblLicHistItem.lintCancelledByLicHistId IS NULL
<% End Sub %>
<% Sub vLicHist %>
SELECT
tblLicHist.intLicHistId AS lintLicHistId,
tblLicHist.lintProductId AS lintProductId,
tblLicHist.dteDate AS dteDate,
tblLicHist.dteDateExpire AS dteDateExpire,
(tblLicHist.intMultiCountChange+tblLicHist.intCountChange) AS intChange,
tblLicHist.intMultiCountChange AS intMultiCountChange,
tblLicHist.txtMemo AS txtMemo,
vProduct.txtName AS txtProduct,
vProduct.lintLangId AS lintLangId
FROM
vProduct
INNER JOIN
tblLicHist
ON vProduct.intProductId = tblLicHist.lintProductId
<% End Sub %>
<% Sub vSwInstLast %>
SELECT
intInstHistId,
lintComputerNodeId,
lintProductId,
dteDate,
lintUserId,
txtMemo,
intCount,
lintLicHistItemId
FROM tblInstHist AS I
WHERE dteDate =
(SELECT MAX(dteDate)
FROM tblInstHist AS I2, vProduct
WHERE I.lintComputerNodeId = I2.lintComputerNodeId AND I.lintProductId = I2.lintProductId AND I2.intCount = 1 AND vProduct.intProductId = I2.lintProductId
)
<% End Sub %>
<% Sub vLicAudit %>
SELECT
vProduct.intProductId AS lintProductId,
vProduct.txtName AS txtProduct,
vProduct.lintLangId AS lintLangId,
tblCompany.txtName AS txtCompany,
vProduct.lintProductTypeId AS lintProductTypeId,
<% If dbt = dbtJet Then %>
IIF(vLic1.intCount IS NULL,0,vLic1.intCount) AS intLicCount,
IIF(vLic1.intMultiCount IS NULL,0,vLic1.intMultiCount) AS intLicMultiCount,
IIF(vLic2Count.intCount IS NULL,0,vLic2Count.intCount) AS intLicOEMCount,
IIF(vProductInstCount.intCount IS NULL,0,vProductInstCount.intCount) AS intInstAllCount,
IIF(vProductInstNotebootCount.intCount IS NULL,0,vProductInstNotebootCount.intCount) AS intInstNotebookCount,
IIF(vProductInstOEMCount.intCount IS NULL,0,vProductInstOEMCount.intCount) AS intInstOEMCount,
IIF(vInstTrialCount.intCount IS NULL,0,vInstTrialCount.intCount) AS intInstTrialCount,
(intInstAllCount-intInstNotebookCount-intInstOEMCount-intInstTrialCount) AS intInstCount,
IIF(lintProductTypeId=2,0,IIF(intLicMultiCount>0,0,(intInstCount+intInstOEMCount)-(intLicCount+intLicOEMCount))) AS intLicMissCount,
IIF(lintProductTypeId=2,0,IIF(intLicMultiCount>0,intLicCount,intLicCount-intInstCount)) AS intLicAddCount,
IIF(lintProductTypeId=2,0,intLicOEMCount-intInstOEMCount) AS intLicOEMAddCount
<% Else %>
ISNULL(vLic1.intCount,0) AS intLicCount,
ISNULL(vLic1.intMultiCount,0) AS intLicMultiCount,
ISNULL(vLic2Count.intCount,0) AS intLicOEMCount,
ISNULL(vProductInstCount.intCount,0) AS intInstAllCount,
ISNULL(vProductInstNotebootCount.intCount,0) AS intInstNotebookCount,
ISNULL(vProductInstOEMCount.intCount,0) AS intInstOEMCount,
ISNULL(vInstTrialCount.intCount,0) AS intInstTrialCount,
(ISNULL(vProductInstCount.intCount,0)-ISNULL(vProductInstNotebootCount.intCount,0)-ISNULL(vProductInstOEMCount.intCount,0)-ISNULL(vInstTrialCount.intCount,0)) AS intInstCount,
CASE vProduct.lintProductTypeId WHEN 2
THEN 0
ELSE CASE WHEN vLic1.intMultiCount IS NULL OR vLic1.intMultiCount=0
THEN (ISNULL(vProductInstCount.intCount,0)-ISNULL(vProductInstNotebootCount.intCount,0)-ISNULL(vInstTrialCount.intCount,0))-(ISNULL(vLic1.intCount,0)+ISNULL(vLic2Count.intCount,0))
ELSE 0
END
END AS intLicMissCount,
CASE vProduct.lintProductTypeId WHEN 2
THEN 0
ELSE CASE WHEN vLic1.intMultiCount IS NULL OR vLic1.intMultiCount=0
THEN ISNULL(vLic1.intCount,0)-(ISNULL(vProductInstCount.intCount,0)-ISNULL(vProductInstNotebootCount.intCount,0)-ISNULL(vProductInstOEMCount.intCount,0)-ISNULL(vInstTrialCount.intCount,0))
ON tblCompany.intCompanyId = tblInvoice.lintResellerCompanyId
;
CREATE VIEW vInstHist
AS <% Call vInstHist %>;
CREATE VIEW vInstTrialCount
AS
SELECT
tblInstTrial.lintProductId AS lintProductId,
COUNT(tblInstTrial.lintComputerNodeId) AS intCount
FROM
tblInstTrial
INNER JOIN
vProductComputer
ON tblInstTrial.lintComputerNodeId = vProductComputer.lintComputerNodeId AND tblInstTrial.lintProductId = vProductComputer.lintProductId
GROUP BY tblInstTrial.lintProductId
;
CREATE VIEW vLicHistAsset
AS <% Call vLicHistAsset %>;
CREATE VIEW vLicHist
AS <% Call vLicHist %>;
CREATE VIEW vLicHistItem
AS <% Call vLicHistItem %>;
CREATE VIEW vLicInst
AS
SELECT
vProductComputer.lintProductId AS lintProductId,
vProductComputer.lintComputerNodeId AS lintComputerNodeId
FROM vProductComputer
WHERE lintLicComputerNodeId IS NULL
;
CREATE VIEW vLicTrans
AS
SELECT
tblLicTrans.lintProductId AS lintProductId,
tblLicTrans.lintComputerNodeId AS lintComputerNodeId,
tblNode.txtName AS txtLicComputer
FROM
tblLicTrans
INNER JOIN
tblNode
ON tblLicTrans.lintLicComputerNodeId = tblNode.intNodeId
;
CREATE VIEW vProductAllComputers
AS <% Call vProductAllComputers %>;
CREATE VIEW vProductInstCount
AS
SELECT
vProductComputer.lintProductId AS lintProductId,
COUNT(*) AS intCount
FROM vProductComputer
GROUP BY lintProductId
;
CREATE VIEW vProductInstNotebootCount
AS
SELECT
vProductComputer.lintProductId AS lintProductId,
Count(*) AS intCount
FROM
vProductComputer
LEFT JOIN
tblInstTrial
ON vProductComputer.lintComputerNodeId = tblInstTrial.lintComputerNodeId AND vProductComputer.lintProductId = tblInstTrial.lintProductId
WHERE vProductComputer.lintLicComputerNodeId IS NOT NULL AND tblInstTrial.lintComputerNodeId IS NULL
GROUP BY vProductComputer.lintProductId
;
CREATE VIEW vProductInstOEMCount
AS
SELECT
vProductComputer.lintProductId AS lintProductId,
COUNT(*) AS intCount
FROM vProductComputer, vLic2
WHERE vLic2.lintProductId=vProductComputer.lintProductId AND vLic2.lintComputerNodeId= vProductComputer.lintComputerNodeId
GROUP BY vProductComputer.lintProductId
;
CREATE VIEW vLicAudit
AS <% Call vLicAudit %>;
CREATE VIEW vSWComputersBase
AS
SELECT
PC.lintProductId AS lintProductId,
N.intComputerNodeId AS lintComputerNodeId,
N.txtName AS txtComputer,
NUP.txtName AS txtParent
FROM
vProductComputer AS PC
INNER JOIN (
vComputer AS N
LEFT JOIN
tblNode AS NUP
ON NUP.intNodeId=N.lintParentId)
ON N.intComputerNodeId=PC.lintComputerNodeId
;
CREATE VIEW vSWComputers
AS
SELECT DISTINCT
vSWComputersBase.lintProductId AS lintProductId,
vSWComputersBase.lintComputerNodeId AS lintComputerNodeId,
vSWComputersBase.txtComputer AS txtComputer,
tblInstTrial.lintProductId AS lintTrial,
vLicTrans.txtLicComputer AS txtLicComputer,
vSWComputersBase.txtParent AS txtParent
FROM
vLicTrans
RIGHT JOIN (
tblInstTrial
RIGHT JOIN
vSWComputersBase
ON tblInstTrial.lintComputerNodeId = vSWComputersBase.lintComputerNodeId AND tblInstTrial.lintProductId = vSWComputersBase.lintProductId)
ON vLicTrans.lintComputerNodeId = vSWComputersBase.lintComputerNodeId AND vLicTrans.lintProductId = vSWComputersBase.lintProductId
;
CREATE VIEW vDetectUnassigned
AS
SELECT
tblDetFile.lintDetectId AS lintDetectId,
COUNT(*) AS UnassignedCount
FROM tblDetFile
WHERE lintProductId IS NULL
GROUP BY tblDetFile.lintDetectId
;
CREATE VIEW vDetProduct
AS
SELECT DISTINCT
lintDetectId,
lintProductId
FROM tblDetFile
;
CREATE VIEW vDetFolderProduct
AS
SELECT DISTINCT
lintDetectId,
txtFolderPath,
lintProductId
FROM tblDetFile
;
CREATE VIEW vFilesFromPath
AS
SELECT
intFileId,
tblFile.txtName AS txtFileName,
txtExt,
intSize,
tblFileStringInfo.lintFileId AS lintFileStringInfoFileId,
intLanguage,
intCodePage,
txtComments,
txtCompanyName,
txtFileDescription,
txtFileVersion,
txtInternalName,
txtLegalCopyright,
txtLegalTrademarks,
txtOriginalFilename,
txtProductName,
txtProductVersion,
txtPrivateBuild,
txtSpecialBuild,
tblFileVerInfo.lintFileId AS lintFileVerInfoFileId,
intFileVersionMS,
intFileVersionLS,
intProductVersionMS,
intProductVersionLS,
intFileFlagsMask,
intFileFlags,
intFileOS,
intFileType,
intFileSubtype,
intFileDateMS,
intFileDateLS,
intDetFileId,
tblDetFile.lintFileId AS lintDetFileFileId,
lintDetectId,
txtFolderPath,
dteCreated,
dteModified,
dteAccessed,
intAttribs,
lintProductId,
intProductId,
vProduct.txtName AS txtvProductName,
lintLangId,
lintProducerCompanyId,
lintProductTypeId,
lintProductCategoryId,
bolUser
FROM ((
tblFile
INNER JOIN (
vProduct
RIGHT JOIN
tblDetFile
ON vProduct.intProductId = tblDetFile.lintProductId)
ON tblFile.intFileId = tblDetFile.lintFileId)
LEFT JOIN
tblFileStringInfo
ON tblFile.intFileId = tblFileStringInfo.lintFileId)
LEFT JOIN
tblFileVerInfo
ON tblFile.intFileId = tblFileVerInfo.lintFileId
;
CREATE VIEW vImportFile
AS
SELECT
tblFile.intFileId AS lintFileId,
FI.intFileImportId AS lintFileImportId
FROM (
tblFileImport AS FI
INNER JOIN
tblFile
ON (FI.intSize = tblFile.intSize) AND (FI.txtExt = tblFile.txtExt) AND (FI.txtName = tblFile.txtName))
LEFT JOIN
tblFileVerInfo AS FVI
ON tblFile.intFileId = FVI.lintFileId
WHERE (FI.intFileVersionMS IS NULL AND FI.lintFileId IS NULL) OR (FI.intFileVersionMS=FVI.intFileVersionMS AND FI.intFileVersionLS=FVI.intFileVersionLS AND FI.intProductVersionMS=FVI.intProductVersionMS AND FI.intProductVersionLS=FVI.intProductVersionLS)
;
CREATE VIEW vRegPathGroup
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath
FROM tblRegValue
GROUP BY lintDetectId, lintRootRegKeyId, txtPath
;
CREATE VIEW vRegDisplayName
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtDisplayName, intRegValueId
FROM tblRegValue
WHERE txtName='DisplayName'
;
CREATE VIEW vRegDisplayVersion
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtDisplayVersion
FROM tblRegValue
WHERE tblRegValue.txtName='DisplayVersion'
;
CREATE VIEW vRegInstallDate
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtInstallDate
FROM tblRegValue
WHERE tblRegValue.txtName='InstallDate'
;
CREATE VIEW vRegLanguage
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtLanguage
FROM tblRegValue
WHERE tblRegValue.txtName='Language'
;
CREATE VIEW vRegProductId
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtProductId
FROM tblRegValue
WHERE tblRegValue.txtName='ProductId'
;
CREATE VIEW vRegPublisher
AS
SELECT lintDetectId, lintRootRegKeyId, txtPath, txtValue AS txtPublisher
FROM tblRegValue
WHERE tblRegValue.txtName='Publisher'
;
CREATE VIEW vSwInstLast
AS <% Call vSwInstLast %>;
INSERT INTO tblIdSeq (intNextNumber) VALUES (0);
INSERT INTO tblIdSeq (intNextNumber) VALUES (0);
<%
End Sub
%>
<%
Sub UpgradeDbX_v4v5
%>
ALTER TABLE tblNode
ADD bolHidden bit;
ALTER TABLE tblSetting
ADD intValue int;
<%
End Sub
%>
<%
Sub UpgradeDbX_7a8
%>
DROP VIEW vProductAllComputers;
CREATE VIEW vProductAllComputers
AS <% Call vProductAllComputers %>;
DROP VIEW vProductComputerBase;
CREATE VIEW vProductComputerBase
AS <% Call vProductComputerBase %>;
<% If dbt <> dbtJet Then %>
ALTER VIEW vLicAudit
AS <% Call vLicAudit %>;
<% End If %>
CREATE VIEW vSwInstLast
AS SELECT * FROM tblInstHist;
<%
End Sub
%>
<%
Sub UpgradeDbX_z9na10
%>
<% Call tblLicHistItem %>
ALTER TABLE tblInstHist
ADD lintLicHistItemId int CONSTRAINT FK_tblInstHist_lintLicHistItemId_tblLicHistInst_intLicHistItemId REFERENCES tblLicHistItem ( intLicHistItemId );
CREATE INDEX tblInstHist_lintLicHistItemId ON tblInstHist ( lintLicHistItemId );
ALTER TABLE tblLicHist
ADD dteDateExpire datetime,
lintUserId int CONSTRAINT FK_tblLicHist_lintUserId_tblUser_intUserId REFERENCES tblUser ( intUserId ),
lintCancelLicHistId int CONSTRAINT FK_tblLicHist_lintCancel_tblLicHist_intLicHistId REFERENCES tblLicHist ( intLicHistId );
CREATE INDEX tblLicHist_lintUserId ON tblLicHist ( lintUserId );
CREATE INDEX tblLicHist_lintCancelLicHistId ON tblLicHist ( lintCancelLicHistId );