Created
September 15, 2016 14:25
-
-
Save christoph2/c39665791bc655992b9899c975a9c944 to your computer and use it in GitHub Desktop.
KNX ETS4 Database Schema
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
-- [ApplProgsWithHashIssues] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - table for ApplicationPrograms with possible invalid hashes after Upgrade from Schema 1.0 to 1.1 | |
*/ | |
-- MediumType -- | |
IF object_id('ApplProgsWithHashIssues', 'U') IS NULL | |
begin | |
/** @brief table for ApplicationPrograms with possible invalid hashes after Upgrade from Schema 1.0 to 1.1. | |
@access EtsInternal | |
*/ | |
CREATE TABLE dbo.ApplProgsWithHashIssues | |
( | |
ApplicationProgramID varchar(300) not null primary key, ---< ID of the application program. | |
); | |
GRANT DELETE ON dbo.ApplProgsWithHashIssues TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplProgsWithHashIssues TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplProgsWithHashIssues TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplProgsWithHashIssues TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplProgsWithHashIssues TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplProgsWithHashIssues TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplProgsWithHashIssues TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplProgsWithHashIssues TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplProgsWithHashIssues TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplProgsWithHashIssues TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplProgsWithHashIssues TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplProgsWithHashIssues TO ETSWriteProjectAccess; | |
end | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ApplicationProgramTemporaryImportTables] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Temporary tables for application program import | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- ApplicationProgram | |
IF object_id('tempdb..#ApplicationProgram', 'U') IS NOT NULL DROP TABLE #ApplicationProgram; | |
/** @brief Internal temporary import table for ApplicationProgram information | |
*/ | |
create table #ApplicationProgram | |
( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
[Name] nvarchar(255), | |
Description nvarchar(max), | |
ApplicationNumber int, | |
ApplicationVersion smallint, | |
OriginalManufacturerID varchar(300), | |
ProgramType varchar(50), | |
MaskID varchar(300), | |
MinEtsVersion varchar(10), | |
HelpFile nvarchar(255), | |
HelpTopic nvarchar(50), | |
PEIType smallint, | |
Linkable bit, | |
LoadProcedureStyle varchar(20), | |
DynamicTableManagement bit, | |
AddressTableMaxEntries int, | |
AssociationTableMaxEntries int, | |
PreEts4Style bit, | |
DefaultLanguage varchar(20), | |
NonRegRelevantDataVersion int, | |
AddressTableSegmentID varchar(300), | |
AddressTableOffset int, | |
AssociationTableSegmentID varchar(300), | |
AssociationTableOffset int, | |
ComObjectTableSegmentID varchar(300), | |
ComObjectTableOffset int, | |
[Hash] varchar(max), | |
LoadProcedures xml, | |
EtsDownloadPlugin varchar(max), | |
EtsUiPlugin varchar(max), | |
EtsDataHandler varchar(max), | |
ReplacesVersions varchar(max), | |
ConvertedFromPreEts4Data bit, | |
RequiresExternalSoftware bit, | |
Broken bit, | |
EtsDataHandlerCapabilities varchar(200), | |
IPConfig varchar(20), | |
AdditionalAddressesCount int, | |
DownloadInfoIncomplete bit, | |
CreatedFromLegacySchemaVersion bit, | |
); | |
--GRANT ALL ON #ApplicationProgram TO EtsInternal; | |
GO | |
-- ApplicationProgramTranslatedText | |
IF object_id('tempdb..#ApplicationProgramTranslatedText', 'U') IS NOT NULL DROP TABLE #ApplicationProgramTranslatedText; | |
CREATE TABLE #ApplicationProgramTranslatedText | |
( | |
ApplicationProgramID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedName nvarchar(255), | |
TranslatedDescription nvarchar(max), | |
TranslatedHelpFile nvarchar(255), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationProgramTranslatedText TO EtsInternal; | |
GO | |
-- ApplicationProgramDynamic | |
IF object_id('tempdb..#ApplicationProgramDynamic', 'U') IS NOT NULL DROP TABLE #ApplicationProgramDynamic; | |
CREATE TABLE #ApplicationProgramDynamic | |
( | |
ApplicationProgramID varchar(300), | |
ApplicationProgramDynamic xml, | |
); | |
-- DeviceCompare | |
IF object_id('tempdb..#DeviceCompare', 'U') IS NOT NULL DROP TABLE #DeviceCompare; | |
CREATE TABLE #DeviceCompare | |
( | |
ApplicationProgramID varchar(300), | |
Excludes xml, | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationProgramDynamic TO EtsInternal; | |
GO | |
IF object_id('tempdb..#ApplicationProgramDynamicTranslatedText', 'U') IS NOT NULL DROP TABLE #ApplicationProgramDynamicTranslatedText; | |
CREATE TABLE #ApplicationProgramDynamicTranslatedText | |
( | |
ApplicationProgramID varchar(300), | |
ElementID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(max), | |
); | |
-- ApplicationProgramOption | |
IF object_id('tempdb..#ApplicationProgramOption', 'U') IS NOT NULL DROP TABLE #ApplicationProgramOption; | |
CREATE TABLE #ApplicationProgramOption | |
( | |
ApplicationProgramID varchar(300), | |
PreferPartialDownload bit, | |
EasyControlModeStyle bit, | |
ObjectTableLengthAlwaysOne bit, | |
TextParameterEncoding varchar(100), | |
TextParameterZeroTerminate bit, | |
ParameterByteOrder varchar(50), | |
LegacyNoPartialDownload bit, | |
LegacyNoMemoryWriteVerify bit, | |
LegacyNoOptimisticWrite bit, | |
LegacyNoPropertyWriteErrors bit, | |
LegacyNoBackgroundDownload bit, | |
LegacyDoNotCheckManufacturer bit, | |
LegacyAlwaysReloadOnCoVisibilityChange bit, | |
LegacyNeverReloadOnCoVisibilityChange bit, | |
LegacyNoSupportOfUndoDelete bit, | |
LegacyAllowPartialDownloadOnAp2Mismatch bit, | |
LegacyKeepObjectTableGaps bit, | |
PartialDownloadOnlyVisibleParameters bit, | |
LegacyProxyCommunicationObjects bit, | |
DeviceInfoIgnoreRunState bit default 0, | |
DeviceInfoIgnoreLoadedState bit default 0, | |
DeviceCompareAllowCompatibleManufacturerId bit default 0, | |
LineCoupler0912NewProgrammingStyle bit default 0, | |
TextParameterEncodingSelector varchar(50), | |
Comparable bit, | |
Reconstructable bit | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationProgramOption TO EtsInternal; | |
GO | |
-- ApplicationSegment | |
IF object_id('tempdb..#ApplicationSegment', 'U') IS NOT NULL DROP TABLE #ApplicationSegment; | |
CREATE TABLE #ApplicationSegment | |
( | |
ID varchar(300), | |
ProgramID varchar(300) not null, | |
[Name] varchar(50), | |
AddressSpace smallint, | |
InterfaceObjectRef smallint, | |
Address int, | |
[Size] int, | |
LoadStateMachine int, | |
MemoryType varchar(100), | |
Data varbinary(max), | |
Mask varbinary(max) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationSegment | |
GO | |
-- ParameterType | |
IF object_id('tempdb..#ParameterType', 'U') IS NOT NULL DROP TABLE #ParameterType; | |
CREATE TABLE #ParameterType | |
( | |
ID varchar(300), | |
ApplicationProgramID varchar(300), | |
[Name] varchar(50) not null, | |
Plugin varchar(max), | |
[InternalDescription] varchar(max) default null, | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterType TO EtsInternal; | |
GO | |
-- ParameterTypeTime | |
IF object_id('tempdb..#ParameterTypeTime', 'U') IS NOT NULL DROP TABLE #ParameterTypeTime; | |
CREATE TABLE #ParameterTypeTime | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
SizeInBit int, | |
Unit varchar(40), | |
MinInclusive bigint, | |
MaxInclusive bigint, | |
UIHint varchar(20) | |
); | |
GO | |
-- ParameterTypeNumber | |
IF object_id('tempdb..#ParameterTypeNumber', 'U') IS NOT NULL DROP TABLE #ParameterTypeNumber; | |
CREATE TABLE #ParameterTypeNumber | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
SizeInBit int, | |
Type varchar(20), | |
MinInclusive bigint, | |
MaxInclusive bigint, | |
UIHint varchar(20) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterTypeNumber TO EtsInternal; | |
GO | |
-- ParameterTypeFloat | |
IF object_id('tempdb..#ParameterTypeFloat', 'U') IS NOT NULL DROP TABLE #ParameterTypeFloat; | |
CREATE TABLE #ParameterTypeFloat | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
Encoding varchar(30), | |
MinInclusive float, | |
MaxInclusive float, | |
DisplayFormat varchar(100), | |
UIHint varchar(20), | |
FormattingScript nvarchar(max) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterTypeFloat TO EtsInternal; | |
GO | |
-- ParameterTypeText | |
IF object_id('tempdb..#ParameterTypeText', 'U') IS NOT NULL DROP TABLE #ParameterTypeText; | |
CREATE TABLE #ParameterTypeText | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
SizeInBit bigint, | |
Pattern nvarchar(max) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterTypeText TO EtsInternal; | |
GO | |
-- ParameterTypeDate | |
IF object_id('tempdb..#ParameterTypeDate', 'U') IS NOT NULL DROP TABLE #ParameterTypeDate; | |
CREATE TABLE #ParameterTypeDate | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
Encoding varchar(50), | |
DisplayTheYear bit default 1 | |
); | |
GO | |
-- ParameterTypeIPAddress | |
IF object_id('tempdb..#ParameterTypeIPAddress', 'U') IS NOT NULL DROP TABLE #ParameterTypeIPAddress; | |
CREATE TABLE #ParameterTypeIPAddress | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
AddressType varchar(50), | |
Version varchar(20), | |
); | |
GO | |
-- ParameterTypePicture | |
IF object_id('tempdb..#ParameterTypePicture', 'U') IS NOT NULL DROP TABLE #ParameterTypePicture; | |
CREATE TABLE #ParameterTypePicture | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
BaggageId varchar(300), | |
HorizontalAlignment varchar(10) | |
); | |
GO | |
-- ParameterTypeRestriction | |
IF object_id('tempdb..#ParameterTypeRestriction', 'U') IS NOT NULL DROP TABLE #ParameterTypeRestriction; | |
CREATE TABLE #ParameterTypeRestriction | |
( | |
ID uniqueidentifier, | |
ParameterTypeID varchar(300), | |
SizeInBit bigint, | |
Base varchar(20), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterTypeRestriction TO EtsInternal; | |
GO | |
-- ParameterEnumValue | |
IF object_id('tempdb..#ParameterEnumValue', 'U') IS NOT NULL DROP TABLE #ParameterEnumValue; | |
CREATE TABLE #ParameterEnumValue | |
( | |
ID varchar(300), | |
ParameterTypeID varchar(300), | |
[Value] bigint, | |
[Text] nvarchar(255), | |
DisplayOrder smallint, | |
BinaryValue varbinary(max), | |
AutomaticDisplayOrder bit | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterEnumValue TO EtsInternal; | |
GO | |
-- ParameterEnumValueTranslatedText | |
IF object_id('tempdb..#ParameterEnumValueTranslatedText', 'U') IS NOT NULL DROP TABLE #ParameterEnumValueTranslatedText; | |
CREATE TABLE #ParameterEnumValueTranslatedText | |
( | |
ParameterEnumValueID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(255), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterEnumValueTranslatedText TO EtsInternal; | |
GO | |
-- ParameterCalculation | |
IF object_id('tempdb..#ParameterCalculation', 'U') IS NOT NULL DROP TABLE #ParameterCalculation; | |
CREATE TABLE #ParameterCalculation | |
( | |
ID varchar(300), | |
ProgramID varchar(300), | |
[Name] varchar(50), | |
[Language] varchar(20), | |
LRTransformation varchar(max), | |
RLTransformation varchar(max), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterCalculation TO EtsInternal; | |
GO | |
-- ParameterUnion | |
IF object_id('tempdb..#ParameterUnion', 'U') IS NOT NULL DROP TABLE #ParameterUnion; | |
CREATE TABLE #ParameterUnion | |
( | |
ID varchar(300), | |
ApplicationProgramID varchar(300), | |
SizeInBit bigint, | |
Type varchar(50), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterUnion TO EtsInternal; | |
GO | |
-- Parameter | |
IF object_id('tempdb..#Parameter', 'U') IS NOT NULL DROP TABLE #Parameter; | |
CREATE TABLE #Parameter | |
( | |
ID varchar(300), | |
ApplicationProgramID varchar(300), | |
[Name] varchar(50), | |
[Text] nvarchar(255), | |
ParameterTypeID varchar(300), | |
Access varchar(15), | |
Value sql_variant, | |
ValueType varchar(128), | |
Type varchar(50), | |
LegacyPatchAlways bit, | |
ParameterUnionOffset int, | |
ParameterUnionBitOffset smallint, | |
ParameterUnionID varchar(300), | |
DefaultUnionParameter bit, | |
SuffixText nvarchar(20) | |
); | |
GO | |
-- ParameterMemory | |
IF object_id('tempdb..#ParameterMemory', 'U') IS NOT NULL DROP TABLE #ParameterMemory; | |
CREATE TABLE #ParameterMemory | |
( | |
ID varchar(300), | |
ParameterID varchar(300), | |
ParameterUnionID varchar(300), | |
CodeSegmentID varchar(300), | |
Offset bigint, | |
BitOffset smallint, | |
); | |
GO | |
-- ParameterProperty | |
IF object_id('tempdb..#ParameterProperty', 'U') IS NOT NULL DROP TABLE #ParameterProperty; | |
CREATE TABLE #ParameterProperty | |
( | |
ID varchar(300), | |
ParameterID varchar(300), | |
ParameterUnionID varchar(300), | |
ObjectIndex smallint, | |
ObjectType int, | |
Occurrence smallint, | |
PropertyId smallint, | |
Offset bigint, | |
BitOffset smallint, | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterProperty TO EtsInternal; | |
GO | |
-- ParameterTranslatedText | |
IF object_id('tempdb..#ParameterTranslatedText', 'U') IS NOT NULL DROP TABLE #ParameterTranslatedText; | |
CREATE TABLE #ParameterTranslatedText | |
( | |
ParameterID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(255), | |
TranslatedDefaultValue nvarchar(max), | |
TranslatedSuffixText nvarchar(20), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterTranslatedText TO EtsInternal; | |
GO | |
-- ParameterRef | |
IF object_id('tempdb..#ParameterRef', 'U') IS NOT NULL DROP TABLE #ParameterRef; | |
CREATE TABLE #ParameterRef | |
( | |
ID varchar(300), | |
ApplicationProgramID varchar(300), | |
ParameterID varchar(300), | |
[Name] varchar(50), | |
[Text] nvarchar(255), | |
DisplayOrder int, | |
Access varchar(15), | |
Value sql_variant, | |
ValueType varchar(128), | |
CalculationID varchar(300), | |
CalculationSet varchar(1), | |
AliasName varchar(50), | |
AutomaticDisplayOrder bit, | |
Tag nvarchar(max), | |
SuffixText nvarchar(20) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterRef TO EtsInternal; | |
GO | |
-- ParameterRefTranslatedText | |
IF object_id('tempdb..#ParameterRefTranslatedText', 'U') IS NOT NULL DROP TABLE #ParameterRefTranslatedText; | |
CREATE TABLE #ParameterRefTranslatedText | |
( | |
ParameterRefID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(255), | |
TranslatedDefaultValue nvarchar(max), | |
TranslatedSuffixText nvarchar(20), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ParameterRefTranslatedText TO EtsInternal; | |
GO | |
-- ParameterCalculation.LParameter | |
IF object_id('tempdb..#LParameter', 'U') IS NOT NULL DROP TABLE #LParameter; | |
CREATE TABLE #LParameter | |
( | |
ParameterCalculationID varchar(300), | |
ParameterRefID varchar(300), | |
AliasName varchar(50), | |
) | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #LParameter TO EtsInternal; | |
GO | |
-- ParameterCalculation.RParameter | |
IF object_id('tempdb..#RParameter', 'U') IS NOT NULL DROP TABLE #RParameter; | |
CREATE TABLE #RParameter | |
( | |
ParameterCalculationID varchar(300), | |
ParameterRefID varchar(300), | |
AliasName varchar(50), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #RParameter TO EtsInternal; | |
GO | |
-- CommunicationObject | |
IF object_id('tempdb..#CommunicationObject', 'U') IS NOT NULL DROP TABLE #CommunicationObject; | |
CREATE TABLE #CommunicationObject | |
( | |
ID varchar(300) primary key, | |
ProgramID varchar(300), | |
[Name] nvarchar(50), | |
[Text] nvarchar(255), | |
[FunctionText] nvarchar(255), | |
VisibleDescription nvarchar(max), | |
Number bigint, | |
ObjectSize varchar(20), | |
ReadFlag bit, | |
WriteFlag bit, | |
CommunicationFlag bit, | |
TransmitFlag bit, | |
UpdateFlag bit, | |
ReadOnInitFlag bit, | |
DatapointType varchar(max), | |
Priority varchar(6), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #CommunicationObject TO EtsInternal; | |
GO | |
-- CommunicationObjectTranslatedText | |
IF object_id('tempdb..#CommunicationObjectTranslatedText', 'U') IS NOT NULL DROP TABLE #CommunicationObjectTranslatedText; | |
CREATE TABLE #CommunicationObjectTranslatedText | |
( | |
CommunicationObjectID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(255), | |
TranslatedFunction nvarchar(255), | |
TranslatedDescription nvarchar(max), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #CommunicationObjectTranslatedText TO EtsInternal; | |
GO | |
-- CommunicationObjectRef | |
IF object_id('tempdb..#CommunicationObjectRef', 'U') IS NOT NULL DROP TABLE #CommunicationObjectRef; | |
CREATE TABLE #CommunicationObjectRef | |
( | |
ID varchar(300), | |
CommunicationObjectID varchar(300), | |
ApplicationProgramID varchar(300), | |
[Name] nvarchar(50), | |
[Text] nvarchar(255), | |
[FunctionText] nvarchar(255), | |
VisibleDescription nvarchar(max), | |
ObjectSize varchar(20), | |
ReadFlag bit, | |
WriteFlag bit, | |
CommunicationFlag bit, | |
TransmitFlag bit, | |
UpdateFlag bit, | |
ReadOnInitFlag bit, | |
DatapointType varchar(max), | |
Priority varchar(6), | |
Tag nvarchar(max) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #CommunicationObjectRef TO EtsInternal; | |
GO | |
-- CommunicationObjectRefTranslatedText | |
IF object_id('tempdb..#CommunicationObjectRefTranslatedText', 'U') IS NOT NULL DROP TABLE #CommunicationObjectRefTranslatedText; | |
CREATE TABLE #CommunicationObjectRefTranslatedText | |
( | |
CommunicationObjectRefID varchar(300), | |
[Language] varchar(20), | |
[Version] int, | |
TranslatedText nvarchar(255), | |
TranslatedFunction nvarchar(255), | |
TranslatedDescription nvarchar(max), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #CommunicationObjectRefTranslatedText TO EtsInternal; | |
GO | |
-- AddressFixup | |
IF object_id('tempdb..#AddressFixup', 'U') IS NOT NULL DROP TABLE #AddressFixup; | |
CREATE TABLE #AddressFixup | |
( | |
ProgramID varchar(300), | |
MaskEntryID varchar(300), | |
SegmentID varchar(300), | |
Offset int, | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #AddressFixup TO EtsInternal; | |
GO | |
-- ApplicationBinaryData | |
IF object_id('tempdb..#ApplicationBinaryData', 'U') IS NOT NULL DROP TABLE #ApplicationBinaryData; | |
CREATE TABLE #ApplicationBinaryData | |
( | |
ID varchar(300), | |
ProgramID varchar(300), | |
[Name] varchar(50), | |
Data varbinary(max) | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationBinaryData TO EtsInternal; | |
GO | |
-- ApplicationProgramBaggage | |
IF object_id('tempdb..#ApplicationProgramBaggage', 'U') IS NOT NULL DROP TABLE #ApplicationProgramBaggage; | |
create table #ApplicationProgramBaggage | |
( | |
ApplicationProgramID varchar(300), | |
BaggageID varchar(300), | |
); | |
--GRANT DELETE, UPDATE, SELECT, INSERT ON #ApplicationProgramBaggage TO EtsInternal; | |
GO | |
IF object_id('tempdb..#ApplicationProgramLanguageVersion', 'U') IS NOT NULL DROP TABLE #ApplicationProgramLanguageVersion; | |
create table #ApplicationProgramLanguageVersion | |
( | |
ApplicationProgramID varchar(300), | |
[Language] varchar(20), | |
CurrentVersion int, | |
); | |
GO | |
-------------------------------------------------------------------------------- | |
-- [Base64Conversion] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains functions that convert base64 string and binary data (varbinary) | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_Base64ToBinary') | |
BEGIN | |
DROP Function dbo.ufn_Base64ToBinary | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_Base64ToBinary | |
( | |
@value varchar(max) | |
) | |
RETURNS varbinary(max) | |
AS | |
BEGIN | |
if @value is not null | |
begin | |
declare @converted varbinary(max) | |
set @converted = (select cast(N'' as xml).value('xs:base64Binary(sql:variable("@value"))', 'varbinary(max)')) | |
return @converted | |
end | |
return null | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_Base64ToBinary TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_Base64ToBinary TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_Base64ToBinary TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_BinaryToBase64') | |
BEGIN | |
DROP Function dbo.ufn_BinaryToBase64 | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_BinaryToBase64 | |
( | |
@value varbinary(max) | |
) | |
RETURNS varchar(max) | |
AS | |
BEGIN | |
if @value is not null | |
begin | |
return (select cast(N'' as xml).value('xs:base64Binary(xs:hexBinary(sql:variable("@value")))', 'varchar(max)')) | |
end | |
return null | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_BinaryToBase64 TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_BinaryToBase64 TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_BinaryToBase64 TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [Bitmap1] | |
-------------------------------------------------------------------------------- | |
[base64 mime encoded serialized .NET Framework object] | |
-------------------------------------------------------------------------------- | |
-- [CatalogTemporaryImportTables] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Temporary tables for catalog data import | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- CatalogSection | |
IF object_id('tempdb..#CatalogSection', 'U') IS NOT NULL DROP TABLE #CatalogSection; | |
create table #CatalogSection | |
( | |
[ID] varchar(300), | |
[ManufacturerID] varchar(300), | |
[ParentCatalogSectionID] varchar(300), | |
[Name] nvarchar(255), | |
[Number] varchar(20) , | |
[VisibleDescription] nvarchar(max) , | |
[DefaultLanguage] varchar(20) , | |
[NonRegRelevantDataVersion] int | |
); | |
GO | |
IF object_id('tempdb..#CatalogItem', 'U') IS NOT NULL DROP TABLE #CatalogItem; | |
CREATE TABLE #CatalogItem( | |
[ID] [varchar](300) NOT NULL, | |
[CatalogSectionID] [varchar](300) NOT NULL, | |
[Name] [nvarchar](255) NULL, | |
[Number] [int] NOT NULL, | |
[VisibleDescription] [nvarchar](max) NULL, | |
[ProductID] [varchar](300) NOT NULL, | |
[Hardware2ProgramID] [varchar](300) NULL, | |
[DefaultLanguage] varchar(20) NULL, | |
[NonRegRelevantDataVersion] [int] NOT NULL, | |
[MediumTypes] [varchar](max) NULL | |
); | |
GO | |
IF object_id('tempdb..#CatalogSectionLanguages', 'U') IS NOT NULL DROP TABLE #CatalogSectionLanguages; | |
CREATE TABLE #CatalogSectionLanguages ( | |
[CatalogSectionID] [varchar](300) NOT NULL, | |
[Language] varchar(20) NOT NULL, | |
[Version] [int] NOT NULL, | |
[TranslatedName] [nvarchar](255) NULL, | |
[TranslatedDescription] [nvarchar](max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#CatalogItemLanguages', 'U') IS NOT NULL DROP TABLE #CatalogItemLanguages ; | |
CREATE TABLE #CatalogItemLanguages ( | |
[CatalogItemID] [varchar](300) NOT NULL, | |
[Language] varchar(20) NOT NULL, | |
[Version] [int] NOT NULL, | |
[TranslatedName] [nvarchar](255) NULL, | |
[TranslatedDescription] [nvarchar](max) NULL, | |
); | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CheckMasterDataVersion] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function for checking master data version | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CheckMasterDataVersion') | |
BEGIN | |
DROP FUNCTION dbo.ufn_CheckMasterDataVersion | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CheckMasterDataVersion | |
( | |
@importXml xml | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @versionInDatabase int | |
set @versionInDatabase = (select DISTINCT CurrentMasterDataVersion from DatabaseInfo) | |
if @versionInDatabase > 0 | |
begin | |
declare @versionInXml int | |
set @versionInXml = ISNULL(@importXml.value('(/KNX/MasterData/@Version)[1]', 'int'), 1) | |
if @versionInXml > @versionInDatabase | |
return 1 | |
else | |
return 0 | |
end | |
return 1 | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CheckMasterDataVersion TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_CheckMasterDataVersion TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_CheckMasterDataVersion TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CleanTemporaryApplicationProgramImportTables] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure clean up all temporary tables after or before import | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CleanTemporaryApplicationProgramImportTables') | |
BEGIN | |
DROP Procedure dbo.usp_CleanTemporaryApplicationProgramImportTables | |
END | |
GO | |
CREATE Procedure dbo.usp_CleanTemporaryApplicationProgramImportTables | |
AS | |
truncate table #ApplicationProgram | |
truncate table #ApplicationProgramDynamic | |
truncate table #DeviceCompare | |
truncate table #ApplicationProgramOption | |
truncate table #ApplicationSegment | |
truncate table #ParameterType | |
truncate table #ParameterTypeTime | |
truncate table #ParameterTypeNumber | |
truncate table #ParameterTypeFloat | |
truncate table #ParameterTypeText | |
truncate table #ParameterTypeDate | |
truncate table #ParameterTypeIPAddress | |
truncate table #ParameterTypeRestriction | |
truncate table #ParameterTypePicture | |
truncate table #ParameterEnumValue | |
truncate table #ParameterCalculation | |
truncate table #ParameterUnion | |
truncate table #Parameter | |
truncate table #ParameterMemory | |
truncate table #ParameterProperty | |
truncate table #ParameterRef | |
truncate table #LParameter | |
truncate table #RParameter | |
truncate table #CommunicationObject | |
truncate table #CommunicationObjectRef | |
truncate table #AddressFixup | |
truncate table #ApplicationBinaryData | |
truncate table #ApplicationProgramBaggage | |
truncate table #CommunicationObjectRefTranslatedText | |
truncate table #CommunicationObjectTranslatedText | |
truncate table #ParameterRefTranslatedText | |
truncate table #ParameterTranslatedText | |
truncate table #ParameterEnumValueTranslatedText | |
truncate table #ApplicationProgramTranslatedText | |
truncate table #ApplicationProgramLanguageVersion | |
truncate table #ApplicationProgramDynamicTranslatedText | |
GO | |
GRANT EXEC ON dbo.usp_CleanTemporaryApplicationProgramImportTables TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CleanTemporaryApplicationProgramImportTables TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CleanTemporaryApplicationProgramImportTables TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CleanupCatalogItems] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Procedure - Cleanup catalog items that are replaced by import aof application program shapes | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CleanupCatalogItems') | |
BEGIN | |
DROP Procedure dbo.usp_CleanupCatalogItems | |
END | |
GO | |
CREATE PROCEDURE [dbo].[usp_CleanupCatalogItems] | |
@catalogItemXml xml = null | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @catalogItemXml | |
-- find imported catalog items | |
declare @importedCatalogItems table (ID varchar(300), ProductID varchar(300), Hardware2ProgramID varchar(300) ) | |
insert into @importedCatalogItems select ID, ProductID, Hardware2ProgramID from CatalogItem where ID in (select ID from openxml(@docHandle, '/ImportedCatalogItems/ImportedCatalogItem') with (ID varchar(300) '@ID')) | |
exec sp_xml_removedocument @docHandle | |
declare @catalogId varchar(300) | |
declare @productId varchar(300) | |
declare @h2PId varchar(300) | |
declare iterationCursor cursor local forward_only fast_forward read_only for select * from @importedCatalogItems | |
open iterationCursor | |
fetch next from iterationCursor into @catalogId, @productId, @h2PId | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from CatalogItem where ID in (select ID from CatalogItem | |
where ID<>@catalogId and ProductID=@productId | |
and dbo.ufn_Hardware2ProgramShapeId(Hardware2ProgramID)=dbo.ufn_Hardware2ProgramShapeId(@h2PId) | |
and Hardware2ProgramID<>@h2PId ) | |
-- cleanup duplicates (H2P and Product, but different ID) | |
if exists (select ID from CatalogItem where ID not in (select ID from @importedCatalogItems) and Hardware2ProgramID = @h2PId and ProductID = @productId ) | |
begin | |
delete from CatalogItem where ID=@catalogId | |
end | |
fetch next from iterationCursor into @catalogId, @productId, @h2PId | |
end | |
close iterationCursor | |
deallocate iterationCursor | |
GO | |
GRANT EXEC ON dbo.usp_CleanupCatalogItems TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CleanupCatalogItems TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_CleanupCatalogItems TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CleanupUnusedBaggages] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure clean up all unuesd baggages after import | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CleanupUnusedBaggages') | |
BEGIN | |
DROP PROCEDURE dbo.usp_CleanupUnusedBaggages | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_CleanupUnusedBaggages | |
AS | |
delete from Baggage output deleted.ID, deleted.ManufacturerID, deleted.TargetPath, deleted.Name where ID not in (select BaggageID from ApplicationProgramBaggage) and ID not in (select BaggageID from ProductBaggage) | |
GO | |
GRANT EXEC ON dbo.usp_CleanupUnusedBaggages TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CleanupUnusedBaggages TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CleanupUnusedBaggages TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CollectHashIssueUpdateData] | |
-------------------------------------------------------------------------------- | |
/** @file Stored Procedures - Stored procedures for collecting project data export | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CollectHashIssueUpdateData') | |
BEGIN | |
DROP Procedure dbo.usp_CollectHashIssueUpdateData | |
END | |
GO | |
CREATE Procedure dbo.usp_CollectHashIssueUpdateData | |
( | |
@sessionId uniqueidentifier | |
) | |
as | |
insert ExportCatalogSection select ID, ParentCatalogSectionID, ManufacturerID, @sessionId from CatalogSection | |
insert into ExportCatalogItem select CatalogItem.ID, ManufacturerID, @sessionId from CatalogItem inner join Product on CatalogItem.ProductID=Product.ID | |
insert into ExportHardware select ID, ManufacturerID, @sessionId from Hardware order by ManufacturerID | |
insert into ExportHardware2Program select ID, HardwareID, @sessionId from Hardware2Program | |
insert into ExportProduct select ID, ManufacturerID, @sessionId from Product | |
insert into ExportApplicationProgram select ID, ManufacturerID, @sessionId from ApplicationProgram | |
insert into ExportManufacturer select distinct(ManufacturerID), @sessionId from ExportHardware | |
select ID from ExportManufacturer as Manufacturers where SessionID=@sessionId order by ID | |
select ID, ManufacturerID from ExportApplicationProgram as ApplicationPrograms where SessionID=@sessionId order by ID | |
GO | |
GRANT EXEC ON dbo.usp_CollectHashIssueUpdateData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CollectHashIssueUpdateData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CollectHashIssueUpdateData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CollectProductExportData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedures - Stored procedures for collecting product data export | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CollectProductExportData') | |
BEGIN | |
DROP Procedure dbo.usp_CollectProductExportData | |
END | |
GO | |
CREATE Procedure dbo.usp_CollectProductExportData | |
( | |
@catalogItemsXml xml, | |
@sessionId uniqueidentifier | |
) | |
as | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @catalogItemsXml | |
declare @catalogItemsToExport table(ID varchar(300)) | |
insert into @catalogItemsToExport select ID from openxml( @docHandle, '/CatalogItems/CatalogItem') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @hardware2ProgramOfCatalogItems table(ID varchar(300) ) | |
insert into @hardware2ProgramOfCatalogItems select Hardware2ProgramID from CatalogItem where ID in (select ID from @catalogItemsToExport) | |
-- Hardware2Program's referenced | |
insert into ExportHardware2Program select distinct(ID), HardwareID, @sessionId from Hardware2Program where ID in (select ID from @hardware2ProgramOfCatalogItems) | |
--referenced catalog items | |
declare @catalogItems table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @catalogItems select distinct(CatalogItem.ID), ManufacturerID from CatalogItem inner join Product on CatalogItem.ProductID=Product.ID where CatalogItem.ID in (select ID from @catalogItemsToExport) | |
declare @hardware table( ID varchar(300) ) | |
insert into @hardware select HardwareID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) | |
declare @products table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @products select ID, ManufacturerID from Product where ID in (select ProductID from CatalogItem where ID in (select ID from @catalogItems)) | |
insert into ExportHardware select distinct(ID), ManufacturerID, @sessionId from Hardware where ID in (select ID from @hardware) | |
delete from @hardware | |
-- collect all hardware2programs referencing the collected hardware (required from application program exchange) | |
--insert into ExportHardware2Program select distinct(ID), HardwareID, @sessionId from Hardware2Program where HardwareID in (select ID from ExportHardware) and ID not in (select ID from ExportHardware2Program) | |
insert into ExportCatalogItem select distinct(ID), ManufacturerID, @sessionId from @catalogItems | |
delete from @catalogItems | |
insert into ExportProduct select distinct(ID), ManufacturerID, @sessionId from @products | |
delete from @products | |
-- ApplicationPrograms and PEI programs referenced | |
declare @applicationProgramIdsTemp table( ID varchar(300) ) | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgramID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgramID is not null | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgram2ID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgram2ID is not null | |
insert into ExportApplicationProgram select distinct(ID), ManufacturerID, @sessionId from ApplicationProgram where ID in (select ID from @applicationProgramIdsTemp) | |
delete from @applicationProgramIdsTemp | |
-- referenced catalog sections | |
declare @catalogSections table( ID varchar(300), ParentID varchar(300), ManufacturerID varchar(300) ) | |
insert into @catalogSections select CatalogSection.ID, ParentCatalogSectionID, ManufacturerID from CatalogSection inner join CatalogItem on CatalogSection.ID=CatalogItem.CatalogSectionID where CatalogItem.ID in (select ID from ExportCatalogItem where SessionID=@sessionId) | |
insert ExportCatalogSection select distinct(ID), ParentID, ManufacturerID, @sessionId from @catalogSections | |
-- insert all sections in parent chain as well | |
declare sectionCursor cursor local forward_only fast_forward read_only for select distinct(ID), ManufacturerID from ExportCatalogSection where SessionID=@sessionId | |
open sectionCursor | |
declare @sectionId varchar(300) | |
declare @manufacturerId varchar(300) | |
fetch next from sectionCursor into @sectionId, @manufacturerId | |
while @@FETCH_STATUS = 0 | |
begin | |
exec dbo.usp_CollectParentCatalogSectionsForExport @sectionId, @manufacturerId, @sessionId | |
fetch next from sectionCursor into @sectionId, @manufacturerId | |
end | |
close sectionCursor | |
deallocate sectionCursor | |
-- referenced baggages (ApplicationProgramBaggage and ProductBaggage) | |
declare @baggages table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @baggages select BaggageID, ManufacturerID from ApplicationProgramBaggage inner join ApplicationProgram on ApplicationProgramBaggage.ApplicationProgramID=ApplicationProgram.ID where ApplicationProgramID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into @baggages select BaggageID, ManufacturerID from ProductBaggage inner join Product on ProductBaggage.ProductID=Product.ID where ProductID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into ExportBaggage select distinct(ID), ManufacturerID, @sessionId, Name, TargetPath from Baggage where ID in (select ID from @baggages) | |
delete from @baggages | |
-- involved manufacturers | |
declare @manufacturers table( ID varchar(300) ) | |
insert into @manufacturers select ManufacturerID from Hardware where ID in (select ID from ExportHardware where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from Product where ID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from ApplicationProgram where ID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into ExportManufacturer select distinct(ID), @sessionId from @manufacturers | |
select ID from ExportManufacturer as Manufacturers where SessionID=@sessionId order by ID | |
select ID, ManufacturerID from ExportApplicationProgram as ApplicationPrograms where SessionID=@sessionId order by ID | |
select ID, ManufacturerID, Name, TargetPath from ExportBaggage as Baggages where SessionID=@sessionId order by ID | |
GO | |
GRANT EXEC ON dbo.usp_CollectProductExportData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CollectProductExportData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CollectProductExportData TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CollectProductExportData2') | |
BEGIN | |
DROP Procedure dbo.usp_CollectProductExportData2 | |
END | |
GO | |
CREATE Procedure dbo.usp_CollectProductExportData2 | |
( | |
@catalogItemsXml xml, | |
@sessionId uniqueidentifier | |
) | |
as | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @catalogItemsXml | |
declare @catalogItemsToExport table(ProductID varchar(300), Hardware2ProgramID varchar(300)) | |
insert into @catalogItemsToExport select ProductID, Hardware2ProgramID from openxml( @docHandle, '/CatalogItems/CatalogItem') with (ProductID nvarchar(300) '@ProductId', Hardware2ProgramID nvarchar(300) '@Hardware2ProgramId') | |
exec sp_xml_removedocument @docHandle | |
declare @hardware2ProgramOfCatalogItems table(ID varchar(300) ) | |
insert into @hardware2ProgramOfCatalogItems select Hardware2ProgramID from @catalogItemsToExport | |
-- Hardware2Program's referenced | |
insert into ExportHardware2Program select distinct(ID), HardwareID, @sessionId from Hardware2Program where ID in (select ID from @hardware2ProgramOfCatalogItems) | |
declare @hardware table( ID varchar(300) ) | |
insert into @hardware select HardwareID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) | |
declare @products table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @products select ID, ManufacturerID from Product where ID in (select ProductID from @catalogItemsToExport) | |
insert into ExportHardware select distinct(ID), ManufacturerID, @sessionId from Hardware where ID in (select ID from @hardware) | |
delete from @hardware | |
insert into ExportProduct select distinct(ID), ManufacturerID, @sessionId from @products | |
delete from @products | |
-- ApplicationPrograms and PEI programs referenced | |
declare @applicationProgramIdsTemp table( ID varchar(300) ) | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgramID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgramID is not null | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgram2ID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgram2ID is not null | |
insert into ExportApplicationProgram select distinct(ID), ManufacturerID, @sessionId from ApplicationProgram where ID in (select ID from @applicationProgramIdsTemp) | |
delete from @applicationProgramIdsTemp | |
-- referenced baggages (ApplicationProgramBaggage and ProductBaggage) | |
declare @baggages table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @baggages select BaggageID, ManufacturerID from ApplicationProgramBaggage inner join ApplicationProgram on ApplicationProgramBaggage.ApplicationProgramID=ApplicationProgram.ID where ApplicationProgramID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into @baggages select BaggageID, ManufacturerID from ProductBaggage inner join Product on ProductBaggage.ProductID=Product.ID where ProductID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into ExportBaggage select distinct(ID), ManufacturerID, @sessionId, Name, TargetPath from Baggage where ID in (select ID from @baggages) | |
delete from @baggages | |
-- involved manufacturers | |
declare @manufacturers table( ID varchar(300) ) | |
insert into @manufacturers select ManufacturerID from Hardware where ID in (select ID from ExportHardware where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from Product where ID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from ApplicationProgram where ID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into ExportManufacturer select distinct(ID), @sessionId from @manufacturers | |
select ID from ExportManufacturer as Manufacturers where SessionID=@sessionId order by ID | |
select ID, ManufacturerID from ExportApplicationProgram as ApplicationPrograms where SessionID=@sessionId order by ID | |
select ID, ManufacturerID, Name, TargetPath from ExportBaggage as Baggages where SessionID=@sessionId order by ID | |
GO | |
GRANT EXEC ON dbo.usp_CollectProductExportData2 TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CollectProductExportData2 TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CollectProductExportData2 TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CollectProjectExportData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedures - Stored procedures for collecting project data export | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CollectProjectExportData') | |
BEGIN | |
DROP Procedure dbo.usp_CollectProjectExportData | |
END | |
GO | |
CREATE Procedure dbo.usp_CollectProjectExportData | |
( | |
@projectsXml xml, | |
@sessionId uniqueidentifier, | |
@exportCatalog bit = 1 | |
) | |
as | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @projectsXml | |
declare @projects table(ID varchar(300)) | |
insert into @projects select ID from openxml( @docHandle, '/Projects/Project') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
-- collect device related information | |
declare @deviceIds table(ID varchar(300), HardwareToProgramID varchar(300), ProductID varchar(300), InstallationID varchar(300)) | |
insert into @deviceIds select ID, Hardware2ProgramID, ProductID, InstallationID from Device where Device.InstallationID in (select ID from Installation where Installation.ProjectId in (select ID from @projects)) | |
-- Hardware2Program's referenced | |
insert into ExportHardware2Program select distinct(ID), HardwareID, @sessionId from Hardware2Program where ID in (select HardwareToProgramID from @deviceIds) | |
if @exportCatalog = 1 | |
begin | |
-- find catalog items that have the same combination of Hardware2ProgramID and ProductID as the devices we must export | |
declare @tempCatalogItems table( ID varchar(300) ) | |
insert into @tempCatalogItems select CatalogItem.ID from CatalogItem inner join @deviceIds on CatalogItem.ProductID+ISNULL(CatalogItem.Hardware2ProgramID, 'NULL')=[@deviceIds].ProductID+ISNULL([@deviceIds].HardwareToProgramID, 'NULL') | |
--referenced catalog items | |
declare @catalogItems table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @catalogItems select CatalogItem.ID, ManufacturerID from CatalogItem inner join Product on CatalogItem.ProductID=Product.ID where CatalogItem.ID in (select ID from @tempCatalogItems) | |
insert into ExportCatalogItem select distinct(ID), ManufacturerID, @sessionId from @catalogItems | |
delete from @catalogItems | |
end | |
declare @hardware table( ID varchar(300) ) | |
insert into @hardware select HardwareID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) | |
declare @products table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @products select ID, ManufacturerID from Product where ID in (select ProductID from @deviceIds) | |
insert into ExportHardware select distinct(ID), ManufacturerID, @sessionId from Hardware where ID in (select ID from @hardware) | |
delete from @hardware | |
-- collect all hardware2programs referencing the collected hardware (required from application program exchange) | |
--insert into ExportHardware2Program select distinct(ID), HardwareID, @sessionId from Hardware2Program where HardwareID in (select ID from ExportHardware) and ID not in (select ID from ExportHardware2Program) | |
insert into ExportProduct select distinct(ID), ManufacturerID, @sessionId from @products | |
delete from @products | |
-- ApplicationPrograms and PEI programs referenced | |
declare @applicationProgramIdsTemp table( ID varchar(300) ) | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgramID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgramID is not null | |
insert into @applicationProgramIdsTemp select Hardware2Program.ApplicationProgram2ID from Hardware2Program where ID in(select ID from ExportHardware2Program where SessionID=@sessionId) and Hardware2Program.ApplicationProgram2ID is not null | |
insert into ExportApplicationProgram select distinct(ID), ManufacturerID, @sessionId from ApplicationProgram where ID in (select ID from @applicationProgramIdsTemp) | |
delete from @applicationProgramIdsTemp | |
if @exportCatalog = 1 | |
begin | |
-- referenced catalog sections | |
declare @catalogSections table( ID varchar(300), ParentID varchar(300), ManufacturerID varchar(300) ) | |
insert into @catalogSections select CatalogSection.ID, ParentCatalogSectionID, ManufacturerID from CatalogSection inner join CatalogItem on CatalogSection.ID=CatalogItem.CatalogSectionID where CatalogItem.ID in (select ID from ExportCatalogItem where SessionID=@sessionId) | |
insert ExportCatalogSection select distinct(ID), ParentID, ManufacturerID, @sessionId from @catalogSections | |
-- insert all sections in parent chain as well | |
declare sectionCursor cursor local forward_only fast_forward read_only for select distinct(ID), ManufacturerID from ExportCatalogSection where SessionID=@sessionId | |
open sectionCursor | |
declare @sectionId varchar(300) | |
declare @manufacturerId varchar(300) | |
fetch next from sectionCursor into @sectionId, @manufacturerId | |
while @@FETCH_STATUS = 0 | |
begin | |
exec dbo.usp_CollectParentCatalogSectionsForExport @sectionId, @manufacturerId, @sessionId | |
fetch next from sectionCursor into @sectionId, @manufacturerId | |
end | |
close sectionCursor | |
deallocate sectionCursor | |
end | |
-- referenced baggages (ApplicationProgramBaggage and ProductBaggage) | |
declare @baggages table( ID varchar(300), ManufacturerID varchar(300) ) | |
insert into @baggages select BaggageID, ManufacturerID from ApplicationProgramBaggage inner join ApplicationProgram on ApplicationProgramBaggage.ApplicationProgramID=ApplicationProgram.ID where ApplicationProgramID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into @baggages select BaggageID, ManufacturerID from ProductBaggage inner join Product on ProductBaggage.ProductID=Product.ID where ProductID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into ExportBaggage select distinct(ID), ManufacturerID, @sessionId, Name, TargetPath from Baggage where ID in (select ID from @baggages) | |
delete from @baggages | |
-- involved manufacturers | |
declare @manufacturers table( ID varchar(300) ) | |
insert into @manufacturers select ManufacturerID from Hardware where ID in (select ID from ExportHardware where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from Product where ID in (select ID from ExportProduct where SessionID=@sessionId) | |
insert into @manufacturers select ManufacturerID from ApplicationProgram where ID in (select ID from ExportApplicationProgram where SessionID=@sessionId) | |
insert into ExportManufacturer select distinct(ID), @sessionId from @manufacturers | |
-- referenced device binary data | |
insert into ExportDeviceBinaryData select DeviceBinaryData.ID, Installation.ProjectID, @sessionId from DeviceBinaryData inner join Device on DeviceBinaryData.DeviceID=Device.ID inner join Installation on Installation.ID=Device.InstallationID where Device.InstallationID in (select ID from Installation where ProjectID in (select ID from @projects)) | |
select ID from ExportManufacturer as Manufacturers where SessionID=@sessionId order by ID | |
select ID, ManufacturerID from ExportApplicationProgram as ApplicationPrograms where SessionID=@sessionId order by ID | |
select ID, ManufacturerID, Name, TargetPath from ExportBaggage as Baggages where SessionID=@sessionId order by ID | |
select ID, ProjectPassword, [Name] from Project where Id in (select ID from @projects) | |
select ID, ProjectId, InstallationId from Installation where ProjectId in (select ID from @projects) | |
select ID, ProjectID from ExportDeviceBinaryData where SessionID=@sessionId order by ID | |
select [Filename], ProjectID from UserFile where ProjectID in (select ID from @projects) order by ProjectID | |
select [Name], [AddinID], ProjectID from AddinData where ProjectID in (select ID from @projects) order by ProjectID, AddinID | |
GO | |
GRANT EXEC ON dbo.usp_CollectProjectExportData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CollectProjectExportData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CollectProjectExportData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CommunicationsFlags] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains functions that convert the communication flags (bit -> enabled/disabled) | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CommunicationFlags') | |
BEGIN | |
DROP Function dbo.ufn_CommunicationFlags | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CommunicationFlags | |
( | |
@value varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
if @value is null | |
begin | |
return null | |
end | |
if @value = 'Disabled' | |
begin | |
return 0 | |
end | |
return 1 | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CommunicationFlags TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_CommunicationFlags TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_CommunicationFlags TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CompareVersions] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains a function that compare tow version informations (eg. 1.2.3.0 < 2.0.0.0) | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CompareVersions') | |
BEGIN | |
DROP Function dbo.ufn_CompareVersions | |
END | |
GO | |
CREATE FUNCTION [dbo].[ufn_CompareVersions] | |
( | |
@v1 varchar(50), | |
@v2 varchar(50) | |
) | |
RETURNS int | |
AS | |
BEGIN | |
set @v1 = ISNULL(@v1, '0.0.0.0') | |
set @v2 = ISNULL(@v2, '0.0.0.0') | |
declare @start1 int | |
set @start1 = 1 | |
declare @start2 int | |
set @start2 = 1 | |
declare @counter int | |
set @counter = 0 | |
declare @part1 int | |
declare @part2 int | |
declare @end1 int | |
set @end1 = 0 | |
declare @end2 int | |
set @end2 = 0 | |
while @counter < 4 | |
begin | |
set @counter = @counter + 1 | |
if @counter = 4 | |
begin | |
set @part1 = convert(int, substring( @v1, @start1, len(@v1))) | |
set @part2 = convert(int, substring( @v2, @start2, len(@v2))) | |
end | |
else | |
begin | |
set @end1 = charindex( '.', @v1, @start1 ) | |
set @end2 = charindex( '.', @v2, @start2 ) | |
set @part1 = convert(int, substring( @v1, @start1, @end1 - @start1)) | |
set @part2 = convert(int, substring( @v2, @start2, @end2 - @start2)) | |
end | |
if @part1 <> @part2 | |
begin | |
return @part2 - @part1 | |
end | |
set @start1 = @end1 + 1 | |
set @start2 = @end2 + 1 | |
end | |
return 0 | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CompareVersions TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_CompareVersions TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_CompareVersions TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CompletionStatus] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains a function that convert the completion state | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CompletionStatus') | |
BEGIN | |
DROP Function dbo.ufn_CompletionStatus | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CompletionStatus | |
( | |
@value varchar(50) | |
) | |
RETURNS varchar(50) | |
AS | |
BEGIN | |
declare @CompletionStatus varchar(50) | |
set @CompletionStatus = ( select CASE | |
WHEN @value = 'undefined' THEN 'Undefined' | |
WHEN @value = 'editing' THEN 'Editing' | |
WHEN @value = 'finishedDesign' THEN 'FinishedDesign' | |
WHEN @value = 'finishedCommisioning' THEN 'FinishedCommisioning' | |
WHEN @value = 'tested' THEN 'Tested' | |
WHEN @value = 'accepted' THEN 'Accepted' | |
ELSE 'Undefined' | |
END) | |
return @CompletionStatus | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CompletionStatus TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_CompletionStatus TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_CompletionStatus TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CompletionStatusToXmlValue] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains a function that convert the db completion state to xml value style | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CompletionStatusToXmlValue') | |
BEGIN | |
DROP Function dbo.ufn_CompletionStatusToXmlValue | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CompletionStatusToXmlValue | |
( | |
@value varchar(50) | |
) | |
RETURNS varchar(50) | |
AS | |
BEGIN | |
declare @CompletionStatus varchar(50) | |
set @CompletionStatus = ( select CASE | |
WHEN @value = 'Undefined' THEN 'Undefined' | |
WHEN @value = 'Editing' THEN 'Editing' | |
WHEN @value = 'FinishedDesign' THEN 'FinishedDesign' | |
WHEN @value = 'FinishedCommisioning' THEN 'FinishedCommisioning' | |
WHEN @value = 'Tested' THEN 'Tested' | |
WHEN @value = 'Accepted' THEN 'Accepted' | |
ELSE 'Undefined' | |
END) | |
return @CompletionStatus | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CompletionStatusToXmlValue TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_CompletionStatusToXmlValue TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_CompletionStatusToXmlValue TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CopyApplicationBinaryDataToDeviceBinaryData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure creates a copy of application binary data for device binary data. This stored procedure is used by create device operation | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CopyApplicationBinaryDataToDeviceBinaryData') | |
BEGIN | |
DROP Procedure dbo.usp_CopyApplicationBinaryDataToDeviceBinaryData | |
END | |
GO | |
CREATE Procedure dbo.usp_CopyApplicationBinaryDataToDeviceBinaryData | |
( | |
@deviceId varchar(300), | |
@applicationProgramId varchar(300) | |
) | |
AS | |
INSERT INTO DeviceBinaryData SELECT newID(), @deviceId, [ID], [Name], [Data] FROM [ApplicationBinaryData] WHERE ProgramID = @applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_CopyApplicationBinaryDataToDeviceBinaryData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CopyApplicationBinaryDataToDeviceBinaryData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CopyApplicationBinaryDataToDeviceBinaryData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CopyCommunicationObjectReferencesToDeviceObjects] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure creates a copy of all communication object refs to device objects. This stored procedure is used by create device operation | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CopyCommunicationObjectReferencesToDeviceObjects') | |
BEGIN | |
DROP Procedure dbo.usp_CopyCommunicationObjectReferencesToDeviceObjects | |
END | |
GO | |
CREATE Procedure dbo.usp_CopyCommunicationObjectReferencesToDeviceObjects | |
( | |
@deviceId varchar(300), | |
@applicationProgramId varchar(300) | |
) | |
AS | |
INSERT INTO DeviceObject SELECT newId(), @deviceId, CoRef.[ID], null, null, null, null, null, null, null, null, null, null, null, null, ISNull(CoRef.ObjectSize, Co.ObjectSize) as ObjectSize, Co.Number as Number FROM [CommunicationObjectRef] CoRef inner join CommunicationObject Co on CoRef.CommunicationObjectID = Co.Id WHERE CoRef.ApplicationProgramID = @applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_CopyCommunicationObjectReferencesToDeviceObjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CopyCommunicationObjectReferencesToDeviceObjects TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CopyCommunicationObjectReferencesToDeviceObjects TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CopyParameterReferencesToDeviceParameters] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure creates a copy of all parameter refs to device parameter. This stored procedure is used by create device operation | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CopyParameterReferencesToDeviceParameter') | |
BEGIN | |
DROP Procedure dbo.usp_CopyParameterReferencesToDeviceParameter | |
END | |
GO | |
CREATE Procedure dbo.usp_CopyParameterReferencesToDeviceParameter | |
( | |
@deviceId varchar(300), | |
@applicationProgramId varchar(300) | |
) | |
AS | |
INSERT INTO DeviceParameter SELECT newID(), @deviceId, [ID], null, null FROM [ParameterRef] WHERE ApplicationProgramID = @applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_CopyParameterReferencesToDeviceParameter TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CopyParameterReferencesToDeviceParameter TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CopyParameterReferencesToDeviceParameter TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CopyScripts] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This file contains stored procedures for all copy operations. Internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProjectDataCounts') | |
BEGIN | |
DROP Procedure dbo.usp_GetProjectDataCounts | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProjectDataCounts | |
( | |
@projectId varchar(300), | |
@projectRelatedCount bigint output, | |
@topologyBuildingTradeCount bigint output, | |
@addressesRangeCount bigint output, | |
@deviceCount bigint output, | |
@deviceParameterCount bigint output, | |
@deviceObjectCount bigint output | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @areas table (ID varchar(300) ) | |
insert into @areas select ID from Area where InstallationID in (select ID from @installations) | |
declare @lines table (ID varchar(300) ) | |
insert into @lines select ID from Line where AreaID in (select ID from @areas) | |
set @projectRelatedCount = (select count(ID) from @installations) | |
set @projectRelatedCount = @projectRelatedCount + (select count(ID) from ProjectHistory where ProjectID=@projectId) | |
set @topologyBuildingTradeCount = (select count(ID) from Area where ID in (select ID from @areas)) | |
set @topologyBuildingTradeCount = @topologyBuildingTradeCount + (select count(ID) from @lines) | |
set @topologyBuildingTradeCount = @topologyBuildingTradeCount + (select count(ID) from Building where InstallationID in (select ID from @installations)) | |
set @topologyBuildingTradeCount = @topologyBuildingTradeCount + (select count(ID) from Trade where InstallationID in (select ID from @installations)) | |
declare @groupAddresses table( ID varchar(300) ) | |
insert into @groupAddresses select ID from GroupAddress where InstallationID in (select ID from @installations) | |
set @addressesRangeCount = (select count(ID) from GroupRange where InstallationID in (select ID from @installations)) | |
set @addressesRangeCount = @addressesRangeCount + (select count(ID) from @groupAddresses) | |
set @addressesRangeCount = @addressesRangeCount + (select count(LineID) from AdditionalGroupAddress where InstallationID in (select ID from @installations)) | |
declare @devices table( ID varchar(300) ) | |
insert into @devices select ID from Device where InstallationID in (select ID from @installations) | |
set @deviceCount = (select count(ID) from @devices) | |
set @deviceParameterCount = (select count(ID) from DeviceParameter where DeviceID in (select ID from @devices)) | |
set @deviceObjectCount = (select count(ID) from DeviceObject where DeviceID in (select ID from @devices)) | |
GO | |
GRANT EXEC ON dbo.usp_GetProjectDataCounts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProjectDataCounts TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetProjectDataCounts TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadDeviceObjects') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadDeviceObjects | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadDeviceObjects | |
( | |
@projectId varchar(300) | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @devices table( ID varchar(300) ) | |
insert into @devices select ID from Device where InstallationID in (select ID from @installations) | |
declare @deviceObject table( ID varchar(300) ) | |
insert into @deviceObject select ID from DeviceObject where DeviceID in (select ID from @devices) | |
select * from DeviceObject where ID in (select ID from @deviceObject) | |
select * from Connector where DeviceObjectID in (select ID from @deviceObject) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadDeviceObjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadDeviceObjects TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadDeviceObjects TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertDeviceObjects') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertDeviceObjects | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertDeviceObjects | |
AS | |
insert into DeviceObject select * from #DeviceObject | |
insert into Connector select * from #Connector | |
truncate table #DeviceObject | |
truncate table #Connector | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertDeviceObjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertDeviceObjects TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertDeviceObjects TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadDeviceParameters') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadDeviceParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadDeviceParameters | |
( | |
@projectId varchar(300) | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @devices table( ID varchar(300) ) | |
insert into @devices select ID from Device where InstallationID in (select ID from @installations) | |
select * from DeviceParameter where DeviceID in (select ID from @devices) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadDeviceParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadDeviceParameters TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadDeviceParameters TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertDeviceParameters') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertDeviceParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertDeviceParameters | |
AS | |
insert into DeviceParameter select * from #DeviceParameter | |
truncate table #DeviceParameter | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertDeviceParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertDeviceParameters TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertDeviceParameters TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadDevices') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadDevices | |
( | |
@projectId varchar(300) | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @devices table( ID varchar(300) ) | |
insert into @devices select ID from Device where InstallationID in (select ID from @installations) | |
select * from Device where ID in (select ID from @devices) | |
select * from AdditionalDeviceAddress where DeviceID in (select ID from @devices) | |
select * from DeviceBinaryData where DeviceID in (select ID from @devices) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadDevices TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadDevices TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertDevices') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertDevices | |
AS | |
insert into Device select * from #Device | |
insert into AdditionalDeviceAddress select * from #AdditionalDeviceAddress | |
insert into DeviceBinaryData select * from #DeviceBinaryData | |
truncate table #Device | |
truncate table #AdditionalDeviceAddress | |
truncate table #DeviceBinaryData | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertDevices TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertDevices TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadProjectData') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadProjectData | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadProjectData | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select * from Project where ID=@projectId | |
select * from Installation where ProjectID=@projectId | |
select * from ProjectHistory where ProjectID=@projectId | |
select * from ProjectTrace where ProjectID=@projectId | |
select ID, ProjectID, [Filename], [Comment] from UserFile where ProjectID=@projectId | |
select ID, ProjectID, AddinID, [Name] from AddinData where ProjectID=@projectId | |
select * from SplitInfo where InstallationID in (select ID from Installation where ProjectID=@projectId) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadProjectData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadProjectData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadProjectData TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertProjectData') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertProjectData | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertProjectData | |
AS | |
insert into Installation select * from #Installation | |
insert into ProjectHistory select * from #ProjectHistory | |
truncate table #Installation | |
truncate table #ProjectHistory | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertProjectData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertProjectData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertProjectData TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadProjectTopologyBuildingTrade') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadProjectTopologyBuildingTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadProjectTopologyBuildingTrade | |
( | |
@projectId varchar(300) | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @areas table (ID varchar(300) ) | |
insert into @areas select ID from Area where InstallationID in (select ID from @installations) | |
declare @buildings table(ID varchar(300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Type] [varchar](20), | |
[Name] [nvarchar](255), [Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] [varchar](50), [Comment] [nvarchar](max), DefaultLineID varchar(300)) | |
insert into @buildings select ID, 0, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment, DefaultLineID from Building where InstallationID in (select ID from @installations) and ParentID is null | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID, @recursionStep, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment, DefaultLineID from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare @Trades TABLE ( [ID] [varchar](300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Name] [nvarchar](255), | |
[Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] varchar(50), [Comment] [nvarchar](max) ) | |
insert into @trades select [ID], 0, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from Trade where InstallationID in (select ID from @installations) and ParentID is null | |
set @countBefore = 0 | |
set @countAfter = 1 | |
set @recursionStep = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @trades) | |
insert into @trades select [ID], @recursionStep, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from Trade where ParentID in (select ID from @trades) and ID not in (select ID from @trades) | |
set @countAfter=(select count(ID) from @trades) | |
set @recursionStep = @recursionStep + 1 | |
end | |
select * from Area where ID in (select ID from @areas) | |
select * from Line where AreaID in (select ID from @areas) | |
select ID, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment, DefaultLineID from @Buildings as Building order by step | |
select ID, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from @Trades as Trade order by step | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadProjectTopologyBuildingTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadProjectTopologyBuildingTrade TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadProjectTopologyBuildingTrade TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertProjectTopologyBuildingTrade') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertProjectTopologyBuildingTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertProjectTopologyBuildingTrade | |
AS | |
insert into Area select * from #Area | |
insert into Line select * from #Line | |
insert into Building select * from #Building | |
insert into Trade select * from #Trade | |
truncate table #Area | |
truncate table #Line | |
truncate table #Building | |
truncate table #Trade | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertProjectTopologyBuildingTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertProjectTopologyBuildingTrade TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertProjectTopologyBuildingTrade TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadProjectAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadProjectAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadProjectAddresses | |
( | |
@projectId varchar(300) | |
) | |
AS | |
declare @installations table (ID varchar(300) ) | |
insert into @installations select ID from Installation where ProjectID=@projectId | |
declare @ranges table(ID varchar(300), InstallationID varchar(300), ParentID varchar(300), [Name] nvarchar(255), Description nvarchar(max), RangeStart int, RangeEnd int, Unfiltered bit, [Comment] nvarchar(max), Step int ) | |
insert into @ranges select *, 0 from GroupRange where ParentID is null AND InstallationID in (select ID from @installations) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @ranges) | |
insert into @ranges select *, @recursionStep from GroupRange where ParentID in (select ID from @ranges) and ID not in (select ID from @ranges) | |
set @countAfter=(select count(ID) from @ranges) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare @gaIds table( ID varchar(300) ) | |
insert into @gaIds select ID from GroupAddress where InstallationID in (select ID from @installations) | |
select ID,InstallationID,ParentID,[Name],Description,RangeStart,RangeEnd,Unfiltered,[Comment] from @ranges as GroupRange order by Step | |
select * from GroupAddress where ID in (select ID from @gaIds) | |
select * from AdditionalGroupAddress where InstallationID in (select ID from @installations) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadProjectAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadProjectAddresses TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadProjectAddresses TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawInsertProjectAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_RawInsertProjectAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_RawInsertProjectAddresses | |
AS | |
insert into GroupAddress select * from #GroupAddress | |
insert into GroupRange select * from #GroupRange | |
insert into AdditionalGroupAddress select * from #AdditionalGroupAddress | |
truncate table #GroupAddress | |
truncate table #GroupRange | |
truncate table #AdditionalGroupAddress | |
GO | |
GRANT EXEC ON dbo.usp_RawInsertProjectAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawInsertProjectAddresses TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawInsertProjectAddresses TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDeviceDataCounts') | |
BEGIN | |
DROP Procedure dbo.usp_GetDeviceDataCounts | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDeviceDataCounts | |
( | |
@deviceId varchar(300), | |
@deviceParameterCount bigint output, | |
@deviceObjectCount bigint output | |
) | |
AS | |
set @deviceParameterCount = (select count(ID) from DeviceParameter where DeviceID = @deviceId) | |
set @deviceObjectCount = (select count(ID) from DeviceObject where DeviceID = @deviceId) | |
GO | |
GRANT EXEC ON dbo.usp_GetDeviceDataCounts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDeviceDataCounts TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetDeviceDataCounts TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadDevice') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadDevice | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadDevice | |
( | |
@deviceIds xml, | |
@getConnectors bit, | |
@getGroupAddresses bit = 0 | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIds | |
declare @devices table(ID varchar(300)) | |
insert into @devices select ID from openxml( @docHandle, '/ids/id') with (ID nvarchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
select * from Device where ID in (select ID from @devices) | |
select * from AdditionalDeviceAddress where DeviceID in (select ID from @devices) | |
--select * from DeviceBinaryData where DeviceID in (select ID from @devices) | |
--select * from DeviceParameter where DeviceID in (select ID from @devices) | |
--select * from DeviceObject where DeviceID in (select ID from @devices) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadDevice TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadDevice TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadDevice TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadDeviceForMerge') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadDeviceForMerge | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadDeviceForMerge | |
( | |
@deviceIds xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIds | |
declare @devices table(ID varchar(300)) | |
insert into @devices select ID from openxml( @docHandle, '/ids/id') with (ID nvarchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
select * from Device where ID in (select ID from @devices) | |
select * from DeviceBinaryData where DeviceID in (select ID from @devices) | |
select * from DeviceParameter where DeviceID in (select ID from @devices) | |
select * from DeviceObject where DeviceID in (select ID from @devices) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadDeviceForMerge TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadDeviceForMerge TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadDeviceForMerge TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadBuildingParts') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadBuildingParts | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadBuildingParts | |
( | |
@buildingPartId varchar(300) | |
) | |
AS | |
declare @buildings table(ID varchar(300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Type] [varchar](20), | |
[Name] [nvarchar](255), [Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] [varchar](20), [Comment] [nvarchar](max), NotReturn bit default 0) | |
insert into @buildings select @buildingPartId, 0, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment, 1 from Building where ID = @buildingPartId | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID, @recursionStep, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment ,0 from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
set @recursionStep = @recursionStep + 1 | |
end | |
select ID, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment from @Buildings as Building where NotReturn = 0 order by step | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadBuildingParts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadBuildingParts TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadBuildingParts TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CopyRawDeviceDependingData') | |
BEGIN | |
DROP Procedure dbo.usp_CopyRawDeviceDependingData | |
END | |
GO | |
CREATE Procedure dbo.usp_CopyRawDeviceDependingData | |
( | |
@DeviceOldNewMappingxml xml, | |
@withAdditionalAddresses bit=1 | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @DeviceOldNewMappingxml | |
declare @oldnewDevices table (oldDeviceId varchar(300), newDeviceId varchar(300)) | |
insert into @oldnewDevices select oldDeviceId, newDeviceId from openxml( @docHandle, '/ids/id') with (oldDeviceID nvarchar(300) '@oldId', newDeviceID nvarchar(300) '@newId') | |
exec sp_xml_removedocument @docHandle | |
create table #DeviceObject | |
( | |
[ID] [varchar](40) NOT NULL, | |
[OldID] [varchar](40) NOT NULL, | |
[DeviceID] [varchar](300) NOT NULL, | |
[CommunicationObjectRefID] [varchar](300) NOT NULL, | |
[Text] [nvarchar](255) NULL, | |
[FunctionText] [nvarchar](max) NULL, | |
[Description] [nvarchar](max) NULL, | |
[IsActive] [bit] NULL, | |
[DatapointType] [varchar](max) NULL, | |
[ReadFlag] [bit] NULL, | |
[WriteFlag] [bit] NULL, | |
[CommunicationFlag] [bit] NULL, | |
[TransmitFlag] [bit] NULL, | |
[UpdateFlag] [bit] NULL, | |
[ReadOnInitFlag] [bit] NULL, | |
[Priority] [varchar](6) NULL, | |
[ObjectSize] [varchar](20) NOT NULL, | |
[Number] [smallint] NOT NULL | |
) | |
insert into #DeviceObject select NEWID() as ID, CO.ID as OldId, DeviceMap.newDeviceId, CO.CommunicationObjectRefID, CO.Text, | |
CO.FunctionText, CO.Description, CO.IsActive, CO.DatapointType, CO.ReadFlag, | |
CO.WriteFlag, CO.CommunicationFlag, CO.TransmitFlag, CO.UpdateFlag, | |
CO.ReadOnInitFlag, CO.Priority, CO.ObjectSize, CO.Number | |
from DeviceObject as CO inner join @oldnewDevices as DeviceMap on DeviceMap.oldDeviceId = CO.DeviceID | |
declare @newId table ([newId] varchar(300)) | |
declare @xml xml = '<Root><Data></Data></Root>' | |
declare @resultxml xml | |
insert into DeviceObject (ID, DeviceID, CommunicationObjectRefID, Text, | |
FunctionText, Description, IsActive, DatapointType, ReadFlag, | |
WriteFlag, CommunicationFlag, TransmitFlag, UpdateFlag, | |
ReadOnInitFlag, Priority, ObjectSize, Number ) | |
select ID, DeviceID, CommunicationObjectRefID, Text, | |
FunctionText, Description, IsActive, DatapointType, ReadFlag, | |
WriteFlag, CommunicationFlag, TransmitFlag, UpdateFlag, | |
ReadOnInitFlag, Priority, ObjectSize, Number | |
from #DeviceObject | |
set @resultxml = (select * from #DeviceObject as DeviceObject for xml auto ) | |
set @xml.modify('insert sql:variable("@resultXml") as last into (/Root/Data)[1]') | |
delete from @newId | |
insert into DeviceParameter output inserted.ID as [newId] into @newId select NEWID() as ID, DeviceMap.newDeviceId, DeviceParameter.ParameterRefID, DeviceParameter.IsActive, DeviceParameter.Value from DeviceParameter inner join @oldnewDevices as DeviceMap on DeviceMap.oldDeviceId = DeviceParameter.DeviceID | |
set @resultxml = (select DeviceParameter.*, SQL_VARIANT_PROPERTY( 'Value', 'BaseType' ) as SqlVariantBaseTypeValue from DeviceParameter inner join @newId as NewIds on NewIds.[NEWID] = DeviceParameter.ID for xml auto) | |
set @xml.modify('insert sql:variable("@resultXml") as last into (/Root/Data)[1]') | |
delete from @newId | |
insert into DeviceBinaryData output inserted.ID as [newId] into @newId select NEWID() as ID, DeviceMap.newDeviceId, DeviceBinaryData.BinaryDataID, DeviceBinaryData.Name, DeviceBinaryData.Data from DeviceBinaryData inner join @oldnewDevices as DeviceMap on DeviceMap.oldDeviceId = DeviceBinaryData.DeviceID | |
set @resultxml = (select DeviceBinaryData.* from DeviceBinaryData inner join @newId as NewIds on NewIds.[NEWID] = DeviceBinaryData.ID for xml auto, binary base64) | |
set @xml.modify('insert sql:variable("@resultXml") as last into (/Root/Data)[1]') | |
delete from @newId | |
if @withAdditionalAddresses = 1 | |
begin | |
insert into AdditionalDeviceAddress select DeviceMap.newDeviceId, AdditionalDeviceAddress.Address from AdditionalDeviceAddress inner join @oldnewDevices as DeviceMap on DeviceMap.oldDeviceId = AdditionalDeviceAddress.DeviceID | |
set @resultxml = (select * from AdditionalDeviceAddress where DeviceID in (select [@oldnewDevices].newDeviceId from @oldnewDevices) for xml auto) | |
set @xml.modify('insert sql:variable("@resultXml") as last into (/Root/Data)[1]') | |
end | |
truncate table #DeviceObject | |
drop table #DeviceObject | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_CopyRawDeviceDependingData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CopyRawDeviceDependingData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CopyRawDeviceDependingData TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadGroupRanges') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadGroupRanges | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadGroupRanges | |
( | |
@rangeIdsXml xml | |
) | |
AS | |
declare @rangeIds table(id varchar(300)) | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @rangeIdsXml | |
insert into @rangeIds select id from openxml(@docHandle, '/ids/id') with (id varchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
declare @ranges table(ID varchar(300), InstallationID varchar(300), ParentID varchar(300), [Name] nvarchar(255), Description nvarchar(max), RangeStart int, RangeEnd int, Unfiltered bit, [Comment] nvarchar(max), Step int ) | |
insert into @ranges select *, 0 from GroupRange where ID in (select Id from @rangeIds) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @ranges) | |
insert into @ranges select *, @recursionStep from GroupRange where ParentID in (select ID from @ranges) and ID not in (select ID from @ranges) | |
set @countAfter=(select count(ID) from @ranges) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare @gaIds table( ID varchar(300) ) | |
insert into @gaIds select ID from GroupAddress where GroupRangeID in (select ID from @ranges) | |
select ID,InstallationID,ParentID,[Name],Description,RangeStart,RangeEnd,Unfiltered,[Comment] from @ranges as GroupRange order by Step, rangestart, rangeend | |
select * from GroupAddress where ID in (select ID from @gaIds) order by address | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadGroupRanges TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadGroupRanges TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadGroupRanges TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadLine') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadLine | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadLine | |
( | |
@lineIdsXml xml | |
) | |
AS | |
declare @lineIds table(id varchar(300)) | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @lineIdsXml | |
insert into @lineids select id from openxml(@docHandle, '/ids/id') with (id varchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
declare @lines TABLE ( [ID] [varchar](300), [AreaID] [varchar](300), [Name] [nvarchar](255), [Description] [nvarchar](max), | |
[Address] smallint, [DomainAddressIsChecked] bit, [DomainAddress] bigint, [MediumTypeID] varchar(300), | |
[CompletionStatus] varchar(50), [Comment] [nvarchar](max), IPRoutingMulticastAddress varchar(50), [MulticastTTL] smallint ) | |
insert into @lines select ID, [AreaID], [Name], [Description], [Address], [DomainAddressIsChecked], [DomainAddress] | |
, [MediumTypeID], [CompletionStatus], [Comment], [IPRoutingMulticastAddress], [MulticastTTL] from Line where ID in (select Id from @lineIds) | |
select * from @lines as Line | |
declare @deviceIds table(id varchar(300)) | |
insert into @deviceIds select id from Device where LineID in (select Id from @lines) | |
select * from Device where id in (select id from @deviceIds) | |
--select * from DeviceBinaryData where DeviceID in (select id from @deviceIds) | |
--select * from DeviceParameter where DeviceID in (select id from @deviceIds) | |
--select * from DeviceObject where DeviceID in (select id from @deviceIds) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadLine TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadLine TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadLine TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadBuildingPart') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadBuildingPart | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadBuildingPart | |
( | |
@buildingPartIds xml, | |
@withDevices bit = 1 | |
) | |
AS | |
declare @buildingIds table(id varchar(300)) | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @buildingPartIds | |
insert into @buildingIds select id from openxml(@docHandle, '/ids/id') with (id varchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
declare @buildings table(ID varchar(300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Type] [varchar](20), | |
[Name] [nvarchar](255), [Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] [varchar](20), [Comment] [nvarchar](max), DefaultLineID varchar(300)) | |
insert into @buildings select ID, 0, InstallationID, ParentID, Type, [Name], Number, Description, [CompletionStatus], Comment, DefaultLineID from Building where ID in (select Id from @buildingIds) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID, @recursionStep, InstallationID, ParentID, Type, Name, Number, Description, [CompletionStatus], Comment, DefaultLineID from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
set @recursionStep = @recursionStep + 1 | |
end | |
select ID, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment, DefaultLineID from @Buildings as Building order by step | |
if @withDevices = 1 | |
begin | |
declare @deviceIds table(id varchar(300)) | |
insert into @deviceIds select id from Device where BuildingID in (select Id from @buildings) | |
select * from Device where id in (select id from @deviceIds) order by Device.LineID, Device.Address | |
select * from AdditionalDeviceAddress where DeviceID in (select id from @deviceIds) | |
end | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadBuildingPart TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadBuildingPart TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadBuildingPart TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadArea') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadArea | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadArea | |
( | |
@areaIdsXml xml | |
) | |
AS | |
declare @areaIds table(id varchar(300)) | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @areaIdsXml | |
insert into @areaIds select id from openxml(@docHandle, '/ids/id') with (id varchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
select * from Area where ID in ( select id from @areaIds ) | |
declare @LineIds table (id varchar(300)) | |
insert into @LineIds select Id from Line where AreaID in ( select id from @areaIds ) | |
select * from Line where AreaID in ( select id from @areaIds) | |
declare @deviceIds table(id varchar(300)) | |
insert into @deviceIds select id from Device where LineID in (select Id from @lineIds) | |
select * from Device where id in (select id from @deviceIds) | |
--select * from DeviceBinaryData where DeviceID in (select id from @deviceIds) | |
--select * from DeviceParameter where DeviceID in (select id from @deviceIds) | |
--select * from DeviceObject where DeviceID in (select id from @deviceIds) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadLine TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadLine TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadLine TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RawLoadTrade') | |
BEGIN | |
DROP Procedure dbo.usp_RawLoadTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_RawLoadTrade | |
( | |
@tradeIdsXml xml | |
) | |
AS | |
declare @tradeIds table(id varchar(300)) | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @tradeIdsXml | |
insert into @tradeids select id from openxml(@docHandle, '/ids/id') with (id varchar(300) '@value') | |
exec sp_xml_removedocument @docHandle | |
declare @Trades TABLE ( [ID] [varchar](300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Name] [nvarchar](255), | |
[Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] varchar(50), [Comment] [nvarchar](max) ) | |
insert into @trades select ID, 0, [InstallationID], [ParentID], [Name], [Number], [Description], [CompletionStatus], [Comment] from Trade where ID in (select Id from @tradeIds) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @trades) | |
insert into @trades select [ID], @recursionStep, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from Trade where ParentID in (select ID from @trades) and ID not in (select ID from @trades) | |
set @countAfter=(select count(ID) from @trades) | |
set @recursionStep = @recursionStep + 1 | |
end | |
select ID, [InstallationID], [ParentID], [Name], [Number], [Description], [CompletionStatus], [Comment] from @Trades as Trade order by step | |
declare @deviceIds table(id varchar(300)) | |
insert into @deviceIds select id from Device where TradeID in (select Id from @trades) | |
select * from Device where id in (select id from @deviceIds) order by Device.LineID, Device.Address | |
select * from AdditionalDeviceAddress where DeviceID in (select id from @deviceIds) | |
GO | |
GRANT EXEC ON dbo.usp_RawLoadTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_RawLoadTrade TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_RawLoadTrade TO ETSReadOnlyAccess | |
GO | |
/*********************************************** | |
Extended Copy stored procedures and function | |
***********************************************/ | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetDeviceObjectsXmlForExtendedCopy') | |
BEGIN | |
DROP function dbo.ufn_GetDeviceObjectsXmlForExtendedCopy | |
END | |
GO | |
CREATE function dbo.ufn_GetDeviceObjectsXmlForExtendedCopy | |
( | |
@deviceId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @deviceCOXml xml | |
set @deviceCOXml = ( select CONVERT(xml, (select | |
CO.CommunicationObjectRefID as '@RefId' | |
, CO.Text as '@Text' | |
, CO.FunctionText as '@FunctionText' | |
, CO.Priority as '@Priority' | |
, case CO.ReadFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadFlag' | |
, case CO.WriteFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@WriteFlag' | |
, case CO.CommunicationFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@CommunicationFlag' | |
, case CO.TransmitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@TransmitFlag' | |
, case CO.UpdateFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@UpdateFlag' | |
, case CO.ReadOnInitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadOnInitFlag' | |
, CO.DatapointType as '@DatapointType' | |
, CO.Description as '@Description' | |
, CO.IsActive as '@IsActive' | |
, CO.Number as '@Number' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Send where DeviceObjectID=CO.ID and [Send]=1 for xml auto)) as 'Connectors/*' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Receive where DeviceObjectID=CO.ID and [Send]=0 for xml auto)) as 'Connectors/*' | |
from DeviceObject as CO inner join CommunicationObjectRef CORef on CO.CommunicationObjectRefID = CORef.ID where DeviceID = @deviceId and (CO.Text is not null or CO.FunctionText is not null or CO.Description is not null | |
or CO.DatapointType is not null or CO.ReadFlag is not null or CO.WriteFlag is not null | |
or CO.CommunicationFlag is not null or CO.TransmitFlag is not null or CO.UpdateFlag is not null | |
or CO.ReadOnInitFlag is not null or CO.Priority is not null or IsActive=1 or exists (select DeviceObjectID from Connector where DeviceObjectID = CO.ID)) order by CO.Number | |
for xml path('ComObjectInstanceRef'), root('ComObjectInstanceRefs')))) | |
return @deviceCOXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GetDeviceObjectsXmlForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetDeviceObjectsXmlForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GetDeviceObjectsXmlForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetDevicesForLineForExtendedCopy') | |
BEGIN | |
DROP function dbo.ufn_GetDevicesForLineForExtendedCopy | |
END | |
GO | |
CREATE function dbo.ufn_GetDevicesForLineForExtendedCopy | |
( | |
@lineId varchar(300), | |
@neededDeviceIds idtable readonly | |
) | |
returns xml | |
AS | |
begin | |
declare @deviceIds idtable | |
if (select count(*) FROM @neededDeviceIds) = 0 | |
begin | |
insert into @deviceIds select ID from Device where LineID = @lineId | |
end | |
else | |
begin | |
insert into @deviceIds select ID from @neededDeviceIds | |
end | |
return dbo.ufn_GetDeviceXmlForExtendedCopy(@deviceIds) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GetDevicesForLineForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetDevicesForLineForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GetDevicesForLineForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetDeviceXmlForExtendedCopy') | |
BEGIN | |
DROP function dbo.ufn_GetDeviceXmlForExtendedCopy | |
END | |
GO | |
CREATE function dbo.ufn_GetDeviceXmlForExtendedCopy | |
( | |
@ids idtable readonly | |
) | |
returns xml | |
AS | |
begin | |
declare @deviceXml xml | |
set @deviceXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, ProductID as '@ProductRefId' | |
, Hardware2ProgramID as '@Hardware2ProgramRefId' | |
, Address as '@Address' | |
, Comment as '@Comment' | |
, LastModified as '@LastModified' | |
, LastDownload as '@LastDownload' | |
, InstallationHints as '@InstallationHints' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as '@CompletionStatus' | |
, IndividualAddressLoaded as '@IndividualAddressLoaded' | |
, ApplicationProgramLoaded as '@ApplicationProgramLoaded' | |
, ParametersLoaded as '@ParametersLoaded' | |
, CommunicationPartLoaded as '@CommunicationPartLoaded' | |
, MediumConfigLoaded as '@MediumConfigLoaded' | |
, LoadedImage as '@LoadedImage' | |
, CheckSums as '@CheckSums' | |
, Description as '@Description' | |
, IsCommunicationObjectVisibilityCalculated as '@IsCommunicationObjectVisibilityCalculated' | |
, Broken as '@Broken' | |
, SerialNumber as '@SerialNumber' | |
, [UniqueId] as '@UniqueId' | |
, [IPConfigAssign] as 'IPConfig/@Assign' | |
, [IPConfigIPAddress] as 'IPConfig/@IPAddress' | |
, [IPConfigSubnetMask] as 'IPConfig/@SubnetMask' | |
, [IPConfigDefaultGateway] as 'IPConfig/@DefaultGateway' | |
, [IPConfigMACAddress] as 'IPConfig/@MACAddress' | |
, dbo.ufn_ParameterInstanceRefsXml(ID) as ParameterInstanceRefs | |
, dbo.ufn_GetDeviceObjectsXmlForExtendedCopy(ID) | |
-- todo how to handle this addresses?! | |
--, dbo.ufn_DeviceInstanceAdditionalAddressesXml(ID) as AdditionalAddresses | |
, dbo.ufn_DeviceBinaryDataXml(ID) | |
from Device as DeviceInstance where ID in (select ID from @ids) order by [Address] | |
for xml path ('DeviceInstance'), binary base64 | |
) | |
return @deviceXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GetDeviceXmlForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetDeviceXmlForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GetDeviceXmlForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetLineXmlForExtendedCopy') | |
BEGIN | |
DROP function dbo.ufn_GetLineXmlForExtendedCopy | |
END | |
GO | |
CREATE function dbo.ufn_GetLineXmlForExtendedCopy | |
( | |
@ids idtable readonly, | |
@neededDeviceIds idtable readonly | |
) | |
returns xml | |
AS | |
begin | |
declare @lineXml xml | |
set @lineXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, Address as '@Address' | |
, MediumTypeID as '@MediumTypeRefId' | |
, Comment as '@Comment' | |
, DomainAddress as '@DomainAddress' | |
, DomainAddressIsChecked as '@DomainAddressIsChecked' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as '@CompletionStatus' | |
, Description as '@Description' | |
, IPRoutingMulticastAddress as '@IPRoutingMulticastAddress' | |
, MulticastTTL as '@MulticastTTL' | |
, dbo.ufn_GetDevicesForLineForExtendedCopy(ID, @neededDeviceIds) | |
--, dbo.ufn_LineAdditionalGroupAddressXml(ID) | |
--, BusAccessName as 'BusAccess/@Name' | |
--, case BusAccessEdi when null then null else '{' + convert(varchar(50), BusAccessEdi) + '}' end as 'BusAccess/@Edi' | |
--, BusAccessParameter as 'BusAccess/@Parameter' | |
from Line as Line where ID in (select ID from @ids) order by [Address] | |
for xml path ('Line'), binary base64 | |
) | |
return @lineXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GetLineXmlForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetLineXmlForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GetLineXmlForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetLinesXmlOfAreaForExtendedCopy') | |
BEGIN | |
DROP function dbo.ufn_GetLinesXmlOfAreaForExtendedCopy | |
END | |
GO | |
CREATE function dbo.ufn_GetLinesXmlOfAreaForExtendedCopy | |
( | |
@areaId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @lineids idtable | |
declare @neededDeviceIds idtable | |
insert into @lineids select ID from Line where AreaID = @areaId | |
return dbo.ufn_GetLineXmlForExtendedCopy(@lineIds, @neededDeviceIds) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GetLinesXmlOfAreaForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetLinesXmlOfAreaForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GetLinesXmlOfAreaForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_BuildingPartExtendedCopyXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_BuildingPartExtendedCopyXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_BuildingPartExtendedCopyXml | |
( | |
@parentBuildingPartId varchar(300), | |
@deviceInstanceIds idtable readonly, | |
@buildingPartIdsWithDevices idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @buildingPartXml xml | |
if @parentBuildingPartId is null | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartExtendedCopyXml( ID, @deviceInstanceIds, @buildingPartIdsWithDevices) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where ParentID is null and BuildingPart.ID in (select id from @buildingPartIdsWithDevices buildingsWithDevices where buildingsWithDevices.id = BuildingPart.Id ) | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartExtendedCopyXml(ID, @deviceInstanceIds, @buildingPartIdsWithDevices) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where ParentID=@parentBuildingPartId and BuildingPart.ID in (select id from @buildingPartIdsWithDevices buildingsWithDevices where buildingsWithDevices.id = BuildingPart.Id ) | |
for xml auto | |
) | |
end | |
return @buildingPartXml | |
end | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TradeExtendedCopyXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_TradeExtendedCopyXml | |
END | |
GO | |
Create FUNCTION dbo.ufn_TradeExtendedCopyXml | |
( | |
@parentTradeId varchar(300), | |
@deviceInstanceIds idTable readonly, | |
@tradeIdsWithDevices idTable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @tradeXml xml | |
if @parentTradeId is null | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeExtendedCopyXml( ID, @deviceInstanceIds, @tradeIdsWithDevices ) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where ParentID is null and Trade.ID in (select id from @tradeIdsWithDevices tradeWithDevices where tradeWithDevices.id = Trade.Id ) | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeExtendedCopyXml( ID, @deviceInstanceIds, @tradeIdsWithDevices) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where ParentID=@parentTradeId and Trade.ID in (select id from @tradeIdsWithDevices tradeWithDevices where tradeWithDevices.id = Trade.Id ) | |
for xml auto | |
) | |
end | |
return @tradeXml | |
end | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_UnassigendDevicesExtendedCopxXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_UnassigendDevicesExtendedCopxXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_UnassigendDevicesExtendedCopxXml | |
( | |
@DeviceIds idtable readonly | |
) | |
returns xml | |
as | |
BEGIN | |
declare @UnassigendDeviceIDs idtable | |
insert into @UnassigendDeviceIDs select ID from Device where ID in (select ID from @DeviceIds) and LineID is NULL | |
return dbo.ufn_GetDeviceXmlForExtendedCopy( @UnassigendDeviceIDs ) | |
END | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadAreaDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadAreaDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadAreaDataForExtendedCopy | |
( | |
@areaIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @areaIdsXml | |
declare @areaIds table(ID varchar(300)) | |
insert into @areaIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @areaXml xml = | |
( | |
select Id, Name, Address, Comment, | |
dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus, | |
Description, | |
dbo.ufn_GetLinesXmlOfAreaForExtendedCopy(ID) from Area where ID in (select ID from @areaIds) order by [Address] for xml auto | |
) | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Topology /><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@areaXml") as last into (/KNX/Project/Installations/Installation/Topology)[1]' ) | |
declare @deviceIds idtable | |
declare @lineIds table (Id varchar(300)) | |
declare @buildingIdsWithDevices idtable | |
declare @tradeIdsWithDevices idtable | |
insert into @lineIds select ID from Line where AreaID in (select ID from @areaIds ) | |
insert into @deviceIds select ID from Device where LineID in (select ID from @lineIds ) | |
insert into @buildingIdsWithDevices select BuildingID from Device where ID in (select ID from @deviceIds ) and BuildingId is not null | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @buildings table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @buildings select ID, ParentID from Building where ID in (select distinct (ID) from @buildingIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @buildings) | |
insert into @buildings select ID, ParentID from Building where ID in (select ParentID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter= (select count(ID) from @buildings) | |
end | |
insert into @buildingIdsWithDevices select ID from @buildings where ID not in (select Id from @buildingIdsWithDevices) | |
declare @buildingsXML xml | |
set @buildingsXML = (select top 1 dbo.ufn_BuildingPartExtendedCopyXml(null, @deviceIds, @buildingIdsWithDevices) from @buildings where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@buildingsXML") as last into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select Top 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadAreaDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadAreaDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadAreaDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadGroupRangeDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadGroupRangeDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadGroupRangeDataForExtendedCopy | |
( | |
@groupRangeIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @groupRangeIdsXml | |
declare @groupRangeIds table(ID varchar(300)) | |
insert into @groupRangeIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @ranges table(ID varchar(300), InstallationID varchar(300), ParentID varchar(300), [Name] nvarchar(255), Description nvarchar(max), RangeStart int, RangeEnd int, Unfiltered bit, [Comment] nvarchar(max), Step int ) | |
insert into @ranges select *, 0 from GroupRange where ID in (select Id from @groupRangeIds) | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @ranges) | |
insert into @ranges select *, @recursionStep from GroupRange where ParentID in (select ID from @ranges) and ID not in (select ID from @ranges) | |
set @countAfter=(select count(ID) from @ranges) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare @groupRangesXML xml | |
declare @fakeIds idtable | |
set @groupRangesXML=( select | |
ID as Id | |
, Name | |
, RangeStart | |
, RangeEnd | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, Description | |
, Comment | |
, dbo.ufn_GroupRangesXml( ID, ID, ID, @fakeIds ) | |
, dbo.ufn_GroupAddressesXml( ID, @fakeIds ) | |
from GroupRange where ID in (select ID from @ranges where Step = 0) | |
for xml auto | |
) | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Topology /><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadGroupRangeDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadGroupRangeDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadGroupRangeDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadGroupAddressDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadGroupAddressDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadGroupAddressDataForExtendedCopy | |
( | |
@groupAddressIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @groupAddressIdsXml | |
declare @groupAddressIds table(ID varchar(300)) | |
insert into @groupAddressIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @groupAddressXml xml | |
set @groupAddressXml=( select | |
ID as Id | |
, Address | |
, Name | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, case Central when 1 then Central else null end as Central | |
, case Global when 1 then Global else null end as Global | |
, Description | |
, Comment | |
, DatapointType | |
from GroupAddress where ID in (select ID from @groupAddressIds) order by Address | |
for xml auto | |
) | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Topology /><Buildings /><GroupAddresses><GroupRanges><GroupRange /></GroupRanges></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@groupAddressXml") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges/GroupRange)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadGroupAddressDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadGroupAddressDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadGroupAddressDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadLineDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadLineDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadLineDataForExtendedCopy | |
( | |
@lineIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @lineIdsXml | |
declare @lineIds idtable | |
insert into @lineIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @emptyIds idtable | |
declare @lineXml xml = dbo.ufn_GetLineXmlForExtendedCopy(@lineIds, @emptyIds) | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Topology><Area /></Topology><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@lineXml") as last into (/KNX/Project/Installations/Installation/Topology/Area)[1]' ) | |
declare @deviceIds idtable | |
declare @buildingIdsWithDevices idtable | |
declare @tradeIdsWithDevices idtable | |
insert into @deviceIds select ID from Device where LineID in (select ID from @lineIds ) | |
insert into @buildingIdsWithDevices select BuildingID from Device where ID in (select ID from @deviceIds ) and BuildingId is not null | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @buildings table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @buildings select ID, ParentID from Building where ID in (select distinct (ID) from @buildingIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @buildings) | |
insert into @buildings select ID, ParentID from Building where ID in (select ParentID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter= (select count(ID) from @buildings) | |
end | |
insert into @buildingIdsWithDevices select ID from @buildings where ID not in (select Id from @buildingIdsWithDevices) | |
declare @buildingsXML xml | |
set @buildingsXML = (select TOP 1 dbo.ufn_BuildingPartExtendedCopyXml(null, @deviceIds, @buildingIdsWithDevices) from @buildings where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@buildingsXML") as last into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select TOP 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadLineDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadLineDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadLineDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadDeviceForLineDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadDeviceForLineDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadDeviceForLineDataForExtendedCopy | |
( | |
@deviceIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdsXml | |
declare @deviceIds idtable | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @deviceXml xml = dbo.ufn_GetDeviceXmlForExtendedCopy(@deviceIds) | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Topology><Area><Line /></Area></Topology><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@deviceXml") as last into (/KNX/Project/Installations/Installation/Topology/Area/Line)[1]' ) | |
declare @buildingIdsWithDevices idtable | |
declare @tradeIdsWithDevices idtable | |
insert into @buildingIdsWithDevices select BuildingID from Device where ID in (select ID from @deviceIds ) and BuildingId is not null | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @buildings table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @buildings select ID, ParentID from Building where ID in (select distinct (ID) from @buildingIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @buildings) | |
insert into @buildings select ID, ParentID from Building where ID in (select ParentID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter= (select count(ID) from @buildings) | |
end | |
insert into @buildingIdsWithDevices select ID from @buildings where ID not in (select Id from @buildingIdsWithDevices) | |
declare @buildingsXML xml | |
set @buildingsXML = (select Top 1 dbo.ufn_BuildingPartExtendedCopyXml(null, @deviceIds, @buildingIdsWithDevices) from @buildings where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@buildingsXML") as last into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select Top 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadDeviceForLineDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadDeviceForLineDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadDeviceForLineDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadDeviceForBuildingPartDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadDeviceForBuildingPartDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadDeviceForBuildingPartDataForExtendedCopy | |
( | |
@deviceIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdsXml | |
declare @deviceIds idtable | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @lineIds table(ID varchar(300), DeviceId varchar(300)) | |
declare @areaIds table(ID varchar(300), LineId varchar(300)) | |
insert into @lineIds select LineID, ID from Device where ID in (select id from @deviceIds) | |
insert into @areaIds select AreaID, ID from Line where ID in (select Id from @lineIds) | |
declare @areaId varchar(300) | |
declare @lineId varchar(300) | |
declare @lineXml xml = '' | |
declare @linePartXml xml | |
declare @deviceXml xml | |
declare @areaPartXml xml | |
declare @areaXml xml = '<Topology><UnassignedDevices /></Topology>' | |
declare @tempLineIds idtable | |
declare areaCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @areaIds | |
open areaCursor | |
fetch next from areaCursor into @areaId | |
while @@FETCH_STATUS = 0 | |
begin | |
set @linePartXml = null | |
set @lineXml = '' | |
set @areaPartXml = null | |
declare lineCursor cursor local forward_only fast_forward read_only for select ID from Line where ID in (select distinct(ID) from @LineIds) and AreaId = @AreaId | |
open lineCursor | |
fetch next from lineCursor into @lineId | |
declare @ids idtable | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from @ids | |
delete from @tempLineIds | |
insert into @ids select ID from Device where ID in (select ID from @deviceIds) and LineID = @lineId | |
insert into @tempLineIds (Id) values ( @lineId ) | |
set @linePartXml = dbo.ufn_GetLineXmlForExtendedCopy(@tempLineIds, @ids) | |
set @lineXml.modify('insert sql:variable("@linePartXml") as first into (/)[1]') | |
fetch next from lineCursor into @lineId | |
end | |
close lineCursor | |
deallocate lineCursor | |
set @areaPartXml = (select Id, Name, Address, Comment, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus, Description, @lineXml from Area where ID = @areaId order by [Address] for xml auto ) | |
set @areaXml.modify('insert sql:variable("@areaPartXml") as first into (/Topology)[1]') | |
fetch next from areaCursor into @areaId | |
end | |
close areaCursor | |
deallocate areaCursor | |
declare @UnassigendDevicesXml xml | |
set @UnassigendDevicesXml = dbo.ufn_UnassigendDevicesExtendedCopxXml(@deviceIds) | |
set @areaXml.modify('insert sql:variable("@UnassigendDevicesXml") as first into (/Topology/UnassignedDevices)[last()]') | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@areaXml") as first into (/KNX/Project/Installations/Installation)[1]' ) | |
declare @tradeIdsWithDevices idtable | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select Top 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadDeviceForBuildingPartDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadDeviceForBuildingPartDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadDeviceForBuildingPartDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadDeviceForAllDevicesForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadDeviceForAllDevicesForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadDeviceForAllDevicesForExtendedCopy | |
( | |
@deviceIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdsXml | |
declare @deviceIds idtable | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @lineIds table(ID varchar(300), DeviceId varchar(300)) | |
declare @areaIds table(ID varchar(300), LineId varchar(300)) | |
insert into @lineIds select LineID, ID from Device where ID in (select id from @deviceIds) | |
insert into @areaIds select AreaID, ID from Line where ID in (select Id from @lineIds) | |
declare @areaId varchar(300) | |
declare @lineId varchar(300) | |
declare @lineXml xml = '' | |
declare @linePartXml xml | |
declare @deviceXml xml | |
declare @areaPartXml xml | |
declare @areaXml xml = '<Topology><UnassignedDevices /></Topology>' | |
declare areaCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @areaIds | |
open areaCursor | |
fetch next from areaCursor into @areaId | |
while @@FETCH_STATUS = 0 | |
begin | |
set @linePartXml = null | |
set @lineXml = '' | |
set @areaPartXml = null | |
declare lineCursor cursor local forward_only fast_forward read_only for select ID from Line where ID in (select distinct(ID) from @LineIds) and AreaId = @AreaId | |
open lineCursor | |
fetch next from lineCursor into @lineId | |
declare @ids idtable | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from @ids | |
insert into @ids select ID from Device where ID in (select ID from @deviceIds) and LineID = @lineId | |
declare @tempLineIds idtable | |
insert into @tempLineIds (Id) values ( @lineId ) | |
set @linePartXml = dbo.ufn_GetLineXmlForExtendedCopy(@tempLineIds, @ids) | |
set @lineXml.modify('insert sql:variable("@linePartXml") as first into (/)[1]') | |
fetch next from lineCursor into @lineId | |
end | |
close lineCursor | |
deallocate lineCursor | |
set @areaPartXml = ( select Id, Name, Address, Comment, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus, Description, @lineXml from Area where ID = @areaId order by [Address] for xml auto ) | |
set @areaXml.modify('insert sql:variable("@areaPartXml") as first into (/Topology)[1]') | |
fetch next from areaCursor into @areaId | |
end | |
close areaCursor | |
deallocate areaCursor | |
declare @UnassigendDevicesXml xml | |
set @UnassigendDevicesXml = dbo.ufn_UnassigendDevicesExtendedCopxXml(@deviceIds) | |
set @areaXml.modify('insert sql:variable("@UnassigendDevicesXml") as first into (/Topology/UnassignedDevices)[last()]') | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@areaXml") as first into (/KNX/Project/Installations/Installation)[1]' ) | |
declare @buildingIdsWithDevices idtable | |
declare @tradeIdsWithDevices idtable | |
insert into @buildingIdsWithDevices select BuildingID from Device where ID in (select ID from @deviceIds ) and BuildingId is not null | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @buildings table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @buildings select ID, ParentID from Building where ID in (select distinct (ID) from @buildingIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @buildings) | |
insert into @buildings select ID, ParentID from Building where ID in (select ParentID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter= (select count(ID) from @buildings) | |
end | |
insert into @buildingIdsWithDevices select ID from @buildings where ID not in (select Id from @buildingIdsWithDevices) | |
declare @buildingsXML xml | |
set @buildingsXML = (select top 1 dbo.ufn_BuildingPartExtendedCopyXml(null, @deviceIds, @buildingIdsWithDevices) from @buildings where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@buildingsXML") as last into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in (select ID from @deviceIds ) and TradeId is not null | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select Top 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadDeviceForAllDevicesForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadDeviceForAllDevicesForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadDeviceForAllDevicesForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadBuildingPartDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadBuildingPartDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadBuildingPartDataForExtendedCopy | |
( | |
@buildingPartIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @buildingPartIdsXml | |
declare @buildingPartIds table (Id varchar(300)) | |
insert into @buildingPartIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
-- collect depending building parts | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
declare @buildings table(ID varchar(300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Type] [varchar](20), | |
[Name] [nvarchar](255), [Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] [varchar](20), [Comment] [nvarchar](max)) | |
insert into @buildings select ID, 0, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment from Building where ID in (select distinct (ID) from @buildingPartIds ) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID, @recursionStep, InstallationID, ParentID, Type, Name, Number, Description, CompletionStatus, Comment from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
set @recursionStep = @recursionStep + 1 | |
end | |
-- collect depending topology structure | |
declare @deviceIds idtable | |
declare @lineIds table(ID varchar(300), DeviceId varchar(300)) | |
declare @areaIds table(ID varchar(300), LineId varchar(300)) | |
insert into @deviceIds select ID from Device Where BuildingID in (select ID from @buildings) | |
insert into @lineIds select LineID, ID from Device where ID in (select id from @deviceIds) | |
insert into @areaIds select AreaID, ID from Line where ID in (select Id from @lineIds) | |
declare @areaId varchar(300) | |
declare @lineId varchar(300) | |
declare @lineXml xml = '' | |
declare @linePartXml xml | |
declare @deviceXml xml | |
declare @areaPartXml xml | |
declare @areaXml xml = '<Topology><UnassignedDevices /></Topology>' | |
declare @tempLineIds idtable | |
declare areaCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @areaIds | |
open areaCursor | |
fetch next from areaCursor into @areaId | |
while @@FETCH_STATUS = 0 | |
begin | |
set @linePartXml = null | |
set @lineXml = '' | |
set @areaPartXml = null | |
declare lineCursor cursor local forward_only fast_forward read_only for select ID from Line where ID in (select distinct(ID) from @LineIds) and AreaId = @AreaId | |
open lineCursor | |
fetch next from lineCursor into @lineId | |
declare @ids idtable | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from @ids | |
delete from @tempLineIds | |
insert into @ids select ID from Device where ID in (select ID from @deviceIds) and LineID = @lineId | |
insert into @tempLineIds (Id) values ( @lineId ) | |
set @linePartXml = dbo.ufn_GetLineXmlForExtendedCopy(@tempLineIds, @ids) | |
set @lineXml.modify('insert sql:variable("@linePartXml") as first into (/)[1]') | |
fetch next from lineCursor into @lineId | |
end | |
close lineCursor | |
deallocate lineCursor | |
set @areaPartXml = (select Id, Name, Address, Comment, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus, Description, @lineXml from Area where ID = @areaId order by [Address] for xml auto ) | |
set @areaXml.modify('insert sql:variable("@areaPartXml") as first into (/Topology)[1]') | |
fetch next from areaCursor into @areaId | |
end | |
close areaCursor | |
deallocate areaCursor | |
declare @UnassigendDevicesXml xml | |
set @UnassigendDevicesXml = dbo.ufn_UnassigendDevicesExtendedCopxXml(@deviceIds) | |
set @areaXml.modify('insert sql:variable("@UnassigendDevicesXml") as first into (/Topology/UnassignedDevices)[last()]') | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@areaXml") as first into (/KNX/Project/Installations/Installation)[1]' ) | |
declare @buildingPartXml xml | |
set @buildingPartXml = (select ID as Id | |
, Name, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, [Description] | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartXml(ID, ID, ID, @deviceIds) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceIds) | |
from Building as BuildingPart where ID in ( select ID from @buildings where Step = 0) for xml auto) | |
set @xml.modify( 'insert sql:variable("@buildingPartXml") as first into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
declare @tradeIdsWithDevices idtable | |
insert into @tradeIdsWithDevices select TradeID from Device where ID in(select ID from @deviceIds ) and TradeId is not null | |
-- collect depending trades | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @trades table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @trades select ID, ParentID from Trade where ID in (select distinct (ID) from @tradeIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @trades) | |
insert into @trades select ID, ParentID from Trade where ID in (select ParentID from @trades) and ID not in (select ID from @trades) | |
set @countAfter= (select count(ID) from @trades) | |
end | |
insert into @tradeIdsWithDevices select ID from @trades where ID not in (select Id from @tradeIdsWithDevices) | |
declare @tradesXML xml | |
set @tradesXML = (select Top 1 dbo.ufn_TradeExtendedCopyXml(null, @deviceIds, @tradeIdsWithDevices) from @trades where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadBuildingPartDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadBuildingPartDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadBuildingPartDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_LoadTradeDataForExtendedCopy') | |
BEGIN | |
DROP Procedure dbo.usp_LoadTradeDataForExtendedCopy | |
END | |
GO | |
CREATE Procedure dbo.usp_LoadTradeDataForExtendedCopy | |
( | |
@tradeIdsXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @tradeIdsXml | |
declare @tradeIds table (Id varchar(300)) | |
insert into @tradeIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
-- collect depending trade | |
declare @trades TABLE ( [ID] [varchar](300), Step int, [InstallationID] [varchar](300), [ParentID] [varchar](300), [Name] [nvarchar](255), | |
[Number] [nvarchar](255), [Description] [nvarchar](max), [CompletionStatus] varchar(50), [Comment] [nvarchar](max) ) | |
insert into @trades select [ID], 0, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from Trade where ID in (select distinct(ID) from @tradeIds) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @trades) | |
insert into @trades select [ID], @recursionStep, [InstallationID],[ParentID],[Name],[Number],[Description],[CompletionStatus],[Comment] from Trade where ParentID in (select ID from @trades) and ID not in (select ID from @trades) | |
set @countAfter=(select count(ID) from @trades) | |
set @recursionStep = @recursionStep + 1 | |
end | |
-- collect depending topology structure | |
declare @deviceIds idtable | |
declare @lineIds table(ID varchar(300), DeviceId varchar(300)) | |
declare @areaIds table(ID varchar(300), LineId varchar(300)) | |
insert into @deviceIds select ID from Device Where TradeID in (select ID from @trades) | |
insert into @lineIds select LineID, ID from Device where ID in (select id from @deviceIds) | |
insert into @areaIds select AreaID, ID from Line where ID in (select Id from @lineIds) | |
declare @areaId varchar(300) | |
declare @lineId varchar(300) | |
declare @lineXml xml = '' | |
declare @linePartXml xml | |
declare @deviceXml xml | |
declare @areaPartXml xml | |
declare @areaXml xml = '<Topology><UnassignedDevices /></Topology>' | |
declare @tempLineIds idtable | |
declare areaCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @areaIds | |
open areaCursor | |
fetch next from areaCursor into @areaId | |
while @@FETCH_STATUS = 0 | |
begin | |
set @linePartXml = null | |
set @lineXml = '' | |
set @areaPartXml = null | |
declare lineCursor cursor local forward_only fast_forward read_only for select ID from Line where ID in (select distinct(ID) from @LineIds) and AreaId = @AreaId | |
open lineCursor | |
fetch next from lineCursor into @lineId | |
declare @ids idtable | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from @ids | |
delete from @tempLineIds | |
insert into @ids select ID from Device where ID in (select ID from @deviceIds) and LineID = @lineId | |
insert into @tempLineIds (Id) values ( @lineId ) | |
set @linePartXml = dbo.ufn_GetLineXmlForExtendedCopy(@tempLineIds, @ids) | |
set @lineXml.modify('insert sql:variable("@linePartXml") as first into (/)[1]') | |
fetch next from lineCursor into @lineId | |
end | |
close lineCursor | |
deallocate lineCursor | |
set @areaPartXml = ( select Id, Name, Address, Comment, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus, Description, @lineXml from Area where ID = @areaId order by [Address] for xml auto) | |
set @areaXml.modify('insert sql:variable("@areaPartXml") as first into (/Topology)[1]') | |
fetch next from areaCursor into @areaId | |
end | |
close areaCursor | |
deallocate areaCursor | |
declare @xml xml = N'<KNX><Project><Installations><Installation><Buildings /><GroupAddresses><GroupRanges /></GroupAddresses><Trades /></Installation></Installations></Project></KNX>' | |
set @xml.modify( 'insert sql:variable("@areaXml") as first into (/KNX/Project/Installations/Installation)[1]' ) | |
declare @buildingIdsWithDevices idtable | |
insert into @buildingIdsWithDevices select BuildingID from Device where ID in (select ID from @deviceIds ) and BuildingId is not null | |
set @countBefore = 0 | |
set @countAfter = 1 | |
set @recursionStep = 1 | |
-- collect depending building parts | |
declare @buildings table(ID varchar(300), [ParentID] [varchar](300) ) | |
insert into @buildings select ID, ParentID from Building where ID in (select distinct (ID) from @buildingIdsWithDevices) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @buildings) | |
insert into @buildings select ID, ParentID from Building where ID in (select ParentID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter= (select count(ID) from @buildings) | |
end | |
insert into @buildingIdsWithDevices select ID from @buildings where ID not in (select Id from @buildingIdsWithDevices) | |
declare @buildingsXML xml | |
set @buildingsXML = (select top 1 dbo.ufn_BuildingPartExtendedCopyXml(null, @deviceIds, @buildingIdsWithDevices) from @buildings where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@buildingsXML") as last into (/KNX/Project/Installations/Installation/Buildings)[1]' ) | |
declare @tradeIdsWithDevices idtable | |
insert into @tradeIdsWithDevices select ID from @trades | |
declare @tradesXML xml | |
set @tradesXML=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeExtendedCopyXml( ID, @deviceIds, @tradeIdsWithDevices ) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceIds) | |
from Trade where ID in (select ID from @trades where Step = 0) | |
for xml auto | |
) | |
set @xml.modify( 'insert sql:variable("@tradesXML") as last into (/KNX/Project/Installations/Installation/Trades)[1]' ) | |
-- collect depending groupranges and group addresses | |
declare @connectors table (Id varchar(300), DeviceId varchar(300), GroupAddressId varchar(300)) | |
insert into @connectors select Id, DeviceId, GroupAddressID from Connector where DeviceID in (select * from @deviceIds) | |
set @countBefore = 0 | |
set @countAfter = 1 | |
declare @groupRanges table(ID varchar(300), ParentID varchar(300) ) | |
declare @groupAddressIds idtable | |
insert into @groupAddressIds select distinct(GroupAddressId) from @connectors | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select distinct (GroupAddress.GroupRangeID) from @connectors as DependingConnectors inner join GroupAddress on DependingConnectors.GroupAddressId = GroupAddress.ID) | |
while @countBefore < @countAfter | |
begin | |
set @countBefore= (select count(ID) from @groupRanges) | |
insert into @groupRanges select ID, ParentID from GroupRange where ID in (select ParentID from @groupRanges) and ID not in (select ID from @groupRanges) | |
set @countAfter= (select count(ID) from @groupRanges) | |
end | |
declare @groupRangesXML xml | |
set @groupRangesXML = (select dbo.ufn_GroupRangesXml(null, null, ID, @groupAddressIds) from @groupRanges where ParentID is null for xml path('')) | |
set @xml.modify( 'insert sql:variable("@groupRangesXML") as last into (/KNX/Project/Installations/Installation/GroupAddresses/GroupRanges)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_LoadTradeDataForExtendedCopy TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_LoadTradeDataForExtendedCopy TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_LoadTradeDataForExtendedCopy TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CreateDBUsers] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - User login scripts | |
*/ | |
-- create login EtsInternal if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]=N'EtsInternal') | |
CREATE LOGIN EtsInternal WITH PASSWORD=N'#EtsInternalPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
-- create login EtsProject if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]='EtsProject') | |
CREATE LOGIN EtsProject WITH PASSWORD='#EtsProjectPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
-- create login EtsReadOnly if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]=N'EtsReadOnly') | |
CREATE LOGIN EtsReadOnly WITH PASSWORD=N'#EtsReadOnlyPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]=N'EtsInternal') | |
CREATE USER EtsInternal FOR LOGIN EtsInternal | |
GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]='EtsProject') | |
CREATE USER EtsProject FOR LOGIN EtsProject | |
GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]=N'EtsReadOnly') | |
CREATE USER EtsReadOnly FOR LOGIN EtsReadOnly | |
GO | |
GRANT ADMINISTER BULK OPERATIONS TO EtsInternal | |
GRANT ADMINISTER BULK OPERATIONS TO EtsProject | |
GO | |
-------------------------------------------------------------------------------- | |
-- [CreateEmptyDatabase] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Script for creating a empty database | |
*/ | |
IF DB_NAME() != 'master' | |
BEGIN | |
RAISERROR('Script executes not against master database',16,1) | |
RETURN | |
END | |
-- create new database at specified location | |
EXECUTE AS CALLER; | |
CREATE DATABASE [#name#] ON PRIMARY | |
( NAME = N'#name#', FILENAME = N'#filename#' , SIZE = 3072KB , FILEGROWTH = 1024KB ) | |
LOG ON | |
( NAME = N'#name#_log', FILENAME = N'#logfilename#' , SIZE = 1024KB , FILEGROWTH = 10%) | |
GO | |
ALTER DATABASE [#name#] SET AUTO_SHRINK ON | |
GO | |
-- create login EtsInternal if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]=N'EtsInternal') | |
CREATE LOGIN EtsInternal WITH PASSWORD=N'#EtsInternalPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
-- create login EtsManufacturer if not existing | |
--IF NOT EXISTS (SELECT name from sys.syslogins where [name]='EtsManufacturer') | |
--CREATE LOGIN EtsManufacturer WITH PASSWORD='#EtsManufacturerPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
--GO | |
-- create login EtsProject if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]='EtsProject') | |
CREATE LOGIN EtsProject WITH PASSWORD='#EtsProjectPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
-- create login EtsProjectTest if not existing | |
--IF NOT EXISTS (SELECT name from sys.syslogins where [name]='EtsProjectTest') | |
--CREATE LOGIN EtsProjectTest WITH PASSWORD='#EtsProjectTestPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
--GO | |
-- create login EtsReadOnly if not existing | |
IF NOT EXISTS (SELECT name from sys.syslogins where [name]=N'EtsReadOnly') | |
CREATE LOGIN EtsReadOnly WITH PASSWORD=N'#EtsReadOnlyPwd#', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF | |
GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]=N'EtsInternal') | |
CREATE USER EtsInternal FOR LOGIN EtsInternal | |
GO | |
--IF NOT EXISTS (SELECT name from sys.sysusers where [name]='EtsManufacturer') | |
--CREATE USER EtsManufacturer FOR LOGIN EtsManufacturer | |
--GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]='EtsProject') | |
CREATE USER EtsProject FOR LOGIN EtsProject | |
GO | |
IF NOT EXISTS (SELECT name from sys.sysusers where [name]=N'EtsReadOnly') | |
CREATE USER EtsReadOnly FOR LOGIN EtsReadOnly | |
GO | |
GRANT ADMINISTER BULK OPERATIONS TO EtsInternal | |
GRANT ADMINISTER BULK OPERATIONS TO EtsProject | |
GO | |
USE tempdb | |
GO | |
IF NOT EXISTS (SELECT name from sys.database_principals where [name]=N'EtsInternal') | |
begin | |
begin try | |
CREATE USER [EtsInternal] FOR LOGIN [EtsInternal] WITH DEFAULT_SCHEMA=[dbo] | |
end try | |
begin catch | |
end catch | |
end | |
GO | |
USE [#name#] | |
GO | |
IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = N'PRIMARY') ALTER DATABASE [#name#] MODIFY FILEGROUP [PRIMARY] DEFAULT | |
IF NOT EXISTS (select * from sys.database_role_members drm join sys.database_principals dp ON drm.role_principal_id = dp.principal_id where dp.name = 'ETSFullAccess') | |
CREATE ROLE ETSFullAccess; | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_datawriter] TO [ETSFullAccess] | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ETSFullAccess] | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_accessadmin] TO [ETSFullAccess] | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [ETSFullAccess] | |
GO | |
IF NOT EXISTS (select * from sys.database_role_members drm join sys.database_principals dp ON drm.role_principal_id = dp.principal_id where dp.name = 'ETSWriteProjectAccess') | |
CREATE ROLE ETSWriteProjectAccess | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_datawriter] TO [ETSWriteProjectAccess] | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ETSWriteProjectAccess] | |
GO | |
IF NOT EXISTS (select * from sys.database_role_members drm join sys.database_principals dp ON drm.role_principal_id = dp.principal_id where dp.name = 'ETSReadOnlyAccess') | |
CREATE ROLE ETSReadOnlyAccess | |
GO | |
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ETSReadOnlyAccess] | |
GO | |
-- add users to newly created database | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsInternal', @name_in_db = N'EtsInternal' | |
--EXEC dbo.sp_grantdbaccess @loginame = N'EtsManufacturer', @name_in_db = N'EtsManufacturer' | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsProject', @name_in_db = N'EtsProject' | |
--EXEC dbo.sp_grantdbaccess @loginame = N'EtsProjectTest', @name_in_db = N'EtsProjectTest' | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsReadOnly', @name_in_db = N'EtsReadOnly' | |
-- add users to newly roles | |
EXEC sp_addrolemember N'ETSFullAccess', N'EtsInternal' | |
GO | |
--EXEC sp_addrolemember N'ETSReadOnlyAccess', N'EtsManufacturer' | |
--GO | |
EXEC sp_addrolemember N'ETSReadOnlyAccess', N'EtsReadOnly' | |
GO | |
EXEC sp_addrolemember N'ETSWriteProjectAccess', N'EtsProject' | |
GO | |
EXEC sp_addrolemember 'db_owner', N'EtsInternal' | |
EXEC sp_addrolemember 'db_datareader', N'EtsInternal' | |
EXEC sp_addrolemember 'db_datawriter', N'EtsInternal' | |
EXEC sp_addrolemember 'db_accessadmin', N'EtsInternal' | |
--EXEC sp_addrolemember 'db_datareader', 'EtsManufacturer' | |
--EXEC sp_addrolemember 'db_datawriter', 'EtsManufacturer' | |
EXEC sp_addrolemember 'db_datareader', 'EtsProject' | |
EXEC sp_addrolemember 'db_datawriter', 'EtsProject' | |
--EXEC sp_addrolemember 'db_datareader', 'EtsProjectTest' | |
--EXEC sp_addrolemember 'db_datawriter', 'EtsProjectTest' | |
EXEC sp_addrolemember 'db_datareader', N'EtsReadOnly' | |
GO | |
REVERT; | |
GO | |
USE master; | |
-------------------------------------------------------------------------------- | |
-- [CreateTableDefinitionAsXml] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Creates Xml Header with table information. Internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CreateTableDefinitionAsXml') | |
BEGIN | |
DROP Function dbo.ufn_CreateTableDefinitionAsXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CreateTableDefinitionAsXml | |
( | |
@tableName nvarchar(1000) | |
) | |
RETURNS xml | |
AS | |
BEGIN | |
declare @header xml = (select TABLE_NAME as TableName, COLUMN_NAME as ColumnName, DATA_TYPE as DataType, CHARACTER_MAXIMUM_LENGTH as CharacterMaxLength from INFORMATION_SCHEMA.COLUMNS as [Column] where TABLE_NAME = @tableName for xml auto) | |
return @header | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_CreateTableDefinitionAsXml TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_CreateTableDefinitionAsXml TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_CreateTableDefinitionAsXml TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteAddinData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a area | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteAddinData') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteAddinData | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteAddinData | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM AddinData Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteAddinData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteAddinData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteAddinData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteAdditionalDeviceAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes additional addresses of a device | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteAdditionalDeviceAddress') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteAdditionalDeviceAddress | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteAdditionalDeviceAddress | |
( | |
@deviceId varchar(300), | |
@address int | |
) | |
AS | |
delete from AdditionalDeviceAddress where DeviceID=@deviceId and Address=@address | |
GO | |
GRANT EXEC ON dbo.usp_DeleteAdditionalDeviceAddress TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteAdditionalDeviceAddress TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteAdditionalDeviceAddress TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteArea] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a area | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteArea') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteArea | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteArea | |
( | |
@Id varchar(300) | |
) | |
AS | |
declare @lines table( ID varchar(300) ) | |
insert into @lines select ID from Line where AreaID = @Id | |
delete from Device where LineID in (select ID from @lines) | |
delete from AdditionalGroupAddress where LineID in (select ID from @lines) | |
DELETE FROM Area Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteArea TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteArea TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteArea TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteAreas') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteAreas | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteAreas | |
( | |
@areaIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @areaIdXml | |
declare @areaIds table(ID varchar(300)) | |
insert into @areaIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @lineIds table(ID varchar(300)) | |
insert into @lineIds select ID from Line where AreaID in (select ID from @areaIds) | |
delete from Device where LineID in (select ID from @lineIds) | |
delete from AdditionalGroupAddress where LineID in (select ID from @lineIds) | |
delete from Area where ID in (select ID from @areaIds) | |
GO | |
GRANT EXEC ON dbo.usp_DeleteAreas TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteAreas TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteAreas TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteBuildingPart] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes building part | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteBuildingPart') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteBuildingPart | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteBuildingPart | |
( | |
@Id varchar(300) | |
) | |
AS | |
--delete from Building where ID=@Id | |
declare @buildings table(ID varchar(300), Step int ) | |
insert into @buildings values(@Id, 0) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID, @recursionStep from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare buildingCursor cursor local forward_only fast_forward read_only for select ID from @buildings order by Step desc | |
open buildingCursor | |
declare @idToDelete varchar(300) | |
fetch next from buildingCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
update Device set BuildingID=null where BuildingID=@idToDelete | |
delete from Building where ID=@idToDelete | |
fetch next from buildingCursor into @idToDelete | |
end | |
close buildingCursor | |
deallocate buildingCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteBuildingPart TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteBuildingPart TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteBuildingPart TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteBuildingParts') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteBuildingParts | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteBuildingParts | |
( | |
@buildingIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @buildingIdXml | |
declare @buildingIds table(ID varchar(300), Step int) | |
insert into @buildingIds select ID, 0 from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildingIds) | |
insert into @buildingIds select ID, @recursionStep from Building where ParentID in (select ID from @buildingIds) and ID not in (select ID from @buildingIds) | |
set @countAfter=(select count(ID) from @buildingIds) | |
set @recursionStep = @recursionStep + 1 | |
end | |
delete from Device where BuildingID in (select ID from @buildingIds) | |
declare buildingCursor cursor local forward_only fast_forward read_only for select ID from @buildingIds order by Step desc | |
open buildingCursor | |
declare @idToDelete varchar(300) | |
fetch next from buildingCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from Building where ID=@idToDelete | |
fetch next from buildingCursor into @idToDelete | |
end | |
close buildingCursor | |
deallocate buildingCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteBuildingParts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteBuildingParts TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteBuildingParts TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteCommunicationObjectInstanceReference] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a device communication object | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteCommunicationObjectInstanceReference') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteCommunicationObjectInstanceReference | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteCommunicationObjectInstanceReference | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM DeviceObject Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteCommunicationObjectInstanceReference TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteCommunicationObjectInstanceReference TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteCommunicationObjectInstanceReference TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteConnector] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a connector | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteConnector') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteConnector | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteConnector | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM Connector Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteConnector TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteConnector TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteConnector TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteDevice] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a device | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteDevice') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteDevice | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteDevice | |
( | |
@Id varchar(300) | |
) | |
AS | |
delete from Device where ID=@Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteDevice TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteDevice TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteDevice TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteDevices') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteDevices | |
( | |
@deviceIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdXml | |
declare @deviceIds table(ID varchar(300)) | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
delete from Device where ID in (select ID from @deviceIds) | |
GO | |
GRANT EXEC ON dbo.usp_DeleteDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteDevices TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteDevices TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetConnectorsOfDevice') | |
BEGIN | |
DROP Procedure dbo.usp_GetConnectorsOfDevice | |
END | |
GO | |
CREATE Procedure dbo.usp_GetConnectorsOfDevice | |
( | |
@Id varchar(300) | |
) | |
AS | |
declare @deviceObjects table( ID varchar(300) ) | |
insert into @deviceObjects select ID from DeviceObject where DeviceID=@Id | |
declare @connectors table( ID varchar(300), GroupAddressID varchar(300) ) | |
insert into @connectors select ID, GroupAddressID from Connector where DeviceObjectID in (select ID from @deviceObjects) order by GroupAddressID | |
select * from @connectors | |
GO | |
GRANT EXEC ON dbo.usp_GetConnectorsOfDevice TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetConnectorsOfDevice TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetConnectorsOfDevice TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetConnectorsOfDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetConnectorsOfDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetConnectorsOfDevices | |
( | |
@deviceIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdXml | |
declare @deviceIds table(ID varchar(300)) | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @deviceObjects table( ID varchar(300) ) | |
insert into @deviceObjects select ID from DeviceObject where DeviceID in (select ID from @deviceIds) | |
select Connector.ID as ID, Connector.DeviceID as DeviceID, Connector.GroupAddressID as GroupAddressID, Connector.DeviceObjectID as DeviceObjectID | |
, Connector.Send as Send, Connector.Acknowledge as Acknowledge | |
, DeviceObject.CommunicationObjectRefID as CommunicationObjectRefID | |
from Connector inner join DeviceObject on Connector.DeviceObjectID = DeviceObject.ID where DeviceObjectID in (select ID from @deviceObjects) order by Connector.DeviceID | |
GO | |
GRANT EXEC ON dbo.usp_GetConnectorsOfDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetConnectorsOfDevices TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetConnectorsOfDevices TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDbDeviceObjectsOfDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetDbDeviceObjectsOfDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDbDeviceObjectsOfDevices | |
( | |
@deviceIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @deviceIdXml | |
declare @deviceIds table(ID varchar(300)) | |
insert into @deviceIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
select ID, DeviceID, CommunicationObjectRefID from DeviceObject where DeviceID in (select ID from @deviceIds) | |
GO | |
GRANT EXEC ON dbo.usp_GetDbDeviceObjectsOfDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDbDeviceObjectsOfDevices TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetDbDeviceObjectsOfDevices TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteDeviceBinaryData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a device binary data | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteDeviceBinaryData') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteDeviceBinaryData | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteDeviceBinaryData | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM DeviceBinaryData Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteDeviceBinaryData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteDeviceBinaryData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteDeviceBinaryData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteGroupAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a group address | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteGroupAddress') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteGroupAddress | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteGroupAddress | |
( | |
@Id varchar(300) | |
) | |
AS | |
-- delete from Connector where GroupAddressID=@Id | |
delete from GroupAddress where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteGroupAddress TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteGroupAddress TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteGroupAddress TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteGroupAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteGroupAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteGroupAddresses | |
( | |
@groupAddressIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @groupAddressIdXml | |
declare @Ids table(ID varchar(300)) | |
insert into @Ids select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
delete from Connector where GroupAddressID in (select ID from @Ids) | |
delete from GroupAddress where ID in (select ID from @Ids) | |
GO | |
GRANT EXEC ON dbo.usp_DeleteGroupAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteGroupAddresses TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteGroupAddresses TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteGroupRange] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a group range | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteGroupRange') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteGroupRange | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteGroupRange | |
( | |
@Id varchar(300) | |
) | |
AS | |
declare @ranges table(ID varchar(300), InstallationID varchar(300), ParentID varchar(300), [Name] nvarchar(255), Description nvarchar(max), RangeStart int, RangeEnd int, Unfiltered bit, [Comment] nvarchar(max), Step int ) | |
insert into @ranges select *, 0 from GroupRange where ID = @id | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @ranges) | |
insert into @ranges select *, @recursionStep from GroupRange where ParentID in (select ID from @ranges) and ID not in (select ID from @ranges) | |
set @countAfter=(select count(ID) from @ranges) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare rangeCursor cursor local forward_only fast_forward read_only for select ID from @ranges order by Step desc | |
open rangeCursor | |
declare @idToDelete varchar(300) | |
fetch next from rangeCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from GroupRange where ID=@idToDelete | |
fetch next from rangeCursor into @idToDelete | |
end | |
close rangeCursor | |
deallocate rangeCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteGroupRange TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteGroupRange TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteGroupRange TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteGroupRanges') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteGroupRanges | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteGroupRanges | |
( | |
@groupRangesIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @groupRangesIdXml | |
declare @Ids table(ID varchar(300)) | |
insert into @Ids select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @ranges table(ID varchar(300), InstallationID varchar(300), ParentID varchar(300), [Name] nvarchar(255), Description nvarchar(max), RangeStart int, RangeEnd int, Unfiltered bit, [Comment] nvarchar(max), Step int ) | |
insert into @ranges select *, 0 from GroupRange where ID in (select Id from @Ids) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @ranges) | |
insert into @ranges select *, @recursionStep from GroupRange where ParentID in (select ID from @ranges) and ID not in (select ID from @ranges) | |
set @countAfter=(select count(ID) from @ranges) | |
set @recursionStep = @recursionStep + 1 | |
end | |
delete from Connector where GroupAddressID in (select ID from GroupAddress where GroupRangeID in (select ID from @ranges)) | |
delete from GroupAddress where GroupRangeID in (select ID from @ranges) | |
declare rangeCursor cursor local forward_only fast_forward read_only for select ID from @ranges order by Step desc | |
open rangeCursor | |
declare @idToDelete varchar(300) | |
fetch next from rangeCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from GroupRange where ID=@idToDelete | |
fetch next from rangeCursor into @idToDelete | |
end | |
close rangeCursor | |
deallocate rangeCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteGroupRanges TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteGroupRanges TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteGroupRanges TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteInstallation] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a installation | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteInstallation') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteInstallation | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteInstallation | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM Installation Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteInstallation TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteInstallation TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteInstallation TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteLine] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a line | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteLine') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteLine | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteLine | |
( | |
@Id varchar(300) | |
) | |
AS | |
delete from Device where LineID = @Id | |
delete from AdditionalGroupAddress where LineID=@Id | |
DELETE FROM Line Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteLine TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteLine TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteLine TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteLines') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteLines | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteLines | |
( | |
@lineIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @lineIdXml | |
declare @lineIds table(ID varchar(300)) | |
insert into @lineIds select ID from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
delete from Device where LineID in (select ID from @lineIds) | |
delete from AdditionalGroupAddress where LineID in (select ID from @lineIds) | |
delete from Line where ID in (select ID from @lineIds) | |
GO | |
GRANT EXEC ON dbo.usp_DeleteLines TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteLines TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteLines TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteParameterInstanceReference] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a device parameter | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteParameterInstanceReference') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteParameterInstanceReference | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteParameterInstanceReference | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM DeviceParameter Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteParameterInstanceReference TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteParameterInstanceReference TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteParameterInstanceReference TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteProject] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a project | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteProject') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteProject | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteProject | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM Project Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteProject TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteProject TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteProject TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteProjectHistory] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a project history entry | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteProjectHistory') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteProjectHistory | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteProjectHistory | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM ProjectHistory Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteProjectHistory TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteProjectHistory TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteProjectHistory TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteProjectTrace] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a project trace | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteProjectTrace') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteProjectTrace | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteProjectTrace | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM ProjectTrace Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteProjectTrace TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteProjectTrace TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteProjectTrace TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteProjectTraceCollection] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a project trace collection | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteProjectTraceCollection') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteProjectTraceCollection | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteProjectTraceCollection | |
( | |
@toDelete xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @toDelete | |
DELETE FROM ProjectTrace Where ID in (select Id from openxml(@docHandle, '/Items/Item') with (ID varchar(300) '@Id') ) | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_DeleteProjectTraceCollection TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteProjectTraceCollection TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteProjectTraceCollection TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteSplitInfo] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteSplitInfo') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteSplitInfo | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteSplitInfo | |
( | |
@Id varchar(300) | |
) | |
AS | |
delete from [SplitInfo] WHERE ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteSplitInfo TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteSplitInfo TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_DeleteSplitInfo TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteSplitInfos') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteSplitInfos | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteSplitInfos | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
delete from [SplitInfo] WHERE InstallationID = @InstallationId | |
GO | |
GRANT EXEC ON dbo.usp_DeleteSplitInfos TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteSplitInfos TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_DeleteSplitInfos TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteToDoItem] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a ToDo item | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteToDoItem') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteToDoItem | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteToDoItem | |
( | |
@Id varchar(300) | |
) | |
AS | |
DELETE FROM ToDoItem Where ID = @Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteToDoItem TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteToDoItem TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteToDoItem TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteTrade] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a trade | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteTrade') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteTrade | |
( | |
@Id varchar(300) | |
) | |
AS | |
-- delete from Trade where ID=@Id | |
declare @trades table(ID varchar(300), Step int ) | |
insert into @trades values(@Id, 0) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @trades) | |
insert into @trades select ID, @recursionStep from Trade where ParentID in (select ID from @trades) and ID not in (select ID from @trades) | |
set @countAfter=(select count(ID) from @trades) | |
set @recursionStep = @recursionStep + 1 | |
end | |
declare tradeCursor cursor local forward_only fast_forward read_only for select ID from @trades order by Step desc | |
open tradeCursor | |
declare @idToDelete varchar(300) | |
fetch next from tradeCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
update Device set TradeID=null where TradeID=@idToDelete | |
delete from Trade where ID=@idToDelete | |
fetch next from tradeCursor into @idToDelete | |
end | |
close tradeCursor | |
deallocate tradeCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteTrade TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteTrade TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteTrades') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteTrades | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteTrades | |
( | |
@tradeIdXml xml | |
) | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @tradeIdXml | |
declare @tradeIds table(ID varchar(300), Step int) | |
insert into @tradeIds select ID, 0 from openxml( @docHandle, '/Items/Item') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
declare @recursionStep int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @tradeIds) | |
insert into @tradeIds select ID, @recursionStep from Trade where ParentID in (select ID from @tradeIds) and ID not in (select ID from @tradeIds) | |
set @countAfter=(select count(ID) from @tradeIds) | |
set @recursionStep = @recursionStep + 1 | |
end | |
delete from Device where TradeID in (select ID from @tradeIds) | |
declare tradeCursor cursor local forward_only fast_forward read_only for select ID from @tradeIds order by Step desc | |
open tradeCursor | |
declare @idToDelete varchar(300) | |
fetch next from tradeCursor into @idToDelete | |
while @@FETCH_STATUS = 0 | |
begin | |
delete from Trade where ID=@idToDelete | |
fetch next from tradeCursor into @idToDelete | |
end | |
close tradeCursor | |
deallocate tradeCursor | |
GO | |
GRANT EXEC ON dbo.usp_DeleteTrades TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteTrades TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteTrades TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [DeleteUserFile] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure deletes a user file | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_DeleteUserFile') | |
BEGIN | |
DROP Procedure dbo.usp_DeleteUserFile | |
END | |
GO | |
CREATE Procedure dbo.usp_DeleteUserFile | |
( | |
@Id varchar(300) | |
) | |
AS | |
delete from UserFile where ID=@Id | |
GO | |
GRANT EXEC ON dbo.usp_DeleteUserFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_DeleteUserFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_DeleteUserFile TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ExchangeApplicationProgram] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ExchangeApplicationProgram') | |
BEGIN | |
DROP Procedure dbo.usp_ExchangeApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_ExchangeApplicationProgram | |
( | |
@applicationProgramIdXml xml | |
) | |
AS | |
set nocount on | |
begin try | |
begin transaction | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @applicationProgramIdXml | |
declare @applicationProgramIds table([NewID] varchar(300), OldID varchar(300)) | |
insert into @applicationProgramIds select [NewID], OldID from openxml( @docHandle, '/Exchange/ApplicationPrograms/ApplicationProgram') with ([NewID] nvarchar(300) '@NewId', [OldID] nvarchar(300) '@OldId') | |
declare @hardware2ProgramIds table([NewID] varchar(300), OldID varchar(300)) | |
insert into @hardware2ProgramIds select [NewID], OldID from openxml( @docHandle, '/Exchange/Hardware2Programs/Hardware2Program') with ([NewID] nvarchar(300) '@NewId', [OldID] nvarchar(300) '@OldId') | |
exec sp_xml_removedocument @docHandle | |
-- exchange Hardare2ProgramID in CatalogItem | |
-- update CatalogItem set Hardware2ProgramID=[NewID] from CatalogItem inner join @hardware2ProgramIds on CatalogItem.Hardware2ProgramID=[@hardware2ProgramIds].OldID | |
-- exchange Hardare2ProgramID in Device | |
update Device set Hardware2ProgramID=[NewID] from Device inner join @hardware2ProgramIds on Device.Hardware2ProgramID=[@hardware2ProgramIds].OldID | |
-- exchange ApplicationProgramID part of CommunicationObjectRefID in DeviceObject | |
update DeviceObject set CommunicationObjectRefID=REPLACE(CommunicationObjectRefID, [OldID],[NewID]) from DeviceObject inner join @applicationProgramIds on DeviceObject.CommunicationObjectRefID like [@applicationProgramIds].OldID + '%' | |
-- exchange ApplicationProgramID part of CommunicationObjectRefID in DeviceObject | |
update DeviceParameter set ParameterRefID=REPLACE(ParameterRefID, [OldID],[NewID]) from DeviceParameter inner join @applicationProgramIds on DeviceParameter.ParameterRefID like [@applicationProgramIds].OldID + '%' | |
-- delete CatalogItem entries that references the Hardware2Program containing broken ApplicationProgram | |
delete from CatalogItem where Hardware2ProgramID in (select OldID from @hardware2ProgramIds where [OldID] <> [NewID]) | |
-- delete Hardware2Program entries that references the broken ApplicationProgram | |
delete from Hardware2Program where ID in (select OldID from @hardware2ProgramIds where [OldID] <> [NewID]) | |
-- delete broken ApplicationProgram entries | |
declare @parameters table( ID varchar(300) ) | |
insert into @parameters select ID from Parameter where ApplicationProgramID in (select OldID from @applicationProgramIds where [OldID] <> [NewID]) | |
declare @parameterUnions table( ID varchar(300) ) | |
insert into @parameterUnions select ID from ParameterUnion where ApplicationProgramID in (select OldID from @applicationProgramIds where [OldID] <> [NewID]) | |
delete from ParameterMemory where ParameterID in (select ID from @parameters) | |
delete from ParameterProperty where ParameterID in (select ID from @parameters) | |
delete from ParameterMemory where ParameterUnionID in (select ID from @parameterUnions) | |
delete from ParameterProperty where ParameterUnionID in (select ID from @parameterUnions) | |
-- resolve FK ring references | |
update ParameterRef set CalculationID = null where CalculationID is not null and ApplicationProgramID in (select OldID from @applicationProgramIds where [OldID] <> [NewID]) | |
delete from ParameterCalculation where ProgramID in (select OldID from @applicationProgramIds where [OldID] <> [NewID]) | |
delete from ApplicationProgram where ID in (select OldID from @applicationProgramIds where [OldID] <> [NewID]) | |
commit transaction | |
end try | |
begin catch | |
if XACT_STATE() <> 0 | |
begin | |
ROLLBACK TRANSACTION; | |
exec usp_RethrowException | |
end | |
end catch | |
GO | |
GRANT EXEC ON dbo.usp_ExchangeApplicationProgram TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ExchangeApplicationProgram TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_ExchangeApplicationProgram TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ExportSessionManagement] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedures - Stored procedure for closing the export session | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CloseExportSession') | |
BEGIN | |
DROP PROCEDURE dbo.usp_CloseExportSession | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_CloseExportSession | |
( | |
@sessionId uniqueidentifier | |
) | |
AS | |
-- clean up export tables | |
delete from ExportManufacturer where SessionID=@sessionId | |
delete from ExportApplicationProgram where SessionID=@sessionId | |
delete from ExportHardware where SessionID=@sessionId | |
delete from ExportHardware2Program where SessionID=@sessionId | |
delete from ExportProduct where SessionID=@sessionId | |
delete from ExportCatalogItem where SessionID=@sessionId | |
delete from ExportCatalogSection where SessionID=@sessionId | |
delete from ExportBaggage where SessionID=@sessionId | |
delete from ExportDeviceBinaryData where SessionID=@sessionId | |
GO | |
GRANT EXEC ON dbo.usp_CloseExportSession TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CloseExportSession TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CloseExportSession TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ExportXmlConversion] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedures - Stored procedures for exporting data as xml | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ParameterTypesXml') | |
BEGIN | |
DROP Function dbo.ufn_ParameterTypesXml | |
END | |
GO | |
CREATE Function dbo.ufn_ParameterTypesXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @restrictions xml | |
set @restrictions = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeRestriction.Base | |
, TypeRestriction.SizeInBit | |
, Enumeration.ID as Id | |
, dbo.ufn_BinaryToBase64(Enumeration.BinaryValue) as BinaryValue | |
, case Enumeration.AutomaticDisplayOrder when 0 then Enumeration.DisplayOrder else null end as DisplayOrder | |
, Enumeration.Text | |
, Enumeration.Value | |
from ParameterType inner join ParameterTypeRestriction as TypeRestriction on ParameterType.ID = TypeRestriction.ParameterTypeID inner join ParameterEnumValue as Enumeration on ParameterType.ID = Enumeration.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId order by ParameterType.ID, Enumeration.DisplayOrder | |
for xml auto) | |
declare @emptyrestrictions xml | |
set @emptyrestrictions = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeRestriction.Base | |
, TypeRestriction.SizeInBit | |
from ParameterType inner join ParameterTypeRestriction as TypeRestriction on ParameterType.ID = TypeRestriction.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId and ParameterType.ID not in (select ParameterTypeID from ParameterEnumValue) order by ParameterType.ID | |
for xml auto) | |
declare @numbers xml | |
set @numbers = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeNumber.MaxInclusive as maxInclusive | |
, TypeNumber.MinInclusive as minInclusive | |
, TypeNumber.SizeInBit | |
, TypeNumber.Type | |
, TypeNumber.UIHint | |
from ParameterType inner join ParameterTypeNumber as TypeNumber on ParameterType.ID = TypeNumber.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @floats xml | |
set @floats = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeFloat.MaxInclusive as maxInclusive | |
, TypeFloat.MinInclusive as minInclusive | |
, TypeFloat.Encoding | |
, TypeFloat.DisplayFormat | |
, TypeFloat.UIHint | |
, TypeFloat.FormattingScript | |
from ParameterType inner join ParameterTypeFloat as TypeFloat on ParameterType.ID = TypeFloat.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @texts xml | |
set @texts = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeText.SizeInBit | |
, TypeText.Pattern | |
from ParameterType inner join ParameterTypeText as TypeText on ParameterType.ID = TypeText.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @pictures xml | |
set @pictures = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypePicture.BaggageId as RefId | |
, TypePicture.HorizontalAlignment | |
from ParameterType inner join ParameterTypePicture as TypePicture on ParameterType.ID = TypePicture.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @dates xml | |
set @dates = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeDate.Encoding | |
, TypeDate.DisplayTheYear | |
from ParameterType inner join ParameterTypeDate as TypeDate on ParameterType.ID = TypeDate.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @netaddresses xml | |
set @netaddresses = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeIPAddress.AddressType as AddressType | |
, TypeIPAddress.Version as Version | |
from ParameterType inner join ParameterTypeIPAddress as TypeIPAddress on ParameterType.ID = TypeIPAddress.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @times xml | |
set @times = (select ParameterType.ID as Id | |
, ParameterType.Name | |
, ParameterType.Plugin | |
, ParameterType.InternalDescription | |
, TypeTime.MaxInclusive as maxInclusive | |
, TypeTime.MinInclusive as minInclusive | |
, TypeTime.SizeInBit | |
, TypeTime.Unit | |
, TypeTime.UIHint | |
from ParameterType inner join ParameterTypeTime as TypeTime on ParameterType.ID = TypeTime.ParameterTypeID | |
where ParameterType.ApplicationProgramID = @applicationProgramId | |
for xml auto) | |
declare @parameterTypeNone table( ParameterTypeNoneID varchar(300), Name varchar(50), TypeNone xml, Plugin varchar(max) ) | |
insert into @parameterTypeNone select ID, Name, N'', Plugin from ParameterType where ParameterType.ApplicationProgramID = @applicationProgramId | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeFloat) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeNumber) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeTime) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeDate) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypePicture) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeRestriction) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeIPAddress) | |
and ParameterType.ID not in (select ParameterTypeID from ParameterTypeText ) | |
declare @nones xml | |
set @nones = (select ParameterTypeNoneID as Id | |
, Name | |
, ParameterType.Plugin | |
, TypeNone | |
from @parameterTypeNone as ParameterType | |
for xml auto) | |
declare @xml xml | |
-- export collection only if at least one exists | |
if @restrictions is not null or @emptyrestrictions is not null | |
or @nones is not null or @numbers is not null or @texts is not null | |
or @dates is not null or @pictures is not null or @times is not null | |
or @netaddresses is not null or @floats is not null | |
begin | |
set @xml = N'<ParameterTypes/>' | |
set @xml.modify( 'insert sql:variable("@restrictions") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@emptyrestrictions") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@nones") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@numbers") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@floats") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@texts") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@dates") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@pictures") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@times") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@netaddresses") as last into (/*)[1]' ) | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ParameterTypesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ParameterTypesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ParameterTypesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ParametersXml') | |
BEGIN | |
DROP Function dbo.ufn_ParametersXml | |
END | |
GO | |
CREATE Function dbo.ufn_ParametersXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @memoryParameters xml | |
set @memoryParameters = ( | |
select Parameter.ID as Id | |
, Parameter.Name | |
, Parameter.Text | |
, Parameter.ParameterTypeID as ParameterType | |
, Parameter.Access | |
, ISNULL(Parameter.Value, '') as Value | |
, Parameter.LegacyPatchAlways | |
, Parameter.SuffixText | |
, Memory.CodeSegmentID as CodeSegment | |
, Memory.BitOffset | |
, Memory.Offset | |
from Parameter inner join ParameterMemory as Memory on Parameter.ID = Memory.ParameterID | |
where ApplicationProgramID = @applicationProgramId and Type = 'Memory' and Parameter.ParameterUnionID is null | |
for xml auto ) | |
declare @propertyParameters xml | |
set @propertyParameters = ( | |
select Parameter.ID as Id | |
, Parameter.Name | |
, Parameter.Text | |
, Parameter.ParameterTypeID as ParameterType | |
, Parameter.Access | |
, ISNULL(Parameter.Value, '') as Value | |
, Parameter.LegacyPatchAlways | |
, Parameter.SuffixText | |
, Property.BitOffset | |
, Property.ObjectIndex | |
, Property.ObjectType | |
, Property.Occurrence | |
, Property.Offset | |
, Property.PropertyId | |
from Parameter inner join ParameterProperty as Property on Parameter.ID = Property.ParameterID | |
where ApplicationProgramID = @applicationProgramId and Type = 'Property' and Parameter.ParameterUnionID is null | |
for xml auto ) | |
declare @noneParameters xml | |
set @noneParameters = ( | |
select Parameter.ID as Id | |
, Parameter.Name | |
, Parameter.Text | |
, Parameter.ParameterTypeID as ParameterType | |
, Parameter.Access | |
, ISNULL(Parameter.Value, '') as Value | |
, Parameter.LegacyPatchAlways | |
, Parameter.SuffixText | |
from Parameter where ApplicationProgramID = @applicationProgramId and Type = 'None' and Parameter.ParameterUnionID is null | |
for xml auto ) | |
declare @memoryUnionXml table (ID varchar(300), MemoryXml xml, ParameterXml xml) | |
insert into @memoryUnionXml select ParameterUnion.ID as ID, null, null from ParameterUnion where ParameterUnion.ApplicationProgramID = @applicationProgramId and ParameterUnion.Type='Memory' | |
declare memoryCursor cursor local forward_only fast_forward read_only for select ID from @memoryUnionXml | |
open memoryCursor | |
declare @id varchar(300) | |
fetch next from memoryCursor into @id | |
while @@FETCH_STATUS = 0 | |
begin | |
update @memoryUnionXml set MemoryXml=(select Memory.CodeSegmentID as CodeSegment, Memory.BitOffset, Memory.Offset from ParameterMemory as Memory where Memory.ParameterUnionID=@id for xml auto) where [@memoryUnionXml].ID=@id | |
update @memoryUnionXml set ParameterXml=(select Parameter.ID as Id, Parameter.Name, Parameter.Access, Parameter.DefaultUnionParameter | |
, Parameter.ParameterTypeID as ParameterType, ISNULL(Value, '') as Value | |
, Parameter.Text, Parameter.SuffixText, Parameter.ParameterUnionOffset as Offset, Parameter.ParameterUnionBitOffset as BitOffset from Parameter where Parameter.ParameterUnionID=@id for xml auto) where [@memoryUnionXml].ID=@id | |
fetch next from memoryCursor into @id | |
end | |
close memoryCursor | |
deallocate memoryCursor | |
declare @memoryUnionParameters xml | |
set @memoryUnionParameters = ( | |
select[Union].SizeInBit as '@SizeInBit' | |
, MemoryXml as '*' | |
, ParameterXml as '*' | |
from ParameterUnion as [Union] inner join @memoryUnionXml on [Union].ID=[@memoryUnionXml].ID | |
where [Union].ApplicationProgramID = @applicationProgramId and [Union].Type = 'Memory' | |
for xml path('Union') ) | |
declare @propertyUnionXml table (ID varchar(300), PropertyXml xml, ParameterXml xml) | |
insert into @propertyUnionXml select ParameterUnion.ID as ID, null, null from ParameterUnion where ParameterUnion.ApplicationProgramID = @applicationProgramId and ParameterUnion.Type='Property' | |
declare propertyCursor cursor local forward_only fast_forward read_only for select ID from @propertyUnionXml | |
open propertyCursor | |
fetch next from propertyCursor into @id | |
while @@FETCH_STATUS = 0 | |
begin | |
update @propertyUnionXml set PropertyXml=(select Property.BitOffset, Property.ObjectIndex, Property.ObjectType, Property.Occurrence, Property.Offset, Property.PropertyId from ParameterProperty as Property where Property.ParameterUnionID=@id for xml auto) where [@propertyUnionXml].ID=@id | |
update @propertyUnionXml set ParameterXml=(select Parameter.ID as Id, Parameter.Name, Parameter.Access, Parameter.DefaultUnionParameter | |
, Parameter.ParameterTypeID as ParameterType, ISNULL(Value, '') as Value | |
, Parameter.Text, Parameter.SuffixText, Parameter.ParameterUnionOffset as Offset, Parameter.ParameterUnionBitOffset as BitOffset from Parameter where Parameter.ParameterUnionID=@id for xml auto) where [@propertyUnionXml].ID=@id | |
fetch next from propertyCursor into @id | |
end | |
close propertyCursor | |
deallocate propertyCursor | |
declare @propertyUnionParameters xml | |
set @propertyUnionParameters = ( | |
select[Union].SizeInBit as '@SizeInBit' | |
, PropertyXml as '*' | |
, ParameterXml as '*' | |
from ParameterUnion as [Union] inner join @propertyUnionXml on [Union].ID=[@propertyUnionXml].ID | |
where [Union].ApplicationProgramID = @applicationProgramId and [Union].Type = 'Property' | |
for xml path('Union') ) | |
declare @xml xml | |
-- export only if at least one exists | |
if @memoryParameters is not null or @propertyParameters is not null | |
or @noneParameters is not null or @memoryUnionParameters is not null | |
or @propertyUnionParameters is not null | |
begin | |
set @xml= N'<Parameters/>' | |
set @xml.modify( 'insert sql:variable("@memoryParameters") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@propertyParameters") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@noneParameters") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@memoryUnionParameters") as last into (/*)[1]' ) | |
set @xml.modify( 'insert sql:variable("@propertyUnionParameters") as last into (/*)[1]' ) | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ParametersXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ParametersXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ParametersXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ParameterRefsXml') | |
BEGIN | |
DROP Function dbo.ufn_ParameterRefsXml | |
END | |
GO | |
CREATE Function dbo.ufn_ParameterRefsXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
-- declare @preEts4Style bit | |
-- set @preEts4Style = (select PreEts4Style from ApplicationProgram where ID=@applicationProgramId) | |
declare @parameterRefs xml | |
set @parameterRefs = ( | |
select ParameterRef.ID as Id | |
, case when Parameter.Access <> ParameterRef.Access then ParameterRef.Access else null end as Access | |
, ParameterRef.AliasName | |
, case AutomaticDisplayOrder when 0 then ParameterRef.DisplayOrder else null end as DisplayOrder | |
, ParameterRef.Name | |
, ParameterRef.ParameterID as RefId | |
, case when Parameter.Text <> ParameterRef.Text then ParameterRef.Text else null end as [Text] | |
, ParameterRef.Tag | |
, ParameterRef.SuffixText | |
, case when Parameter.Value <> ParameterRef.Value then ISNULL(ParameterRef.Value, '') else null end as Value | |
from ParameterRef inner join Parameter on Parameter.ID = ParameterRef.ParameterID where ParameterRef.ApplicationProgramID = @applicationProgramId order by ParameterRef.DisplayOrder | |
for xml auto ) | |
declare @xml xml | |
--export only if at least one exists | |
if @parameterRefs is not null | |
begin | |
set @xml= '<ParameterRefs/>' | |
set @xml.modify( 'insert sql:variable("@parameterRefs") as last into (/*)[1]' ) | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ParameterRefsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ParameterRefsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ParameterRefsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ParameterCalculationsXml') | |
BEGIN | |
DROP Function dbo.ufn_ParameterCalculationsXml | |
END | |
GO | |
CREATE Function dbo.ufn_ParameterCalculationsXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @parameters table( ID varchar(300), LParameters xml, RParameters xml) | |
insert into @parameters select ID, null, null from ParameterCalculation where ParameterCalculation.ProgramID = @applicationProgramId | |
declare parameterCursor cursor local forward_only fast_forward read_only for select ID from @parameters | |
declare @id varchar(300) | |
open parameterCursor | |
fetch next from parameterCursor into @id | |
while @@FETCH_STATUS = 0 | |
begin | |
update @parameters set LParameters=(select LParameter.ParameterRefID as '@RefId', AliasName as '@AliasName' from [ParameterCalculation.LParameter] as LParameter where LParameter.ParameterCalculationID=@id for xml path('ParameterRefRef'), root('LParameters')) where ID=@id | |
update @parameters set RParameters=(select RParameter.ParameterRefID as '@RefId', AliasName as '@AliasName' from [ParameterCalculation.RParameter] as RParameter where RParameter.ParameterCalculationID=@id for xml path('ParameterRefRef'), root('RParameters')) where ID=@id | |
fetch next from parameterCursor into @id | |
end | |
close parameterCursor | |
deallocate parameterCursor | |
declare @parameterCalc xml | |
set @parameterCalc = ( | |
select ParameterCalculation.ID as '@Id' | |
, ParameterCalculation.Language as '@Language' | |
, ParameterCalculation.Name as '@Name' | |
, ParameterCalculation.RLTransformation as 'RLTransformation' | |
, ParameterCalculation.LRTransformation as 'LRTransformation' | |
, [@parameters].LParameters as '*' | |
, [@parameters].RParameters as '*' | |
from ParameterCalculation inner join @parameters on ParameterCalculation.ID=[@parameters].ID | |
where ParameterCalculation.ProgramID = @applicationProgramId | |
for xml path('ParameterCalculation')) | |
declare @parameterCalcs xml | |
if @parameterCalc is not null | |
begin | |
set @parameterCalcs= N'<ParameterCalculations/>' | |
set @parameterCalcs.modify( 'insert sql:variable("@parameterCalc") as last into (/*)[1]' ) | |
end | |
return @parameterCalcs | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ParameterCalculationsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ParameterCalculationsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ParameterCalculationsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ComObjectTableXml') | |
BEGIN | |
DROP Function dbo.ufn_ComObjectTableXml | |
END | |
GO | |
CREATE Function dbo.ufn_ComObjectTableXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @comObjTable xml | |
set @comObjTable = ( | |
select | |
ComObject.ID as Id | |
, ComObject.DatapointType | |
, ComObject.FunctionText | |
, ComObject.Name | |
, ComObject.Number | |
, ComObject.ObjectSize | |
, ComObject.Priority | |
, case ComObject.CommunicationFlag when 1 then 'Enabled' else 'Disabled' end as CommunicationFlag | |
, case ComObject.ReadFlag when 1 then 'Enabled' else 'Disabled' end as ReadFlag | |
, case ComObject.ReadOnInitFlag when 1 then 'Enabled' else 'Disabled' end as ReadOnInitFlag | |
, case ComObject.TransmitFlag when 1 then 'Enabled' else 'Disabled' end as TransmitFlag | |
, case ComObject.UpdateFlag when 1 then 'Enabled' else 'Disabled' end as UpdateFlag | |
, case ComObject.WriteFlag when 1 then 'Enabled' else 'Disabled' end as WriteFlag | |
, ComObject.Text | |
, ComObject.VisibleDescription | |
from CommunicationObject as ComObject where ComObject.ProgramID=@applicationProgramId | |
for xml auto | |
) | |
declare @xml xml=(select ComObjectTable.ComObjectTableSegmentID as CodeSegment | |
, ComObjectTable.ComObjectTableOffset as Offset from ApplicationProgram as ComObjectTable where ID=@applicationProgramId for xml auto) | |
if @comObjTable is not null | |
begin | |
set @xml.modify( 'insert sql:variable("@comObjTable") as last into (/*)[1]' ) | |
end | |
else | |
begin | |
if @xml.exist('/ComObjectTable/@CodeSegment') = 0 and @xml.exist('/ComObjectTable/@Offset') = 0 | |
set @xml=null | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ComObjectTableXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ComObjectTableXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ComObjectTableXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ComObjectRefsXml') | |
BEGIN | |
DROP Function dbo.ufn_ComObjectRefsXml | |
END | |
GO | |
CREATE Function dbo.ufn_ComObjectRefsXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @comObjRefs xml | |
set @comObjRefs = ( | |
select ComObjectRef.ID as Id | |
, ComObjectRef.CommunicationObjectID as RefId | |
, ComObjectRef.DatapointType | |
, ComObjectRef.FunctionText | |
, ComObjectRef.Name | |
, ComObjectRef.ObjectSize | |
, ComObjectRef.Priority | |
, case ComObjectRef.CommunicationFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as CommunicationFlag | |
, case ComObjectRef.ReadFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as ReadFlag | |
, case ComObjectRef.ReadOnInitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as ReadOnInitFlag | |
, case ComObjectRef.TransmitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as TransmitFlag | |
, case ComObjectRef.UpdateFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as UpdateFlag | |
, case ComObjectRef.WriteFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as WriteFlag | |
, ComObjectRef.Text | |
, ComObjectRef.Tag | |
, ComObjectRef.VisibleDescription | |
from CommunicationObjectRef as ComObjectRef where ComObjectRef.ApplicationProgramID=@applicationProgramId | |
for xml auto | |
) | |
declare @xml xml | |
if @comObjRefs is not null | |
begin | |
set @xml = '<ComObjectRefs/>' | |
set @xml.modify( 'insert sql:variable("@comObjRefs") as last into (/*)[1]' ) | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ComObjectRefsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ComObjectRefsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ComObjectRefsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_AddressTableXml') | |
BEGIN | |
DROP Function dbo.ufn_AddressTableXml | |
END | |
GO | |
CREATE Function dbo.ufn_AddressTableXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return(select AddressTable.AddressTableSegmentID as CodeSegment | |
, AddressTable.AddressTableOffset as Offset | |
, AddressTable.AddressTableMaxEntries as MaxEntries | |
from ApplicationProgram as AddressTable where AddressTable.ID = @applicationProgramId | |
for xml auto) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_AddressTableXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_AddressTableXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_AddressTableXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_AssociationTableXml') | |
BEGIN | |
DROP Function dbo.ufn_AssociationTableXml | |
END | |
GO | |
CREATE Function dbo.ufn_AssociationTableXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return(select AssociationTable.AssociationTableSegmentID as CodeSegment | |
, AssociationTable.AssociationTableOffset as Offset | |
, AssociationTable.AssociationTableMaxEntries as MaxEntries | |
from ApplicationProgram as AssociationTable where AssociationTable.ID = @applicationProgramId | |
for xml auto) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_AssociationTableXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_AssociationTableXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_AssociationTableXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_FixupListXml') | |
BEGIN | |
DROP Function dbo.ufn_FixupListXml | |
END | |
GO | |
CREATE Function dbo.ufn_FixupListXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @offsets table( ID varchar(600), Xml xml ) | |
insert into @offsets select distinct(AddressFixup.MaskEntryID+AddressFixup.SegmentID) as ID, null from AddressFixup where AddressFixup.ProgramID=@applicationProgramId | |
update @offsets set Xml=(select Offset from AddressFixup where MaskEntryID+SegmentID=ID for Xml path('')) | |
declare @xml xml='<FixupList/>' | |
declare @hasFixups bit=0 | |
if (select count(ID) from @offsets) > 0 | |
begin | |
declare @id varchar(300) | |
declare @fixupXml xml | |
declare fixupCursor cursor local forward_only fast_forward read_only for select ID, Xml from @offsets | |
open fixupCursor | |
fetch next from fixupCursor into @id, @fixupXml | |
while @@FETCH_STATUS = 0 | |
begin | |
set @hasFixups=1 | |
declare @fixup xml | |
set @fixup=(select top(1) MaskEntryID as FunctionRef, SegmentID as CodeSegment from AddressFixup as Fixup where MaskEntryID+SegmentID=@id and ProgramID=@applicationProgramId for xml auto) | |
set @fixup.modify('insert sql:variable("@fixupXml") as last into (./*)[1]') | |
set @xml.modify('insert sql:variable("@fixup") as last into (./*)[1]') | |
fetch next from fixupCursor into @id, @fixupXml | |
end | |
close fixupCursor | |
deallocate fixupCursor | |
end | |
if @hasFixups = 1 | |
return @xml | |
return null | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_FixupListXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_FixupListXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_FixupListXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GuidToString') | |
BEGIN | |
DROP Function dbo.ufn_GuidToString | |
END | |
GO | |
CREATE Function dbo.ufn_GuidToString | |
( | |
@guid uniqueidentifier | |
) | |
returns varchar(100) | |
AS | |
begin | |
if @guid is null | |
return null | |
return '{' + convert(varchar(100), @guid) + '}' | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GuidToString TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_GuidToString TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GuidToString TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramExtensionXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramExtensionXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramExtensionXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @baggages xml | |
set @baggages=( | |
select Baggage.BaggageID as RefId | |
from ApplicationProgramBaggage as Baggage where Baggage.ApplicationProgramID=@applicationProgramId | |
for xml auto) | |
declare @extension xml | |
set @extension=( | |
select Extension.EtsDownloadPlugin | |
, Extension.EtsUiPlugin | |
, Extension.EtsDataHandler | |
, Extension.RequiresExternalSoftware | |
, Extension.EtsDataHandlerCapabilities | |
from ApplicationProgram as Extension where Extension.ID=@applicationProgramId for xml auto) | |
set @extension.modify('insert sql:variable("@baggages") as last into (./*)[1]') | |
return @extension | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramExtensionXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramExtensionXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramExtensionXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramBinaryDataXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramBinaryDataXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramBinaryDataXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @binaryData xml | |
set @binaryData=( | |
select BinaryData.ID as '@Id' | |
, BinaryData.Name as '@Name' | |
, dbo.ufn_BinaryToBase64(BinaryData.Data) as 'Data' | |
from ApplicationBinaryData as BinaryData where BinaryData.ProgramID=@applicationProgramId | |
for xml path('BinaryData'), binary base64) | |
return @binaryData | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramBinaryDataXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramBinaryDataXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramBinaryDataXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramDynamicXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramDynamicXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramDynamicXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return (select ApplicationProgramDynamic.ApplicationProgramDynamic from ApplicationProgramDynamic where ApplicationProgramDynamic.ApplicationProgramID=@applicationProgramId) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramDynamicXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramDynamicXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramDynamicXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_DeviceCompareXml') | |
BEGIN | |
DROP Function dbo.ufn_DeviceCompareXml | |
END | |
GO | |
CREATE Function dbo.ufn_DeviceCompareXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return (select Excludes from DeviceCompare where DeviceCompare.ApplicationProgramID=@applicationProgramId) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_DeviceCompareXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_DeviceCompareXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_DeviceCompareXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramOptionsXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramOptionsXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramOptionsXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @xml xml | |
set @xml=( select | |
PreferPartialDownload as PreferPartialDownloadIfApplicationLoaded | |
, EasyControlModeStyle as EasyCtrlModeModeStyleEmptyGroupComTables | |
, ObjectTableLengthAlwaysOne as SetObjectTableLengthAlwaysToOne | |
, TextParameterEncoding | |
, TextParameterZeroTerminate | |
, ParameterByteOrder | |
, LegacyNoPartialDownload | |
, LegacyNoMemoryWriteVerify as LegacyNoMemoryVerifyMode | |
, LegacyNoOptimisticWrite | |
, LegacyNoPropertyWriteErrors as LegacyDoNotReportPropertyWriteErrors | |
, LegacyNoBackgroundDownload | |
, LegacyDoNotCheckManufacturer as LegacyDoNotCheckManufacturerId | |
, LegacyAlwaysReloadOnCoVisibilityChange as LegacyAlwaysReloadAppIfCoVisibilityChanged | |
, LegacyNeverReloadOnCoVisibilityChange as LegacyNeverReloadAppIfCoVisibilityChanged | |
, LegacyNoSupportOfUndoDelete as LegacyDoNotSupportUndoDelete | |
, LegacyAllowPartialDownloadOnAp2Mismatch as LegacyAllowPartialDownloadIfAp2Mismatch | |
, LegacyKeepObjectTableGaps | |
, PartialDownloadOnlyVisibleParameters | |
, LegacyProxyCommunicationObjects | |
, DeviceInfoIgnoreRunState | |
, DeviceInfoIgnoreLoadedState | |
, DeviceCompareAllowCompatibleManufacturerId | |
, LineCoupler0912NewProgrammingStyle | |
, TextParameterEncodingSelector | |
, Comparable | |
, Reconstructable | |
from ApplicationProgramOption as Options where ApplicationProgramID=@applicationProgramId for xml auto | |
) | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramOptionsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramOptionsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramOptionsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramCodeXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramCodeXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramCodeXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @absolutSegments xml | |
set @absolutSegments=(select | |
Id as '@Id' | |
, Name as '@Name' | |
, Address as '@Address' | |
, Size as '@Size' | |
, CASE AddressSpace WHEN 3 THEN 1 ELSE 0 END as '@UserMemory' | |
, dbo.ufn_BinaryToBase64(Data) as 'Data' | |
, dbo.ufn_BinaryToBase64(Mask) as 'Mask' | |
from ApplicationSegment where ProgramID = @applicationProgramId and AddressSpace between 2 and 3 for xml path('AbsoluteSegment'), binary base64 | |
) | |
declare @relativeSegments xml | |
set @relativeSegments=(select | |
Id as '@Id' | |
, Name as '@Name' | |
, Address as '@Offset' | |
, Size as '@Size' | |
, LoadStateMachine as '@LoadStateMachine' | |
, dbo.ufn_BinaryToBase64(Data) as 'Data' | |
, dbo.ufn_BinaryToBase64(Mask) as 'Mask' | |
from ApplicationSegment where ProgramID = @applicationProgramId and AddressSpace = 12 for xml path('RelativeSegment'), binary base64 | |
) | |
declare @code xml | |
set @code= N'<Code/>' | |
if @absolutSegments is not null or @relativeSegments is not null | |
begin | |
set @code.modify('insert sql:variable("@absolutSegments") as last into (./*)[1]') | |
set @code.modify('insert sql:variable("@relativeSegments") as last into (./*)[1]') | |
end | |
return @code | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramCodeXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramCodeXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramCodeXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_LoadProcedureXml') | |
BEGIN | |
DROP Function dbo.ufn_LoadProcedureXml | |
END | |
GO | |
CREATE Function dbo.ufn_LoadProcedureXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return (select LoadProcedures as '*' from ApplicationProgram where ID=@applicationProgramId for xml path('')) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_LoadProcedureXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_LoadProcedureXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_LoadProcedureXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ApplicationProgramXml') | |
BEGIN | |
DROP Function dbo.ufn_ApplicationProgramXml | |
END | |
GO | |
CREATE Function dbo.ufn_ApplicationProgramXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
return ( select | |
ID as Id | |
, Name | |
, ApplicationNumber | |
, ApplicationVersion | |
, ProgramType | |
, MaskID as MaskVersion | |
, Description as VisibleDescription | |
, LoadProcedureStyle | |
, PEIType as PeiType | |
, HelpTopic | |
, HelpFile | |
, DefaultLanguage | |
, DynamicTableManagement | |
, Linkable | |
, MinEtsVersion | |
, OriginalManufacturerID as OriginalManufacturer | |
, PreEts4Style | |
, NonRegRelevantDataVersion | |
, ReplacesVersions | |
, Hash | |
, ConvertedFromPreEts4Data | |
, Broken | |
, IPConfig | |
, AdditionalAddressesCount | |
, DownloadInfoIncomplete | |
, CreatedFromLegacySchemaVersion | |
from ApplicationProgram where ID=@applicationProgramId | |
for xml auto | |
) | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ApplicationProgramXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ApplicationProgramXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ApplicationProgramTranslationsXml') | |
BEGIN | |
DROP Procedure dbo.usp_ApplicationProgramTranslationsXml | |
END | |
GO | |
CREATE Procedure dbo.usp_ApplicationProgramTranslationsXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
-- collect translations from the different tables | |
declare @languages table( ID varchar(300), Language varchar(20), Version int, AttributeName varchar(200), Text nvarchar(max) ) | |
-- ApplicationProgramTranslatedText | |
insert into @languages select @applicationProgramId, Language, Version, 'Name', TranslatedName | |
from ApplicationProgramTranslatedText as A where ApplicationProgramID=@applicationProgramId and TranslatedName is not null | |
insert into @languages select @applicationProgramId, Language, Version, 'VisibleDescription', TranslatedDescription | |
from ApplicationProgramTranslatedText as A where ApplicationProgramID=@applicationProgramId and TranslatedDescription is not null | |
insert into @languages select @applicationProgramId, Language, Version, 'HelpFile', TranslatedHelpFile | |
from ApplicationProgramTranslatedText as A where ApplicationProgramID=@applicationProgramId and TranslatedHelpFile is not null | |
-- CommunicationObjectTranslatedText | |
insert into @languages select CommunicationObjectID, Language, Version, 'Text', TranslatedText | |
from CommunicationObjectTranslatedText where CommunicationObjectID in (select ID from CommunicationObject where ProgramID=@applicationProgramId) and TranslatedText is not null | |
insert into @languages select CommunicationObjectID, Language, Version, 'FunctionText', TranslatedFunction | |
from CommunicationObjectTranslatedText where CommunicationObjectID in (select ID from CommunicationObject where ProgramID=@applicationProgramId) and TranslatedFunction is not null | |
insert into @languages select CommunicationObjectID, Language, Version, 'VisibleDescription', TranslatedDescription | |
from CommunicationObjectTranslatedText where CommunicationObjectID in (select ID from CommunicationObject where ProgramID=@applicationProgramId) and TranslatedDescription is not null | |
-- CommunicationObjectRefTranslatedText | |
insert into @languages select CommunicationObjectRefID, Language, Version, 'Text', TranslatedText | |
from CommunicationObjectRefTranslatedText where CommunicationObjectRefID in (select ID from CommunicationObjectRef where ApplicationProgramID=@applicationProgramId) and TranslatedText is not null | |
insert into @languages select CommunicationObjectRefID, Language, Version, 'FunctionText', TranslatedFunction | |
from CommunicationObjectRefTranslatedText where CommunicationObjectRefID in (select ID from CommunicationObjectRef where ApplicationProgramID=@applicationProgramId) and TranslatedFunction is not null | |
insert into @languages select CommunicationObjectRefID, Language, Version, 'VisibleDescription', TranslatedDescription | |
from CommunicationObjectRefTranslatedText where CommunicationObjectRefID in (select ID from CommunicationObjectRef where ApplicationProgramID=@applicationProgramId) and TranslatedDescription is not null | |
-- ParameterRefTranslatedText | |
insert into @languages select ParameterRefID, Language, Version, 'Text', TranslatedText | |
from ParameterRefTranslatedText where ParameterRefID in (select ID from ParameterRef where ApplicationProgramID=@applicationProgramId) and TranslatedText is not null | |
insert into @languages select ParameterRefID, Language, Version, 'Value', TranslatedDefaultValue | |
from ParameterRefTranslatedText where ParameterRefID in (select ID from ParameterRef where ApplicationProgramID=@applicationProgramId) and TranslatedDefaultValue is not null | |
insert into @languages select ParameterRefID, Language, Version, 'SuffixText', TranslatedSuffixText | |
from ParameterRefTranslatedText where ParameterRefID in (select ID from ParameterRef where ApplicationProgramID=@applicationProgramId) and TranslatedSuffixText is not null | |
---- ParameterTranslatedText | |
insert into @languages select ParameterID, Language, Version, 'Text', TranslatedText | |
from ParameterTranslatedText where ParameterID in (select ID from Parameter where ApplicationProgramID=@applicationProgramId) and TranslatedText is not null | |
insert into @languages select ParameterID, Language, Version, 'Value', TranslatedDefaultValue | |
from ParameterTranslatedText where ParameterID in (select ID from Parameter where ApplicationProgramID=@applicationProgramId) and TranslatedDefaultValue is not null | |
insert into @languages select ParameterID, Language, Version, 'SuffixText', TranslatedSuffixText | |
from ParameterTranslatedText where ParameterID in (select ID from Parameter where ApplicationProgramID=@applicationProgramId) and TranslatedSuffixText is not null | |
-- ParameterEnumValueTranslatedText | |
declare @parameterType table(ID varchar(300) ) | |
insert into @parameterType select ID from ParameterType where ApplicationProgramID=@applicationProgramId | |
insert into @languages select ParameterEnumValueID, Language, Version, 'Text', TranslatedText | |
from ParameterEnumValueTranslatedText inner join ParameterEnumValue on ParameterEnumValueTranslatedText.ParameterEnumValueID=ParameterEnumValue.ID where ParameterEnumValue.ParameterTypeID in (select ID from @parameterType) and TranslatedText is not null | |
---- ApplicationProgramDynamicTranslatedText | |
insert into @languages select ElementID, Language, Version, 'Text', TranslatedText | |
from ApplicationProgramDynamicTranslatedText where ApplicationProgramID=@applicationProgramId and TranslatedText is not null | |
select * from @languages | |
GO | |
GRANT EXEC ON dbo.usp_ApplicationProgramTranslationsXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ApplicationProgramTranslationsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ApplicationProgramTranslationsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ApplicationProgramCompleteXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_ApplicationProgramCompleteXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_ApplicationProgramCompleteXml | |
( | |
@applicationProgramId varchar(300), | |
@hasTables bit, | |
@alwaysCreateComObjTable bit | |
) | |
AS | |
declare @applicationProgramCompleteXml xml | |
-- build static part | |
declare @code xml | |
set @code = dbo.ufn_ApplicationProgramCodeXml(@applicationProgramId) | |
declare @parameterTypes xml | |
set @parameterTypes = dbo.ufn_ParameterTypesXml(@applicationProgramId) | |
declare @parameters xml | |
set @parameters = dbo.ufn_ParametersXml(@applicationProgramId) | |
declare @parameterRefs xml | |
set @parameterRefs = dbo.ufn_ParameterRefsXml(@applicationProgramId) | |
declare @parameterCalculations xml | |
set @parameterCalculations = dbo.ufn_ParameterCalculationsXml(@applicationProgramId) | |
declare @commObjTable xml | |
set @commObjTable = dbo.ufn_ComObjectTableXml(@applicationProgramId) | |
if @commObjTable is null and @alwaysCreateComObjTable = 1 | |
begin | |
set @commObjTable = '<ComObjectTable/>' | |
end | |
declare @commObjRefs xml | |
set @commObjRefs = dbo.ufn_ComObjectRefsXml(@applicationProgramId) | |
declare @addressTable xml | |
set @addressTable = dbo.ufn_AddressTableXml(@applicationProgramId) | |
declare @associationTable xml | |
set @associationTable = dbo.ufn_AssociationTableXml(@applicationProgramId) | |
declare @fixups xml | |
set @fixups = dbo.ufn_FixupListXml(@applicationProgramId) | |
declare @loadProcedures xml | |
set @loadProcedures = dbo.ufn_LoadProcedureXml(@applicationProgramId) | |
declare @extension xml | |
set @extension = dbo.ufn_ApplicationProgramExtensionXml(@applicationProgramId) | |
declare @binaryData xml | |
set @binaryData = dbo.ufn_ApplicationProgramBinaryDataXml(@applicationProgramId) | |
declare @options xml | |
set @options = dbo.ufn_ApplicationProgramOptionsXml(@applicationProgramId) | |
declare @deviceCompare xml | |
set @deviceCompare = dbo.ufn_DeviceCompareXml(@applicationProgramId) | |
declare @applicationProgramStatic xml ='<Static/>' | |
set @applicationProgramStatic.modify('insert sql:variable("@code") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@parameterTypes") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@parameters") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@parameterRefs") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@parameterCalculations") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@commObjTable") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@commObjRefs") as last into (/*)[1]') | |
if @hasTables = 1 | |
begin | |
set @applicationProgramStatic.modify('insert sql:variable("@addressTable") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@associationTable") as last into (/*)[1]') | |
end | |
set @applicationProgramStatic.modify('insert sql:variable("@fixups") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@loadProcedures") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@extension") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@binaryData") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@deviceCompare") as last into (/*)[1]') | |
set @applicationProgramStatic.modify('insert sql:variable("@options") as last into (/*)[1]') | |
-- get dynamic part and registration signature | |
declare @applicationProgramDynamic xml | |
set @applicationProgramDynamic = dbo.ufn_ApplicationProgramDynamicXml(@applicationProgramId) | |
-- combine with application program | |
declare @applicationProgram xml | |
set @applicationProgram = dbo.ufn_ApplicationProgramXml(@applicationProgramId) | |
set @applicationProgram.modify('insert sql:variable("@applicationProgramStatic") as last into (/*)[1]') | |
set @applicationProgram.modify('insert sql:variable("@applicationProgramDynamic") as last into (/*)[1]') | |
-- create manufacturer part | |
declare @manufacturerXml xml | |
set @manufacturerXml=(select ID as RefId from Manufacturer where ID=(select ManufacturerID from ApplicationProgram where ID=@applicationProgramId) for xml auto ) | |
set @applicationProgramCompleteXml='<KNX><ManufacturerData/></KNX>' | |
set @applicationProgramCompleteXml.modify('insert sql:variable("@manufacturerXml") as last into (/KNX/ManufacturerData)[1]') | |
set @applicationProgramCompleteXml.modify('insert <ApplicationPrograms/> as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
set @applicationProgramCompleteXml.modify('insert sql:variable("@applicationProgram") as last into (/KNX/ManufacturerData/Manufacturer/ApplicationPrograms)[1]') | |
-- add the translations of the application program to manufacturer element | |
-- declare @translations xml | |
-- set @translations = dbo.ufn_ApplicationProgramTranslationsXml(@applicationProgramId) | |
-- set @applicationProgramCompleteXml.modify('insert sql:variable("@translations") as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
select @applicationProgramCompleteXml | |
GO | |
GRANT EXEC ON dbo.usp_ApplicationProgramCompleteXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ApplicationProgramCompleteXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ApplicationProgramCompleteXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_Hardware2ProgramXml') | |
BEGIN | |
DROP Function dbo.ufn_Hardware2ProgramXml | |
END | |
GO | |
CREATE Function dbo.ufn_Hardware2ProgramXml | |
( | |
@hardwareId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
AS | |
begin | |
declare h2pCursor cursor local forward_only fast_forward read_only for select ID from ExportHardware2Program where HardwareID=@hardwareId and SessionID=@sessionId | |
open h2pCursor | |
declare @id varchar(300) | |
declare @hardwareToProgramsXml xml = '<Hardware2Programs/>' | |
declare @hash2p bit = 0 | |
fetch next from h2pCursor into @id | |
while @@FETCH_STATUS = 0 | |
begin | |
set @hash2p = 1 | |
declare @hardwareToProgramXml xml | |
set @hardwareToProgramXml=( select | |
Hardware2Program.ID as '@Id' | |
, Hardware2Program.MediumTypes as '@MediumTypes' | |
, Hardware2Program.Hash as '@Hash' | |
, Hardware2Program.CheckSums as '@CheckSums' | |
, Hardware2Program.LoadedImage as '@LoadedImage' | |
, Hardware2Program.ApplicationProgramID as 'ApplicationProgramRef/@RefId' | |
, Hardware2Program.RegistrationSignature as 'RegistrationInfo/@RegistrationSignature' | |
, Hardware2Program.RegistrationKey as 'RegistrationInfo/@RegistrationKey' | |
, Hardware2Program.OriginalRegistrationNumber as 'RegistrationInfo/@OriginalRegistrationNumber' | |
, Convert(date, Hardware2Program.RegistrationDate) as 'RegistrationInfo/@RegistrationDate' | |
, Hardware2Program.RegistrationNumber as 'RegistrationInfo/@RegistrationNumber' | |
, Hardware2Program.RegistrationStatus as 'RegistrationInfo/@RegistrationStatus' | |
from Hardware2Program where ID=@id | |
for xml path('Hardware2Program'), binary base64 | |
) | |
declare @peiProgramId varchar(300) | |
set @peiProgramId=(select Hardware2Program.ApplicationProgram2ID from Hardware2Program where ID=@id) | |
if @peiProgramId is not null | |
begin | |
declare @peiProgram xml = '<ApplicationProgramRef RefId="' + @peiProgramId + '"/>' | |
set @hardwareToProgramXml.modify('insert sql:variable("@peiProgram") after (/Hardware2Program/ApplicationProgramRef)[1]') | |
end | |
set @hardwareToProgramsXml.modify('insert sql:variable("@hardwareToProgramXml") as last into (/*)[1]') | |
fetch next from h2pCursor into @id | |
end | |
close h2pCursor | |
deallocate h2pCursor | |
if @hash2p = 1 | |
return @hardwareToProgramsXml | |
return null | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_Hardware2ProgramXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_Hardware2ProgramXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_Hardware2ProgramXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ProductBaggagesXml') | |
BEGIN | |
DROP Function dbo.ufn_ProductBaggagesXml | |
END | |
GO | |
CREATE Function dbo.ufn_ProductBaggagesXml | |
( | |
@productId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @productBaggage xml | |
set @productBaggage= (select | |
BaggageID as RefId | |
from ProductBaggage as Baggage where ProductID=@productId | |
for xml auto | |
) | |
if @productBaggage is null | |
return null | |
declare @productBaggages xml | |
if @productBaggage is not null | |
begin | |
set @productBaggages = '<Baggages/>' | |
set @productBaggages.modify('insert sql:variable("@productBaggage") as last into (/*)[1]') | |
end | |
return @productBaggages | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ProductBaggagesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ProductBaggagesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ProductBaggagesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ProductAttributesXml') | |
BEGIN | |
DROP Function dbo.ufn_ProductAttributesXml | |
END | |
GO | |
CREATE Function dbo.ufn_ProductAttributesXml | |
( | |
@productId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @productAttribute xml | |
set @productAttribute= (select | |
ID as Id | |
, Name | |
, Value | |
from ProductAttribute as Attribute where ProductID=@productId | |
for xml auto | |
) | |
if @productAttribute is null | |
return null | |
declare @productAttributes xml | |
if @productAttribute is not null | |
begin | |
set @productAttributes= N'<Attributes/>' | |
set @productAttributes.modify('insert sql:variable("@productAttribute") as last into (/*)[1]') | |
end | |
return @productAttributes | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ProductAttributesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ProductAttributesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ProductAttributesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ProductRegistrationInfoXml') | |
BEGIN | |
DROP Function dbo.ufn_ProductRegistrationInfoXml | |
END | |
GO | |
CREATE Function dbo.ufn_ProductRegistrationInfoXml | |
( | |
@productId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @registrationInfoXml xml | |
set @registrationInfoXml=( select | |
RegistrationStatus | |
, RegistrationNumber | |
, RegistrationSignature | |
, RegistrationKey | |
, OriginalRegistrationNumber | |
, Convert(date, RegistrationDate) as RegistrationDate | |
from Product as RegistrationInfo where ID=@productId | |
for xml auto | |
) | |
return @registrationInfoXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ProductRegistrationInfoXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ProductRegistrationInfoXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ProductRegistrationInfoXml TO EtsReadOnly | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ProductsXml') | |
BEGIN | |
DROP Function dbo.ufn_ProductsXml | |
END | |
GO | |
CREATE Function dbo.ufn_ProductsXml | |
( | |
@hardwareId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
AS | |
begin | |
declare @productsXml xml = '<Products/>' | |
declare @hasProducts bit = 0 | |
declare productCursor cursor local forward_only fast_forward read_only for select ID from Product where ID in (select ID from ExportProduct where SessionID=@sessionId) and HardwareID=@hardwareId | |
open productCursor | |
declare @id varchar(300) | |
fetch next from productCursor into @id | |
while @@FETCH_STATUS = 0 | |
begin | |
set @hasProducts=1 | |
declare @productXml xml | |
set @productXml=( select | |
ID as '@Id' | |
, Text as '@Text' | |
, OrderNumber as '@OrderNumber' | |
, IsRailMounted as '@IsRailMounted' | |
, WidthInMillimeter as '@WidthInMillimeter' | |
, VisibleDescription as '@VisibleDescription' | |
, DefaultLanguage as '@DefaultLanguage' | |
, Hash as '@Hash' | |
, NonRegRelevantDataVersion as '@NonRegRelevantDataVersion' | |
, dbo.ufn_ProductBaggagesXml(ID) as '*' | |
, dbo.ufn_ProductAttributesXml(ID) as '*' | |
, dbo.ufn_ProductRegistrationInfoXml(ID) as '*' | |
from Product where ID=@id | |
for xml path('Product') | |
) | |
set @productsXml.modify('insert sql:variable("@productXml") as last into (/*)[1]') | |
fetch next from productCursor into @id | |
end | |
close productCursor | |
deallocate productCursor | |
if @hasProducts = 1 | |
return @productsXml | |
return null | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ProductsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ProductsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ProductsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_HardwareXml') | |
BEGIN | |
DROP Function dbo.ufn_HardwareXml | |
END | |
GO | |
CREATE Function dbo.ufn_HardwareXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
AS | |
begin | |
declare @hardwareXml xml | |
set @hardwareXml=( select | |
Hardware.ID as Id | |
, Name | |
, SerialNumber | |
, VersionNumber | |
, BusCurrent | |
, IsAccessory | |
, HasIndividualAddress | |
, HasApplicationProgram | |
, HasApplicationProgram2 | |
, IsPowerSupply | |
, IsChoke | |
, IsCoupler | |
, IsPowerLineRepeater | |
, IsPowerLineSignalFilter | |
, IsCable | |
, OriginalManufacturerID as OriginalManufacturer | |
, NonRegRelevantDataVersion | |
, IsIPEnabled | |
, dbo.ufn_ProductsXml(ID, @sessionId) | |
, dbo.ufn_Hardware2ProgramXml(ID, @sessionId) | |
, case NoDownloadWithoutPlugin when 1 then 1 else null end as NoDownloadWithoutPlugin | |
from Hardware where Hardware.ID in (select ID from ExportHardware where ManufacturerID=@manufacturerId and SessionID=@sessionId) | |
for xml auto | |
) | |
declare @hardwareCompleteXml xml | |
if @hardwareXml is not null | |
begin | |
set @hardwareCompleteXml = '<Hardware/>' | |
set @hardwareCompleteXml.modify('insert sql:variable("@hardwareXml") as last into (/*)[1]') | |
end | |
return @hardwareCompleteXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_HardwareXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_HardwareXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_HardwareXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_HardwareTranslationsXml') | |
BEGIN | |
DROP Function dbo.ufn_HardwareTranslationsXml | |
END | |
GO | |
CREATE Function dbo.ufn_HardwareTranslationsXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
AS | |
begin | |
-- collect translations from the different tables | |
declare @languages table( ID varchar(300), UnitID varchar(300), Language varchar(20), Version int, AttributeName varchar(200), Text nvarchar(max) ) | |
-- ProductTranslatedText | |
insert into @languages select ProductID, ProductID, Language, Version, 'Text', TranslatedName | |
from ProductTranslatedText where ProductID in (select ID from ExportProduct where ManufacturerID=@manufacturerId and SessionID=@sessionId) and TranslatedName is not null | |
insert into @languages select ProductID, ProductID, Language, Version, 'VisibleDescription', TranslatedDescription | |
from ProductTranslatedText where ProductID in (select ID from ExportProduct where ManufacturerID=@manufacturerId and SessionID=@sessionId) and TranslatedDescription is not null | |
-- ProductAttributeTranslatedText | |
insert into @languages select ProductAttributeID, null, Language, Version, 'Value', TranslatedValue | |
from ProductAttributeTranslatedText where ProductAttributeID in (select ID from ProductAttribute as P where ProductID in (select ID from ExportProduct where ManufacturerID=@manufacturerId and SessionID=@sessionId)) and TranslatedValue is not null | |
merge @languages as Target using( select ID, ProductID from ProductAttribute) as Source | |
on ( Target.ID=Source.ID) | |
when matched then update set Target.UnitID=Source.ProductID; | |
-- create a language section for each language code | |
declare @languageSection table(Language varchar(20), SectionXml xml ) | |
insert into @languageSection select distinct(Language), N'<Language Identifier="' + Language + N'"></Language>' from @languages | |
declare @allTranslations xml = '<Languages/>' | |
declare @currentLanguage varchar(20) | |
declare @sectionXml xml | |
declare @hasLanguages bit = 0 | |
declare languageCursor cursor local forward_only fast_forward read_only for select Language, SectionXml from @languageSection | |
open languageCursor | |
fetch next from languageCursor into @currentLanguage, @sectionXml | |
while @@FETCH_STATUS = 0 | |
begin | |
-- insert a unit for each product | |
declare unitCursor cursor local forward_only fast_forward read_only for select distinct(UnitID), Version from @languages where Language=@currentLanguage | |
open unitCursor | |
declare @unitId varchar(300) | |
declare @version int | |
fetch next from unitCursor into @unitId, @version | |
while @@FETCH_STATUS = 0 | |
begin | |
declare @unitXml xml = '<TranslationUnit RefId="' + @unitId + N'" Version="' + convert(nvarchar(100),@version) + N'"/>' | |
declare idCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @languages where Language=@currentLanguage and UnitID=@unitId | |
open idCursor | |
declare @id varchar(300) | |
fetch next from idCursor into @id | |
declare @elementXml xml | |
while @@FETCH_STATUS = 0 | |
begin | |
set @elementXml = '<TranslationElement RefId="' + @id + '"/>' | |
declare @translations xml=( select | |
AttributeName as '@AttributeName' | |
, Text as '@Text' | |
from @languages where Language = @currentLanguage and UnitID=@unitId and ID=@id order by AttributeName for xml path('Translation')) | |
set @elementXml.modify('insert sql:variable("@translations") as last into (/TranslationElement)[1]') | |
set @unitXml.modify('insert sql:variable("@elementXml") as last into (/TranslationUnit)[1]') | |
fetch next from idCursor into @id | |
end | |
close idCursor | |
deallocate idCursor | |
set @sectionXml.modify('insert sql:variable("@unitXml") as last into (/Language)[1]') | |
fetch next from unitCursor into @unitId, @version | |
end | |
close unitCursor | |
deallocate unitCursor | |
set @allTranslations.modify('insert sql:variable("@sectionXml") as last into (/Languages)[1]') | |
set @hasLanguages = 1 | |
fetch next from languageCursor into @currentLanguage, @sectionXml | |
end | |
close languageCursor | |
deallocate languageCursor | |
if @hasLanguages = 1 | |
return @allTranslations | |
return null | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_HardwareTranslationsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_HardwareTranslationsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_HardwareTranslationsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HardwareCompleteXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_HardwareCompleteXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_HardwareCompleteXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier, | |
@includeLanguages bit = 1 | |
) | |
AS | |
declare @hardwareCompleteXml xml = '<KNX><ManufacturerData><Manufacturer RefId="' + @manufacturerId + '"/></ManufacturerData></KNX>' | |
declare @hardwareXml xml | |
set @hardwareXml = dbo.ufn_HardwareXml( @manufacturerId, @sessionId ) | |
set @hardwareCompleteXml.modify('insert sql:variable("@hardwareXml") as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
if @includeLanguages = 1 | |
begin | |
declare @languagesXml xml | |
set @languagesXml = dbo.ufn_HardwareTranslationsXml( @manufacturerId, @sessionId ) | |
set @hardwareCompleteXml.modify('insert sql:variable("@languagesXml") as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
end | |
select @hardwareCompleteXml | |
GO | |
GRANT EXEC ON dbo.usp_HardwareCompleteXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_HardwareCompleteXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_HardwareCompleteXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_BaggageCompleteXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_BaggageCompleteXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_BaggageCompleteXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
AS | |
declare @baggageCompleteXml xml | |
declare @baggageXml xml | |
set @baggageXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, TargetPath as '@TargetPath' | |
, InstallOnImport as '@InstallOnImport' | |
, case [GroupAddresses16BitEnabled] when 1 then [GroupAddresses16BitEnabled] else null end as '@GroupAddresses16BitEnabled' | |
, case [ReadOnly] when 1 then [ReadOnly] else null end as 'FileInfo/@ReadOnly' | |
, case Hidden when 1 then Hidden else null end as 'FileInfo/@Hidden' | |
, Version as 'FileInfo/@Version' | |
, TimeInfo as 'FileInfo/@TimeInfo' | |
from Baggage where ManufacturerID=@manufacturerId and ID in (select ID from ExportBaggage where SessionID=@sessionId) | |
for xml path ('Baggage'), root('Baggages') | |
) | |
if @baggageXml is not null | |
begin | |
set @baggageCompleteXml = '<KNX><ManufacturerData><Manufacturer RefId="' + @manufacturerId + '"/></ManufacturerData></KNX>' | |
set @baggageCompleteXml.modify('insert sql:variable("@baggageXml") as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
end | |
select @baggageCompleteXml | |
GO | |
GRANT EXEC ON dbo.usp_BaggageCompleteXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_BaggageCompleteXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_BaggageCompleteXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ParameterInstanceRefsXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_ParameterInstanceRefsXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_ParameterInstanceRefsXml | |
( | |
@deviceId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @parameterInstanceRef xml | |
set @parameterInstanceRef=( select | |
ParameterRefID as RefId | |
, Value | |
from DeviceParameter as ParameterInstanceRef where DeviceID=@deviceId and Value is not null | |
for xml auto | |
) | |
return @parameterInstanceRef | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ParameterInstanceRefsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ParameterInstanceRefsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ParameterInstanceRefsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ComObjectInstanceRefsXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_ComObjectInstanceRefsXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_ComObjectInstanceRefsXml | |
( | |
@deviceId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @comObjectInstanceRef xml | |
set @comObjectInstanceRef=( select | |
CommunicationObjectRefID as '@RefId' | |
, Text as '@Text' | |
, FunctionText as '@FunctionText' | |
, Priority as '@Priority' | |
, case ReadFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadFlag' | |
, case WriteFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@WriteFlag' | |
, case CommunicationFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@CommunicationFlag' | |
, case TransmitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@TransmitFlag' | |
, case UpdateFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@UpdateFlag' | |
, case ReadOnInitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadOnInitFlag' | |
, DatapointType as '@DatapointType' | |
, Description as '@Description' | |
, IsActive as '@IsActive' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Send where DeviceObjectID=DeviceObject.ID and [Send]=1 for xml auto)) as 'Connectors/*' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Receive where DeviceObjectID=DeviceObject.ID and [Send]=0 for xml auto)) as 'Connectors/*' | |
from DeviceObject where DeviceID=@deviceId | |
and (Text is not null or FunctionText is not null or Description is not null | |
or DatapointType is not null or ReadFlag is not null or WriteFlag is not null | |
or CommunicationFlag is not null or TransmitFlag is not null or UpdateFlag is not null | |
or ReadOnInitFlag is not null or Priority is not null or (select COUNT(ID) from Connector where DeviceObjectID = DeviceObject.ID) > 0) | |
for xml path('ComObjectInstanceRef') | |
) | |
return @comObjectInstanceRef | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ComObjectInstanceRefsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ComObjectInstanceRefsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ComObjectInstanceRefsXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_DeviceInstanceAdditionalAddressesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_DeviceInstanceAdditionalAddressesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_DeviceInstanceAdditionalAddressesXml | |
( | |
@deviceId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @address xml | |
set @address=( select | |
Address | |
from AdditionalDeviceAddress as Address where DeviceID=@deviceId order by Address | |
for xml auto | |
) | |
return @address | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_DeviceInstanceAdditionalAddressesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_DeviceInstanceAdditionalAddressesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_DeviceInstanceAdditionalAddressesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_DeviceBinaryDataXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_DeviceBinaryDataXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_DeviceBinaryDataXml | |
( | |
@deviceId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @binaryData xml | |
set @binaryData=( select | |
ID as '@Id' | |
, BinaryDataID as '@RefId' | |
, Name as '@Name' | |
--, Data as 'Data' | |
from DeviceBinaryData where DeviceID=@deviceId | |
for xml path('BinaryData'), root('BinaryData'), binary base64 | |
) | |
return @binaryData | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_DeviceBinaryDataXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_DeviceBinaryDataXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_DeviceBinaryDataXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_DeviceInstanceXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_DeviceInstanceXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_DeviceInstanceXml | |
( | |
@installationId varchar(300), -- can be null if lineId is specified | |
@lineId varchar(300) | |
) | |
returns xml | |
AS | |
begin | |
declare @deviceXml xml | |
declare @deviceIds table( ID varchar(300) ) | |
if @lineId is null | |
begin | |
insert into @deviceIds select ID from Device where LineID is null and InstallationID=@installationId | |
end | |
else | |
begin | |
insert into @deviceIds select ID from Device where LineID=@lineId | |
end | |
set @deviceXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, ProductID as '@ProductRefId' | |
, Hardware2ProgramID as '@Hardware2ProgramRefId' | |
, Address as '@Address' | |
, Comment as '@Comment' | |
, LastModified as '@LastModified' | |
, LastDownload as '@LastDownload' | |
, InstallationHints as '@InstallationHints' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as '@CompletionStatus' | |
, IndividualAddressLoaded as '@IndividualAddressLoaded' | |
, ApplicationProgramLoaded as '@ApplicationProgramLoaded' | |
, ParametersLoaded as '@ParametersLoaded' | |
, CommunicationPartLoaded as '@CommunicationPartLoaded' | |
, MediumConfigLoaded as '@MediumConfigLoaded' | |
, LoadedImage as '@LoadedImage' | |
, CheckSums as '@CheckSums' | |
, Description as '@Description' | |
, IsCommunicationObjectVisibilityCalculated as '@IsCommunicationObjectVisibilityCalculated' | |
, Broken as '@Broken' | |
, SerialNumber as '@SerialNumber' | |
, [UniqueId] as '@UniqueId' | |
, [IPConfigAssign] as 'IPConfig/@Assign' | |
, [IPConfigIPAddress] as 'IPConfig/@IPAddress' | |
, [IPConfigSubnetMask] as 'IPConfig/@SubnetMask' | |
, [IPConfigDefaultGateway] as 'IPConfig/@DefaultGateway' | |
, [IPConfigMACAddress] as 'IPConfig/@MACAddress' | |
, dbo.ufn_ParameterInstanceRefsXml(ID) as 'ParameterInstanceRefs' | |
-- ComObjectInstanceRefs | |
, convert(xml, ( select | |
CommunicationObjectRefID as '@RefId' | |
, Text as '@Text' | |
, FunctionText as '@FunctionText' | |
, Priority as '@Priority' | |
, case ReadFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadFlag' | |
, case WriteFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@WriteFlag' | |
, case CommunicationFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@CommunicationFlag' | |
, case TransmitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@TransmitFlag' | |
, case UpdateFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@UpdateFlag' | |
, case ReadOnInitFlag when 1 then 'Enabled' when 0 then 'Disabled' else null end as '@ReadOnInitFlag' | |
, DatapointType as '@DatapointType' | |
, Description as '@Description' | |
, IsActive as '@IsActive' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Send where DeviceObjectID=DeviceObject.ID and [Send]=1 for xml auto)) as 'Connectors/*' | |
, convert(xml, (select GroupAddressID as GroupAddressRefId, case Acknowledge when 1 then Acknowledge else null end as Acknowledge from Connector as Receive where DeviceObjectID=DeviceObject.ID and [Send]=0 for xml auto)) as 'Connectors/*' | |
from DeviceObject where DeviceID = DeviceInstance.ID for xml path('ComObjectInstanceRef'), root('ComObjectInstanceRefs'))) | |
, dbo.ufn_DeviceInstanceAdditionalAddressesXml(ID) as 'AdditionalAddresses' | |
, dbo.ufn_DeviceBinaryDataXml(ID) as '*' | |
from Device as DeviceInstance where ID in (select ID from @deviceIds) order by Address | |
for xml path('DeviceInstance'), binary base64 | |
) | |
return @deviceXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_DeviceInstanceXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_DeviceInstanceXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_DeviceInstanceXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_LineAdditionalGroupAddressXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_LineAdditionalGroupAddressXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_LineAdditionalGroupAddressXml | |
( | |
@lineId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @addressXml xml | |
set @addressXml=( select | |
GroupAddress as '@Address' | |
from AdditionalGroupAddress where LineID=@lineId | |
for xml path('GroupAddress') | |
) | |
declare @xml xml | |
if @addressXml is not null | |
begin | |
set @xml=N'<AdditionalGroupAddresses/>' | |
set @xml.modify('insert sql:variable("@addressXml") as last into (/*)[1]') | |
end | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_LineAdditionalGroupAddressXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_LineAdditionalGroupAddressXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_LineAdditionalGroupAddressXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_LineXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_LineXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_LineXml | |
( | |
@areaId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @lineXml xml | |
set @lineXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, Address as '@Address' | |
, MediumTypeID as '@MediumTypeRefId' | |
, Comment as '@Comment' | |
, DomainAddress as '@DomainAddress' | |
, DomainAddressIsChecked as '@DomainAddressIsChecked' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as '@CompletionStatus' | |
, Description as '@Description' | |
, IPRoutingMulticastAddress as '@IPRoutingMulticastAddress' | |
, MulticastTTL as '@MulticastTTL' | |
, dbo.ufn_DeviceInstanceXml(null, ID) | |
, dbo.ufn_LineAdditionalGroupAddressXml(ID) | |
, BusAccessName as 'BusAccess/@Name' | |
, case BusAccessEdi when null then null else '{' + convert(varchar(50), BusAccessEdi) + '}' end as 'BusAccess/@Edi' | |
, BusAccessParameter as 'BusAccess/@Parameter' | |
from Line where AreaID=@areaId order by Address | |
for xml path('Line') | |
) | |
return @lineXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_LineXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_LineXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_LineXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_AreaXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_AreaXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_AreaXml | |
( | |
@installationId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @areaXml xml | |
set @areaXml=( select | |
ID as Id | |
, Name | |
, Address | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, dbo.ufn_LineXml(ID) | |
from Area where InstallationID=@installationId | |
for xml auto | |
) | |
return @areaXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_AreaXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_AreaXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_AreaXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_BuildingPartDeviceInstanceRefXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_BuildingPartDeviceInstanceRefXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_BuildingPartDeviceInstanceRefXml | |
( | |
@buildingPartId varchar(300), | |
@deviceInstanceIds idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @deviceRefXml xml | |
declare @deviceIdsCount int = (select count(Id) from @deviceInstanceIds ) | |
if @deviceIdsCount = 0 | |
begin | |
set @deviceRefXml=( select | |
ID as RefId | |
from Device as DeviceInstanceRef where BuildingID=@buildingPartId | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @deviceRefXml=( select | |
ID as RefId | |
from Device as DeviceInstanceRef where ID in (select ID from @deviceInstanceIds) and BuildingID=@buildingPartId | |
for xml auto | |
) | |
end | |
return @deviceRefXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_BuildingPartDeviceInstanceRefXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_BuildingPartDeviceInstanceRefXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_BuildingPartDeviceInstanceRefXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_BuildingPartXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_BuildingPartXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_BuildingPartXml | |
( | |
@installationId varchar(300), | |
@parentBuildingPartId varchar(300), | |
@id varchar(300) = null, | |
@deviceInstanceIds idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @buildingPartXml xml | |
if @id is not null | |
begin | |
if @parentBuildingPartId is null | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartXml(ID, ID, ID, @deviceInstanceIds) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where ID = @id and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartXml(ID, ID, ID, @deviceInstanceIds) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where ParentID=@parentBuildingPartId | |
for xml auto | |
) | |
end | |
end | |
else | |
begin | |
if @parentBuildingPartId is null | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartXml(@installationId, ID, null, @deviceInstanceIds) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where InstallationID=@installationId and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @buildingPartXml=( select | |
ID as Id | |
, Name | |
, Type | |
, Number | |
, Comment | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, Description | |
, DefaultLineID as DefaultLine | |
, dbo.ufn_BuildingPartXml(@installationId, ID, null, @deviceInstanceIds) | |
, dbo.ufn_BuildingPartDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Building as BuildingPart where InstallationID=@installationId and ParentID=@parentBuildingPartId | |
for xml auto | |
) | |
end | |
end | |
return @buildingPartXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_BuildingPartXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_BuildingPartXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_BuildingPartXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GroupRangesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_GroupRangesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_GroupRangesXml | |
( | |
@installationId varchar(300), | |
@parentGroupRange varchar(300), | |
@id varchar(300) = null, | |
@groupAddressIds idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @groupRangeXml xml | |
if @id is not null | |
begin | |
if @parentGroupRange is null | |
begin | |
set @groupRangeXml=( select | |
ID as Id | |
, Name | |
, RangeStart | |
, RangeEnd | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, Description | |
, Comment | |
, dbo.ufn_GroupRangesXml( ID, ID, ID, @groupAddressIds ) | |
, dbo.ufn_GroupAddressesXml( ID, @groupAddressIds ) | |
from GroupRange where ID=@id and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @groupRangeXml=( select | |
ID as Id | |
, Name | |
, RangeStart | |
, RangeEnd | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, Description | |
, Comment | |
, dbo.ufn_GroupRangesXml( ID, ID, ID, @groupAddressIds ) | |
, dbo.ufn_GroupAddressesXml( ID, @groupAddressIds ) | |
from GroupRange where ParentID=@parentGroupRange | |
for xml auto | |
) | |
end | |
end | |
else | |
begin | |
if @parentGroupRange is null | |
begin | |
set @groupRangeXml=( select | |
ID as Id | |
, Name | |
, RangeStart | |
, RangeEnd | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, Description | |
, Comment | |
, dbo.ufn_GroupRangesXml( @installationId, ID, null, @groupAddressIds ) | |
, dbo.ufn_GroupAddressesXml( ID, @groupAddressIds ) | |
from GroupRange where InstallationID=@installationId and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @groupRangeXml=( select | |
ID as Id | |
, Name | |
, RangeStart | |
, RangeEnd | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, Description | |
, Comment | |
, dbo.ufn_GroupRangesXml( @installationId, ID, null, @groupAddressIds ) | |
, dbo.ufn_GroupAddressesXml( ID, @groupAddressIds ) | |
from GroupRange where InstallationID=@installationId and ParentID=@parentGroupRange | |
for xml auto | |
) | |
end | |
end | |
return @groupRangeXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GroupRangesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_GroupRangesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GroupRangesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GroupAddressesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_GroupAddressesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_GroupAddressesXml | |
( | |
@groupRangeId varchar(300), | |
@groupAddressIds idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @groupAddressXml xml | |
declare @groupaddresscount int = ( select COUNT(id) from @groupAddressIds ) | |
if @groupaddresscount = 0 | |
begin | |
set @groupAddressXml=( select | |
ID as Id | |
, Address | |
, Name | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, case Central when 1 then Central else null end as Central | |
, case Global when 1 then Global else null end as Global | |
, Description | |
, Comment | |
, DatapointType | |
from GroupAddress where GroupRangeID=@groupRangeId order by Address | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @groupAddressXml=( select | |
ID as Id | |
, Address | |
, Name | |
, case Unfiltered when 1 then Unfiltered else null end as Unfiltered | |
, case Central when 1 then Central else null end as Central | |
, case Global when 1 then Global else null end as Global | |
, Description | |
, Comment | |
, DatapointType | |
from GroupAddress where GroupRangeID=@groupRangeId and ID in (select ID from @groupAddressIds) order by Address | |
for xml auto | |
) | |
end | |
return @groupAddressXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_GroupAddressesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_GroupAddressesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_GroupAddressesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TradeDeviceInstanceRefXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_TradeDeviceInstanceRefXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_TradeDeviceInstanceRefXml | |
( | |
@tradeId varchar(300), | |
@deviceInstanceIds idtable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @tradeDeviceInstanceRefXml xml | |
declare @deviceinstancecount int = ( select COUNT(id) from @deviceInstanceIds ) | |
if @deviceinstancecount = 0 | |
BEGIN | |
set @tradeDeviceInstanceRefXml=( select | |
ID as RefId | |
from Device as DeviceInstanceRef where TradeID=@tradeId | |
for xml auto | |
) | |
END | |
ELSE | |
BEGIN | |
set @tradeDeviceInstanceRefXml=( select | |
ID as RefId | |
from Device as DeviceInstanceRef where ID in (select Id from @deviceInstanceIds) and TradeID=@tradeId | |
for xml auto | |
) | |
END | |
return @tradeDeviceInstanceRefXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_TradeDeviceInstanceRefXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_TradeDeviceInstanceRefXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_TradeDeviceInstanceRefXml TO ETSReadOnlyAccess | |
GO | |
--IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TradeXml') | |
-- BEGIN | |
-- DROP FUNCTION dbo.ufn_TradeXml | |
-- END | |
--GO | |
--Create FUNCTION dbo.ufn_TradeXml | |
--( | |
-- @installationId varchar(300), | |
-- @parentTradeId varchar(300), | |
-- @id varchar(300) = null | |
--) | |
--returns xml | |
--as | |
--begin | |
-- declare @tradeXml xml | |
-- if @id is not null | |
-- begin | |
-- if @parentTradeId is null | |
-- begin | |
-- set @tradeXml=( select | |
-- ID as Id | |
-- , Name | |
-- , Number | |
-- , Comment | |
-- , Description | |
-- , dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
-- , dbo.ufn_TradeXml( ID, ID, ID ) | |
-- , dbo.ufn_TradeDeviceInstanceRefXml(ID) | |
-- from Trade where ID = @id and ParentID is null | |
-- for xml auto | |
-- ) | |
-- end | |
-- else | |
-- begin | |
-- set @tradeXml=( select | |
-- ID as Id | |
-- , Name | |
-- , Number | |
-- , Comment | |
-- , Description | |
-- , dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
-- , dbo.ufn_TradeXml( ID, ID, ID) | |
-- , dbo.ufn_TradeDeviceInstanceRefXml(ID) | |
-- from Trade where ParentID=@parentTradeId | |
-- for xml auto | |
-- ) | |
-- end | |
-- end | |
-- else | |
-- begin | |
-- if @parentTradeId is null | |
-- begin | |
-- set @tradeXml=( select | |
-- ID as Id | |
-- , Name | |
-- , Number | |
-- , Comment | |
-- , Description | |
-- , dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
-- , dbo.ufn_TradeXml( @installationId, ID, null ) | |
-- , dbo.ufn_TradeDeviceInstanceRefXml(ID) | |
-- from Trade where InstallationID=@installationId and ParentID is null | |
-- for xml auto | |
-- ) | |
-- end | |
-- else | |
-- begin | |
-- set @tradeXml=( select | |
-- ID as Id | |
-- , Name | |
-- , Number | |
-- , Comment | |
-- , Description | |
-- , dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
-- , dbo.ufn_TradeXml( @installationId, ID, null ) | |
-- , dbo.ufn_TradeDeviceInstanceRefXml(ID) | |
-- from Trade where InstallationID=@installationId and ParentID=@parentTradeId | |
-- for xml auto | |
-- ) | |
-- end | |
-- end | |
-- return @tradeXml | |
--end | |
--GO | |
--GRANT EXEC ON dbo.ufn_TradeXml TO ETSFullAccess | |
--DENY EXEC ON dbo.ufn_TradeXml TO ETSWriteProjectAccess | |
--DENY EXEC ON dbo.ufn_TradeXml TO ETSReadOnlyAccess | |
--GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_EmptyTagXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_EmptyTagXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_EmptyTagXml | |
( | |
@tagName varchar(100), | |
@innerXml xml | |
) | |
returns xml | |
as | |
begin | |
declare @xml xml = '<' + @tagName + '/>' | |
if @innerXml is not null | |
set @xml.modify('insert sql:variable("@innerXml") as last into (/*)[1]') | |
return @xml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_EmptyTagXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_EmptyTagXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_EmptyTagXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TopologyXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_TopologyXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_TopologyXml | |
( | |
@installationId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @topologyXml xml=( select | |
dbo.ufn_AreaXml(ID) as '*' | |
, dbo.ufn_DeviceInstanceXml(@installationId, null) as 'UnassignedDevices/*' | |
from Installation where ID=@installationId | |
for xml path('Topology') | |
) | |
if @topologyXml is null | |
return dbo.ufn_EmptyTagXml('Topology', null) | |
return @topologyXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_TopologyXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_TopologyXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_TopologyXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_SplitInfoXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_SplitInfoXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_SplitInfoXml | |
( | |
@installationId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @splitXml xml=( select * from SplitInfo where InstallationID = @installationId for xml auto ) | |
return @splitXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_SplitInfoXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_SplitInfoXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_SplitInfoXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_InstallationXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_InstallationXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_InstallationXml | |
( | |
@installationId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @tradeDeviceInstanceRefXml xml | |
-- device is is in export empty, all devices will be exported | |
declare @deviceIds idtable | |
set @tradeDeviceInstanceRefXml=( select | |
InstallationId as '@InstallationId' | |
, Name as '@Name' | |
, BCUKey as '@BCUKey' | |
, DefaultLineID as '@DefaultLine' | |
, IPRoutingMulticastAddress as '@IPRoutingMulticastAddress' | |
, SplitType as '@SplitType' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as '@CompletionStatus' | |
, dbo.ufn_TopologyXml(ID) as '*' | |
, dbo.ufn_EmptyTagXml( 'Buildings', dbo.ufn_BuildingPartXml(ID, null, null, @deviceIds)) | |
, dbo.ufn_EmptyTagXml( 'GroupAddresses', dbo.ufn_EmptyTagXml('GroupRanges', dbo.ufn_GroupRangesXml(ID, null, null, @deviceIds))) | |
, dbo.ufn_TradeXml(ID, null, null, @deviceIds) as 'Trades/*' | |
, case BusAccessName when null then null else BusAccessName end as 'BusAccess/@Name' | |
, case BusAccessEdi when null then null else '{' + convert(varchar(50), BusAccessEdi) + '}' end as 'BusAccess/@Edi' | |
, case BusAccessParameter when null then null else BusAccessParameter end as 'BusAccess/@Parameter' | |
, dbo.ufn_SplitInfoXml( ID ) as 'SplitInfos/*' | |
from Installation where ID=@installationId | |
for xml path('Installation') | |
) | |
return @tradeDeviceInstanceRefXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_InstallationXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_InstallationXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_InstallationXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InstallationCompleteXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_InstallationCompleteXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_InstallationCompleteXml | |
( | |
@installationId varchar(300) | |
) | |
as | |
declare @installationPartXml xml | |
set @installationPartXml = dbo.ufn_InstallationXml( @installationId ) | |
declare @installationXml xml | |
if @installationPartXml is not null | |
begin | |
declare @projectXml xml | |
set @projectXml=(select ProjectID as Id from Installation as Project where ID=@installationId for xml auto) | |
set @installationXml = '<KNX/>' | |
set @installationXml.modify('insert sql:variable("@projectXml") as last into (/KNX)[1]') | |
set @installationXml.modify('insert <Installations/> as last into (/KNX/Project)[1]') | |
set @installationXml.modify('insert sql:variable("@installationPartXml") as last into (/KNX/Project/Installations)[1]') | |
end | |
select @installationXml | |
GO | |
GRANT EXEC ON dbo.usp_InstallationCompleteXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_InstallationCompleteXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InstallationCompleteXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TradeXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_TradeXml | |
END | |
GO | |
Create FUNCTION dbo.ufn_TradeXml | |
( | |
@installationId varchar(300), | |
@parentTradeId varchar(300), | |
@id varchar(300) = null, | |
@deviceInstanceIds idTable readonly | |
) | |
returns xml | |
as | |
begin | |
declare @tradeXml xml | |
if @id is not null | |
begin | |
if @parentTradeId is null | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeXml( ID, ID, ID, @deviceInstanceIds ) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where ID = @id and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeXml( ID, ID, ID, @deviceInstanceIds) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where ParentID=@parentTradeId | |
for xml auto | |
) | |
end | |
end | |
else | |
begin | |
if @parentTradeId is null | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeXml( @installationId, ID, null, @deviceInstanceIds ) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where InstallationID=@installationId and ParentID is null | |
for xml auto | |
) | |
end | |
else | |
begin | |
set @tradeXml=( select | |
ID as Id | |
, Name | |
, Number | |
, Comment | |
, Description | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as CompletionStatus | |
, dbo.ufn_TradeXml( @installationId, ID, null, @deviceInstanceIds ) | |
, dbo.ufn_TradeDeviceInstanceRefXml(ID, @deviceInstanceIds) | |
from Trade where InstallationID=@installationId and ParentID=@parentTradeId | |
for xml auto | |
) | |
end | |
end | |
return @tradeXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_TradeXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_TradeXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_TradeXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_HistoryEntriesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_HistoryEntriesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_HistoryEntriesXml | |
( | |
@projectId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @historyXml xml | |
set @historyXml=( select | |
[Date] | |
, [User] | |
, [Text] | |
, [Detail] | |
from ProjectHistory as HistoryEntry where ProjectID=@projectId order by [Date] | |
for xml auto | |
) | |
return @historyXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_HistoryEntriesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_HistoryEntriesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_HistoryEntriesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TraceEntriesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_TraceEntriesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_TraceEntriesXml | |
( | |
@projectId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @traceXml xml | |
set @traceXml=( select | |
[Date] | |
, [UserName] | |
, [Description] as Comment | |
from ProjectTrace where ProjectID=@projectId order by [Date] | |
for xml auto | |
) | |
return @traceXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_TraceEntriesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_TraceEntriesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_TraceEntriesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_UserFilesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_UserFilesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_UserFilesXml | |
( | |
@projectId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @userFilesXml xml | |
set @userFilesXml=( select | |
[Filename], | |
[Comment] | |
from UserFile where ProjectID=@projectId | |
for xml auto | |
) | |
return @userFilesXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_UserFilesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_UserFilesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_UserFilesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_AddinDataXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_AddinDataXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_AddinDataXml | |
( | |
@projectId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @addinDataXml xml | |
set @addinDataXml=( select | |
[AddinId] | |
, [Name] | |
from AddinData where ProjectID=@projectId | |
for xml auto | |
) | |
return @addinDataXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_AddinDataXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_AddinDataXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_AddinDataXml TO ETSReadOnlyAccess | |
GO | |
-- ToDoItems | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ToDoItemEntriesXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_ToDoItemEntriesXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_ToDoItemEntriesXml | |
( | |
@projectId varchar(300) | |
) | |
returns xml | |
as | |
begin | |
declare @toDoItemXml xml | |
set @toDoItemXml=( select | |
[Description] | |
, [ObjectPath] | |
, [CurrentStatus] | |
from ToDoItem where ProjectID=@projectId | |
for xml auto | |
) | |
return @toDoItemXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ToDoItemEntriesXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_ToDoItemEntriesXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_ToDoItemEntriesXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ProjectInformationXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_ProjectInformationXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_ProjectInformationXml | |
( | |
@projectId varchar(300) | |
) | |
as | |
declare @projectInformationXml xml | |
set @projectInformationXml=( select | |
ID as '@Id' | |
, Name as 'ProjectInformation/@Name' | |
, ProjectNumber as 'ProjectInformation/@ProjectNumber' | |
, ContractNumber as 'ProjectInformation/@ContractNumber' | |
, LastModified as 'ProjectInformation/@LastModified' | |
, ProjectStart as 'ProjectInformation/@ProjectStart' | |
, ProjectEnd as 'ProjectInformation/@ProjectEnd' | |
, IpProjectId as 'ProjectInformation/@ProjectId' | |
, ProjectPassword as 'ProjectInformation/@ProjectPassword' | |
, Comment as 'ProjectInformation/@Comment' | |
, ProjectTracingLevel as 'ProjectInformation/@ProjectTracingLevel' | |
, ProjectTracingPassword as 'ProjectInformation/@ProjectTracingPassword' | |
, Hide16BitGroupsFromLegacyPlugins as 'ProjectInformation/@Hide16BitGroupsFromLegacyPlugins' | |
, GroupAddressStyle as 'ProjectInformation/@GroupAddressStyle' | |
, [CodePage] as 'ProjectInformation/@CodePage' | |
, dbo.ufn_CompletionStatusToXmlValue(CompletionStatus) as 'ProjectInformation/@CompletionStatus' | |
, dbo.ufn_HistoryEntriesXml( ID ) as 'ProjectInformation/HistoryEntries/*' | |
, dbo.ufn_TraceEntriesXml( ID ) as 'ProjectInformation/ProjectTraces/*' | |
, dbo.ufn_ToDoItemEntriesXml( ID ) as 'ProjectInformation/ToDoItems/*' | |
, dbo.ufn_UserFilesXml( ID ) as 'UserFiles/*' | |
, dbo.ufn_AddinDataXml( ID ) as 'AddinData/*' | |
from Project where ID=@projectId | |
for xml path('Project') | |
) | |
declare @projectXml xml | |
if @projectInformationXml is not null | |
begin | |
set @projectXml = '<KNX/>' | |
set @projectXml.modify('insert sql:variable("@projectInformationXml") as last into (/KNX)[1]') | |
end | |
select @projectXml | |
GO | |
GRANT EXEC ON dbo.usp_ProjectInformationXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ProjectInformationXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ProjectInformationXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CollectParentCatalogSectionsForExport') | |
BEGIN | |
DROP PROCEDURE dbo.usp_CollectParentCatalogSectionsForExport | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_CollectParentCatalogSectionsForExport | |
( | |
@catalogSectionId varchar(300), | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
as | |
declare @parentId varchar(300) | |
set @parentId=(select ParentCatalogSectionID from CatalogSection where ID=@catalogSectionId) | |
if (select ID from ExportCatalogSection where ID=@catalogSectionId and SessionID=@sessionId) is null | |
begin | |
insert into ExportCatalogSection (ID, ParentID, ManufacturerID, SessionID) values(@catalogSectionId, @parentId, @manufacturerId, @sessionId) | |
end | |
if @parentId is not null | |
begin | |
exec dbo.usp_CollectParentCatalogSectionsForExport @parentId, @manufacturerId, @sessionId | |
end | |
GO | |
GRANT EXEC ON dbo.usp_CollectParentCatalogSectionsForExport TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CollectParentCatalogSectionsForExport TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CollectParentCatalogSectionsForExport TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CatalogSectionXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_CatalogSectionXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CatalogSectionXml | |
( | |
@parentId varchar(300), | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
as | |
begin | |
declare @sectionXml xml | |
if @parentId is null | |
begin | |
set @sectionXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, Number as '@Number' | |
, VisibleDescription as '@VisibleDescription' | |
, DefaultLanguage as '@DefaultLanguage' | |
, NonRegRelevantDataVersion as '@NonRegRelevantDataVersion' | |
, dbo.ufn_CatalogSectionXml(ID, @manufacturerId, @sessionId) as '*' | |
, dbo.ufn_CatalogItemXml(ID, @sessionId) as '*' | |
from CatalogSection where ParentCatalogSectionID is null and ID in (select ID from ExportCatalogSection where SessionID=@sessionId and ManufacturerID=@manufacturerId) | |
for xml path('CatalogSection') | |
) | |
end | |
else | |
begin | |
set @sectionXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, Number as '@Number' | |
, VisibleDescription as '@VisibleDescription' | |
, DefaultLanguage as '@DefaultLanguage' | |
, NonRegRelevantDataVersion as '@NonRegRelevantDataVersion' | |
, dbo.ufn_CatalogSectionXml(ID, @manufacturerId, @sessionId) as '*' | |
, dbo.ufn_CatalogItemXml(ID, @sessionId) as '*' | |
from CatalogSection where ParentCatalogSectionID=@parentId and ID in (select ID from ExportCatalogSection where SessionID=@sessionId and ManufacturerID=@manufacturerId) | |
for xml path('CatalogSection') | |
) | |
end | |
return @sectionXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_CatalogSectionXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_CatalogSectionXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_CatalogSectionXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CatalogItemXml') | |
BEGIN | |
DROP FUNCTION dbo.ufn_CatalogItemXml | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_CatalogItemXml | |
( | |
@sectionId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
as | |
begin | |
declare @catalogItemXml xml | |
set @catalogItemXml=( select | |
ID as '@Id' | |
, Name as '@Name' | |
, Number as '@Number' | |
, VisibleDescription as '@VisibleDescription' | |
, ProductID as '@ProductRefId' | |
, Hardware2ProgramID as '@Hardware2ProgramRefId' | |
, DefaultLanguage as '@DefaultLanguage' | |
, NonRegRelevantDataVersion as '@NonRegRelevantDataVersion' | |
, MediumTypes as '@MediumTypes' | |
from CatalogItem where CatalogSectionID=@sectionId and ID in (select ID from ExportCatalogItem where SessionID=@sessionId) | |
for xml path('CatalogItem') | |
) | |
return @catalogItemXml | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_CatalogItemXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_CatalogItemXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_CatalogItemXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CatalogCompleteXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_CatalogCompleteXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_CatalogCompleteXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier, | |
@includeLanguages bit = 1 | |
) | |
as | |
declare @catalogXml xml | |
declare @catalogSectionsXml xml | |
set @catalogSectionsXml=dbo.ufn_CatalogSectionXml(null, @manufacturerId, @sessionId) | |
if @catalogSectionsXml is not null | |
begin | |
set @catalogXml = '<KNX><ManufacturerData><Manufacturer RefId="' + @manufacturerId + '"><Catalog/></Manufacturer></ManufacturerData></KNX>' | |
set @catalogXml.modify('insert sql:variable("@catalogSectionsXml") as last into (/KNX/ManufacturerData/Manufacturer/Catalog)[1]') | |
if @includeLanguages = 1 | |
begin | |
declare @catalogTranslations xml | |
set @catalogTranslations=dbo.ufn_CatalogTranslationsXml(@manufacturerId, @sessionId) | |
set @catalogXml.modify('insert sql:variable("@catalogTranslations") as last into (/KNX/ManufacturerData/Manufacturer)[1]') | |
end | |
end | |
select @catalogXml | |
GO | |
GRANT EXEC ON dbo.usp_CatalogCompleteXml TO ETSFullAccess | |
DENY EXEC ON dbo.usp_CatalogCompleteXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CatalogCompleteXml TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_CatalogTranslationsXml') | |
BEGIN | |
DROP Function dbo.ufn_CatalogTranslationsXml | |
END | |
GO | |
CREATE Function dbo.ufn_CatalogTranslationsXml | |
( | |
@manufacturerId varchar(300), | |
@sessionId uniqueidentifier | |
) | |
returns xml | |
AS | |
begin | |
-- collect translations from the different tables | |
declare @languages table( ID varchar(300), UnitID varchar(300), Language varchar(20), Version int, AttributeName varchar(200), Text nvarchar(max) ) | |
-- CatalogSectionTranslatedText | |
insert into @languages select CatalogSectionID, CatalogSectionID, Language, Version, 'Name', TranslatedName | |
from CatalogSectionTranslatedText where CatalogSectionID in (select ID from ExportCatalogSection where ManufacturerID=@manufacturerId and SessionID=@sessionId) and TranslatedName is not null | |
insert into @languages select CatalogSectionID, CatalogSectionID, Language, Version, 'VisibleDescription', TranslatedDescription | |
from CatalogSectionTranslatedText where CatalogSectionID in (select ID from ExportCatalogSection where ManufacturerID=@manufacturerId and SessionID=@sessionId) and TranslatedDescription is not null | |
-- CatalogItemTranslatedText | |
insert into @languages select CatalogItemID, CatalogItemID, Language, Version, 'Name', TranslatedName | |
from CatalogItemTranslatedText where CatalogItemID in (select CatalogItem.ID from CatalogItem inner join CatalogSection on CatalogItem.CatalogSectionID=CatalogSection.ID where CatalogItem.ID in (select ID from ExportCatalogItem where ManufacturerID=@manufacturerId and SessionID=@sessionId)) and TranslatedName is not null | |
insert into @languages select CatalogItemID, CatalogItemID, Language, Version, 'VisibleDescription', TranslatedDescription | |
from CatalogItemTranslatedText where CatalogItemID in (select CatalogItem.ID from CatalogItem inner join CatalogSection on CatalogItem.CatalogSectionID=CatalogSection.ID where CatalogItem.ID in (select ID from ExportCatalogItem where ManufacturerID=@manufacturerId and SessionID=@sessionId)) and TranslatedDescription is not null | |
-- create a language section for each language code | |
declare @languageSection table(Language varchar(20), SectionXml xml ) | |
insert into @languageSection select distinct(Language), N'<Language Identifier="' + Language + N'"></Language>' from @languages | |
declare @allTranslations xml = '<Languages/>' | |
declare @currentLanguage varchar(20) | |
declare @sectionXml xml | |
declare languageCursor cursor local forward_only fast_forward read_only for select Language, SectionXml from @languageSection | |
open languageCursor | |
fetch next from languageCursor into @currentLanguage, @sectionXml | |
while @@FETCH_STATUS = 0 | |
begin | |
-- insert a unit for each product | |
declare unitCursor cursor local forward_only fast_forward read_only for select distinct(UnitID), Version from @languages where Language=@currentLanguage | |
open unitCursor | |
declare @unitId varchar(300) | |
declare @version int | |
fetch next from unitCursor into @unitId, @version | |
while @@FETCH_STATUS = 0 | |
begin | |
declare @unitXml xml = '<TranslationUnit RefId="' + @unitId + N'" Version="' + convert(nvarchar(100),@version) + N'"/>' | |
declare idCursor cursor local forward_only fast_forward read_only for select distinct(ID) from @languages where Language=@currentLanguage and UnitID=@unitId | |
open idCursor | |
declare @id varchar(300) | |
fetch next from idCursor into @id | |
declare @elementXml xml | |
while @@FETCH_STATUS = 0 | |
begin | |
set @elementXml = '<TranslationElement RefId="' + @id + '"/>' | |
declare @translations xml=( select | |
AttributeName as '@AttributeName' | |
, Text as '@Text' | |
from @languages where Language = @currentLanguage and UnitID=@unitId and ID=@id order by AttributeName for xml path('Translation')) | |
set @elementXml.modify('insert sql:variable("@translations") as last into (/TranslationElement)[1]') | |
set @unitXml.modify('insert sql:variable("@elementXml") as last into (/TranslationUnit)[1]') | |
fetch next from idCursor into @id | |
end | |
close idCursor | |
deallocate idCursor | |
set @sectionXml.modify('insert sql:variable("@unitXml") as last into (/Language)[1]') | |
fetch next from unitCursor into @unitId, @version | |
end | |
close unitCursor | |
deallocate unitCursor | |
set @allTranslations.modify('insert sql:variable("@sectionXml") as last into (/Languages)[1]') | |
fetch next from languageCursor into @currentLanguage, @sectionXml | |
end | |
close languageCursor | |
deallocate languageCursor | |
return @allTranslations | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_CatalogTranslationsXml TO ETSFullAccess | |
DENY EXEC ON dbo.ufn_CatalogTranslationsXml TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.ufn_CatalogTranslationsXml TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetAddinData] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAddinData') | |
BEGIN | |
DROP Procedure dbo.usp_GetAddinData | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAddinData | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select ID, AddinID, [Name] from AddinData where ProjectID=@projectId | |
GO | |
GRANT EXEC ON dbo.usp_GetAddinData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAddinData TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAddinData TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetAdditionalAddresses] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAdditionalAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_GetAdditionalAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAdditionalAddresses | |
( | |
@deviceId varchar(300) | |
) | |
AS | |
select DeviceID+'_'+convert(varchar(40), Address) as ID, DeviceID, Address from [AdditionalDeviceAddress] WHERE DeviceID = @deviceId Order by Address | |
GO | |
GRANT EXEC ON dbo.usp_GetAdditionalAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAdditionalAddresses TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAdditionalAddresses TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetAdditionalGroupAddresses] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAdditionalGroupAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_GetAdditionalGroupAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAdditionalGroupAddresses | |
( | |
@lineId varchar(300) | |
) | |
AS | |
select GroupAddress from [AdditionalGroupAddress] WHERE LineID = @lineId | |
GO | |
GRANT EXEC ON dbo.usp_GetAdditionalGroupAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAdditionalGroupAddresses TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAdditionalGroupAddresses TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetAllDevicesByAreas] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAllDevicesByAreas') | |
BEGIN | |
DROP Procedure dbo.usp_GetAllDevicesByAreas | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAllDevicesByAreas | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND LineID is not NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetAllDevicesByAreas TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesByAreas TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesByAreas TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAllDevicesInBuildingParts') | |
BEGIN | |
DROP Procedure dbo.usp_GetAllDevicesInBuildingParts | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAllDevicesInBuildingParts | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND BuildingID is not NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetAllDevicesInBuildingParts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesInBuildingParts TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesInBuildingParts TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAllDevicesInTrades') | |
BEGIN | |
DROP Procedure dbo.usp_GetAllDevicesInTrades | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAllDevicesInTrades | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND TradeID is not NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetAllDevicesInTrades TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesInTrades TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAllDevicesInTrades TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAreaDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetAreaDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAreaDevices | |
( | |
@AreaId varchar(300) | |
) | |
AS | |
declare @LineIds table( id varchar(300)) | |
insert @LineIds select Id from Line where AreaID = @AreaId | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.LineID in (Select Id from @LineIds) | |
GO | |
GRANT EXEC ON dbo.usp_GetAreaDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAreaDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAreaDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationBinaryDatas] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationBinaryDatas') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationBinaryDatas | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationBinaryDatas | |
( | |
@programId varchar(300) | |
) | |
AS | |
select ID, ProgramID, Name from [ApplicationBinaryData] where ProgramID = @programId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationBinaryDatas TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationBinaryDatas TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationBinaryDatas TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationFixUpOffsets] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationFixUpOffsets') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationFixUpOffsets | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationFixUpOffsets | |
( | |
@programId varchar(300), | |
@maskEntryId varchar(300), | |
@segmentId varchar(300) | |
) | |
AS | |
select Offset from [AddressFixup] where ProgramID = @programId and SegmentID = @segmentId and MaskEntryID = @maskEntryId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationFixUpOffsets TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationFixUpOffsets TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationFixUpOffsets TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationFixUps] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationFixUps') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationFixUps | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationFixUps | |
( | |
@programId varchar(300) | |
) | |
AS | |
select distinct ProgramID,MaskEntryID,SegmentID from [AddressFixup] where ProgramID = @programId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationFixUps TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationFixUps TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationFixUps TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationOptions] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationOptions') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationOptions | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationOptions | |
( | |
@programId varchar(300) | |
) | |
AS | |
select * from [ApplicationProgramOption] where ApplicationProgramID = @programId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationOptions TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationOptions TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationOptions TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgram] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgram') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationProgram | |
( | |
@manufacturerId varchar(300), | |
@Language varchar(20) = '' | |
) | |
AS | |
declare @ApplicationProgram table ( [ID] [varchar](300),[ManufacturerID] [varchar](300),[Name] [nvarchar](255), [Description] [nvarchar](max), | |
[ApplicationNumber] [int], [ApplicationVersion] [smallint], [OriginalManufacturerID] [varchar](300), [ProgramType] [varchar](50), | |
[MaskID] [varchar](300), [MinEtsVersion] [varchar](10), [HelpFile] [nvarchar](255), [HelpTopic] [nvarchar](50), [PEIType] [smallint], [Linkable] [bit], | |
[LoadProcedureStyle] [varchar](20), [DynamicTableManagement] [bit], [AddressTableMaxEntries] [int], [AssociationTableMaxEntries] [int], | |
[PreEts4Style] [bit] , | |
[DefaultLanguage] varchar(20) , [NonRegRelevantDataVersion] [int] , [AddressTableSegmentID] [varchar](300) , [AddressTableOffset] [int] , | |
[AssociationTableSegmentID] [varchar](300) , [AssociationTableOffset] [int] , [ComObjectTableSegmentID] [varchar](300) , [ComObjectTableOffset] [int] , | |
[Hash] varchar(max) , [LoadProcedures] [xml] , [EtsDownloadPlugin] [varchar](max) , [EtsUiPlugin] [varchar](max) , [EtsDataHandler] [varchar](max) , | |
[ReplacesVersions] [varchar](max), ConvertedFromPreEts4Data bit, RequiresExternalSoftware bit, Broken bit, EtsDataHandlerCapabilities varchar(200) | |
, IPConfig varchar(20), AdditionalAddressesCount varchar(20), DownloadInfoIncomplete bit, CreatedFromLegacySchemaVersion bit ) | |
--global declaration of parameter | |
declare @ID varchar(300) | |
declare @ManuID varchar(300) | |
declare @Name nvarchar(255) | |
declare @Description nvarchar(max) | |
declare @ApplicationNumber int | |
declare @ApplicationVersion smallint | |
declare @OriginalManufacturerID varchar(300) | |
declare @ProgramType varchar(50) | |
declare @MaskID varchar(300) | |
declare @MinEtsVersion varchar(10) | |
declare @HelpFile varchar(255) | |
declare @HelpTopic varchar(50) | |
declare @PEIType smallint | |
declare @Linkable bit | |
declare @LoadProcedureStyle varchar(20) | |
declare @DynamicTableManagement bit | |
declare @AddressTableMaxEntries int | |
declare @AssociationTableMaxEntries int | |
declare @PreEts4Style bit | |
declare @DefaultLanguage varchar(20) | |
declare @NonRegRelevantDataVersion int | |
declare @AddressTableSegmentID varchar(300) | |
declare @AddressTableOffset int | |
declare @AssociationTableSegmentID varchar(300) | |
declare @AssociationTableOffset int | |
declare @ComObjectTableSegmentID varchar(300) | |
declare @ComObjectTableOffset int | |
declare @Hash varchar(max) | |
declare @LoadProcedures xml | |
declare @EtsDownloadPlugin varchar(max) | |
declare @EtsUiPlugin varchar(max) | |
declare @EtsDataHandler varchar(max) | |
declare @ReplacesVersions varchar(max) | |
declare @ConvertedFromPreEts4Data bit | |
declare @RequiresExternalSoftware bit | |
declare @Broken bit | |
declare @EtsDataHandlerCapabilities varchar(200) | |
declare @IPConfig varchar(20) | |
declare @AdditionalAddressesCount varchar(20) | |
declare @DownloadInfoIncomplete bit | |
declare @CreatedFromLegacySchemaVersion bit | |
declare iterationCursor cursor local forward_only fast_forward read_only for select * from [ApplicationProgram] where ManufacturerID = @manufacturerId | |
open iterationCursor | |
fetch next from iterationCursor into @ID, @ManuID, @Name, @Description, @ApplicationNumber, @ApplicationVersion, @OriginalManufacturerID | |
, @ProgramType, @MaskID, @MinEtsVersion, @HelpFile, @HelpTopic, @PEIType, @Linkable, @LoadProcedureStyle | |
, @DynamicTableManagement, @AddressTableMaxEntries, @AssociationTableMaxEntries, @PreEts4Style, @DefaultLanguage | |
, @NonRegRelevantDataVersion, @AddressTableSegmentID, @AddressTableOffset, @AssociationTableSegmentID, @AssociationTableOffset | |
, @ComObjectTableSegmentID, @ComObjectTableOffset, @Hash, @LoadProcedures, @EtsDownloadPlugin, @EtsUiPlugin | |
, @EtsDataHandler, @ReplacesVersions, @ConvertedFromPreEts4Data, @RequiresExternalSoftware, @Broken, @EtsDataHandlerCapabilities, @IPConfig | |
, @AdditionalAddressesCount, @DownloadInfoIncomplete, @CreatedFromLegacySchemaVersion | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
if @Language = @DefaultLanguage | |
BEGIN | |
insert into @ApplicationProgram ([ID],[ManufacturerID],[Name],[Description],[ApplicationNumber],[ApplicationVersion],[OriginalManufacturerID],[ProgramType] | |
,[MaskID],[MinEtsVersion],[HelpFile],[HelpTopic],[PEIType],[Linkable],[LoadProcedureStyle],[DynamicTableManagement] | |
,[AddressTableMaxEntries],[AssociationTableMaxEntries],[PreEts4Style] | |
,[DefaultLanguage],[NonRegRelevantDataVersion],[AddressTableSegmentID],[AddressTableOffset],[AssociationTableSegmentID] | |
,[AssociationTableOffset],[ComObjectTableSegmentID],[ComObjectTableOffset],[Hash] | |
,[LoadProcedures],[EtsDownloadPlugin],[EtsUiPlugin],[EtsDataHandler],[ReplacesVersions], ConvertedFromPreEts4Data, RequiresExternalSoftware, Broken | |
, EtsDataHandlerCapabilities, IPConfig, AdditionalAddressesCount, DownloadInfoIncomplete, CreatedFromLegacySchemaVersion) | |
values (@ID, @ManuID, @Name, @Description, @ApplicationNumber, @ApplicationVersion, @OriginalManufacturerID, @ProgramType, @MaskID, | |
@MinEtsVersion, @HelpFile, @HelpTopic, @PEIType, @Linkable, @LoadProcedureStyle, @DynamicTableManagement, @AddressTableMaxEntries, | |
@AssociationTableMaxEntries, @PreEts4Style, @DefaultLanguage, @NonRegRelevantDataVersion, | |
@AddressTableSegmentID, @AddressTableOffset, @AssociationTableSegmentID, @AssociationTableOffset, @ComObjectTableSegmentID, @ComObjectTableOffset, | |
@Hash, @LoadProcedures, @EtsDownloadPlugin, @EtsUiPlugin, @EtsDataHandler, @ReplacesVersions, @ConvertedFromPreEts4Data | |
, @RequiresExternalSoftware, @Broken, @EtsDataHandlerCapabilities, @IPConfig, @AdditionalAddressesCount, @DownloadInfoIncomplete, @CreatedFromLegacySchemaVersion) | |
END | |
ELSE | |
BEGIN | |
insert into @ApplicationProgram ([ID],[ManufacturerID],[Name],[Description],[ApplicationNumber],[ApplicationVersion],[OriginalManufacturerID],[ProgramType] | |
,[MaskID],[MinEtsVersion],[HelpFile],[HelpTopic],[PEIType],[Linkable],[LoadProcedureStyle],[DynamicTableManagement] | |
,[AddressTableMaxEntries],[AssociationTableMaxEntries],[PreEts4Style] | |
,[DefaultLanguage],[NonRegRelevantDataVersion],[AddressTableSegmentID],[AddressTableOffset],[AssociationTableSegmentID] | |
,[AssociationTableOffset],[ComObjectTableSegmentID],[ComObjectTableOffset],[Hash] | |
,[LoadProcedures],[EtsDownloadPlugin],[EtsUiPlugin],[EtsDataHandler],[ReplacesVersions], ConvertedFromPreEts4Data, RequiresExternalSoftware, Broken | |
, EtsDataHandlerCapabilities, IPConfig, AdditionalAddressesCount, DownloadInfoIncomplete, CreatedFromLegacySchemaVersion) | |
values (@ID, @ManuID, dbo.ufn_TranslatedApplicationProgramName(@ID, @Language, @DefaultLanguage), | |
dbo.ufn_TranslatedApplicationProgramDescription(@ID, @Language, @DefaultLanguage), @ApplicationNumber, @ApplicationVersion, @OriginalManufacturerID, @ProgramType, @MaskID, | |
@MinEtsVersion, dbo.ufn_TranslatedApplicationProgramHelpFile(@ID, @Language, @DefaultLanguage), @HelpTopic, @PEIType, @Linkable, @LoadProcedureStyle, @DynamicTableManagement, @AddressTableMaxEntries, | |
@AssociationTableMaxEntries, @PreEts4Style, @DefaultLanguage, @NonRegRelevantDataVersion, | |
@AddressTableSegmentID, @AddressTableOffset, @AssociationTableSegmentID, @AssociationTableOffset, @ComObjectTableSegmentID, @ComObjectTableOffset, | |
@Hash, @LoadProcedures, @EtsDownloadPlugin, @EtsUiPlugin, @EtsDataHandler, @ReplacesVersions, @ConvertedFromPreEts4Data, | |
@RequiresExternalSoftware, @Broken, @EtsDataHandlerCapabilities, @IPConfig, @AdditionalAddressesCount, @DownloadInfoIncomplete, @CreatedFromLegacySchemaVersion) | |
END | |
fetch next from iterationCursor into @ID, @ManuID, @Name, @Description, @ApplicationNumber, @ApplicationVersion, @OriginalManufacturerID | |
, @ProgramType, @MaskID, @MinEtsVersion, @HelpFile, @HelpTopic, @PEIType, @Linkable, @LoadProcedureStyle | |
, @DynamicTableManagement, @AddressTableMaxEntries, @AssociationTableMaxEntries, @PreEts4Style, @DefaultLanguage | |
, @NonRegRelevantDataVersion, @AddressTableSegmentID, @AddressTableOffset, @AssociationTableSegmentID, @AssociationTableOffset | |
, @ComObjectTableSegmentID, @ComObjectTableOffset,@Hash, @LoadProcedures, @EtsDownloadPlugin, @EtsUiPlugin | |
, @EtsDataHandler, @ReplacesVersions, @ConvertedFromPreEts4Data, @RequiresExternalSoftware, @Broken, @EtsDataHandlerCapabilities, @IPConfig | |
, @AdditionalAddressesCount, @DownloadInfoIncomplete, @CreatedFromLegacySchemaVersion | |
END | |
close iterationCursor | |
deallocate iterationCursor | |
Select * from @ApplicationProgram | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationProgram TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgram TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgram TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgramBaggages] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgramBaggages') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationProgramBaggages | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationProgramBaggages | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
select * from [ApplicationProgramBaggage] where ApplicationProgramID = @applicationprogramId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationProgramBaggages TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramBaggages TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramBaggages TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgramDynamicText] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgramDynamicText') | |
BEGIN | |
DROP PROCEDURE dbo.usp_GetApplicationProgramDynamicText | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_GetApplicationProgramDynamicText | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
select ApplicationProgramDynamic from ApplicationProgramDynamic where ApplicationProgramID = @applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicText TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicText TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicText TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgramDynamicTranslation] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function for determine the application program dynamic translated description | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetApplicationProgramDynamicTranslation') | |
BEGIN | |
DROP Function dbo.[ufn_GetApplicationProgramDynamicTranslation] | |
END | |
GO | |
CREATE FUNCTION [dbo].[ufn_GetApplicationProgramDynamicTranslation] | |
( | |
@ID varchar(300), | |
@language varchar(20), | |
@dbLanguage varchar(20) | |
) | |
returns nvarchar(max) | |
AS | |
begin | |
declare @primaryLanguage varchar(20) | |
set @primaryLanguage = SUBSTRING( @language, 1, 2 ) | |
declare @ResultTable table( Language varchar(20), Text nvarchar(max) ) | |
insert into @ResultTable select Language, TranslatedText as Text from ApplicationProgramDynamicTranslatedText where ElementID = @ID and Language in (@language, @dbLanguage, @primaryLanguage) | |
declare @translation nvarchar(max) | |
-- find direct matching translation | |
set @translation = (select Text from @ResultTable where Language=@language) | |
if @translation is null | |
begin | |
--find translation that matches primary language | |
set @translation = (select Text from @ResultTable where Language=@primaryLanguage) | |
if @translation is null | |
begin | |
-- find translation that best matches primarylanguage | |
set @translation = (select TOP 1 TranslatedText from ApplicationProgramDynamicTranslatedText where ElementID = @ID and Language like @primaryLanguage + '%') | |
if @translation is null | |
begin | |
set @translation = null | |
end | |
end | |
end | |
return @translation | |
end | |
GO | |
GRANT EXEC ON dbo.[ufn_GetApplicationProgramDynamicTranslation] TO ETSFullAccess | |
GRANT EXEC ON dbo.[ufn_GetApplicationProgramDynamicTranslation] TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.[ufn_GetApplicationProgramDynamicTranslation] TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgramDynamicTranslation') | |
BEGIN | |
DROP Procedure dbo.[usp_GetApplicationProgramDynamicTranslation] | |
END | |
GO | |
CREATE PROCEDURE [dbo].[usp_GetApplicationProgramDynamicTranslation] | |
( | |
@ID varchar(300), | |
@language varchar(20), | |
@dbLanguage varchar(20) | |
) | |
AS | |
select dbo.ufn_GetApplicationProgramDynamicTranslation( @ID, @language, @dbLanguage ) | |
GO | |
GRANT EXEC ON dbo.[usp_GetApplicationProgramDynamicTranslation] TO ETSFullAccess | |
GRANT EXEC ON dbo.[usp_GetApplicationProgramDynamicTranslation] TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.[usp_GetApplicationProgramDynamicTranslation] TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAllApplicationProgramDynamicTranslation') | |
BEGIN | |
DROP Procedure dbo.[usp_GetAllApplicationProgramDynamicTranslation] | |
END | |
GO | |
CREATE PROCEDURE [dbo].[usp_GetAllApplicationProgramDynamicTranslation] | |
( | |
@ID varchar(300), | |
@language varchar(20), | |
@dbLanguage varchar(20) | |
) | |
AS | |
select distinct(ElementID), dbo.ufn_GetApplicationProgramDynamicTranslation( ElementID, @language, @dbLanguage ) as Text from ApplicationProgramDynamicTranslatedText where ApplicationProgramID = @ID | |
GO | |
GRANT EXEC ON dbo.[usp_GetAllApplicationProgramDynamicTranslation] TO ETSFullAccess | |
GRANT EXEC ON dbo.[usp_GetAllApplicationProgramDynamicTranslation] TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.[usp_GetAllApplicationProgramDynamicTranslation] TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgramDynamicXml] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgramDynamicXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_GetApplicationProgramDynamicXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_GetApplicationProgramDynamicXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
declare @Xml xml | |
Set @Xml = (select ApplicationProgramDynamic from ApplicationProgramDynamic where ApplicationProgramID = @applicationProgramId) | |
select @Xml | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicXml TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicXml TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramDynamicXml TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationProgramShapes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationProgramShapes') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationProgramShapes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationProgramShapes | |
( | |
@idWithWildcards varchar(300) | |
) | |
AS | |
--set nocount on | |
select ID, Broken from ApplicationProgram where ID like @idWithWildcards | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationProgramShapes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramShapes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationProgramShapes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetApplicationSegments] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetApplicationSegments') | |
BEGIN | |
DROP Procedure dbo.usp_GetApplicationSegments | |
END | |
GO | |
CREATE Procedure dbo.usp_GetApplicationSegments | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
-- collect applicatioNSegments | |
select * from ApplicationSegment where (AddressSpace = 3 OR AddressSpace = 2) and ProgramID = @applicationProgramId | |
-- collect relative segments | |
select * from ApplicationSegment where AddressSpace = 12 and ProgramID = @applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_GetApplicationSegments TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetApplicationSegments TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetApplicationSegments TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetAreas] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAreas') | |
BEGIN | |
DROP Procedure dbo.usp_GetAreas | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAreas | |
( | |
@installationId varchar(300) | |
) | |
AS | |
select * from [Area] WHERE InstallationId = @installationId | |
GO | |
GRANT EXEC ON dbo.usp_GetAreas TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAreas TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAreas TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetBaggages] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetBaggages') | |
BEGIN | |
DROP Procedure dbo.usp_GetBaggages | |
END | |
GO | |
CREATE Procedure dbo.usp_GetBaggages | |
( | |
@manufacturerId varchar(300) | |
) | |
AS | |
select [ID], ManufacturerID, TargetPath, Name, Hidden, [ReadOnly], TimeInfo, [Version], [Compression], LastUsed, InstallOnImport, GroupAddresses16BitEnabled from dbo.Baggage where ManufacturerId=@manufacturerId | |
GO | |
GRANT EXEC ON dbo.usp_GetBaggages TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetBaggages TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetBaggages TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetBuildingPartDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetBuildingPartDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetBuildingPartDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetBuildingPartDevices | |
( | |
@buildingPartId varchar(300), | |
@CollectInSubParts bit = 0 | |
) | |
AS | |
if @CollectInSubParts = 0 | |
begin | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.BuildingID = @buildingPartId | |
end | |
else | |
begin | |
declare @buildings table( ID varchar(300) ) | |
insert into @buildings (ID) Values ( @buildingPartId ) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @buildings) | |
insert into @buildings select ID from Building where ParentID in (select ID from @buildings) and ID not in (select ID from @buildings) | |
set @countAfter=(select count(ID) from @buildings) | |
end | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.BuildingID in (select id from @buildings) | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetBuildingPartDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetBuildingPartDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetBuildingPartDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetBuildingParts] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetBuildingParts') | |
BEGIN | |
DROP Procedure dbo.usp_GetBuildingParts | |
END | |
GO | |
CREATE Procedure dbo.usp_GetBuildingParts | |
( | |
@installationId varchar(300) | |
) | |
AS | |
select * from [Building] where InstallationID = @installationId | |
GO | |
GRANT EXEC ON dbo.usp_GetBuildingParts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetBuildingParts TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetBuildingParts TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCatalogItems] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCatalogItems') | |
BEGIN | |
DROP Procedure dbo.usp_GetCatalogItems | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCatalogItems | |
( | |
@catalogSectionId varchar(300), | |
@Language varchar(20) = '' | |
) | |
AS | |
DECLARE @rootDefault varchar(300) | |
SET @rootdefault = (select Top 1 DefaultLanguage from CatalogSection where ID = @catalogSectionId ) | |
IF @Language = @rootdefault | |
BEGIN | |
select * from [CatalogItem] where CatalogSectionID = @catalogSectionId | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] | |
,[CatalogSectionID] | |
,dbo.ufn_TranslatedCatalogItemName(ID, @Language, @rootDefault) as [Name] | |
,[Number] | |
,dbo.ufn_TranslatedCatalogItemDescription(ID, @Language, @rootDefault) as [VisibleDescription] | |
,[ProductID] | |
,[Hardware2ProgramID] | |
,[DefaultLanguage] | |
,[NonRegRelevantDataVersion] | |
,[MediumTypes] | |
from [CatalogItem] where CatalogSectionID = @catalogSectionId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetCatalogItems TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCatalogItems TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCatalogItems TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCatalogSections] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCatalogSections') | |
BEGIN | |
DROP Procedure dbo.usp_GetCatalogSections | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCatalogSections | |
( | |
@manufacturerId varchar(300), | |
@parentCatalogSectionId varchar(300) = null, | |
@Language varchar(20) = '' | |
) | |
AS | |
IF @parentCatalogSectionId IS NULL | |
BEGIN | |
SELECT [ID] | |
,[ManufacturerID] | |
,[ParentCatalogSectionID] | |
,dbo.ufn_TranslatedCatalogSectionName(ID, @Language,[DefaultLanguage] ) as [Name] | |
,[Number] | |
,dbo.ufn_TranslatedCatalogSectionDescription(ID, @Language,[DefaultLanguage]) as [VisibleDescription] | |
,[DefaultLanguage] | |
,[NonRegRelevantDataVersion] | |
FROM [CatalogSection] where ManufacturerID = @manufacturerId and ParentCatalogSectionID IS NULL | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] | |
,[ManufacturerID] | |
,[ParentCatalogSectionID] | |
,dbo.ufn_TranslatedCatalogSectionName(ID, @Language,[DefaultLanguage] ) as [Name] | |
,[Number] | |
,dbo.ufn_TranslatedCatalogSectionDescription(ID, @Language,[DefaultLanguage]) as [VisibleDescription] | |
,[DefaultLanguage] | |
,[NonRegRelevantDataVersion] | |
FROM [CatalogSection] where ManufacturerID = @manufacturerId and ParentCatalogSectionID = @parentCatalogSectionId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetCatalogSections TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCatalogSections TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCatalogSections TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCommunicationObjectInstanceReferences] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCommunicationObjectInstanceReferences') | |
BEGIN | |
DROP Procedure dbo.usp_GetCommunicationObjectInstanceReferences | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCommunicationObjectInstanceReferences | |
( | |
@deviceId varchar(300), | |
@hardware2ProgramId varchar(300), | |
@onlyActive bit = 0 | |
) | |
AS | |
if @hardware2ProgramId is not null | |
begin | |
declare @applicationProgramId varchar(300) = ( select ApplicationProgramID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @applicationProgram2Id varchar(300) = ( select ApplicationProgram2ID from Hardware2Program where Id = @hardware2ProgramId ) | |
if @onlyActive = 0 | |
begin | |
declare @allDeviceObjects table( ID uniqueidentifier | |
, DeviceID varchar(300) | |
, CommunicationObjectRefID varchar(300) | |
, [Text] nvarchar(255) | |
, [FunctionText] nvarchar(max) | |
, [Description] nvarchar(max) | |
, IsActive bit | |
, DatapointType varchar(max) | |
, ReadFlag bit | |
, WriteFlag bit | |
, CommunicationFlag bit | |
, TransmitFlag bit | |
, UpdateFlag bit | |
, ReadOnInitFlag bit | |
, Priority varchar(6) | |
, ObjectSize varchar(20) | |
, Number bigint ) | |
insert into @allDeviceObjects select * from [DeviceObject] WHERE DeviceId = @deviceId | |
if @applicationProgramId is not null | |
begin | |
INSERT INTO @allDeviceObjects SELECT newId(), @deviceId, CoRef.[ID], null, null, null, 0, null, null, null, null, null, null, null, null | |
, ISNull(CoRef.ObjectSize, Co.ObjectSize) as ObjectSize, Co.Number as Number | |
FROM [CommunicationObjectRef] CoRef inner join CommunicationObject Co on CoRef.CommunicationObjectID = Co.Id WHERE CoRef.ApplicationProgramID = @applicationProgramId and CORef.ID not in (select CommunicationObjectRefID from DeviceObject Where DeviceID = @deviceId ) | |
end | |
if @applicationProgram2Id is not null | |
begin | |
INSERT INTO @allDeviceObjects SELECT newId(), @deviceId, CoRef.[ID], null, null, null, 0, null, null, null, null, null, null, null, null | |
, ISNull(CoRef.ObjectSize, Co.ObjectSize) as ObjectSize, Co.Number as Number | |
FROM [CommunicationObjectRef] CoRef inner join CommunicationObject Co on CoRef.CommunicationObjectID = Co.Id WHERE CoRef.ApplicationProgramID = @applicationProgram2Id and CORef.ID not in (select CommunicationObjectRefID from DeviceObject Where DeviceID = @deviceId ) | |
end | |
select * from @allDeviceObjects | |
end | |
else | |
begin | |
select * from [DeviceObject] WHERE DeviceId = @deviceId and IsActive=1 | |
end | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectInstanceReferences TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectInstanceReferences TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectInstanceReferences TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCommunicationObjectReferences] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCommunicationObjectRefs') | |
BEGIN | |
DROP Procedure dbo.usp_GetCommunicationObjectRefs | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCommunicationObjectRefs | |
( | |
@applicationprogramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
select * from dbo.CommunicationObjectRef where ApplicationProgramID=@applicationprogramId | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] | |
,[CommunicationObjectID] | |
,[ApplicationProgramID] | |
,[Name] | |
,dbo.ufn_TranslatedCommunicationObjectRefText(ID, @languageName, @appdefault) as Text | |
,dbo.ufn_TranslatedCommunicationObjectRefFunctionText(ID, @languageName, @appdefault) as FunctionText | |
,dbo.ufn_TranslatedCommunicationObjectRefDescription(ID, @languageName, @appdefault) as VisibleDescription | |
,[ObjectSize] | |
,[ReadFlag] | |
,[WriteFlag] | |
,[CommunicationFlag] | |
,[TransmitFlag] | |
,[UpdateFlag] | |
,[ReadOnInitFlag] | |
,[DatapointType] | |
,[Priority] | |
,[Tag] | |
FROM [CommunicationObjectRef] where ApplicationProgramID=@applicationprogramId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefs TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefs TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefs TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCommunicationObjectReferencesUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCommunicationObjectRefsUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetCommunicationObjectRefsUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCommunicationObjectRefsUnlocalized | |
( | |
@applicationprogramId varchar(300) | |
) | |
AS | |
select * from dbo.CommunicationObjectRef where ApplicationProgramID=@applicationprogramId | |
GO | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefsUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefsUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectRefsUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCommunicationObjects] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCommunicationObjects') | |
BEGIN | |
DROP Procedure dbo.usp_GetCommunicationObjects | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCommunicationObjects | |
( | |
@applicationprogramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
SELECT * from CommunicationObject where ProgramId=@applicationprogramId | |
END | |
ELSE | |
BEGIN | |
select [ID], [ProgramID],[Name] | |
,dbo.ufn_TranslatedCommunicationObjectText(ID, @languageName, @appdefault) as Text | |
,dbo.ufn_TranslatedCommunicationObjectFunctionText(ID, @languageName, @appdefault) as FunctionText | |
,dbo.ufn_TranslatedCommunicationObjectDescription(ID, @languageName, @appdefault) as VisibleDescription | |
,[Number],[ObjectSize],[ReadFlag],[WriteFlag],[CommunicationFlag] | |
,[TransmitFlag],[UpdateFlag],[ReadOnInitFlag],[DatapointType],[Priority] from CommunicationObject where ProgramId=@applicationprogramId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetCommunicationObjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjects TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjects TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCommunicationObjectsUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCommunicationObjectsUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetCommunicationObjectsUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCommunicationObjectsUnlocalized | |
( | |
@applicationprogramId varchar(300) | |
) | |
AS | |
SELECT * from CommunicationObject where ProgramId=@applicationprogramId | |
GO | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectsUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectsUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCommunicationObjectsUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetCompatibilityManufacturers] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetCompatibilityManufacturers') | |
BEGIN | |
DROP Procedure dbo.usp_GetCompatibilityManufacturers | |
END | |
GO | |
CREATE Procedure dbo.usp_GetCompatibilityManufacturers | |
( | |
@CompatibilityGroup int | |
) | |
AS | |
Select ID from Manufacturer Where CompatibilityGroup = @CompatibilityGroup | |
GO | |
GRANT EXEC ON dbo.usp_GetCompatibilityManufacturers TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetCompatibilityManufacturers TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetCompatibilityManufacturers TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetConnectors] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetConnectors') | |
BEGIN | |
DROP Procedure dbo.usp_GetConnectors | |
END | |
GO | |
CREATE Procedure dbo.usp_GetConnectors | |
( | |
@deviceObjectId varchar(300) | |
) | |
AS | |
select * from [Connector] WHERE DeviceObjectID = @deviceObjectId | |
GO | |
GRANT EXEC ON dbo.usp_GetConnectors TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetConnectors TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetConnectors TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDatapointSubtypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDatapointSubtypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetDatapointSubtypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDatapointSubtypes | |
( | |
@DatapointTypeId nvarchar(300), | |
@language varchar(20) | |
) | |
AS | |
declare @dbLanguage varchar(20) | |
set @dbLanguage = (select top(1) DatabaseLanguage from DatabaseInfo) | |
SELECT ID, Number, [Name], [Default], dbo.ufn_TranslatedDatapointSubtypeText(ID, @language, @dbLanguage) as [Text] FROM DatapointSubtype where DatapointSubtype.DatapointTypeID = @DatapointTypeId | |
GO | |
GRANT EXEC ON dbo.usp_GetDatapointSubtypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDatapointSubtypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDatapointSubtypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDatapointTypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDatapointTypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetDatapointTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDatapointTypes | |
( | |
@language varchar(20) | |
) | |
AS | |
declare @dbLanguage varchar(20) | |
set @dbLanguage = (select top(1) DatabaseLanguage from DatabaseInfo) | |
SELECT ID, Number, [Name], LengthInBit, [Default], dbo.ufn_TranslatedDatapointTypeText(ID, @language, @dbLanguage) as [Text] FROM DataPointType | |
GO | |
GRANT EXEC ON dbo.usp_GetDatapointTypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDatapointTypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDatapointTypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDeviceBinaryDatas] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDeviceBinaryDatas') | |
BEGIN | |
DROP Procedure dbo.usp_GetDeviceBinaryDatas | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDeviceBinaryDatas | |
( | |
@deviceId varchar(300) | |
) | |
AS | |
select ID, DeviceID, BinaryDataID, [Name] from [DeviceBinaryData] WHERE DeviceID = @deviceId | |
GO | |
GRANT EXEC ON dbo.usp_GetDeviceBinaryDatas TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDeviceBinaryDatas TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDeviceBinaryDatas TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDeviceCompareXml] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDeviceCompareXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_GetDeviceCompareXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_GetDeviceCompareXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
declare @Xml xml | |
Set @Xml = (select Excludes from DeviceCompare where ApplicationProgramID = @applicationProgramId) | |
select @Xml | |
GO | |
GRANT EXEC ON dbo.usp_GetDeviceCompareXml TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDeviceCompareXml TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDeviceCompareXml TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDevices | |
( | |
@installationId varchar(300) | |
) | |
AS | |
select distinct(DeviceId) from DeviceObject where DeviceId in (select DeviceId from Device where InstallationID=@installationId) and IsActive = 1 | |
select Device.*, Product.ManufacturerID, Product.HardwareID from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @installationId | |
--select Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @installationId | |
GO | |
GRANT EXEC ON dbo.usp_GetDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDevicesWithoutRoom] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDevicesWithoutRoom') | |
BEGIN | |
DROP Procedure dbo.usp_GetDevicesWithoutRoom | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDevicesWithoutRoom | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND BuildingID = NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutRoom TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutRoom TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutRoom TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDevicesWithoutTrade] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDevicesWithoutTrade') | |
BEGIN | |
DROP Procedure dbo.usp_GetDevicesWithoutTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDevicesWithoutTrade | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND TradeID = NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutTrade TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDevicesWithoutTrade TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetDownwardCompabilityMasks] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: Returns the downward compatible masks for a specified mask version | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetDownwardCompabilityMasks') | |
BEGIN | |
DROP Procedure dbo.usp_GetDownwardCompabilityMasks | |
END | |
GO | |
CREATE Procedure dbo.usp_GetDownwardCompabilityMasks | |
( | |
@maskVersion varchar(300) | |
) | |
AS | |
select * from dbo.MaskCompatibility where NewMaskID=@maskVersion | |
GO | |
GRANT EXEC ON dbo.usp_GetDownwardCompabilityMasks TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetDownwardCompabilityMasks TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetDownwardCompabilityMasks TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetFilterTable] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLineCouplerFilterTable') | |
BEGIN | |
DROP Procedure dbo.usp_GetLineCouplerFilterTable | |
END | |
GO | |
CREATE Procedure dbo.usp_GetLineCouplerFilterTable | |
( | |
@lineId varchar(300) | |
) | |
AS | |
declare @installationId varchar(300) = (select InstallationID from Area inner join Line on Area.ID=Line.AreaID where Line.ID = @lineId) | |
declare @groupAddressesInLine table( ID varchar(300) ) | |
insert into @groupAddressesInLine select GroupAddress.ID from GroupAddress inner join Connector on Connector.GroupAddressID=GroupAddress.ID inner join Device on Device.ID=Connector.DeviceID where Device.LineID=@lineId | |
declare @groupAddressesOtherLine table( ID varchar(300) ) | |
insert into @groupAddressesOtherLine select GroupAddress.ID from GroupAddress inner join Connector on Connector.GroupAddressID=GroupAddress.ID inner join Device on Device.ID=Connector.DeviceID where GroupAddress.InstallationID = @installationId and Device.LineID <> @lineId | |
declare @gaToOther table ( ID varchar(300), Address int ) | |
insert into @gaToOther select ID, Address from GroupAddress where ID in (select [@groupAddressesOtherLine].ID from @groupAddressesInLine inner join @groupAddressesOtherLine on [@groupAddressesInLine].ID=[@groupAddressesOtherLine].ID) | |
declare @start int | |
declare @end int | |
declare ranges cursor local forward_only fast_forward read_only for select RangeStart, RangeEnd from GroupRange where Unfiltered = 1 and GroupRange.InstallationID=@installationId | |
open ranges | |
fetch next from ranges into @start, @end | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
insert @gaToOther select ID, Address from GroupAddress where Address >= @start and Address <= @end | |
fetch next from ranges into @start, @end | |
END | |
close ranges | |
deallocate ranges | |
insert into @gaToOther select ID, Address from GroupAddress where InstallationID=@installationId and Unfiltered = 1 | |
insert into @gaToOther select null, GroupAddress from AdditionalGroupAddress where AdditionalGroupAddress.LineID=@lineId | |
select distinct(Address) from @gaToOther order by Address | |
GO | |
GRANT EXEC ON dbo.usp_GetLineCouplerFilterTable TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLineCouplerFilterTable TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLineCouplerFilterTable TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetAreaCouplerFilterTable') | |
BEGIN | |
DROP Procedure dbo.usp_GetAreaCouplerFilterTable | |
END | |
GO | |
CREATE Procedure dbo.usp_GetAreaCouplerFilterTable | |
( | |
@areaId varchar(300) | |
) | |
AS | |
declare @installationId varchar(300) = (select InstallationID from Area where ID = @areaId) | |
declare @linesOfArea table( ID varchar(300) ) | |
insert into @linesOfArea select ID from Line where AreaID=@areaId | |
declare @linesOfOtherArea table( ID varchar(300) ) | |
insert into @linesOfOtherArea select Line.ID from Line inner join Area on Line.AreaID=Area.ID where Area.ID <> @areaId and Area.InstallationID=@installationId | |
declare @groupAddressesInLine table( ID varchar(300) ) | |
insert into @groupAddressesInLine select GroupAddress.ID from GroupAddress inner join Connector on Connector.GroupAddressID=GroupAddress.ID inner join Device on Device.ID=Connector.DeviceID where Device.LineID in (select ID from @linesOfArea) | |
declare @groupAddressesOtherLine table( ID varchar(300) ) | |
insert into @groupAddressesOtherLine select GroupAddress.ID from GroupAddress inner join Connector on Connector.GroupAddressID=GroupAddress.ID inner join Device on Device.ID=Connector.DeviceID where GroupAddress.InstallationID = @installationId and Device.LineID not in (select ID from @linesOfArea) | |
declare @gaToOther table ( ID varchar(300), Address int ) | |
insert into @gaToOther select ID, Address from GroupAddress where ID in (select [@groupAddressesOtherLine].ID from @groupAddressesInLine inner join @groupAddressesOtherLine on [@groupAddressesInLine].ID=[@groupAddressesOtherLine].ID) | |
declare @start int | |
declare @end int | |
declare ranges cursor local forward_only fast_forward read_only for select RangeStart, RangeEnd from GroupRange where Unfiltered = 1 and GroupRange.InstallationID=@installationId | |
open ranges | |
fetch next from ranges into @start, @end | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
insert @gaToOther select ID, Address from GroupAddress where Address >= @start and Address <= @end | |
fetch next from ranges into @start, @end | |
END | |
close ranges | |
deallocate ranges | |
insert into @gaToOther select ID, Address from GroupAddress where InstallationID=@installationId and Unfiltered = 1 | |
insert into @gaToOther select null, GroupAddress from AdditionalGroupAddress where AdditionalGroupAddress.LineID in (select ID from @linesOfArea) | |
select distinct(Address) from @gaToOther order by Address | |
GO | |
GRANT EXEC ON dbo.usp_GetAreaCouplerFilterTable TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetAreaCouplerFilterTable TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetAreaCouplerFilterTable TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetGroupAddresses] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetGroupAddresses') | |
BEGIN | |
DROP Procedure dbo.usp_GetGroupAddresses | |
END | |
GO | |
CREATE Procedure dbo.usp_GetGroupAddresses | |
( | |
@installationId varchar(300) | |
) | |
AS | |
declare @GroupAddressesWithConnectors table(GroupAddId varchar(300), ObjectSize varchar(30)) | |
insert into @GroupAddressesWithConnectors | |
select distinct(conn.GroupAddressID), ObjectSize as ComObjectSize from Connector as conn, DeviceObject as do | |
where conn.DeviceObjectId = do.Id and do.DeviceID in (select ID from Device where InstallationId=@installationId) | |
order by conn.GroupAddressID | |
select [GroupAddress].*, groups.ObjectSize from [GroupAddress] left join @GroupAddressesWithConnectors as groups on groups.GroupAddId = GroupAddress.ID where GroupAddress.InstallationID=@installationId | |
select ID, GroupAddressID, DeviceID, DeviceObjectID from Connector where GroupAddressID in (select GroupAddId from @GroupAddressesWithConnectors) order by GroupAddressID | |
GO | |
GRANT EXEC ON dbo.usp_GetGroupAddresses TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddresses TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddresses TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetGroupAddressById') | |
BEGIN | |
DROP Procedure dbo.usp_GetGroupAddressById | |
END | |
GO | |
CREATE Procedure dbo.usp_GetGroupAddressById | |
( | |
@installationId varchar(300), | |
@groupAddressId varchar(300) | |
) | |
AS | |
declare @GroupAddressesWithConnectors table(GroupAddId varchar(300), ObjectSize varchar(30)) | |
insert into @GroupAddressesWithConnectors select distinct(conn.GroupAddressID), ObjectSize as ComObjectSize from Connector as conn inner join DeviceObject do on conn.DeviceObjectId = do.Id | |
where conn.GroupAddressID in (select distinct(GroupAddressID) from Connector inner join GroupAddress on Connector.GroupAddressID = GroupAddress.ID where InstallationID = @InstallationID and GroupAddress.Id = @groupAddressId ) order by conn.GroupAddressID | |
select [GroupAddress].*, groups.ObjectSize from [GroupAddress] left join @GroupAddressesWithConnectors as groups on groups.GroupAddId = GroupAddress.ID where InstallationID = @InstallationID and GroupAddress.Id = @groupAddressId | |
select ID, GroupAddressID, DeviceID, DeviceObjectID from Connector where GroupAddressID in (select GroupAddId from @GroupAddressesWithConnectors) order by GroupAddressID | |
GO | |
GRANT EXEC ON dbo.usp_GetGroupAddressById TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddressById TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddressById TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetGroupAddressByDevice') | |
BEGIN | |
DROP Procedure dbo.usp_GetGroupAddressByDevice | |
END | |
GO | |
CREATE Procedure dbo.usp_GetGroupAddressByDevice | |
( | |
@deviceId varchar(300) | |
) | |
AS | |
declare @GroupAddressesWithConnectors table(ConnectorId varchar(300), GroupAddressId varchar(300), ObjectSize varchar(30) ) | |
insert into @GroupAddressesWithConnectors select ID, GroupAddressID, null from Connector where DeviceID = @deviceId | |
declare @ConnectorId varchar(300) | |
declare connectorCursor cursor local forward_only fast_forward read_only for select ConnectorId from @GroupAddressesWithConnectors | |
open connectorCursor | |
fetch next from connectorCursor into @ConnectorId | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
update @GroupAddressesWithConnectors set ObjectSize = (select ObjectSize from DeviceObject where ID in (Select DeviceObjectID from Connector where ID = @ConnectorId)) | |
fetch next from connectorCursor into @ConnectorId | |
END | |
close connectorCursor | |
deallocate connectorCursor | |
select [GroupAddress].*, groups.ObjectSize from [GroupAddress] left join @GroupAddressesWithConnectors as groups on groups.GroupAddressID = GroupAddress.ID where GroupAddress.ID in (select GroupAddressID from Connector where DeviceID = @deviceId) | |
select ID, GroupAddressID, DeviceID, DeviceObjectID from Connector where GroupAddressID in (select GroupAddressID from @GroupAddressesWithConnectors) order by GroupAddressID | |
GO | |
GRANT EXEC ON dbo.usp_GetGroupAddressByDevice TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddressByDevice TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetGroupAddressByDevice TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetGroupRanges] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetGroupRanges') | |
BEGIN | |
DROP Procedure dbo.usp_GetGroupRanges | |
END | |
GO | |
CREATE Procedure dbo.usp_GetGroupRanges | |
( | |
@installationId varchar(300) | |
) | |
AS | |
select * from [GroupRange] where InstallationID = @installationId | |
GO | |
GRANT EXEC ON dbo.usp_GetGroupRanges TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetGroupRanges TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetGroupRanges TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetHandler] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Script Template | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_ChangeDataHandler') | |
BEGIN | |
DROP Function dbo.ufn_ChangeDataHandler | |
END | |
GO | |
CREATE Function dbo.ufn_ChangeDataHandler | |
( | |
@DBHandler varchar(300) , | |
@XMLHandler varchar(300) | |
) | |
returns varchar(50) | |
AS | |
begin | |
IF @DBHandler IS NOT NULL AND @XMLHandler IS NOT NULL | |
BEGIN | |
return @XmlHandler | |
END | |
IF @DBHandler IS NOT NULL AND @XMLHandler IS NULL | |
BEGIN | |
RETURN @DBHandler | |
END | |
RETURN @XmlHandler | |
end | |
GO | |
GRANT EXEC ON dbo.ufn_ChangeDataHandler TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_ChangeDataHandler TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_ChangeDataHandler TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetHardware] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetHardware') | |
BEGIN | |
DROP Procedure dbo.usp_GetHardware | |
END | |
GO | |
CREATE Procedure dbo.usp_GetHardware | |
( | |
@manufacturerId varchar(300) | |
) | |
AS | |
select * from dbo.Hardware where ManufacturerId=@manufacturerId | |
GO | |
GRANT EXEC ON dbo.usp_GetHardware TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetHardware TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetHardware TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetHardware2Programs] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetHardware2Programs') | |
BEGIN | |
DROP Procedure dbo.usp_GetHardware2Programs | |
END | |
GO | |
CREATE Procedure dbo.usp_GetHardware2Programs | |
( | |
@hardwareId varchar(300) | |
) | |
AS | |
select * from dbo.Hardware2Program where HardwareId=@hardwareId | |
GO | |
GRANT EXEC ON dbo.usp_GetHardware2Programs TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetHardware2Programs TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetHardware2Programs TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetHawkConfigurationData] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: Returns the hawk configuration data for a specified mask version | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetHawkConfigurationData') | |
BEGIN | |
DROP Procedure dbo.usp_GetHawkConfigurationData | |
END | |
GO | |
CREATE Procedure dbo.usp_GetHawkConfigurationData | |
( | |
@maskVersion varchar(300) | |
) | |
AS | |
select * from HawkConfigurationData where MaskVersionID=@maskVersion | |
GO | |
GRANT EXEC ON dbo.usp_GetHawkConfigurationData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetHawkConfigurationData TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetHawkConfigurationData TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetIdMapping] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetIdForPath') | |
BEGIN | |
DROP Procedure dbo.usp_GetIdForPath | |
END | |
GO | |
CREATE Procedure dbo.usp_GetIdForPath | |
( | |
@path varchar(900) | |
) | |
AS | |
declare @id bigint = (select NumberID from IdMapping where Path=@path) | |
if @id is null | |
begin | |
insert into IdMapping output inserted.NumberID as NumberID values(@path) | |
end | |
else | |
begin | |
select @id as NumberID | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetIdForPath TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetIdForPath TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetIdForPath TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetPathForId') | |
BEGIN | |
DROP Procedure dbo.usp_GetPathForId | |
END | |
GO | |
CREATE Procedure dbo.usp_GetPathForId | |
( | |
@id bigint | |
) | |
AS | |
select Path from IdMapping where NumberID=@id | |
GO | |
GRANT EXEC ON dbo.usp_GetPathForId TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetPathForId TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetPathForId TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetInitialDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetInitialDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetInitialDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetInitialDevices | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND [IndividualAddressLoaded] = 0 | |
GO | |
GRANT EXEC ON dbo.usp_GetInitialDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetInitialDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetInitialDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetInstallations] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetInstallations') | |
BEGIN | |
DROP Procedure dbo.usp_GetInstallations | |
END | |
GO | |
CREATE Procedure dbo.usp_GetInstallations | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select * from Installation WHERE ProjectID = @projectId | |
GO | |
GRANT EXEC ON dbo.usp_GetInstallations TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetInstallations TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetInstallations TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetKnxMasterData] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetKnxMasterData') | |
BEGIN | |
DROP Procedure dbo.usp_GetKnxMasterData | |
END | |
GO | |
CREATE Procedure dbo.usp_GetKnxMasterData | |
--( | |
--) | |
AS | |
select CurrentMasterDataVersion from dbo.DatabaseInfo | |
GO | |
GRANT EXEC ON dbo.usp_GetKnxMasterData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetKnxMasterData TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetKnxMasterData TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetLParameters] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLParameters') | |
BEGIN | |
DROP Procedure dbo.usp_GetLParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_GetLParameters | |
( | |
@parameterCalculationId varchar(300) | |
) | |
AS | |
select * from [ParameterCalculation.LParameter] where ParameterCalculationId=@parameterCalculationId | |
GO | |
GRANT EXEC ON dbo.usp_GetLParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLParameters TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLParameters TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetLanguages] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLanguages') | |
BEGIN | |
DROP Procedure dbo.usp_GetLanguages | |
END | |
GO | |
CREATE Procedure dbo.usp_GetLanguages | |
AS | |
declare @allLanguages table( Language varchar(20) ) | |
insert into @allLanguages select distinct([Language]) from ApplicationProgramDynamicTranslatedText | |
insert into @allLanguages select distinct([Language]) from ApplicationProgramTranslatedText | |
insert into @allLanguages select distinct([Language]) from CatalogItemTranslatedText | |
insert into @allLanguages select distinct([Language]) from CatalogSectionTranslatedText | |
insert into @allLanguages select distinct([Language]) from CommunicationObjectRefTranslatedText | |
insert into @allLanguages select distinct([Language]) from CommunicationObjectTranslatedText | |
insert into @allLanguages select distinct([Language]) from ParameterEnumValueTranslatedText | |
insert into @allLanguages select distinct([Language]) from ParameterRefTranslatedText | |
insert into @allLanguages select distinct([Language]) from ParameterTranslatedText | |
insert into @allLanguages select distinct([Language]) from ProductAttributeTranslatedText | |
select distinct(Language) from @allLanguages | |
GO | |
GRANT EXEC ON dbo.usp_GetLanguages TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLanguages TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLanguages TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetLineDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLineDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetLineDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetLineDevices | |
( | |
@lineId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.LineID = @lineId | |
GO | |
GRANT EXEC ON dbo.usp_GetLineDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLineDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLineDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetLines] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLines') | |
BEGIN | |
DROP Procedure dbo.usp_GetLines | |
END | |
GO | |
CREATE Procedure dbo.usp_GetLines | |
( | |
@areaId varchar(300) | |
) | |
AS | |
select * from [Line] WHERE AreaId = @areaId | |
GO | |
GRANT EXEC ON dbo.usp_GetLines TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLines TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLines TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetLoadProcedureXml] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetLoadProcedureXml') | |
BEGIN | |
DROP PROCEDURE dbo.usp_GetLoadProcedureXml | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_GetLoadProcedureXml | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
declare @loadProcedureXml xml | |
Set @loadProcedureXml = (select LoadProcedures from ApplicationProgram where ID = @applicationProgramId) | |
if @loadProcedureXml is null | |
BEGIN | |
set @loadProcedureXml = '<LoadProcedures />' | |
END | |
select @loadProcedureXml | |
GO | |
GRANT EXEC ON dbo.usp_GetLoadProcedureXml TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetLoadProcedureXml TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetLoadProcedureXml TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetManufacturerPublicKeys] | |
-------------------------------------------------------------------------------- | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetManufacturerPublicKeys') | |
BEGIN | |
DROP Procedure dbo.usp_GetManufacturerPublicKeys | |
END | |
GO | |
CREATE Procedure dbo.usp_GetManufacturerPublicKeys | |
( | |
@ManufacturerId varchar(300) | |
) | |
AS | |
SELECT * from ManufacturerPublicKey where ManufacturerID = @ManufacturerId | |
GO | |
GRANT EXEC ON dbo.usp_GetManufacturerPublicKeys TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetManufacturerPublicKeys TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetManufacturerPublicKeys TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetManufacturers] | |
-------------------------------------------------------------------------------- | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetManufacturers') | |
BEGIN | |
DROP Procedure dbo.usp_GetManufacturers | |
END | |
GO | |
CREATE Procedure dbo.usp_GetManufacturers | |
AS | |
SELECT * from Manufacturer | |
GO | |
GRANT EXEC ON dbo.usp_GetManufacturers TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetManufacturers TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetManufacturers TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetMaskEntries] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetMaskEntries') | |
BEGIN | |
DROP Procedure dbo.usp_GetMaskEntries | |
END | |
GO | |
CREATE Procedure dbo.usp_GetMaskEntries | |
( | |
@maskVersion varchar(300) | |
) | |
AS | |
select * from dbo.MaskEntry where MaskID=@maskVersion | |
GO | |
GRANT EXEC ON dbo.usp_GetMaskEntries TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetMaskEntries TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetMaskEntries TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetMaskVersions] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetMaskVersions') | |
BEGIN | |
DROP Procedure dbo.usp_GetMaskVersions | |
END | |
GO | |
CREATE Procedure dbo.usp_GetMaskVersions | |
--( | |
--) | |
AS | |
select * from dbo.MaskVersion | |
GO | |
GRANT EXEC ON dbo.usp_GetMaskVersions TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetMaskVersions TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetMaskVersions TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetMediumTypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: Get the medium types | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetMediumTypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetMediumTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetMediumTypes | |
--( | |
--) | |
AS | |
select * from dbo.MediumType | |
GO | |
GRANT EXEC ON dbo.usp_GetMediumTypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetMediumTypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetMediumTypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetModifiedDevice] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetModifiedDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetModifiedDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetModifiedDevices | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId | |
AND [IndividualAddressLoaded] = 1 AND ( [ApplicationProgramLoaded] = 0 OR [CommunicationPartLoaded] = 0 OR [MediumConfigLoaded] = 0 OR [ParametersLoaded] = 0 ) | |
GO | |
GRANT EXEC ON dbo.usp_GetModifiedDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetModifiedDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetModifiedDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetObjectTypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetInterfaceObjectTypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetInterfaceObjectTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetInterfaceObjectTypes | |
( | |
@language varchar(20) | |
) | |
AS | |
declare @dbLanguage varchar(20) | |
set @dbLanguage = (select top(1) DatabaseLanguage from DatabaseInfo) | |
SELECT ID, Number, [Name], dbo.ufn_TranslatedInterfaceObjectTypeText(ID, @language, @dbLanguage) as [Text] FROM InterfaceObjectType | |
GO | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectTypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectTypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectTypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterCalculations] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterCalculations') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterCalculations | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterCalculations | |
( | |
@programId varchar(300) | |
) | |
AS | |
select * from dbo.ParameterCalculation where ProgramId=@programId | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterCalculations TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterCalculations TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterCalculations TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterInstanceReferences] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterInstanceReferences') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterInstanceReferences | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterInstanceReferences | |
( | |
@deviceId varchar(300), | |
@hardware2ProgramId varchar(300) | |
) | |
AS | |
if @hardware2ProgramId is not null | |
begin | |
declare @applicationProgramId varchar(300) = ( select ApplicationProgramID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @applicationProgram2Id varchar(300) = ( select ApplicationProgram2ID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @allParams table ( ID uniqueidentifier | |
, DeviceID varchar(300) | |
, ParameterRefID varchar(300) | |
, IsActive bit | |
, [Value] sql_variant ) | |
insert into @allParams select * from [DeviceParameter] WHERE DeviceID = @deviceId | |
if @applicationProgramId is not null | |
begin | |
INSERT INTO @allParams SELECT newID(), @deviceId, [ID], null, null FROM [ParameterRef] WHERE ApplicationProgramID = @applicationProgramId and ID not in (select ParameterRefID from DeviceParameter where DeviceID = @deviceId) | |
end | |
if @applicationProgram2Id is not null | |
begin | |
INSERT INTO @allParams SELECT newID(), @deviceId, [ID], null, null FROM [ParameterRef] WHERE ApplicationProgramID = @applicationProgram2Id and ID not in (select ParameterRefID from DeviceParameter where DeviceID = @deviceId) | |
end | |
select * from @allParams | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterInstanceReferences TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterInstanceReferences TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterInstanceReferences TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterReferences] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterReferences') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterReferences | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterReferences | |
( | |
@applicationProgramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
select * from dbo.ParameterRef where ApplicationProgramID=@applicationProgramId | |
end | |
else | |
begin | |
SELECT [ID] | |
,[ApplicationProgramID] | |
,[ParameterID] | |
,[Name] | |
,dbo.ufn_TranslateParameterRefText(ID, @languageName, @appdefault ) as [Text] | |
,[DisplayOrder] | |
,[Access] | |
,dbo.ufn_TranslateParameterRefDefaultValue(ID, @languageName, @appdefault ) as[Value] | |
,[ValueType] | |
,[CalculationID] | |
,[CalculationSet] | |
,[AliasName] | |
,[Tag] | |
,dbo.ufn_TranslateParameterRefSuffixText(ID, @languageName, @appdefault ) as [SuffixText] | |
FROM [ParameterRef] where ApplicationProgramID=@applicationProgramId | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterReferences TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterReferences TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterReferences TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterReferencesUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterReferencesUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterReferencesUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterReferencesUnlocalized | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
select * from dbo.ParameterRef where ApplicationProgramID=@applicationProgramId | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterReferencesUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterReferencesUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterReferencesUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterTypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterTypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterTypes | |
( | |
@applicationProgramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
-- collect number parameter types | |
declare @typeNumber table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), SizeInBit int, Type varchar(20), MinInclusive bigint, MaxInclusive bigint, UIHint varchar(20)) | |
insert into @typeNumber select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, SizeInBit, Type, MinInclusive, MaxInclusive, UIHint from ParameterType inner join ParameterTypeNumber on ParameterType.ID=ParameterTypeNumber.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect float parameter types | |
declare @typeFloat table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), Encoding varchar(30), MinInclusive float, MaxInclusive float, DisplayFormat varchar(100), UIHint varchar(20), FormattingScript nvarchar(max)) | |
insert into @typeFloat select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, Encoding, MinInclusive, MaxInclusive, DisplayFormat, UIHint, FormattingScript from ParameterType inner join ParameterTypeFloat on ParameterType.ID=ParameterTypeFloat.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect text parameter types | |
declare @typeText table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), SizeInBit int, Pattern nvarchar(max)) | |
insert into @typeText select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, SizeInBit, Pattern from ParameterType inner join ParameterTypeText on ParameterType.ID=ParameterTypeText.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect restriction parameter types | |
declare @typeRestriction table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), SizeInBit int, Base varchar(20)) | |
insert into @typeRestriction select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, SizeInBit, Base from ParameterType inner join ParameterTypeRestriction on ParameterType.ID=ParameterTypeRestriction.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect date parameter types | |
declare @typeDate table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), Encoding varchar(50), DisplayTheYear bit) | |
insert into @typeDate select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, Encoding, DisplayTheYear from ParameterType inner join ParameterTypeDate on ParameterType.ID=ParameterTypeDate.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect net address parameter types | |
declare @typeNetAddress table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), AddressType varchar(50), Version varchar(20)) | |
insert into @typeNetAddress select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, AddressType, ParameterTypeIPAddress.Version from ParameterType inner join ParameterTypeIPAddress on ParameterType.ID=ParameterTypeIPAddress.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect time parameter types | |
declare @typeTime table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), SizeInBit int, Unit varchar(40), MinInclusive bigint, MaxInclusive bigint, UIHint varchar(20)) | |
insert into @typeTime select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, SizeInBit, Unit, MinInclusive, MaxInclusive, UIHint from ParameterType inner join ParameterTypeTime on ParameterType.ID=ParameterTypeTime.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- collect picture parameter types | |
declare @typePicture table( ID varchar(300), ApplicationProgramID varchar(300), Name varchar(50), Plugin varchar(max), InternalDescription varchar(max), BaggageID varchar(300), HorizontalAlignment varchar(10)) | |
insert into @typePicture select ParameterType.ID as ID, ApplicationProgramID, Name, Plugin, InternalDescription, BaggageID, HorizontalAlignment from ParameterType inner join ParameterTypePicture on ParameterType.ID=ParameterTypePicture.ParameterTypeID where ApplicationProgramID=@applicationProgramId | |
-- resturn result sets; ATTENTION: order matters!!! | |
select * from @typeNumber | |
select * from @typeFloat | |
select * from @typeText | |
select * from @typePicture | |
select * from @typeRestriction | |
-- resturn result set of parameter type none (must be in ParameterType, but in no specialization) | |
select ID, ApplicationProgramID, Name, Plugin, InternalDescription from ParameterType where ApplicationProgramID=@applicationProgramId | |
and ID not in (select ID from @typeNumber) and ID not in (select ID from @typeFloat) | |
and ID not in (select ID from @typeText) and ID not in (select ID from @typeRestriction) | |
and ID not in (select ID from @typeDate) and ID not in (select ID from @typeNetAddress) | |
and ID not in (select ID from @typeTime) and ID not in (select ID from @typePicture) | |
select * from @typeDate | |
select * from @typeNetAddress | |
select * from @typeTime | |
-- get enum values of TypeRestriction | |
DECLARE @appdefault varchar(20) = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
select * from [ParameterEnumValue] where ParameterTypeID in (select ID from @typeRestriction) | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] | |
,[ParameterTypeID] | |
,[Value] | |
,dbo.ufn_TranslateParameterEnumValueText(ID, @languageName, @appdefault) as Text | |
,[DisplayOrder] | |
,[BinaryValue] | |
FROM [ParameterEnumValue] where ParameterTypeID in (select ID from @typeRestriction) | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterTypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterTypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterTypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterUnionParameters] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterUnionParameters') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterUnionParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterUnionParameters | |
( | |
@unionId varchar(300), | |
@type varchar(100), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID in (Select ApplicationProgramId from ParameterUnion where id = @unionId )) | |
IF @languageName = @appdefault | |
BEGIN | |
If @type = 'Memory' | |
BEGIN | |
select p.*, pm.BitOffset, pm.CodeSegmentID, pm.Offset from Parameter p inner join ParameterMemory pm on p.ParameterUnionID = pm.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
ELSE | |
BEGIN | |
select p.*, pp.ObjectType, pp.ObjectIndex, pp.BitOffset, pp.Occurrence, pp.Offset, pp.PropertyId from Parameter p inner join ParameterProperty pp on p.ParameterUnionID = pp.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
end | |
else | |
begin | |
If @type = 'Memory' | |
BEGIN | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,p.[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter] | |
,dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText] | |
, pm.BitOffset, pm.CodeSegmentID, pm.Offset from Parameter p inner join ParameterMemory pm on p.ParameterUnionID = pm.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
ELSE | |
BEGIN | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,p.[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter] | |
,dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText], | |
pp.ObjectType, pp.ObjectIndex, pp.BitOffset, pp.Occurrence, pp.Offset, pp.PropertyId from Parameter p inner join ParameterProperty pp on p.ParameterUnionID = pp.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterUnionParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionParameters TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionParameters TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterUnionParametersUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterUnionParametersUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterUnionParametersUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterUnionParametersUnlocalized | |
( | |
@unionId varchar(300), | |
@type varchar(100) | |
) | |
AS | |
If @type = 'Memory' | |
BEGIN | |
select p.*, pm.BitOffset, pm.CodeSegmentID, pm.Offset from Parameter p inner join ParameterMemory pm on p.ParameterUnionID = pm.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
ELSE | |
BEGIN | |
select p.*, pp.ObjectType, pp.ObjectIndex, pp.BitOffset, pp.Occurrence, pp.Offset, pp.PropertyId from Parameter p inner join ParameterProperty pp on p.ParameterUnionID = pp.ParameterUnionID where p.ParameterUnionID = @unionId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterUnionParametersUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionParametersUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionParametersUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterUnions] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterUnions') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterUnions | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterUnions | |
( | |
@applicationProgramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
declare @unionIds table (Id varchar(300)) | |
insert into @unionIds select id from dbo.ParameterUnion where ApplicationProgramID=@applicationProgramId | |
declare @appdefault varchar(20) | |
set @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationProgramId) | |
select * from dbo.ParameterUnion where ApplicationProgramID=@applicationProgramId | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,p.[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter], | |
dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText], pm.BitOffset, pm.CodeSegmentID, pm.Offset from Parameter p inner join ParameterMemory pm on p.ParameterUnionID = pm.ParameterUnionID where p.ParameterUnionID in (select Id from @unionIds) | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,p.[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter], | |
dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText],pp.ObjectType, pp.ObjectIndex, pp.BitOffset, pp.Occurrence, pp.Offset, pp.PropertyId from Parameter p inner join ParameterProperty pp on p.ParameterUnionID = pp.ParameterUnionID where p.ParameterUnionID in (select Id from @unionIds) | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterUnions TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnions TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnions TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameterUnionsUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameterUnionsUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameterUnionsUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameterUnionsUnlocalized | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
declare @unionIds table (Id varchar(300)) | |
insert into @unionIds select id from dbo.ParameterUnion where ApplicationProgramID=@applicationProgramId | |
select * from dbo.ParameterUnion where ApplicationProgramID=@applicationProgramId | |
select * from Parameter p inner join ParameterMemory pm on p.ParameterUnionID = pm.ParameterUnionID where p.ParameterUnionID in (select Id from @unionIds) | |
select * from Parameter p inner join ParameterProperty pp on p.ParameterUnionID = pp.ParameterUnionID where p.ParameterUnionID in (select Id from @unionIds) | |
GO | |
GRANT EXEC ON dbo.usp_GetParameterUnionsUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionsUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameterUnionsUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParameters] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParameters') | |
BEGIN | |
DROP Procedure dbo.usp_GetParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParameters | |
( | |
@applicationProgramId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
select * from dbo.Parameter where ApplicationProgramID=@applicationProgramId and Type = 'None' and ParameterUnionID is null | |
select p.*, pm.BitOffset, pm.CodeSegmentID, pm.Offset from dbo.Parameter p inner join ParameterMemory pm on p.ID = pm.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Memory' and p.ParameterUnionID is null | |
select p.*, pp.BitOffset, pp.ObjectIndex, pp.ObjectType, pp.Occurrence, pp.Offset, pp.PropertyId from dbo.Parameter p inner join ParameterProperty pp on p.ID = pp.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Property'and p.ParameterUnionID is null | |
end | |
else | |
begin | |
SELECT [ID] | |
,[ApplicationProgramID] | |
,[Name] | |
,dbo.ufn_TranslateParameterText( ID, @languageName,@appdefault ) as [Text] | |
,[ParameterTypeID] | |
,[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( ID, @languageName,@appdefault ) as [Value] | |
,[ValueType] | |
,[Type] | |
,[LegacyPatchAlways] | |
,[ParameterUnionOffset] | |
,[ParameterUnionBitOffset] | |
,[ParameterUnionID] | |
,[DefaultUnionParameter] | |
,dbo.ufn_TranslateParameterSuffixText(ID, @languageName, @appdefault ) as [SuffixText] | |
from dbo.Parameter where ApplicationProgramID=@applicationProgramId and Type = 'None' and ParameterUnionID is null | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter], dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText], pm.BitOffset, pm.CodeSegmentID, pm.Offset from dbo.Parameter p inner join ParameterMemory pm on p.ID = pm.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Memory' and p.ParameterUnionID is null | |
select p.[ID] | |
,p.[ApplicationProgramID] | |
,p.[Name] | |
,dbo.ufn_TranslateParameterText( p.ID, @languageName,@appdefault ) as [Text] | |
,p.[ParameterTypeID] | |
,p.[Access] | |
,dbo.ufn_TranslateParameterDefaultValue( p.ID, @languageName,@appdefault ) as [Value] | |
,[ValueType] | |
,p.[Type] | |
,p.[LegacyPatchAlways] | |
,p.[ParameterUnionOffset] | |
,p.[ParameterUnionBitOffset] | |
,p.[ParameterUnionID] | |
,p.[DefaultUnionParameter], dbo.ufn_TranslateParameterSuffixText(p.ID, @languageName, @appdefault ) as [SuffixText], pp.BitOffset, pp.ObjectIndex, pp.ObjectType, pp.Occurrence, pp.Offset, pp.PropertyId from dbo.Parameter p inner join ParameterProperty pp on p.ID = pp.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Property' and p.ParameterUnionID is null | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParameters TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParameters TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetParametersUnlocalized] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetParametersUnlocalized') | |
BEGIN | |
DROP Procedure dbo.usp_GetParametersUnlocalized | |
END | |
GO | |
CREATE Procedure dbo.usp_GetParametersUnlocalized | |
( | |
@applicationProgramId varchar(300) | |
) | |
AS | |
select * from dbo.Parameter where ApplicationProgramID=@applicationProgramId and Type = 'None' and ParameterUnionID is null | |
select p.*, pm.BitOffset, pm.CodeSegmentID, pm.Offset from dbo.Parameter p inner join ParameterMemory pm on p.ID = pm.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Memory' and p.ParameterUnionID is null | |
select p.*, pp.BitOffset, pp.ObjectIndex, pp.ObjectType, pp.Occurrence, pp.Offset, pp.PropertyId from dbo.Parameter p inner join ParameterProperty pp on p.ID = pp.ParameterID where p.ApplicationProgramID=@applicationProgramId and p.Type = 'Property'and p.ParameterUnionID is null | |
GO | |
GRANT EXEC ON dbo.usp_GetParametersUnlocalized TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetParametersUnlocalized TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetParametersUnlocalized TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProductAttributes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProductAttributes') | |
BEGIN | |
DROP Procedure dbo.usp_GetProductAttributes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProductAttributes | |
( | |
@productId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @rootdefault varchar(20) | |
SET @rootdefault = (select Top 1 DefaultLanguage from Product where ID = @productId ) | |
IF @languageName = @rootdefault | |
BEGIN | |
select * from dbo.ProductAttribute where ProductID=@productId | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] ,[ProductID] ,[Name] ,dbo.ufn_TranslateProductAttributeValue(ID, @languageName, @rootdefault) as Value FROM [ProductAttribute] where ProductID=@productId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetProductAttributes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProductAttributes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProductAttributes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProductBaggages] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProductBaggages') | |
BEGIN | |
DROP Procedure dbo.usp_GetProductBaggages | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProductBaggages | |
( | |
@productId varchar(300) | |
) | |
AS | |
select ProductID + BaggageID as ID, * from dbo.ProductBaggage where ProductID=@productId | |
GO | |
GRANT EXEC ON dbo.usp_GetProductBaggages TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProductBaggages TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProductBaggages TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProductRegistrationLevel] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function - Determine the product registration level, Only internal use in inport | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetProductRegistrationLevel') | |
BEGIN | |
DROP Function dbo.ufn_GetProductRegistrationLevel | |
END | |
GO | |
CREATE FUNCTION [dbo].[ufn_GetProductRegistrationLevel] | |
( | |
@RegistrationStatus varchar(100) | |
) | |
RETURNS int | |
AS | |
BEGIN | |
declare @level int | |
set @level = ( select CASE | |
WHEN @RegistrationStatus = 'Unregistered' THEN 0 | |
WHEN @RegistrationStatus = 'Registered' THEN 10 | |
WHEN @RegistrationStatus = 'Certified' THEN 20 | |
WHEN @RegistrationStatus = 'FutureUseNotRecommended' THEN 30 | |
WHEN @RegistrationStatus = 'FutureUseNotAllowed' THEN 40 | |
ELSE -1 | |
END) | |
return @level | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_GetProductRegistrationLevel TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetProductRegistrationLevel TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_GetProductRegistrationLevel TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProducts] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProducts') | |
BEGIN | |
DROP Procedure dbo.usp_GetProducts | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProducts | |
( | |
@hardwareId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
SELECT [ID] | |
,[HardwareID] | |
,[ManufacturerID] | |
,[OrderNumber] | |
,dbo.ufn_TranslateProductText(ID, @languageName, [DefaultLanguage]) as Text | |
,dbo.ufn_TranslateProductDescription(ID, @languageName, [DefaultLanguage]) as [VisibleDescription] | |
,[IsRailMounted] | |
,[WidthInMillimeter] | |
,[DefaultLanguage] | |
,[NonRegRelevantDataVersion] | |
,[RegistrationStatus] | |
,[RegistrationNumber] | |
,[RegistrationDate] | |
,[RegistrationSignature] | |
,[OriginalRegistrationNumber] | |
, [Hash] | |
FROM [Product] where HardwareId=@hardwareId | |
GO | |
GRANT EXEC ON dbo.usp_GetProducts TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProducts TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProducts TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProjectHistory] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProjectHistory') | |
BEGIN | |
DROP Procedure dbo.usp_GetProjectHistory | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProjectHistory | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select * from ProjectHistory WHERE ProjectID = @projectId order by Date Asc | |
GO | |
GRANT EXEC ON dbo.usp_GetProjectHistory TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProjectHistory TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProjectHistory TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProjectTraces] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProjectTraces') | |
BEGIN | |
DROP Procedure dbo.usp_GetProjectTraces | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProjectTraces | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select * from ProjectTrace WHERE ProjectID = @projectId order by Date Asc | |
GO | |
GRANT EXEC ON dbo.usp_GetProjectTraces TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProjectTraces TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProjectTraces TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProjects] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProjects') | |
BEGIN | |
DROP Procedure dbo.usp_GetProjects | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProjects | |
AS | |
select * from [Project] | |
GO | |
GRANT EXEC ON dbo.usp_GetProjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProjects TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProjects TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetProjectsDeviceCount] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetProjectsDeviceCount') | |
BEGIN | |
DROP Procedure dbo.usp_GetProjectsDeviceCount | |
END | |
GO | |
CREATE Procedure dbo.usp_GetProjectsDeviceCount | |
( | |
@projectId varchar(300) = null | |
) | |
AS | |
if @projectId is null | |
begin | |
select distinct(InstallationID) as InstallationID, COUNT(ID) as DeviceCount from Device group by InstallationID | |
end | |
else | |
begin | |
select distinct(InstallationID) as InstallationID, COUNT(ID) as DeviceCount from Device where InstallationID in (select ID from Installation where ProjectID=@projectId) group by InstallationID | |
end | |
GO | |
GRANT EXEC ON dbo.usp_GetProjectsDeviceCount TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetProjectsDeviceCount TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetProjectsDeviceCount TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetPropertyDataTypes] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetPropertyDataTypes') | |
BEGIN | |
DROP Procedure dbo.usp_GetPropertyDataTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_GetPropertyDataTypes | |
AS | |
SELECT ID, Number, [Name], Size, [ReadSize] FROM PropertyDataType | |
GO | |
GRANT EXEC ON dbo.usp_GetPropertyDataTypes TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetPropertyDataTypes TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetPropertyDataTypes TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetPropertyIdentifiers] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetInterfaceObjectProperties') | |
BEGIN | |
DROP Procedure dbo.usp_GetInterfaceObjectProperties | |
END | |
GO | |
CREATE Procedure dbo.usp_GetInterfaceObjectProperties | |
( | |
@language varchar(20) | |
) | |
AS | |
declare @dbLanguage varchar(20) | |
set @dbLanguage = (select top(1) DatabaseLanguage from DatabaseInfo) | |
SELECT ID, Number, InterfaceObjectTypeId, [Name], dbo.ufn_TranslatedInterfaceObjectPropertyText(ID, @language, @dbLanguage) as [Text], PropertyDataTypeId, IsArray FROM InterfaceObjectProperty | |
GO | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectProperties TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectProperties TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetInterfaceObjectProperties TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetRParameters] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetRParameters') | |
BEGIN | |
DROP Procedure dbo.usp_GetRParameters | |
END | |
GO | |
CREATE Procedure dbo.usp_GetRParameters | |
( | |
@parameterCalculationId varchar(300) | |
) | |
AS | |
select * from [ParameterCalculation.RParameter] where ParameterCalculationId=@parameterCalculationId | |
GO | |
GRANT EXEC ON dbo.usp_GetRParameters TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetRParameters TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetRParameters TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetSplitInfos] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetSplitInfos') | |
BEGIN | |
DROP Procedure dbo.usp_GetSplitInfos | |
END | |
GO | |
CREATE Procedure dbo.usp_GetSplitInfos | |
( | |
@installationId varchar(300) | |
) | |
AS | |
select * from [SplitInfo] WHERE InstallationID = @installationId | |
GO | |
GRANT EXEC ON dbo.usp_GetSplitInfos TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetSplitInfos TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetSplitInfos TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetTempTablesAsXml] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Script Template | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetTempTablesAsXml') | |
BEGIN | |
DROP Procedure dbo.usp_GetTempTablesAsXml | |
END | |
GO | |
CREATE Procedure dbo.usp_GetTempTablesAsXml | |
AS | |
set nocount on | |
declare @xml xml | |
set @xml = N'<Root/>' | |
declare @fragment xml = (select * from #ApplicationProgram for xml path('ApplicationProgram'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramTranslatedText for xml path('ApplicationProgramTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramDynamic for xml path('ApplicationProgramDynamic'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #DeviceCompare for xml path('DeviceCompare'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramDynamicTranslatedText for xml path('ApplicationProgramDynamicTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramOption for xml path('ApplicationProgramOption'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationSegment for xml path('ApplicationSegment'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterType for xml path('ParameterType'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeTime for xml path('ParameterTypeTime'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeNumber for xml path('ParameterTypeNumber'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeFloat for xml path('ParameterTypeFloat'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeText for xml path('ParameterTypeText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeDate for xml path('ParameterTypeDate'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeIPAddress for xml path('ParameterTypeIPAddress'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTypeRestriction for xml path('ParameterTypeRestriction'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterEnumValue for xml path('ParameterEnumValue'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterEnumValueTranslatedText for xml path('ParameterEnumValueTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterCalculation for xml path('ParameterCalculation'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterUnion for xml path('ParameterUnion'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #Parameter for xml path('Parameter'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterMemory for xml path('ParameterMemory'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterProperty for xml path('ParameterProperty'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterTranslatedText for xml path('ParameterTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterRef for xml path('ParameterRef'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ParameterRefTranslatedText for xml path('ParameterRefTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #LParameter for xml path('LParameter'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #RParameter for xml path('RParameter'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #CommunicationObject for xml path('CommunicationObject'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #CommunicationObjectTranslatedText for xml path('CommunicationObjectTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #CommunicationObjectRef for xml path('CommunicationObjectRef'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #CommunicationObjectRefTranslatedText for xml path('CommunicationObjectRefTranslatedText'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #AddressFixup for xml path('AddressFixup'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationBinaryData for xml path('ApplicationBinaryData'), binary base64, ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramBaggage for xml path('ApplicationProgramBaggage'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
set @fragment = (select * from #ApplicationProgramLanguageVersion for xml path('ApplicationProgramLanguageVersion'), ELEMENTS XSINIL) | |
set @xml.modify( 'insert sql:variable("@fragment") as last into (/*)[1]' ) | |
select @xml | |
GO | |
GRANT EXEC ON dbo.usp_GetTempTablesAsXml TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetTempTablesAsXml TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetTempTablesAsXml TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetToDoItems] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetToDoItem') | |
BEGIN | |
DROP Procedure dbo.usp_GetToDoItem | |
END | |
GO | |
CREATE Procedure dbo.usp_GetToDoItem | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select * from ToDoItem WHERE ProjectID = @projectId order by Id Asc | |
GO | |
GRANT EXEC ON dbo.usp_GetToDoItem TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetToDoItem TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetToDoItem TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetTradeDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetTradeDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetTradeDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetTradeDevices | |
( | |
@tradeId varchar(300), | |
@CollectInSubTrades bit = 0 | |
) | |
AS | |
if @CollectInSubTrades = 0 | |
BEGIN | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.TradeID = @tradeId | |
END | |
ELSE | |
BEGIN | |
declare @Trades TABLE ( [ID] varchar(300 ) ) | |
insert into @trades (ID) VALUES (@tradeId) | |
declare @countBefore int = 0 | |
declare @countAfter int = 1 | |
while @countBefore < @countAfter | |
begin | |
set @countBefore=(select count(ID) from @trades) | |
insert into @trades select [ID] from Trade where ParentID in (select ID from @trades) and ID not in (select ID from @trades) | |
set @countAfter=(select count(ID) from @trades) | |
end | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.TradeID in (SELECT ID FROM @Trades) | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetTradeDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetTradeDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetTradeDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetTrades] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetTrades') | |
BEGIN | |
DROP Procedure dbo.usp_GetTrades | |
END | |
GO | |
CREATE Procedure dbo.usp_GetTrades | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
select * from [Trade] where InstallationID = @InstallationId | |
GO | |
GRANT EXEC ON dbo.usp_GetTrades TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetTrades TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetTrades TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetTransactionLogfileNames] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetTransactionLogfileNames') | |
BEGIN | |
DROP PROCEDURE dbo.usp_GetTransactionLogfileNames | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_GetTransactionLogfileNames | |
AS | |
-- get logfilename of current database | |
select physical_name as Logfilename from sys.database_files where type=1 | |
-- get logfilename of tempdb | |
declare @templogquery nvarchar(300)=' | |
use tempdb | |
select physical_name as Logfilename from sys.database_files where type=1' | |
exec (@templogquery) | |
GO | |
GRANT EXEC ON dbo.usp_GetTransactionLogfileNames TO ETSFullAccess | |
DENY EXEC ON dbo.usp_GetTransactionLogfileNames TO ETSReadOnlyAccess | |
DENY EXEC ON dbo.usp_GetTransactionLogfileNames TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetTypeRestrictionEnumerations] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetTypeRestrictionEnumerations') | |
BEGIN | |
DROP Procedure dbo.usp_GetTypeRestrictionEnumerations | |
END | |
GO | |
CREATE Procedure dbo.usp_GetTypeRestrictionEnumerations | |
( | |
@parameterTypeId varchar(300), | |
@languageName varchar(20) = '' | |
) | |
AS | |
DECLARE @appdefault varchar(20) | |
DECLARE @applicationProgramId varchar(300) | |
SET @applicationProgramId = (select Top 1 ApplicationProgramID from ParameterType where ID = @parameterTypeId) | |
SET @appdefault = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applicationprogramId ) | |
IF @languageName = @appdefault | |
BEGIN | |
select * from [ParameterEnumValue] where ParameterTypeID = @parameterTypeId | |
END | |
ELSE | |
BEGIN | |
SELECT [ID] | |
,[ParameterTypeID] | |
,[Value] | |
,dbo.ufn_TranslateParameterEnumValueText(ID, @languageName, @appdefault) as Text | |
,[DisplayOrder] | |
,[BinaryValue] | |
FROM [ParameterEnumValue] where ParameterTypeID = @parameterTypeId | |
END | |
GO | |
GRANT EXEC ON dbo.usp_GetTypeRestrictionEnumerations TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetTypeRestrictionEnumerations TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetTypeRestrictionEnumerations TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetUnassignedDevices] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetUnassingedDevices') | |
BEGIN | |
DROP Procedure dbo.usp_GetUnassingedDevices | |
END | |
GO | |
CREATE Procedure dbo.usp_GetUnassingedDevices | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT Device.*, Product.ManufacturerID, Product.HardwareID, (Select Top 1 1 FROM DeviceObject where DeviceId = Device.Id and IsActive = 1) as HasActiveCOs from Device inner join Product on Device.ProductID=Product.ID where Device.InstallationID = @InstallationId AND LineID = NULL | |
GO | |
GRANT EXEC ON dbo.usp_GetUnassingedDevices TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetUnassingedDevices TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetUnassingedDevices TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetUserFiles] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetUserFiles') | |
BEGIN | |
DROP Procedure dbo.usp_GetUserFiles | |
END | |
GO | |
CREATE Procedure dbo.usp_GetUserFiles | |
( | |
@projectId varchar(300) | |
) | |
AS | |
select ID, Filename, Comment, DATALENGTH(Data) as [DataLength] from UserFile WHERE ProjectID = @projectId order by [Filename] Asc | |
GO | |
GRANT EXEC ON dbo.usp_GetUserFiles TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetUserFiles TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetUserFiles TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetUserFilesData') | |
BEGIN | |
DROP Procedure dbo.usp_GetUserFilesData | |
END | |
GO | |
CREATE Procedure dbo.usp_GetUserFilesData | |
( | |
@id varchar(300) | |
) | |
AS | |
select Data from UserFile WHERE ID = @id | |
GO | |
GRANT EXEC ON dbo.usp_GetUserFilesData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetUserFilesData TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_GetUserFilesData TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [GetXmlNamespace] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function - Gets the current KNX xml namespace | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_GetXmlNamespace') | |
BEGIN | |
DROP Function dbo.ufn_GetXmlNamespace | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_GetXmlNamespace() | |
RETURNS varchar(max) | |
AS | |
BEGIN | |
declare @schemaversion varchar(max) | |
set @schemaversion = (select SchemaVersion from dbo.DatabaseInfo) | |
return '<KNX xmlns:knx="' + @schemaversion + '"/>' | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_GetXmlNamespace TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_GetXmlNamespace TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_GetXmlNamespace TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [Hardware2ProgramShapeId] | |
-------------------------------------------------------------------------------- | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_Hardware2ProgramShapeId') | |
BEGIN | |
DROP Function dbo.ufn_Hardware2ProgramShapeId | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_Hardware2ProgramShapeId | |
( | |
@Id varchar(300) | |
) | |
RETURNS varchar(300) | |
AS | |
BEGIN | |
if @Id is not null | |
begin | |
declare @converted varchar(300) | |
declare @idx int = PATINDEX( '%[_]HP%', @Id) | |
set @converted = LEFT(@Id, @idx)+SUBSTRING(@Id, @idx, 12)+'____'+SUBSTRING(@Id, @idx+16, 300) | |
return @converted | |
end | |
return null | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_Hardware2ProgramShapeId TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_Hardware2ProgramShapeId TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_Hardware2ProgramShapeId TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [HardwareTemporaryImportTables] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Temporary tables for hardware data import | |
*/ | |
-- Hardware -- | |
IF object_id('tempdb..#Hardware', 'U') IS NOT NULL DROP TABLE #Hardware; | |
CREATE TABLE #Hardware | |
( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SerialNumber varchar(50), | |
VersionNumber smallint, | |
OriginalManufacturerID varchar(300), | |
[Name] nvarchar(255), | |
IsAccessory bit, | |
HasIndividualAddress bit, | |
HasApplicationProgram bit, | |
HasApplicationProgram2 bit, | |
IsPowerSupply bit, | |
IsChoke bit, | |
IsCoupler bit, | |
IsPowerLineRepeater bit, | |
IsPowerLineSignalFilter bit, | |
IsCable bit, | |
BusCurrent real, | |
NonRegRelevantDataVersion int, | |
NoDownloadWithoutPlugin bit, | |
IsIPEnabled bit | |
); | |
GO | |
-- Product | |
IF object_id('tempdb..#Product', 'U') IS NOT NULL DROP TABLE #Product; | |
CREATE TABLE #Product | |
( | |
ID varchar(300), | |
HardwareID varchar(300), | |
ManufacturerID varchar(300), | |
OrderNumber varchar(50), | |
[Text] nvarchar(255), | |
VisibleDescription nvarchar(max), | |
IsRailMounted bit, | |
WidthInMillimeter real, | |
DefaultLanguage varchar(20), | |
NonRegRelevantDataVersion int, | |
RegistrationStatus varchar(100), | |
RegistrationNumber nvarchar(max), | |
RegistrationDate smalldatetime, | |
RegistrationSignature varchar(max), | |
RegistrationKey varchar(max), | |
OriginalRegistrationNumber nvarchar(max), | |
[Hash] varchar(max), | |
); | |
GO | |
-- Product | |
IF object_id('tempdb..#ProductBaggage', 'U') IS NOT NULL DROP TABLE #ProductBaggage; | |
CREATE TABLE #ProductBaggage | |
( | |
ProductID varchar(300), | |
BaggageID varchar(300), | |
); | |
GO | |
-- Product | |
IF object_id('tempdb..#ProductAttribute', 'U') IS NOT NULL DROP TABLE #ProductAttribute; | |
CREATE TABLE #ProductAttribute | |
( | |
ID varchar(300), | |
ProductID varchar(300), | |
Name varchar(20), | |
Value nvarchar(255), | |
); | |
GO | |
-- Product | |
IF object_id('tempdb..#Hardware2Program', 'U') IS NOT NULL DROP TABLE #Hardware2Program; | |
CREATE TABLE #Hardware2Program | |
( | |
[ID] [varchar](300) NOT NULL, | |
[HardwareID] [varchar](300) NOT NULL, | |
[ApplicationProgramID] [varchar](300) NULL, | |
[ApplicationProgram2ID] [varchar](300) NULL, | |
[RegistrationStatus] varchar(100) NOT NULL, | |
[RegistrationNumber] nvarchar(max) NULL, | |
[OriginalRegistrationNumber] nvarchar(max) NULL, | |
[RegistrationDate] [smalldatetime] NULL, | |
[RegistrationSignature] varchar(max) NULL, | |
[RegistrationKey] varchar(max) NULL, | |
[MediumTypes] [varchar](max) NULL, | |
[Hash] varchar(max) NULL, | |
[CheckSums] varbinary(max) NULL, | |
[LoadedImage] varbinary(max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#ProductAttributeLanguage', 'U') IS NOT NULL DROP TABLE #ProductAttributeLanguage; | |
CREATE TABLE #ProductAttributeLanguage ( | |
[ProductAttributeID] [varchar](300) NOT NULL, | |
[Language] varchar(20) NOT NULL, | |
[Version] [int] NOT NULL, | |
[TranslatedValue] [nvarchar](255) NULL, | |
); | |
GO | |
IF object_id('tempdb..#ProductLanguage', 'U') IS NOT NULL DROP TABLE #ProductLanguage; | |
CREATE TABLE #ProductLanguage ( | |
[ProductID] [varchar](300) NOT NULL, | |
[Language] varchar(20) NOT NULL, | |
[Version] [int] NOT NULL, | |
[TranslatedName] [nvarchar](255) NULL, | |
[TranslatedDescription] [nvarchar](max) NULL, | |
); | |
GO | |
-------------------------------------------------------------------------------- | |
-- [HashIssueScript] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateDeleteDuplicateHardware2Program') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateDeleteDuplicateHardware2Program | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateDeleteDuplicateHardware2Program | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
delete from Hardware2Program where ID in (select Id from openxml(@docHandle, '/Items/Item') with (Id varchar(300) '@Id')) | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateHardware2Program TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateHardware2Program TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateHardware2Program TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateDeleteDuplicateCatalog') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateDeleteDuplicateCatalog | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateDeleteDuplicateCatalog | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
delete from CatalogItem where ID in (select Id from openxml(@docHandle, '/Items/Item') with (Id varchar(300) '@Id')) | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateCatalog TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateCatalog TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateCatalog TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateDeleteDuplicateApplicationProgram') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateDeleteDuplicateApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateDeleteDuplicateApplicationProgram | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
declare @apIds table( ID varchar(300) ) | |
insert into @apIds select Id from openxml(@docHandle, '/Items/Item') with (Id varchar(300) '@Id') | |
declare @paramIds table( ID varchar(300) ) | |
insert into @paramIds select ID from Parameter where ApplicationProgramID in (select ID from @apIds) | |
delete from ParameterMemory where ParameterID in (select ID from @paramIds) | |
delete from ParameterProperty where ParameterID in (select ID from @paramIds) | |
delete from @paramIds | |
insert into @paramIds select ID from ParameterUnion where ApplicationProgramID in (select ID from @apIds) | |
delete from ParameterMemory where ParameterUnionID in (select ID from @paramIds) | |
delete from ParameterProperty where ParameterUnionID in (select ID from @paramIds) | |
delete from @paramIds | |
-- resolve FK ring references | |
update ParameterRef set CalculationID = null where CalculationID is not null and ApplicationProgramID in (select ID from @apIds) | |
delete from ParameterCalculation where ProgramID in (select ID from @apIds) | |
delete from ApplicationProgram where ID in (select ID from @apIds) | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateApplicationProgram TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateApplicationProgram TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateDeleteDuplicateApplicationProgram TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateHardware2Program') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateHardware2Program | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateHardware2Program | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
declare itemCursor cursor local forward_only fast_forward read_only for select OldId, NewId, Hash, RegistrationSignature, RegistrationKey, ApplProg, ApplProg2, DuplicateOld from openxml(@docHandle, '/Items/Item') with (OldId varchar(300) '@OldId', NewId varchar(300) '@NewId' | |
, Hash varchar(max) '@Hash', RegistrationSignature varchar(max) '@RegistrationSignature', RegistrationKey varchar(max) '@RegistrationKey', ApplProg varchar(300) '@ApplProg', ApplProg2 varchar(300) '@ApplProg2', DuplicateOld bit '@DuplicateOld') | |
open itemCursor | |
declare @oldId varchar(300) | |
declare @newId varchar(300) | |
declare @hash varchar(max) | |
declare @regSig varchar(max) | |
declare @regKey varchar(max) | |
declare @appl varchar(300) | |
declare @appl2 varchar(300) | |
declare @duplicate bit | |
fetch next from itemCursor into @oldId, @newId, @hash, @regSig, @regKey, @appl, @appl2, @duplicate | |
while @@FETCH_STATUS = 0 | |
begin | |
update CatalogItem set Hardware2ProgramID=@newId where Hardware2ProgramID=@oldId | |
update Device set Hardware2ProgramID=@newId where Hardware2ProgramID=@oldId | |
if @duplicate = 0 | |
begin | |
update Hardware2Program set ID=@newId, Hash=@hash, RegistrationSignature=@regSig, RegistrationKey=@regKey, ApplicationProgramID=@appl, ApplicationProgram2ID=@appl2 where ID=@oldId | |
end | |
else | |
begin | |
delete from Hardware2Program where ID=@oldId | |
end | |
fetch next from itemCursor into @oldId, @newId, @hash, @regSig, @regKey, @appl, @appl2, @duplicate | |
end | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateHardware2Program TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateHardware2Program TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateHardware2Program TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateCatalog') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateCatalog | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateCatalog | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
declare itemCursor cursor local forward_only fast_forward read_only for select OldId, NewId, DuplicateOld from openxml(@docHandle, '/Items/Item') with (OldId varchar(300) '@OldId', NewId varchar(300) '@NewId', DuplicateOld bit '@DuplicateOld') | |
open itemCursor | |
declare @oldId varchar(300) | |
declare @newId varchar(300) | |
declare @duplicate bit | |
fetch next from itemCursor into @oldId, @newId, @duplicate | |
while @@FETCH_STATUS = 0 | |
begin | |
if @duplicate = 0 | |
begin | |
update CatalogItem set ID=@newId where ID=@oldId | |
update CatalogItemTranslatedText set CatalogItemID=@newId where CatalogItemID=@oldId | |
end | |
else | |
begin | |
delete from CatalogItem where ID=@oldId | |
delete from CatalogItemTranslatedText where CatalogItemID=@oldId | |
end | |
fetch next from itemCursor into @oldId, @newId, @duplicate | |
end | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateCatalog TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateCatalog TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateCatalog TO ETSWriteProjectAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_HashUpdateApplicationProgram') | |
BEGIN | |
DROP Procedure dbo.usp_HashUpdateApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_HashUpdateApplicationProgram | |
( | |
@xml xml | |
) | |
AS | |
set nocount on | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @xml | |
declare itemCursor cursor local forward_only fast_forward read_only for select OldId, NewId, Hash, DuplicateOld from openxml(@docHandle, '/Items/Item') with (OldId varchar(300) '@OldId', NewId varchar(300) '@NewId', Hash varchar(max) '@Hash', DuplicateOld bit '@DuplicateOld') | |
open itemCursor | |
declare @oldId varchar(300) | |
declare @newId varchar(300) | |
declare @hash varchar(max) | |
declare @duplicate bit | |
fetch next from itemCursor into @oldId, @newId, @hash, @duplicate | |
while @@FETCH_STATUS = 0 | |
begin | |
declare @like varchar(300) = REPLACE(@oldId, '_', '[_]') + '%' | |
if @duplicate = 0 | |
begin | |
update AddressFixup set ProgramID=@newId, SegmentID=REPLACE(SegmentID, @oldId, @newId) where ProgramID=@oldId | |
update ApplicationBinaryData set ProgramID=@newId, ID=REPLACE(ID, @oldId, @newId) where ProgramID=@oldId | |
update ApplicationProgram set ID=@newId | |
, AddressTableSegmentID=REPLACE(AddressTableSegmentID, @oldId, @newId) | |
, AssociationTableSegmentID=REPLACE(AssociationTableSegmentID, @oldId, @newId) | |
, ComObjectTableSegmentID=REPLACE(ComObjectTableSegmentID, @oldId, @newId) | |
, Hash=@hash | |
where ID=@oldId | |
update ApplicationProgramBaggage set ApplicationProgramID=@newId, BaggageID=REPLACE(BaggageID, @oldId, @newId) where ApplicationProgramID=@oldId | |
update ApplicationProgramDynamic set ApplicationProgramID=@newId | |
, ApplicationProgramDynamic=Convert(xml,REPLACE(Convert(nvarchar(max),ApplicationProgramDynamic), @oldId, @newId)) where ApplicationProgramID=@oldId | |
update ApplicationProgramDynamicTranslatedText set ApplicationProgramID=@newId, ElementID=REPLACE(ElementID, @oldId, @newId) where ApplicationProgramID=@oldId | |
update ApplicationProgramLanguageVersion set ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update ApplicationProgramOption set ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update ApplicationProgramTranslatedText set ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update ApplicationSegment set ProgramID=@newId, ID=REPLACE(ID, @oldId, @newId) where ProgramID=@oldId | |
update CommunicationObject set ProgramID=@newId, ID=REPLACE(ID, @oldId, @newId) where ProgramID=@oldId | |
update CommunicationObjectRef set ApplicationProgramID=@newId, ID=REPLACE(ID, @oldId, @newId) | |
, CommunicationObjectID=REPLACE(CommunicationObjectID, @oldId, @newId) where ApplicationProgramID=@oldId | |
update CommunicationObjectRefTranslatedText set CommunicationObjectRefID=REPLACE(CommunicationObjectRefID, @oldId, @newId) where CommunicationObjectRefID like @like | |
update CommunicationObjectTranslatedText set CommunicationObjectID=REPLACE(CommunicationObjectID, @oldId, @newId) where CommunicationObjectID like @like | |
update DeviceCompare set ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update Parameter set ID=REPLACE(ID, @oldId, @newId), ApplicationProgramID=@newId | |
, ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) | |
, ParameterUnionID=REPLACE(ParameterUnionID, @oldId, @newId) | |
where ApplicationProgramID=@oldId | |
update ParameterCalculation set ID=REPLACE(ID, @oldId, @newId), ProgramID=@newId where ProgramID=@oldId | |
update [ParameterCalculation.LParameter] set ParameterCalculationID=REPLACE(ParameterCalculationID, @oldId, @newId) | |
, ParameterRefID=REPLACE(ParameterRefID, @oldId, @newId) where ParameterRefID like @like | |
update [ParameterCalculation.RParameter] set ParameterCalculationID=REPLACE(ParameterCalculationID, @oldId, @newId) | |
, ParameterRefID=REPLACE(ParameterRefID, @oldId, @newId) where ParameterRefID like @like | |
update ParameterEnumValue set ID=REPLACE(ID, @oldId, @newId), ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ID like @like | |
update ParameterEnumValueTranslatedText set ParameterEnumValueID=REPLACE(ParameterEnumValueID, @oldId, @newId) where ParameterEnumValueID like @like | |
update ParameterMemory set ID=REPLACE(ID, @oldId, @newId), ParameterID=REPLACE(ParameterID, @oldId, @newId) | |
, ParameterUnionID=REPLACE(ParameterUnionID, @oldId, @newId), CodeSegmentID=REPLACE(CodeSegmentID, @oldId, @newId) | |
where ID like @like | |
update ParameterProperty set ID=REPLACE(ID, @oldId, @newId), ParameterID=REPLACE(ParameterID, @oldId, @newId) | |
, ParameterUnionID=REPLACE(ParameterUnionID, @oldId, @newId) where ID like @like | |
update ParameterRef set ID=REPLACE(ID, @oldId, @newId), ApplicationProgramID=@newId, CalculationID=REPLACE(CalculationID, @oldId, @newId) | |
, ParameterID=REPLACE(ParameterID, @oldId, @newId) where ApplicationProgramID=@oldId | |
update ParameterRefTranslatedText set ParameterRefID=REPLACE(ParameterRefID, @oldId, @newId) where ParameterRefID like @like | |
update ParameterTranslatedText set ParameterID=REPLACE(ParameterID, @oldId, @newId) where ParameterID like @like | |
update ParameterType set ID=REPLACE(ID, @oldId, @newId), ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update ParameterTypeDate set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeFloat set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeIPAddress set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeNumber set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypePicture set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeRestriction set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeText set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterTypeTime set ParameterTypeID=REPLACE(ParameterTypeID, @oldId, @newId) where ParameterTypeID like @like | |
update ParameterUnion set ID=REPLACE(ID, @oldId, @newId), ApplicationProgramID=@newId where ApplicationProgramID=@oldId | |
update IdMapping set [Path]=REPLACE([Path], @oldId, @newId) | |
end | |
update DeviceBinaryData set BinaryDataID=REPLACE(BinaryDataID, @oldId, @newId) where BinaryDataID like @like | |
update DeviceObject set CommunicationObjectRefID=REPLACE(CommunicationObjectRefID, @oldId, @newId) where CommunicationObjectRefID like @like | |
update DeviceParameter set ParameterRefID=REPLACE(ParameterRefID, @oldId, @newId) where ParameterRefID like @like | |
fetch next from itemCursor into @oldId, @newId, @hash, @duplicate | |
end | |
exec sp_xml_removedocument @docHandle | |
GO | |
GRANT EXEC ON dbo.usp_HashUpdateApplicationProgram TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_HashUpdateApplicationProgram TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_HashUpdateApplicationProgram TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [Icon1] | |
-------------------------------------------------------------------------------- | |
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 | |
-------------------------------------------------------------------------------- | |
-- [ImportBaggageFile] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports baggage binary data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportBaggageFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportBaggageFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportBaggageFile | |
( | |
@baggageId varchar(300), | |
@baggageFile nvarchar(300), | |
@compressionMode char = null | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update Baggage set [Compression]=''' + @compressionMode + ''', Data=(select * from OPENROWSET( BULK N''' + @baggageFile + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where ID=''' + @baggageId + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportBaggageFile TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportBaggageFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportBaggageFile TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportBaggages] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports baggage informations into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportBaggages') | |
BEGIN | |
DROP Procedure dbo.usp_ImportBaggages | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportBaggages | |
( | |
@importXml xml | |
) | |
AS | |
--begin transaction | |
declare @docHandle int | |
-- all xpath queries and must use namespace 'knx' from here | |
-- we have to declare an explicit namespace, because default namespace does not work if specified in XML | |
declare @xmlNamespace varchar(max) | |
set @xmlNamespace = dbo.ufn_GetXmlNamespace() | |
exec sp_xml_preparedocument @docHandle output, @importXml, @xmlNamespace | |
begin try | |
MERGE Baggage AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:ManufacturerData/knx:Manufacturer/knx:Baggages/knx:Baggage') with (ID varchar(300) '@Id', ManufacturerID varchar(300) '../../@RefId', TargetPath varchar(255) '@TargetPath', Name nvarchar(255) '@Name', InstallOnImport bit '@InstallOnImport', GroupAddresses16BitEnabled bit '@GroupAddresses16BitEnabled' | |
, Version varchar(50) './knx:FileInfo/@Version[1]', TimeInfo datetime './knx:FileInfo/@TimeInfo[1]', Hidden bit './knx:FileInfo/@Hidden[1]', ReadOnly bit './knx:FileInfo/@ReadOnly[1]' | |
, Data varbinary(max) './knx:Data' )) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, ManufacturerID, TargetPath, [Name], InstallOnImport, GroupAddresses16BitEnabled, Version, TimeInfo, Hidden, ReadOnly, Data) | |
VALUES( Source.ID, Source.ManufacturerID, Source.TargetPath, Source.Name, Source.InstallOnImport, Source.GroupAddresses16BitEnabled, Source.Version, Source.TimeInfo, ISNULL(Source.Hidden, 0), ISNULL(Source.ReadOnly, 0), Source.Data) | |
WHEN MATCHED AND (dbo.ufn_CompareVersions(Target.Version, Source.Version) > 0 or (dbo.ufn_CompareVersions(Target.Version, Source.Version) = 0 and Target.TimeInfo < Source.TimeInfo)) THEN | |
UPDATE | |
SET Target.InstallOnImport = Source.InstallOnImport, Target.GroupAddresses16BitEnabled = Source.GroupAddresses16BitEnabled, Target.Version = Source.Version, Target.TimeInfo = Source.TimeInfo | |
, Target.Hidden = ISNULL(Source.Hidden, 0), Target.ReadOnly = ISNULL(Source.ReadOnly, 0), Target.Data = Source.Data | |
OUTPUT $action as Action, deleted.ID as DeletedID, deleted.TargetPath as DeletedTargetPath, deleted.Name as DeletedName, deleted.InstallOnImport as DeletedInstallOnImport | |
, inserted.ID as InsertedID, inserted.TargetPath as InsertedTargetPath, inserted.Name as InsertedName, inserted.InstallOnImport as InsertedInstallOnImport, inserted.GroupAddresses16BitEnabled as GroupAddresses16BitEnabled; | |
--commit transaction | |
exec sp_xml_removedocument @docHandle | |
return 0 | |
end try | |
begin catch | |
--rollback transaction | |
if @docHandle != 0 | |
begin | |
exec sp_xml_removedocument @docHandle | |
end | |
declare @message nvarchar(2048) = ERROR_MESSAGE() | |
declare @severity int = ERROR_SEVERITY() | |
declare @state int = ERROR_STATE() | |
RAISERROR( @message, @severity, @state ) | |
return -1 | |
end catch | |
GO | |
GRANT EXEC ON dbo.usp_ImportBaggages TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportBaggages TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportBaggages TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportCatalogData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports catalog data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportCatalogData') | |
BEGIN | |
DROP Procedure dbo.usp_ImportCatalogData | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportCatalogData | |
AS | |
MERGE CatalogSection AS Target | |
using #CatalogSection as Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, ParentCatalogSectionID, ManufacturerID, Name, Number, VisibleDescription, DefaultLanguage, NonRegRelevantDataVersion) | |
VALUES( Source.ID, Source.ParentCatalogSectionID, Source.ManufacturerID, Source.Name, Source.Number, Source.VisibleDescription, Source.DefaultLanguage | |
, Source.NonRegRelevantDataVersion) | |
WHEN MATCHED AND dbo.ufn_NonRegVersionUpdateRequired(Target.NonRegRelevantDataVersion, Source.NonRegRelevantDataVersion) = 1 THEN | |
UPDATE SET Target.Name = Source.Name, Target.Number = Source.Number, Target.NonRegRelevantDataVersion = Source.NonRegRelevantDataVersion | |
, Target.VisibleDescription = Source.VisibleDescription, Target.DefaultLanguage = Source.DefaultLanguage; | |
MERGE CatalogItem AS Target | |
using #CatalogItem as Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, CatalogSectionID, Name, Number, VisibleDescription, ProductId, Hardware2ProgramID, DefaultLanguage, NonRegRelevantDataVersion, MediumTypes) | |
VALUES( Source.ID, Source.CatalogSectionID, Source.Name, Source.Number, Source.VisibleDescription, Source.ProductID, Source.Hardware2ProgramID | |
, Source.DefaultLanguage, Source.NonRegRelevantDataVersion, Source.MediumTypes) | |
WHEN MATCHED AND dbo.ufn_NonRegVersionUpdateRequired(Target.NonRegRelevantDataVersion, Source.NonRegRelevantDataVersion) = 1 THEN | |
UPDATE SET Target.Name = Source.Name, Target.Number = Source.Number, Target.MediumTypes = Source.MediumTypes, Target.ProductID = Source.ProductID | |
, Target.NonRegRelevantDataVersion = Source.NonRegRelevantDataVersion, Target.VisibleDescription = Source.VisibleDescription | |
, Target.Hardware2ProgramID = Source.Hardware2ProgramID, Target.DefaultLanguage = Source.DefaultLanguage; | |
merge CatalogItemTranslatedText as target | |
using #CatalogItemLanguages as source | |
on (target.Language + target.CatalogItemID = source.Language + source.CatalogItemID ) | |
WHEN NOT MATCHED THEN | |
INSERT ([CatalogItemID], [Language] ,[Version] ,[TranslatedName] ,[TranslatedDescription]) Values (source.CatalogItemID, source.Language, source.Version ,source.TranslatedName, source.TranslatedDescription) | |
WHEN MATCHED AND dbo.ufn_TranslationUpdateRequired(target.Version, source.Version) = 1 THEN | |
UPDATE SET target.Version = source.Version, target.TranslatedName = source.TranslatedName, target.TranslatedDescription = source.TranslatedDescription; | |
merge CatalogSectionTranslatedText as target | |
using #CatalogSectionLanguages as source | |
on (target.Language + target.CatalogSectionID = source.Language + source.CatalogSectionID ) | |
WHEN NOT MATCHED THEN | |
INSERT ([CatalogSectionID], [Language] ,[Version] ,[TranslatedName] ,[TranslatedDescription]) Values (source.CatalogSectionID, source.Language, source.Version ,source.TranslatedName, source.TranslatedDescription) | |
WHEN MATCHED AND dbo.ufn_TranslationUpdateRequired(target.Version, source.Version) = 1 THEN | |
UPDATE SET target.Version = source.Version, target.TranslatedName = source.TranslatedName, target.TranslatedDescription = source.TranslatedDescription; | |
GO | |
GRANT EXEC ON dbo.usp_ImportCatalogData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportCatalogData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportCatalogData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportDataPointSubTypes] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedure for import the data point subtype xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportDataPointSubTypes') | |
BEGIN | |
DROP Procedure dbo.usp_ImportDataPointSubTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportDataPointSubTypes | |
( | |
@docHandle int | |
) | |
AS | |
MERGE dbo.DatapointSubType AS Target | |
USING (select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:DatapointTypes/knx:DatapointType/knx:DatapointSubtypes/knx:DatapointSubtype') with (ID varchar(300) '@Id', Number int '@Number', Name varchar(255) '@Name', Text nvarchar(255) '@Text', [Default] bit, ParentID varchar(300) '../../@Id')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (DatapointTypeID, ID, Number, Name, Text, [Default] ) | |
VALUES( Source.ParentID, Source.ID, Source.Number, Source.Name, Source.Text, Source.[Default] ) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number=Source.Number, Target.Name = Source.Name, Target.Text = Source.Text, Target.[Default] = Source.[Default]; | |
GO | |
GRANT EXEC ON dbo.usp_ImportDataPointSubTypes TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportDataPointSubTypes TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportDataPointSubTypes TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportDataPointTypes] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedure for import the data point type xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportDataPointTypes') | |
BEGIN | |
DROP Procedure dbo.usp_ImportDataPointTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportDataPointTypes | |
( | |
@docHandle int | |
) | |
AS | |
MERGE DatapointType AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:DatapointTypes/knx:DatapointType') with (ID varchar(300) '@Id', Number int '@Number', Name varchar(255) '@Name', Text nvarchar(255) '@Text', LengthInBit smallint '@SizeInBit', [Default] bit '@Default' )) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, Number, Name, Text, LengthInBit, [Default]) | |
VALUES( Source.ID, Source.Number, Source.Name, Source.Text, Source.LengthInBit, Source.[Default]) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.Name = Source.Name, Target.Text = Source.Text, Target.LengthInBit = Source.LengthInBit, Target.[Default] = Source.[Default]; | |
GO | |
GRANT EXEC ON dbo.usp_ImportDataPointTypes TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportDataPointTypes TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportDataPointTypes TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportHardwareData] | |
-------------------------------------------------------------------------------- | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportHardwareData') | |
BEGIN | |
DROP Procedure dbo.usp_ImportHardwareData | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportHardwareData | |
AS | |
set nocount on; | |
MERGE Hardware AS Target | |
USING #Hardware as Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT ( | |
[ID] ,[ManufacturerID] ,[SerialNumber], [VersionNumber] ,[OriginalManufacturerID] ,[Name] ,[IsAccessory] ,[HasIndividualAddress] | |
,[HasApplicationProgram] ,[HasApplicationProgram2] ,[IsPowerSupply] ,[IsChoke] ,[IsCoupler] ,[IsPowerLineRepeater] | |
,[IsPowerLineSignalFilter] ,[IsCable] ,[BusCurrent] ,[NonRegRelevantDataVersion], NoDownloadWithoutPlugin, IsIPEnabled | |
) | |
VALUES( Source.ID,Source.ManufacturerID, Source.SerialNumber, Source.VersionNumber, Source.OriginalManufacturerID, Source.Name, ISNULL(Source.IsAccessory, 0), Source.HasIndividualAddress, | |
Source.HasApplicationProgram ,Source.HasApplicationProgram2, Source.IsPowerSupply, Source.IsChoke, Source.IsCoupler, Source.IsPowerLineRepeater, | |
Source.IsPowerLineSignalFilter, Source.IsCable ,Source.BusCurrent , Source.NonRegRelevantDataVersion, Source.NoDownloadWithoutPlugin, Source.IsIPEnabled | |
) | |
WHEN MATCHED and dbo.ufn_NonRegVersionUpdateRequired(Target.NonRegRelevantDataVersion, Source.NonRegRelevantDataVersion ) = 1 THEN | |
UPDATE SET Target.Name = Source.Name, Target.BusCurrent = Source.BusCurrent, Target.NonRegRelevantDataVersion = Source.NonRegRelevantDataVersion | |
, Target.NoDownloadWithoutPlugin = Source.NoDownloadWithoutPlugin; | |
-- Product | |
insert [Product] select * from #Product where ID not in (select ID from [Product]) | |
declare @updateProduct table (ID varchar(300), UpdateRegStatus bit, UpdateNonReg bit, RegistrationStatus varchar(50), RegistrationNumber nvarchar(max) | |
, RegistrationDate smalldatetime, RegistrationSignature varchar(max), RegistrationKey varchar(max), OriginalRegistrationNumber nvarchar(max) | |
, Text nvarchar(255), IsRailMounted bit, WidthInMillimeter real, VisibleDescription nvarchar(max), DefaultLanguage varchar(20) | |
, NonRegRelevantDataVersion int, Hash varchar(max)) | |
insert into @updateProduct | |
select Source.ID, case when dbo.ufn_GetProductRegistrationLevel(Target.RegistrationStatus) < dbo.ufn_GetProductRegistrationLevel(Source.RegistrationStatus) then 1 else 0 end | |
, dbo.ufn_NonRegVersionUpdateRequired( Target.NonRegRelevantDataVersion, Source.NonRegRelevantDataVersion ) | |
, Source.RegistrationStatus, Source.RegistrationNumber, Source.RegistrationDate, Source.RegistrationSignature, Source.RegistrationKey, Source.OriginalRegistrationNumber | |
, Source.Text, Source.IsRailMounted, Source.WidthInMillimeter, Source.VisibleDescription, Source.DefaultLanguage, Source.NonRegRelevantDataVersion | |
, Source.Hash | |
from #Product as Source inner join [Product] as Target on Source.ID=Target.ID | |
update Product set RegistrationStatus = Source.RegistrationStatus, RegistrationNumber = Source.RegistrationNumber | |
, RegistrationDate = Source.RegistrationDate, RegistrationSignature = Source.RegistrationSignature, RegistrationKey = Source.RegistrationKey | |
, OriginalRegistrationNumber = Source.OriginalRegistrationNumber, Text = Source.Text, IsRailMounted = Source.IsRailMounted | |
, WidthInMillimeter = Source.WidthInMillimeter, VisibleDescription = Source.VisibleDescription, DefaultLanguage = Source.DefaultLanguage | |
, NonRegRelevantDataVersion = Source.NonRegRelevantDataVersion, Hash = Source.Hash | |
from @updateProduct as Source inner join Product on Product.ID = Source.ID where Source.UpdateRegStatus = 1 | |
update Product set Text = Source.Text, IsRailMounted = Source.IsRailMounted | |
, WidthInMillimeter = Source.WidthInMillimeter, VisibleDescription = Source.VisibleDescription, DefaultLanguage = Source.DefaultLanguage | |
, NonRegRelevantDataVersion = Source.NonRegRelevantDataVersion, Hash = Source.Hash, RegistrationSignature=Source.RegistrationSignature, RegistrationKey=Source.RegistrationKey | |
from @updateProduct as Source inner join Product on Product.ID = Source.ID where Source.UpdateRegStatus = 0 and Source.UpdateNonReg = 1 | |
truncate table #Product | |
-- Hardware2Program | |
insert [Hardware2Program] select * from #Hardware2Program where ID not in (select ID from [Hardware2Program]) | |
declare @updateHardware2Program table (ID varchar(300), UpdateRegStatus bit, UpdateNonReg bit, RegistrationStatus varchar(50), RegistrationNumber nvarchar(max) | |
, RegistrationDate smalldatetime, RegistrationSignature varchar(max), RegistrationKey varchar(max), MediumTypes varchar(max), Hash varchar(max), CheckSums varbinary(max), LoadedImage varbinary(max) | |
, OriginalRegistrationNumber nvarchar(max)) | |
insert into @updateHardware2Program | |
select Source.ID, case when dbo.ufn_GetProductRegistrationLevel(Target.RegistrationStatus) < dbo.ufn_GetProductRegistrationLevel(Source.RegistrationStatus) then 1 else 0 end | |
, dbo.ufn_NonRegVersionUpdateRequired( (select NonRegRelevantDataVersion from Hardware where ID=Target.HardwareID), (select NonRegRelevantDataVersion from #Hardware where ID=Source.HardwareID)) | |
, Source.RegistrationStatus, Source.RegistrationNumber, Source.RegistrationDate, Source.RegistrationSignature, Source.RegistrationKey, Source.MediumTypes, Source.Hash, Source.CheckSums, Source.LoadedImage | |
, Source.OriginalRegistrationNumber | |
from #Hardware2Program as Source inner join [Hardware2Program] as Target on Source.ID=Target.ID | |
update Hardware2Program set RegistrationStatus = Source.RegistrationStatus, RegistrationNumber = Source.RegistrationNumber, | |
RegistrationDate = Source.RegistrationDate, RegistrationSignature = Source.RegistrationSignature, RegistrationKey = Source.RegistrationKey | |
, MediumTypes = Source.MediumTypes, Hash = Source.Hash, CheckSums = Source.CheckSums, LoadedImage = Source.LoadedImage, OriginalRegistrationNumber = Source.OriginalRegistrationNumber | |
from @updateHardware2Program as Source inner join Hardware2Program on Hardware2Program.ID = Source.ID | |
where Source.UpdateRegStatus = 1 | |
update Hardware2Program set MediumTypes = Source.MediumTypes, Hash = Source.Hash, CheckSums = Source.CheckSums, LoadedImage = Source.LoadedImage | |
from @updateHardware2Program as Source inner join Hardware2Program on Hardware2Program.ID = Source.ID | |
where Source.UpdateRegStatus = 0 and Source.UpdateNonReg = 1 | |
truncate table #Hardware2Program | |
truncate table #Hardware | |
-- ProductAttribute | |
delete from [ProductAttribute] where ProductID in (select ProductID from #ProductAttribute) and ID not in (select ID from #ProductAttribute) | |
MERGE [ProductAttribute] AS Target | |
USING #ProductAttribute as Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT ( [ID] , ProductID, Name, Value ) | |
VALUES ( Source.ID, Source.ProductID, Source.Name, Source.Value ) | |
WHEN MATCHED THEN | |
UPDATE SET Target.Name = Source.Name, Target.Value = Source.Value; | |
truncate table #ProductAttribute | |
-- ProductBaggages | |
delete from [ProductBaggage] where ProductID in (select ProductID from #ProductBaggage) and ProductID+BaggageID not in (select ProductID+BaggageID from #ProductBaggage) | |
MERGE [ProductBaggage] AS Target | |
USING #ProductBaggage as Source | |
ON | |
( | |
Target.ProductID+Target.BaggageID = Source.ProductID+Source.BaggageID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT ( ProductID, BaggageID ) | |
VALUES ( Source.ProductID, Source.BaggageID ); | |
truncate table #ProductBaggage | |
merge ProductAttributeTranslatedText as target | |
using #ProductAttributeLanguage as source | |
on (target.Language + target.ProductAttributeID = source.Language + source.ProductAttributeID ) | |
WHEN NOT MATCHED THEN | |
INSERT ([ProductAttributeID], [Language] ,[Version] ,[TranslatedValue]) Values (source.ProductAttributeID, source.Language, source.Version ,source.TranslatedValue) | |
WHEN MATCHED AND dbo.ufn_TranslationUpdateRequired(target.Version, source.Version) = 1 THEN | |
UPDATE SET target.Version = source.Version, target.TranslatedValue = source.TranslatedValue; | |
truncate table #ProductAttributeLanguage | |
merge ProductTranslatedText as target | |
using #ProductLanguage as source | |
on (target.Language + target.ProductID = source.Language + source.ProductID ) | |
WHEN NOT MATCHED THEN | |
INSERT ([ProductID], [Language] ,[Version] ,[TranslatedName] ,[TranslatedDescription]) Values (source.ProductID, source.Language, source.Version ,source.TranslatedName, source.TranslatedDescription) | |
WHEN MATCHED AND dbo.ufn_TranslationUpdateRequired(target.Version, source.Version) = 1 THEN | |
UPDATE SET target.Version = source.Version, target.TranslatedName = source.TranslatedName, target.TranslatedDescription = source.TranslatedDescription; | |
truncate table #ProductLanguage | |
GO | |
GRANT EXEC ON dbo.usp_ImportHardwareData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportHardwareData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportHardwareData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportKnxData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Root stored procedure for import the KNX master data xml | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportKnxData') | |
BEGIN | |
DROP Procedure dbo.usp_ImportKnxData | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportKnxData | |
( | |
@importXml xml | |
) | |
AS | |
declare @docHandle int | |
-- all xpath queries and must use namespace 'knx' from here | |
-- we have to declare an explicit namespace, because default namespace does not work if specified in XML | |
declare @xmlNamespace varchar(max) | |
set @xmlNamespace = dbo.ufn_GetXmlNamespace() | |
exec sp_xml_preparedocument @docHandle output, @importXml, @xmlNamespace | |
begin try | |
--begin transaction | |
declare @currentVersion int | |
set @currentVersion = (select CurrentMasterDataVersion from DatabaseInfo) | |
declare @importVersion int | |
set @importVersion = (select Version from openxml(@docHandle, '/knx:KNX/knx:MasterData') with (Version integer '@Version')) | |
if @importVersion > @currentVersion | |
begin | |
exec dbo.usp_ImportDataPointTypes @docHandle | |
exec dbo.usp_ImportDataPointSubTypes @docHandle | |
exec dbo.usp_ImportInterfaceObjectTypes @docHandle | |
exec dbo.usp_ImportPropertyDataTypes @docHandle | |
exec dbo.usp_ImportInterfaceObjectProperties @docHandle | |
exec dbo.usp_ImportMediumTypes @docHandle | |
exec dbo.usp_ImportMaskVersions @docHandle | |
exec dbo.usp_ImportMaskEntries @docHandle | |
exec dbo.usp_ImportManufacturers @docHandle | |
exec dbo.usp_ImportManufacturerPublicKeys @docHandle | |
exec dbo.usp_ImportLanguages @docHandle | |
update dbo.DatabaseInfo set CurrentMasterDataVersion = @importVersion, KnxMasterDataXml = @importXml | |
end | |
-- commit changes | |
--commit transaction | |
exec sp_xml_removedocument @docHandle | |
return 0 | |
end try | |
begin catch | |
--rollback transaction | |
if @docHandle != 0 | |
begin | |
exec sp_xml_removedocument @docHandle | |
end | |
exec dbo.usp_RethrowException | |
end catch | |
GO | |
GRANT EXEC ON dbo.usp_ImportKnxData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportKnxData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportKnxData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportManufacturers] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the manufacturer section xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportManufacturers') | |
BEGIN | |
DROP Procedure dbo.usp_ImportManufacturers | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportManufacturers | |
( | |
@docHandle int | |
) | |
AS | |
-- insert new with this merge and update only DefaultLnaguage and CompatibilityGroup on existing | |
MERGE dbo.Manufacturer AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:Manufacturers/knx:Manufacturer') with (ID varchar(300) '@Id', KnxManufacturerID smallint '@KnxManufacturerId', Name nvarchar(255) '@Name', NameVersion int '@NameVersion', DefaultLanguage languageid '@DefaultLanguage', CompatibilityGroup int '@CompatibilityGroup', OrderNumberFormattingScript varchar(max) '@OrderNumberFormattingScript')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, KnxManufacturerID, Name, DefaultLanguage, CompatibilityGroup, OrderNumberFormattingScript ) | |
VALUES( Source.ID, Source.KnxManufacturerID, Source.Name, Source.DefaultLanguage, Source.CompatibilityGroup, Source.OrderNumberFormattingScript) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.DefaultLanguage = Source.DefaultLanguage, Target.CompatibilityGroup = Source.CompatibilityGroup, Target.Name=Source.Name, Target.OrderNumberFormattingScript=Source.OrderNumberFormattingScript; | |
GO | |
GRANT EXEC ON dbo.usp_ImportManufacturers TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportManufacturers TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportManufacturers TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportManufacturersPublicKeys] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the manufacturer section xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportManufacturerPublicKeys') | |
BEGIN | |
DROP Procedure dbo.usp_ImportManufacturerPublicKeys | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportManufacturerPublicKeys | |
( | |
@docHandle int | |
) | |
AS | |
MERGE dbo.ManufacturerPublicKey AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:Manufacturers/knx:Manufacturer/knx:PublicKeys/knx:PublicKey') with (ID varchar(300) '@Id', ManufacturerID varchar(300) '../../@Id', Number int '@Number', [Revoked] bit '@Revoked', [Key] varchar(max) '/knx:RSAKeyValue')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, ManufacturerId ,Number, [Revoked], [Key]) | |
VALUES( Source.ID, Source.ManufacturerID, Source.Number, Source.[Revoked], Source.[Key]) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.[Revoked] = Source.[Revoked], Target.[Key] = Source.[Key]; | |
GO | |
GRANT EXEC ON dbo.usp_ImportManufacturerPublicKeys TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportManufacturerPublicKeys TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportManufacturerPublicKeys TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportMaskEntries] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the mask entries xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportMaskEntries') | |
BEGIN | |
DROP Procedure dbo.usp_ImportMaskEntries | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportMaskEntries | |
( | |
@docHandle int | |
) | |
AS | |
MERGE dbo.MaskEntry AS Target | |
USING ( select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:MaskVersions/knx:MaskVersion/knx:MaskEntries/knx:MaskEntry') with (ID varchar(300) '@Id', MaskID varchar(300) '../../@Id', Name nvarchar(20) '@Name', Address int '@Address')) AS Source | |
ON | |
( | |
Target.ID = Source.ID and Target.MaskID = Source.MaskID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, MaskID, Name, Address) | |
VALUES( Source.ID, Source.MaskID, Source.Name, Source.Address) | |
WHEN MATCHED THEN | |
UPDATE SET Target.Name = Source.Name, Target.Address = Source.Address; | |
GO | |
GRANT EXEC ON dbo.usp_ImportMaskEntries TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportMaskEntries TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportMaskEntries TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportMaskVersions] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the mask version xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportMaskVersions') | |
BEGIN | |
DROP Procedure dbo.usp_ImportMaskVersions | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportMaskVersions | |
( | |
@docHandle int | |
) | |
AS | |
-- insert mask versions | |
MERGE dbo.MaskVersion AS Target | |
USING ( select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:MaskVersions/knx:MaskVersion') with (ID varchar(300) '@Id', MaskVersion int '@MaskVersion', [Name] varchar(50) '@Name', ManagementModel varchar(20) '@ManagementModel', MediumType varchar(300) '@MediumTypeRefId', MgmtDescriptor01 varchar(50) '@MgmtDescriptor01', OtherMediumType varchar(300) '@OtherMediumTypeRefId')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, MaskVersion, MgmtDescriptor01, Name, MediumType, OtherMediumType, ManagementModel) | |
VALUES( Source.ID, Source.MaskVersion, Source.MgmtDescriptor01, Source.Name, Source.MediumType, Source.OtherMediumType, Source.ManagementModel) | |
WHEN MATCHED and Target.MaskVersion = Source.MaskVersion THEN | |
UPDATE | |
SET Target.MgmtDescriptor01 = Source.MgmtDescriptor01, Target.Name = Source.Name, Target.MediumType = Source.MediumType, Target.OtherMediumType = Source.OtherMediumType, Target.ManagementModel = Source.ManagementModel; | |
--insert mask compatibility if existing | |
MERGE dbo.MaskCompatibility AS Target | |
USING ( select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:MaskVersions/knx:MaskVersion/knx:DownwardCompatibleMasks/knx:DownwardCompatibleMask') with (OldMaskID varchar(300) '@RefId', NewMaskID varchar(300) '../../@Id')) AS Source | |
ON | |
( | |
Target.OldMaskID = Source.OldMaskID and Target.NewMaskID = Source.NewMaskID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (OldMaskID, NewMaskID) VALUES( Source.OldMaskID, Source.NewMaskID); | |
-- insert hawk configurations | |
MERGE dbo.HawkConfigurationData AS Target | |
USING ( select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:MaskVersions/knx:MaskVersion/knx:HawkConfigurationData') with (MaskVersionID varchar(300) '../@Id', LegacyVersion int '@LegacyVersion', ConfigurationData xml '.')) AS Source | |
ON | |
( | |
Target.MaskVersionID = Source.MaskVersionID and (Target.LegacyVersion = Source.LegacyVersion or (Target.LegacyVersion is null and Source.LegacyVersion is null)) | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (MaskVersionID, LegacyVersion, ConfigurationData) | |
VALUES( Source.MaskVersionID, Source.LegacyVersion, Source.ConfigurationData) | |
WHEN MATCHED and Target.MaskVersionID = Source.MaskVersionID THEN | |
UPDATE SET Target.ConfigurationData = Source.ConfigurationData; | |
GO | |
GRANT EXEC ON dbo.usp_ImportMaskVersions TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportMaskVersions TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportMaskVersions TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportMasterDataLanguages] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the language section xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportLanguages') | |
BEGIN | |
DROP Procedure dbo.usp_ImportLanguages | |
END | |
GO | |
CREATE Procedure [dbo].[usp_ImportLanguages] | |
( | |
@docHandle int | |
) | |
AS | |
-- create a temporary variable table containing all languages (better performance) | |
declare @languages table (ID varchar(300), Language varchar(20), Version int, AttributeName varchar(200), Text nvarchar(max) ) | |
insert into @languages select ID, Language, ISNULL(Version, 0), AttributeName, Text from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:Languages/knx:Language/knx:TranslationUnit/knx:TranslationElement/knx:Translation') with (ID varchar(300) '../@RefId', Language varchar(20) '../../../@Identifier', Version int '../../@Version', AttributeName varchar(200) '@AttributeName', Text nvarchar(max) '@Text') | |
-- global declarations used by each iteration | |
declare @id varchar(300) | |
declare @language varchar(20) | |
declare @version int | |
declare @attributeName varchar(200) | |
declare @text nvarchar(max) | |
declare @newEntry bit = 0 | |
-- update DatapointTypeTranslatedText table | |
declare typeCursor cursor local forward_only fast_forward read_only for select * from @languages where ID in (select ID from DatapointType) | |
open typeCursor | |
fetch next from typeCursor into @id, @language, @version, @attributeName, @text | |
while @@FETCH_STATUS = 0 | |
begin | |
if not exists(select DatapointTypeID, Language, Version from DatapointTypeTranslatedText where DatapointTypeID=@id and Language=@language) | |
begin | |
insert into DatapointTypeTranslatedText (DatapointTypeID, Language, Version, TranslatedText) values (@id, @language, @version, @text) | |
end | |
else | |
begin | |
update DatapointTypeTranslatedText set TranslatedText=@text where DatapointTypeID=@id and Language=@language | |
end | |
fetch next from typeCursor into @id, @language, @version, @attributeName, @text | |
end | |
close typeCursor | |
deallocate typeCursor | |
-- update DatapointSubypeTranslatedText table | |
declare subtypeCursor cursor local forward_only fast_forward read_only for select * from @languages where ID in (select ID from DatapointSubtype) | |
open subtypeCursor | |
fetch next from subtypeCursor into @id, @language, @version, @attributeName, @text | |
while @@FETCH_STATUS = 0 | |
begin | |
if not exists(select DatapointSubtypeID, Language, Version from DatapointSubtypeTranslatedText where DatapointSubtypeID=@id and Language=@language) | |
begin | |
insert into DatapointSubtypeTranslatedText (DatapointSubtypeID, Language, Version, TranslatedText) values (@id, @language, @version, @text) | |
end | |
else | |
begin | |
update DatapointSubtypeTranslatedText set TranslatedText=@text where DatapointSubtypeID=@id and Language=@language | |
end | |
fetch next from subtypeCursor into @id, @language, @version, @attributeName, @text | |
end | |
close subtypeCursor | |
deallocate subtypeCursor | |
-- update InterfaceObjectTypeTranslatedText table | |
declare InterfaceObjectTypeCursor cursor local forward_only fast_forward read_only for select * from @languages where ID in (select ID from InterfaceObjectType) | |
open InterfaceObjectTypeCursor | |
fetch next from InterfaceObjectTypeCursor into @id, @language, @version, @attributeName, @text | |
while @@FETCH_STATUS = 0 | |
begin | |
if not exists(select InterfaceObjectTypeID, Language, Version from InterfaceObjectTypeTranslatedText where InterfaceObjectTypeID=@id and Language=@language) | |
begin | |
insert into InterfaceObjectTypeTranslatedText (InterfaceObjectTypeID, Language, Version, TranslatedText) values (@id, @language, @version, @text) | |
end | |
else | |
begin | |
update InterfaceObjectTypeTranslatedText set TranslatedText=@text where InterfaceObjectTypeID=@id and Language=@language | |
end | |
fetch next from InterfaceObjectTypeCursor into @id, @language, @version, @attributeName, @text | |
end | |
close InterfaceObjectTypeCursor | |
deallocate InterfaceObjectTypeCursor | |
-- update InterfaceObjectPropertyTranslatedText table | |
declare InterfaceObjectPropertyCursor cursor local forward_only fast_forward read_only for select * from @languages where ID in (select ID from InterfaceObjectProperty) | |
open InterfaceObjectPropertyCursor | |
fetch next from InterfaceObjectPropertyCursor into @id, @language, @version, @attributeName, @text | |
while @@FETCH_STATUS = 0 | |
begin | |
if not exists(select InterfaceObjectPropertyID, Language, Version from InterfaceObjectPropertyTranslatedText where InterfaceObjectPropertyID=@id and Language=@language) | |
begin | |
insert into InterfaceObjectPropertyTranslatedText (InterfaceObjectPropertyID, Language, Version, TranslatedText) values (@id, @language, @version, @text) | |
end | |
else | |
begin | |
update InterfaceObjectPropertyTranslatedText set TranslatedText=@text where InterfaceObjectPropertyID=@id and Language=@language | |
end | |
fetch next from InterfaceObjectPropertyCursor into @id, @language, @version, @attributeName, @text | |
end | |
close InterfaceObjectPropertyCursor | |
deallocate InterfaceObjectPropertyCursor | |
GO | |
GRANT EXEC ON dbo.usp_ImportLanguages TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportLanguages TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportLanguages TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportMediumTypes] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored procedure for import the medium type xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportMediumTypes') | |
BEGIN | |
DROP Procedure dbo.usp_ImportMediumTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportMediumTypes | |
( | |
@docHandle int | |
) | |
AS | |
MERGE dbo.MediumType AS Target | |
USING ( select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:MediumTypes/knx:MediumType') with (ID varchar(300) '@Id', Number int '@Number', Name nvarchar(20) '@Name', Text nvarchar(50) '@Text', DomainAddressLength smallint '@DomainAddressLength')) AS Source | |
ON | |
( | |
Target.ID = Source.Id | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, Number, Name, Text, DomainAddressLength) | |
VALUES( Source.Id, Source.Number, Source.Name, Source.Text, Source.DomainAddressLength) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.Name = Source.Name, Target.Text = Source.Text, Target.DomainAddressLength = Source.DomainAddressLength; | |
GO | |
GRANT EXEC ON dbo.usp_ImportMediumTypes TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportMediumTypes TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportMediumTypes TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportObjectTypes] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedure for import the object types xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportInterfaceObjectTypes') | |
BEGIN | |
DROP Procedure dbo.usp_ImportInterfaceObjectTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportInterfaceObjectTypes | |
( | |
@docHandle int | |
) | |
AS | |
MERGE InterfaceObjectType AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:InterfaceObjectTypes/knx:InterfaceObjectType') with (ID varchar(300) '@Id', Number int '@Number', Name varchar(255) '@Name', Text nvarchar(255) '@Text')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, Number, Name, Text) | |
VALUES( Source.ID, Source.Number, Source.Name, Source.Text) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.Name = Source.Name, Target.Text = Source.Text; | |
GO | |
GRANT EXEC ON dbo.usp_ImportInterfaceObjectTypes TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportInterfaceObjectTypes TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportInterfaceObjectTypes TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportProjectData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports project data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportProjectData') | |
BEGIN | |
DROP Procedure dbo.usp_ImportProjectData | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportProjectData | |
AS | |
-- Project | |
insert into Project select * from #Project | |
-- ProjectHistory | |
INSERT INTO ProjectHistory SELECT NEWID() as ID, ProjectID, [Date], [User], [Text], [Detail] FROM #ProjectHistory | |
-- ProjectTrace | |
INSERT INTO ProjectTrace SELECT NEWID() AS ID, ProjectID, [Date], [User], Description FROM #ProjectTrace | |
-- ToDoItems | |
INSERT INTO ToDoItem SELECT NEWID() AS ID, Description, ObjectPath, ProjectID, CurrentStatus FROM #ToDoItem | |
insert into UserFile select * from #UserFile | |
insert into AddinData select * from #AddinData | |
truncate table #Project | |
truncate table #ProjectHistory | |
truncate table #ProjectTrace | |
truncate table #ToDoItem | |
truncate table #UserFile | |
truncate table #AddinData | |
GO | |
GRANT EXEC ON dbo.usp_ImportProjectData TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportProjectData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportProjectData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportProjectDeviceBinaryData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports baggage binary data file into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportBinaryDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportBinaryDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportBinaryDataFile | |
( | |
@ID varchar(300), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update DeviceBinaryData set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where ID=''' + @Id + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportBinaryDataFile TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportBinaryDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportBinaryDataFile TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportUserFileDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportUserFileDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportUserFileDataFile | |
( | |
@ProjectId varchar(300), | |
@FileName varchar(50), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update UserFile set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where ProjectID=''' + @ProjectId + ''' AND FileName=''' + @FileName + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportUserFileDataFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportUserFileDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportUserFileDataFile TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportAddinDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportAddinDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportAddinDataFile | |
( | |
@Name varchar(50), | |
@AddinID nvarchar(max), | |
@ProjectID varchar(300), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update AddinData set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where Name=''' + @Name + ''' and ProjectID=''' + @ProjectID + ''' and AddinID=''' + @AddinID + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportAddinDataFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportAddinDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportAddinDataFile TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportProjectDeviceBinaryDataFile] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports baggage binary data file into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportBinaryDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportBinaryDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportBinaryDataFile | |
( | |
@ID varchar(300), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update DeviceBinaryData set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where ID=''' + @Id + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportBinaryDataFile TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportBinaryDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportBinaryDataFile TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportUserFileDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportUserFileDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportUserFileDataFile | |
( | |
@ProjectId varchar(300), | |
@FileName varchar(50), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update UserFile set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where ProjectID=''' + @ProjectId + ''' AND FileName=''' + @FileName + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportUserFileDataFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportUserFileDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportUserFileDataFile TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportAddinDataFile') | |
BEGIN | |
DROP Procedure dbo.usp_ImportAddinDataFile | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportAddinDataFile | |
( | |
@Name varchar(50), | |
@AddinID nvarchar(max), | |
@ProjectID varchar(300), | |
@FilePath nvarchar(300) | |
) | |
AS | |
declare @command nvarchar(max) | |
set @command = N'update AddinData set Data=(select * from OPENROWSET( BULK N''' + @FilePath + ''', CODEPAGE=''RAW'', SINGLE_BLOB) as Temp) where Name=''' + @Name + ''' and ProjectID=''' + @ProjectID + ''' and AddinID=''' + @AddinID + '''' | |
exec sp_executesql @command | |
GO | |
GRANT EXEC ON dbo.usp_ImportAddinDataFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportAddinDataFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportAddinDataFile TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportProjectInstallationData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports installation data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportInstallationData') | |
BEGIN | |
DROP Procedure dbo.usp_ImportInstallationData | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportInstallationData | |
AS | |
-- Installation | |
INSERT INTO Installation SELECT * FROM #Installation | |
INSERT INTO GroupRange SELECT * FROM #GroupRange | |
INSERT INTO GroupAddress SELECT * FROM #GroupAddress | |
INSERT INTO Building SELECT * FROM #Building | |
INSERT INTO Trade SELECT * FROM #Trade | |
INSERT INTO Area SELECT * FROM #Area | |
INSERT INTO Line SELECT * FROM #Line | |
INSERT INTO Device SELECT * FROM #Device | |
INSERT INTO DeviceParameter SELECT * FROM #DeviceParameter | |
INSERT INTO DeviceObject SELECT ID, DeviceID, CommunicationObjectRefID, Text, FunctionText, Description, IsActive, DatapointType | |
, dbo.ufn_CommunicationFlags(ReadFlag), dbo.ufn_CommunicationFlags(WriteFlag), dbo.ufn_CommunicationFlags(CommunicationFlag), dbo.ufn_CommunicationFlags(TransmitFlag) | |
, dbo.ufn_CommunicationFlags(UpdateFlag), | |
dbo.ufn_CommunicationFlags(ReadOnInitFlag), Priority, ObjectSize, Number FROM #DeviceObject | |
INSERT INTO Connector SELECT * FROM #Connector | |
INSERT INTO AdditionalDeviceAddress SELECT * FROM #AdditionalDeviceAddress | |
INSERT INTO AdditionalGroupAddress SELECT * FROM #AdditionalGroupAddress | |
INSERT INTO DeviceBinaryData SELECT * FROM #DeviceBinaryData | |
-- insert DeviceParameter and DeviceObject missing in import file | |
declare @hardwareToPrograms table( ID varchar(300) ) | |
insert into @hardwareToPrograms select Hardware2ProgramID from Device where ID in (select ID from #Device) | |
declare @applProgs table( ID varchar(300), Hardware2ProgramID varchar(300) ) | |
insert into @applProgs select ApplicationProgramID, ID from Hardware2Program where ID in (select ID from @hardwareToPrograms ) | |
insert into @applProgs select ApplicationProgram2ID, ID from Hardware2Program where ID in (select ID from @hardwareToPrograms ) | |
declare @device2ApplProg table( DeviceID varchar(300), ApplProgID varchar(300) ) | |
insert into @device2ApplProg select Device.ID, [@applProgs].ID from @applProgs inner join Device on [@applProgs].Hardware2ProgramID=Device.Hardware2ProgramID where Device.ID in (select ID from #Device) | |
--select * from @device2ApplProg | |
merge DeviceParameter as Target | |
using( select DeviceID as DeviceID, ParameterRef.ID as ParameterRefID from ParameterRef inner join @device2ApplProg on ParameterRef.ApplicationProgramID=[@device2ApplProg].ApplProgID ) as Source | |
on( Target.DeviceID=Source.DeviceID and Target.ParameterRefId=Source.ParameterRefId) | |
when not matched then | |
insert (ID, DeviceID, ParameterRefID, IsActive, Value) values(newId(), Source.DeviceID, Source.ParameterRefID, null, null); | |
merge DeviceObject as Target | |
using( select DeviceID as DeviceID, CommunicationObjectRef.ID as CommunicationObjectRefID, ISNull(CommunicationObjectRef.ObjectSize, CommunicationObject.ObjectSize) as ObjectSize, CommunicationObject.Number | |
from CommunicationObjectRef inner join @device2ApplProg on CommunicationObjectRef.ApplicationProgramID=[@device2ApplProg].ApplProgID | |
inner join CommunicationObject on CommunicationObjectRef.CommunicationObjectID = CommunicationObject.ID ) as Source | |
on( Target.DeviceID=Source.DeviceID and Target.CommunicationObjectRefID=Source.CommunicationObjectRefID) | |
when not matched then | |
insert (ID, DeviceID, CommunicationObjectRefID, ObjectSize, Number) values (newid(), Source.DeviceID, Source.CommunicationObjectRefID, Source.ObjectSize,Source.Number); | |
-- cleanup temporary tables | |
truncate Table #Installation | |
truncate Table #GroupAddress | |
truncate Table #GroupRange | |
truncate Table #Building | |
truncate Table #Trade | |
truncate Table #Area | |
truncate Table #Line | |
truncate Table #Device | |
truncate Table #DeviceParameter | |
truncate Table #DeviceObject | |
truncate Table #Connector | |
truncate Table #AdditionalDeviceAddress | |
truncate Table #AdditionalGroupAddress | |
truncate Table #DeviceBinaryData | |
GO | |
GRANT EXEC ON dbo.usp_ImportInstallationData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportInstallationData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportInstallationData TO ETSReadOnlyAccess | |
GO | |
/** @file | |
This stored procedure imports depended device data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportDeviceDependedDataFromApplicationProgram') | |
BEGIN | |
DROP Procedure usp_ImportDeviceDependedDataFromApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportDeviceDependedDataFromApplicationProgram | |
@deviceId varchar(300), | |
@hardware2ProgramId varchar(300) | |
AS | |
if @hardware2ProgramId is not null | |
begin | |
declare @applicationProgramId varchar(300) = ( select ApplicationProgramID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @applicationProgram2Id varchar(300) = ( select ApplicationProgram2ID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @cos table( ID varchar(300), ObjectSize varchar(20), Number smallint ) | |
declare @coRefs table( ID varchar(300), ObjectSize varchar(20), RefID varchar(300) ) | |
if @applicationProgramId is not null | |
begin | |
insert into @cos select ID, ObjectSize, Number from [CommunicationObject] where ProgramID=@applicationProgramId | |
insert into @coRefs select ID, ObjectSize, CommunicationObjectID from [CommunicationObjectRef] where ApplicationProgramID=@applicationProgramId | |
end | |
if @applicationProgram2Id is not null | |
begin | |
insert into @cos select ID, ObjectSize, Number from [CommunicationObject] where ProgramID=@applicationProgram2Id | |
insert into @coRefs select ID, ObjectSize, CommunicationObjectID from [CommunicationObjectRef] where ApplicationProgramID=@applicationProgram2Id | |
end | |
INSERT INTO DeviceObject SELECT newId(), @deviceId, [@coRefs].[ID], null, null, null, null, null, null, null, null, null, null, null, null | |
, ISNull([@coRefs].ObjectSize, [@cos].ObjectSize) as ObjectSize, [@cos].Number as Number | |
FROM @coRefs inner join @cos on [@coRefs].RefID = [@cos].ID WHERE [@coRefs].ID not in (select CommunicationObjectRefID from DeviceObject Where DeviceID = @deviceId ) | |
delete from @cos | |
delete from @coRefs | |
if @applicationProgramId is not null | |
begin | |
--INSERT INTO DeviceObject SELECT newId(), @deviceId, CoRef.[ID], null, null, null, null, null, null, null, null, null, null, null, null, ISNull(CoRef.ObjectSize, Co.ObjectSize) as ObjectSize, Co.Number as Number FROM [CommunicationObjectRef] CoRef inner join CommunicationObject Co on CoRef.CommunicationObjectID = Co.Id WHERE CoRef.ApplicationProgramID = @applicationProgramId and CORef.ID not in (select CommunicationObjectRefID from DeviceObject Where DeviceID = @deviceId ) | |
INSERT INTO DeviceParameter SELECT newID(), @deviceId, [ID], null, null FROM [ParameterRef] WHERE ApplicationProgramID = @applicationProgramId and ID not in (select ParameterRefID from DeviceParameter where DeviceID = @deviceId) | |
INSERT INTO DeviceBinaryData SELECT newID(), @deviceId, [ID], [Name], [Data] FROM [ApplicationBinaryData] WHERE ProgramID = @applicationProgramId | |
end | |
if @applicationProgram2Id is not null | |
begin | |
--INSERT INTO DeviceObject SELECT newId(), @deviceId, CoRef.[ID], null, null, null, null, null, null, null, null, null, null, null, null, ISNull(CoRef.ObjectSize, Co.ObjectSize) as ObjectSize, Co.Number as Number FROM [CommunicationObjectRef] CoRef inner join CommunicationObject Co on CoRef.CommunicationObjectID = Co.Id WHERE CoRef.ApplicationProgramID = @applicationProgram2Id and CORef.ID not in (select CommunicationObjectRefID from DeviceObject Where DeviceID = @deviceId ) | |
INSERT INTO DeviceParameter SELECT newID(), @deviceId, [ID], null, null FROM [ParameterRef] WHERE ApplicationProgramID = @applicationProgram2Id and ID not in (select ParameterRefID from DeviceParameter where DeviceID = @deviceId) | |
INSERT INTO DeviceBinaryData SELECT newID(), @deviceId, [ID], [Name], [Data] FROM [ApplicationBinaryData] WHERE ProgramID = @applicationProgram2Id | |
end | |
end | |
GO | |
GRANT EXEC ON dbo.usp_ImportDeviceDependedDataFromApplicationProgram TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_ImportDeviceDependedDataFromApplicationProgram TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportDeviceDependedDataFromApplicationProgram TO ETSReadOnlyAccess | |
GO | |
/** @file | |
This stored procedure selects ObjectSize and Number of CommunicationObjects | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_GetObjetSizeAndNumberOfCommunicationObjects') | |
BEGIN | |
DROP Procedure usp_GetObjetSizeAndNumberOfCommunicationObjects | |
END | |
GO | |
CREATE Procedure dbo.usp_GetObjetSizeAndNumberOfCommunicationObjects | |
@communicationObjectReferencesXml xml | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @communicationObjectReferencesXml | |
declare @coRefIds idtable | |
insert into @coRefIds select ID from openxml( @docHandle, '/Ids/Id') with (ID nvarchar(300) '@Id') | |
exec sp_xml_removedocument @docHandle | |
SELECT CORef.ID, ISNULL(CORef.ObjectSize, CO.ObjectSize) as ObjectSize, Co.Number as Number from CommunicationObjectRef CORef inner join CommunicationObject CO on CORef.CommunicationObjectID = CO.ID WHERE CORef.ID in (select ID from @coRefIds) | |
GO | |
GRANT EXEC ON dbo.usp_GetObjetSizeAndNumberOfCommunicationObjects TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_GetObjetSizeAndNumberOfCommunicationObjects TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_GetObjetSizeAndNumberOfCommunicationObjects TO ETSReadOnlyAccess | |
GO | |
/** @file | |
This stored procedure selects ObjectSize and Number of CommunicationObjects | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UpdateDeviceForBuildingsAndTrades') | |
BEGIN | |
DROP Procedure usp_UpdateDeviceForBuildingsAndTrades | |
END | |
GO | |
CREATE Procedure dbo.usp_UpdateDeviceForBuildingsAndTrades | |
@mappingXml xml | |
AS | |
declare @docHandle int | |
exec sp_xml_preparedocument @docHandle output, @mappingXml | |
declare @deviceMapping table(deviceId varchar(300), buildingId varchar(300), tradeId varchar(300)) | |
insert into @deviceMapping select deviceId, buildingId, tradeId from openxml( @docHandle, '/Devices/Device') with (deviceId nvarchar(300) '@DeviceId', tradeId nvarchar(300) '@TradeId', buildingId nvarchar(300) '@BuildingId') | |
exec sp_xml_removedocument @docHandle | |
update Device set Device.BuildingId = map.BuildingId, Device.TradeId = map.TradeId FROM Device inner join @deviceMapping map on Device.Id = map.deviceId | |
GO | |
GRANT EXEC ON dbo.usp_UpdateDeviceForBuildingsAndTrades TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_UpdateDeviceForBuildingsAndTrades TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_UpdateDeviceForBuildingsAndTrades TO ETSReadOnlyAccess | |
GO | |
/** @file | |
This stored procedure cleans up connectors with referrenced inactive communication objects | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_CleanupInActiveDeviceObjectsWithConnectors') | |
BEGIN | |
DROP Procedure usp_CleanupInActiveDeviceObjectsWithConnectors | |
END | |
GO | |
CREATE Procedure dbo.usp_CleanupInActiveDeviceObjectsWithConnectors | |
@installationId varchar(300) | |
AS | |
declare @deleted table (deviceid varchar(300), communicationObjectRefd varchar(300)) | |
insert into @deleted select DeviceObject.DeviceID, DeviceObject.CommunicationObjectRefID from Connector inner join DeviceObject on Connector.DeviceObjectID = DeviceObject.ID where DeviceObject.IsActive = 0 and DeviceObject.DeviceID in (select ID from Device where Device.InstallationID = @installationId) | |
delete from connector where connector.ID in (select Connector.ID from Connector inner join DeviceObject on Connector.DeviceObjectID = DeviceObject.ID where DeviceObject.IsActive = 0 and DeviceObject.DeviceID in (select ID from Device where Device.InstallationID = @installationId) ) | |
select * from @deleted | |
GO | |
GRANT EXEC ON dbo.usp_CleanupInActiveDeviceObjectsWithConnectors TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_CleanupInActiveDeviceObjectsWithConnectors TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_CleanupInActiveDeviceObjectsWithConnectors TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportPropertyDataTypes] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedure for import the object types xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportPropertyDataTypes') | |
BEGIN | |
DROP Procedure dbo.usp_ImportPropertyDataTypes | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportPropertyDataTypes | |
( | |
@docHandle int | |
) | |
AS | |
MERGE PropertyDataType AS Target | |
USING (select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:PropertyDataTypes/knx:PropertyDataType') with (ID varchar(300) '@Id', Number int '@Number', Name varchar(255) '@Name', Size int '@Size', ReadSize int '@ReadSize')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, Number, Name, Size, ReadSize) | |
VALUES( Source.ID, Source.Number, Source.Name, Source.Size, Source.ReadSize) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.Name = Source.Name, Target.Size = Source.Size, Target.ReadSize = Source.ReadSize; | |
GO | |
GRANT EXEC ON dbo.usp_ImportPropertyDataTypes TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportPropertyDataTypes TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportPropertyDataTypes TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ImportPropertyIdentifiers] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Stored Procedure for import the Property Identifier xml, internal use only | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ImportInterfaceObjectProperties') | |
BEGIN | |
DROP Procedure dbo.usp_ImportInterfaceObjectProperties | |
END | |
GO | |
CREATE Procedure dbo.usp_ImportInterfaceObjectProperties | |
( | |
@docHandle int | |
) | |
AS | |
MERGE InterfaceObjectProperty AS Target | |
USING ( | |
select * from openxml(@docHandle, '/knx:KNX/knx:MasterData/knx:InterfaceObjectProperties/knx:InterfaceObjectProperty') with (ID varchar(300) '@Id', InterfaceObjectTypeId varchar(300) '@InterfaceObjectType', | |
Number int '@Number', Name varchar(255) '@Name', Text nvarchar(255) '@Text', PropertyDataTypeId varchar(255) '@PDT', IsArray bit '@Array')) AS Source | |
ON | |
( | |
Target.ID = Source.ID | |
) | |
WHEN NOT MATCHED THEN | |
INSERT (ID, Number, InterfaceObjectTypeId, Name, Text, PropertyDataTypeId, IsArray) | |
VALUES( Source.ID, Source.Number, Source.InterfaceObjectTypeId, Source.Name, Source.Text, Source.PropertyDataTypeId, Source.IsArray) | |
WHEN MATCHED THEN | |
UPDATE | |
SET Target.Number = Source.Number, Target.InterfaceObjectTypeId = Source.InterfaceObjectTypeId, Target.Name = Source.Name, Target.Text = Source.Text, Target.PropertyDataTypeId = Source.PropertyDataTypeId, Target.IsArray = Source.IsArray; | |
GO | |
GRANT EXEC ON dbo.usp_ImportInterfaceObjectProperties TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ImportInterfaceObjectProperties TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_ImportInterfaceObjectProperties TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InitGeneral] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - General | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- ---------------------------------------------------------------------------- | |
-- Types | |
-- ---------------------------------------------------------------------------- | |
IF type_id('languageid') IS NOT NULL DROP TYPE dbo.languageid; | |
/** @brief Determines a language. | |
This is encoded as xml:lang, e.g. "en" for English or "en-US" for english (united states). | |
*/ | |
CREATE TYPE dbo.languageid FROM varchar(20); | |
GO | |
IF type_id('completionstatus') IS NOT NULL DROP TYPE dbo.completionstatus; | |
/** @brief Specifies the completion status of a project item | |
Defined values: | |
- 'Undefined' | |
- 'Editing' | |
- 'FinishedDesign' | |
- 'FinishedCommissioning' | |
- 'Tested' | |
- 'Accepted' | |
*/ | |
CREATE TYPE dbo.completionstatus FROM varchar(50); | |
GO | |
IF type_id('projectracinglevels') IS NOT NULL DROP TYPE dbo.projecttracinglevels; | |
/** @brief Specifies the project tracing level of a project | |
Defined values: | |
- 'None': no project tracing | |
- 'OperationUsed': only operation descriptions | |
- 'Detailed': with detailed operation descriptions | |
*/ | |
CREATE TYPE dbo.projecttracinglevels FROM varchar(50); | |
GO | |
IF type_id('todoitemstatus') IS NOT NULL DROP TYPE dbo.todoitemstatus; | |
/** @brief Specifies the todo item status | |
Defined values: | |
- 'Open' | |
- 'Accomplished' | |
*/ | |
CREATE TYPE dbo.todoitemstatus FROM varchar(50); | |
GO | |
IF type_id('registrationstatus') IS NOT NULL DROP TYPE dbo.registrationstatus; | |
/** @brief Specifies the registration status of a product | |
Defined values: | |
- 'Unregistered': not registered (0) | |
- 'Registered': registered (10) | |
- 'Certified': certified (20) | |
- 'FutureUseNotRecommended': registered, but future use not recommended (30) | |
- 'FutureUseNotAllowed': registered, but future use not allowed (40) | |
*/ | |
CREATE TYPE dbo.registrationstatus FROM varchar(100) not null; | |
IF type_id('id') IS NOT NULL DROP TYPE dbo.id; | |
/** @brief Determines a unique identifier as defined in XML schema. | |
*/ | |
CREATE TYPE dbo.id FROM varchar(300); | |
GO | |
IF type_id('idtable') IS NOT NULL DROP TYPE dbo.idtable; | |
/** @brief a internal type for functions parameter. | |
*/ | |
CREATE TYPE dbo.idtable as table(id varchar(300)); | |
GO | |
IF type_id('ipv4address') IS NOT NULL DROP TYPE dbo.ipv4address; | |
/** @brief Determines a unique identifier as defined in XML schema. | |
*/ | |
CREATE TYPE dbo.ipv4address FROM varchar(20); | |
GO | |
-- ---------------------------------------------------------------------------- | |
-- General | |
-- ---------------------------------------------------------------------------- | |
-- DatabaseInfo -- | |
IF object_id('DatabaseInfo', 'U') IS NOT NULL DROP TABLE dbo.DatabaseInfo; | |
/** @brief Contains general information about the database. | |
@access EtsInternal; DatabaseInfo::DatabaseLanguage also EtsProject | |
@schema6ref ETE_DATABASE | |
*/ | |
CREATE TABLE dbo.DatabaseInfo | |
( | |
DatabaseVersion int not null default #current-databaseversion#, ---< Schema version number, 12.3 is encoded as 0x000C0002 | |
DatabaseID uniqueidentifier not null default newid(), ---< On creation of a new database, a GUID is written here which may be used to identify a specific database. | |
---< When a database is physically copied as a file, both share the same GUID. | |
DatabaseLanguage dbo.[languageid], ---< The current database language. | |
---< All texts in this language have been copied to their base tables. | |
CurrentMasterDataVersion int not null default 0, ---< The current version of KNX master data imported into the database. A value of 0 means no KNX master data available. | |
SchemaVersion varchar(max) default 'http://knx.org/xml/project/11', | |
KnxMasterDataXml xml, | |
CurrentProductExtensionVersion int not null default 0 | |
); | |
GO | |
INSERT INTO dbo.DatabaseInfo (DatabaseLanguage) VALUES('#current-language#'); | |
GO | |
IF object_id('ExportManufacturer') IS NOT NULL | |
DROP TABLE dbo.ExportManufacturer | |
/** @brief Contains manufacturer information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportManufacturer( | |
ID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportManufacturer TO ETSFullAccess | |
GO | |
IF object_id('ExportApplicationProgram') IS NOT NULL | |
DROP TABLE dbo.ExportApplicationProgram | |
/** @brief Contains application program information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportApplicationProgram( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportApplicationProgram TO ETSFullAccess | |
GO | |
IF object_id('ExportHardware') IS NOT NULL | |
DROP TABLE dbo.ExportHardware | |
/** @brief Contains hardware information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportHardware( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportHardware TO ETSFullAccess | |
GO | |
IF object_id('ExportHardware2Program') IS NOT NULL | |
DROP TABLE dbo.ExportHardware2Program | |
/** @brief Contains hardware-to-program information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportHardware2Program( | |
ID varchar(300), | |
HardwareID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportHardware2Program TO ETSFullAccess | |
GO | |
IF object_id('ExportProduct') IS NOT NULL | |
DROP TABLE dbo.ExportProduct | |
/** @brief Contains product information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportProduct( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportProduct TO ETSFullAccess | |
GO | |
IF object_id('ExportCatalogItem') IS NOT NULL | |
DROP TABLE dbo.ExportCatalogItem | |
/** @brief Contains catalog item information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportCatalogItem | |
( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportCatalogItem TO ETSFullAccess | |
GO | |
IF object_id('ExportCatalogSection') IS NOT NULL | |
DROP TABLE dbo.ExportCatalogSection | |
/** @brief Contains catalog section information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportCatalogSection( | |
ID varchar(300), | |
ParentID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportCatalogSection TO ETSFullAccess | |
GO | |
IF object_id('ExportBaggage') IS NOT NULL | |
DROP TABLE dbo.ExportBaggage | |
/** @brief Contains baggage information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportBaggage( | |
ID varchar(300), | |
ManufacturerID varchar(300), | |
SessionID uniqueidentifier, | |
Name varchar(255), | |
TargetPath varchar(255), | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportBaggage TO ETSFullAccess | |
GO | |
IF object_id('ExportDeviceBinaryData') IS NOT NULL | |
DROP TABLE dbo.ExportDeviceBinaryData | |
/** @brief Contains device binary data information collected by export procedure. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE dbo.ExportDeviceBinaryData( | |
ID varchar(300), | |
ProjectID varchar(300), | |
SessionID uniqueidentifier, | |
primary key(ID, SessionID) | |
) | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.ExportDeviceBinaryData TO ETSFullAccess | |
GO | |
IF object_id('IdMapping') IS NOT NULL | |
DROP TABLE dbo.IdMapping | |
/** @brief Contains mapping information for simulating ETS3 integer ID's used by som ETS3-Plug-Ins. | |
@access EtsInternal; | |
Internal access only | |
*/ | |
CREATE TABLE [dbo].[IdMapping]( | |
[Path] [varchar](900) NOT NULL, ---< The path to the object | |
[NumberID] [bigint] IDENTITY(1,1) NOT NULL, ---< The simulated ETS3 integer ID. | |
CONSTRAINT [PK_IdMapping] PRIMARY KEY CLUSTERED | |
( | |
[Path] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | |
) ON [PRIMARY] | |
GRANT INSERT, UPDATE, SELECT, DELETE ON dbo.IdMapping TO ETSFullAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InitManufacturerData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - %Manufacturer Data | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- ---------------------------------------------------------------------------- | |
-- Manufacturer data | |
-- ---------------------------------------------------------------------------- | |
-- Hardware -- | |
IF object_id('Hardware', 'U') IS NOT NULL DROP TABLE Hardware; | |
/** @brief Represents the hardware of a product. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Hardware/Hardware. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref HW_PRODUCT | |
*/ | |
CREATE TABLE dbo.Hardware | |
( | |
ID varchar(300) primary key, ---< Artificial primary key. | |
ManufacturerID varchar(300) not null foreign key references Manufacturer(ID) on delete cascade, ---< The manufacturer; foreign key to $fkspec. | |
SerialNumber varchar(50) not null, ---< Serial number. | |
---< @xmlref Corresponds to XML attribute SerialNumber. | |
VersionNumber smallint not null check( VersionNumber >= 0 and VersionNumber <= 32767 ), ---< Version number. | |
---< @xmlref Corresponds to XML attribute VersionNumber. | |
OriginalManufacturerID varchar(300) foreign key references Manufacturer(ID), ---< For OEM products, the original manufacturer; foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute OriginalManufacturer. | |
[Name] nvarchar(255), ---< %Product name. | |
---< @xmlref Corresponds to XML attribute Name. | |
IsAccessory bit not null default 0, ---< 1 if this is an accessory product. | |
---< @xmlref Corresponds to XML attribute IsAccessory. | |
HasIndividualAddress bit not null default 0, ---< 1 if the product has an individual address. | |
---< @xmlref Corresponds to XML attribute HasIndividualAddress. | |
HasApplicationProgram bit not null default 0, ---< 1 if the product has an application program. | |
---< @xmlref Corresponds to XML attribute HasApplicationProgram. | |
HasApplicationProgram2 bit not null default 0, ---< 1 if the product has a PEI program / application program 2. | |
---< @xmlref Corresponds to XML attribute HasApplicationProgram2. | |
IsPowerSupply bit not null default 0, ---< 1 if this is a power supply. | |
---< @xmlref Corresponds to XML attribute IsPowerSupply. | |
IsChoke bit not null default 0, ---< 1 if this is a choke. | |
---< @xmlref Corresponds to XML attribute IsChoke. | |
IsCoupler bit not null default 0, ---< 1 if this is a coupler. | |
---< @xmlref Corresponds to XML attribute IsCoupler. | |
IsPowerLineRepeater bit not null default 0, ---< 1 if this is a PL repeater. | |
---< @xmlref Corresponds to XML attribute IsPowerLineRepeater. | |
IsPowerLineSignalFilter bit not null default 0, ---< 1 if this is a PL signal filter. | |
---< @xmlref Corresponds to XML attribute IsPowerLineSignalFilter. | |
IsCable bit not null default 0, ---< 1 if this is a cable. | |
---< @xmlref Corresponds to XML attribute IsCable. | |
BusCurrent real, ---< The bus current in mA. | |
---< For normal devices, this is the consumption; for power supplies the maximum source current. | |
---< @xmlref Corresponds to XML attribute BusCurrent. | |
NonRegRelevantDataVersion int not null default 0, ---< Version of the non registration-relevant data. | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
NoDownloadWithoutPlugin bit default 0, | |
---< if set to true the hardware can only be downloaded if a download Plug-In exists. | |
---< @xmlref Corresponds to XML attribute NoDownloadWithoutPlugIn. | |
IsIPEnabled bit default 0, | |
---< if set to true the hardware supports IP. | |
---< @xmlref Corresponds to XML attribute IsIPEnabled. | |
); | |
GRANT DELETE ON dbo.Hardware TO ETSFullAccess; | |
DENY DELETE ON dbo.Hardware TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.Hardware TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.Hardware TO ETSFullAccess; | |
DENY INSERT ON dbo.Hardware TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.Hardware TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.Hardware TO ETSFullAccess; | |
DENY UPDATE ON dbo.Hardware TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.Hardware TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Hardware TO ETSFullAccess; | |
GRANT SELECT ON dbo.Hardware TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.Hardware TO ETSWriteProjectAccess; | |
GO | |
-- Product | |
IF object_id('Product', 'U') IS NOT NULL DROP TABLE [Product]; | |
/** @brief Represents a commercial product with an order number. | |
@access EtsInternal The Registration columns are writable only by KNX. | |
@xmlref ManufacturerData/Manufacturer/Hardware/Hardware/Products/Product. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref CATALOG_ENTRY | |
*/ | |
CREATE TABLE dbo.[Product] | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
HardwareID varchar(300) not null foreign key references Hardware(ID) on delete cascade, ---< The corresponding hardware product; foreign key to $fkspec. | |
ManufacturerID varchar(300) not null foreign key references Manufacturer(ID), ---< Foreign key to $fkspec. | |
---< Must be the same as Hardware[Product::HardwareID].ManufacturerID | |
OrderNumber varchar(50) not null, ---< Order number. | |
---< Must be unique within the manufacturer. | |
---< @xmlref Corresponds to XML attribute OrderNumber | |
[Text] nvarchar(255), ---< Name in the current database language. | |
---< Translations are in ProductTranslatedText | |
---< @xmlref Corresponds to XML attribute Text. | |
VisibleDescription nvarchar(max), ---< Default description of the product. | |
---< Translations are in ProductTranslatedText | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
IsRailMounted bit, ---< 1 for rail mounted devices | |
---< @xmlref Corresponds to XML attribute IsRailMounted. | |
WidthInMillimeter real, ---< For rail-mounted devices, the width in mm | |
---< @xmlref Corresponds to XML attribute WidthInMillimeter. | |
DefaultLanguage languageid, ---< Default language for the product, if differing from Manufacturer::DefaultLanguage. | |
---< @xmlref Corresponds to XML attribute DefaultLanguage. | |
NonRegRelevantDataVersion int not null default 0, ---< Version of the non registration-relevant data | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
RegistrationStatus registrationstatus not null check(RegistrationStatus IN('Unregistered', 'Registered', 'Certified' , 'FutureUseNotRecommended' , 'FutureUseNotAllowed' )), ---< Registration status. | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationStatus. | |
RegistrationNumber nvarchar(max), ---< The registration number | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationNumber. | |
RegistrationDate smalldatetime, ---< The registration date | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationDate. | |
RegistrationSignature varchar(max), ---< The registration signature | |
---< @xmlref Corresponds to XML element RegistrationSignature. | |
RegistrationKey varchar(max), ---< The registration signature | |
---< @xmlref Corresponds to XML element RegistrationKey. | |
OriginalRegistrationNumber nvarchar(max), ---< The original registration number | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/OriginalRegistrationNumber. | |
Hash varchar(max), | |
---< @xmlref KNX registration relevant data hash over the parent Hardware/@Id, Product/@Id and @OrderNumber. | |
); | |
GRANT DELETE ON dbo.[Product] TO ETSFullAccess; | |
DENY DELETE ON dbo.[Product] TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.[Product] TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.[Product] TO ETSFullAccess; | |
DENY INSERT ON dbo.[Product] TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.[Product] TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.[Product] TO ETSFullAccess; | |
DENY UPDATE ON dbo.[Product] TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.[Product] TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.[Product] TO ETSFullAccess; | |
GRANT SELECT ON dbo.[Product] TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.[Product] TO ETSWriteProjectAccess; | |
GO | |
-- ProductTranslatedText | |
IF object_id('ProductTranslatedText', 'U') IS NOT NULL DROP TABLE ProductTranslatedText; | |
/** @brief Contains translated texts for the Product table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ProductTranslatedText | |
( | |
ProductID varchar(300) not null foreign key references [Product](ID) on delete cascade, ---< Foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedName nvarchar(255), ---< Translated Name | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Name']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Description']/\@Text. | |
primary key (ProductID, [Language]), | |
); | |
GRANT DELETE ON dbo.ProductTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ProductTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ProductTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ProductTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ProductTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ProductTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ProductTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ProductTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ProductTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProductTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ProductTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ProductTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ProductAttribute | |
IF object_id('ProductAttribute', 'U') IS NOT NULL DROP TABLE ProductAttribute; | |
/** @brief Contains additional (non registration relevant) attributes about a catalog entry. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Hardware/Hardware/Products/Product/Attributes/Attribute. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
*/ | |
CREATE TABLE dbo.ProductAttribute | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProductID varchar(300) not null foreign key references [Product](ID) on delete cascade, ---< The product; foreign key to $fkspec. | |
[Name] varchar(20) not null check(Name in ('Series', 'Colour', 'CatalogName')), ---< Name of the additional attribute. | |
---< One of: | |
---< - "Series" | |
---< - "Colour" | |
---< - "CatalogName" (corresponds to XML attribute CatalogName of the Product element). | |
---< @xmlref Corresponds to XML attribute Name. | |
[Value] nvarchar(255) not null ---< Value of the additional attribute in the current database language. | |
---< Translations are in ProductAttributeTranslatedText. | |
---< @xmlref Corresponds to XML attribute Value. | |
); | |
CREATE UNIQUE INDEX IxProductAttribute ON dbo.ProductAttribute(ProductID,[Name]); | |
GRANT DELETE ON dbo.ProductAttribute TO ETSFullAccess; | |
DENY DELETE ON dbo.ProductAttribute TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ProductAttribute TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ProductAttribute TO ETSFullAccess; | |
DENY INSERT ON dbo.ProductAttribute TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ProductAttribute TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ProductAttribute TO ETSFullAccess; | |
DENY UPDATE ON dbo.ProductAttribute TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ProductAttribute TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProductAttribute TO ETSFullAccess; | |
GRANT SELECT ON dbo.ProductAttribute TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ProductAttribute TO ETSWriteProjectAccess; | |
GO | |
-- ProductAttributeTranslatedText | |
IF object_id('ProductAttributeTranslatedText', 'U') IS NOT NULL DROP TABLE ProductAttributeTranslatedText; | |
/** @brief Contains translated texts for the ProductAttribute table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
@uniquekey UK(ProductAttribute[ProductAttributeTranslatedText::ProductAttributeID]) + ProductAttributeTranslatedText::Language + ProductAttributeTranslatedText::Version | |
*/ | |
CREATE TABLE dbo.ProductAttributeTranslatedText | |
( | |
ProductAttributeID varchar(300) not null foreign key references ProductAttribute(ID) on delete cascade, ---< Foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedValue nvarchar(255), ---< Translated Value | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Value']/\@Text. | |
primary key (ProductAttributeID, [Language]), | |
); | |
GRANT DELETE ON dbo.ProductAttributeTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ProductAttributeTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ProductAttributeTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ProductAttributeTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ProductAttributeTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ProductAttributeTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ProductAttributeTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ProductAttributeTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ProductAttributeTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProductAttributeTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ProductAttributeTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ProductAttributeTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationProgram | |
IF object_id('ApplicationProgram', 'U') IS NOT NULL DROP TABLE ApplicationProgram; | |
/** @brief Contains information about an application program. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref APPLICATION_PROGRAM | |
*/ | |
create table dbo.ApplicationProgram | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ManufacturerID varchar(300) not null foreign key references Manufacturer(ID) on delete cascade, ---< The manufacturer; foreign key to $fkspec. | |
[Name] nvarchar(255), ---< Name in the current database language. | |
---< Translations are in ApplicationProgramTranslatedText. | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), ---< Program description in the current database language. | |
---< Translations are in ApplicationProgramTranslatedText. | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
ApplicationNumber int not null check(ApplicationNumber between 0 and 65535), ---< %Device type (2 octets of the unique application ID). | |
---< @xmlref Corresponds to XML attribute ApplicationNumber. | |
ApplicationVersion smallint not null check(ApplicationVersion between 0 and 255), ---< Version (1 octet of the unique application ID). | |
---< @xmlref Corresponds to XML attribute ApplicationVersion. | |
OriginalManufacturerID varchar(300) foreign key references Manufacturer(ID), ---< For OEM products, the ID of the original manufacturer; foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute OriginalManufacturer. | |
ProgramType varchar(50) not null default 'ApplicationProgram' check(ProgramType in ('ApplicationProgram', 'PeiProgram')), ---< Can be 'ApplicationProgram' or 'PeiProgram'. | |
---< @xmlref Corresponds to XML attribute ProgramType. | |
MaskID varchar(300), --foreign key references MaskVersion(ID), ---< Assigned mask version; foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute MaskVersion. | |
MinEtsVersion varchar(10), ---< @brief Minimum ETS version. | |
---< If not NULL, contains the minimum ETS version where this application program can be used; this can be '3.0', '3.0d', '3.0f' or '4.0' | |
---< @xmlref Corresponds to XML attribute MinETSVersion. | |
HelpFile nvarchar(255), ---< Help file name for the current database language. | |
---< Translations are in ApplicationProgramTranslatedText. | |
---< @xmlref Corresponds to XML attribute HelpFile. | |
HelpTopic bigint, ---< Help topic ID. | |
---< @xmlref Corresponds to XML attribute HelpTopic. | |
PEIType smallint, ---< PEI type. | |
---< @xmlref Corresponds to XML attribute PeiType. | |
Linkable bit not null default 0, ---< Linkable flag. | |
---< If 1, the application program can be loaded also in all mask versions compatible to the one specified in MaskID. | |
---< The fixups as specified in AddressFixup have to be applied. | |
---< @xmlref Corresponds to XML attribute Linkable. | |
LoadProcedureStyle varchar(20) not null default 'DefaultProcedure' check(LoadProcedureStyle in ('DefaultProcedure', 'ProductProcedure', 'MergedProcedure')), ---< Load procedure style | |
---< One of: | |
---< - 'DefaultProcedure': uses the default load procedure | |
---< - 'ProductProcedure': uses a product-specific load procedure (complete procedure given as load controls) | |
---< - 'MergedProcedure': uses a default procedure with product-specific parts (merged procedure) | |
---< @xmlref Corresponds to XML attribute LoadProcedureStyle. | |
DynamicTableManagement bit not null default 0, ---< Dynamic group communication tables | |
---< @xmlref Corresponds to XML attribute DynamicTableManagement. | |
AddressTableMaxEntries int not null default 0, ---< The maximum number of group addresses in the address table size. | |
---< If DynamicTableManagement = 1, only the sum of AddressTableMaxEntries and AssociationTableMaxEntries is relevant. | |
---< @xmlref Corresponds to XML attribute Static/AddressTable/MaxEntries. | |
AssociationTableMaxEntries int not null default 0, ---< The maximum number of association table entries. | |
---< @xmlref Corresponds to XML attribute Static/AssociationTable/MaxEntries. | |
PreEts4Style bit not null default 0, ---< 1 if this has been converted from ETS 2 / ETS 3 product data. | |
---< @xmlref Corresponds to XML attribute PreEts4Style. | |
DefaultLanguage languageid, ---< Default language for the application program if differing from Manufacturer::DefaultLanguage. | |
---< @xmlref Corresponds to XML attribute DefaultLanguage. | |
NonRegRelevantDataVersion int not null default 0, ---< Version of the non registration-relevant data | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
AddressTableSegmentID varchar(300), ---< Segment for address table; foreign key to ApplicationSegment. | |
---< @xmlref Corresponds to XML attribute AddressTable/CodeSegment. | |
AddressTableOffset int, ---< Offset of address table within segment. | |
---< @xmlref Corresponds to XML attribute AddressTable/Offset. | |
AssociationTableSegmentID varchar(300), ---< Segment for association table; foreign key to ApplicationSegment. | |
---< @xmlref Corresponds to XML attribute AssociationTable/CodeSegment. | |
AssociationTableOffset int, ---< Offset of association table within segment. | |
---< @xmlref Corresponds to XML attribute AssociationTable/Offset. | |
ComObjectTableSegmentID varchar(300), ---< Segment for communication object table; foreign key to ApplicationSegment. | |
---< @xmlref Corresponds to XML attribute ComObjectTable/CodeSegment. | |
ComObjectTableOffset int, ---< Offset of communication object table within segment. | |
---< @xmlref Corresponds to XML attribute ComObjectTable/Offset. | |
Hash varchar(max), ---< The registration signature | |
---< @xmlref Corresponds to XML element RegistrationSignature. | |
LoadProcedures xml, | |
--< @xmlref Contains the complete dynamic part of the application program. The structure the schema as defined for the dynamic part. | |
EtsDownloadPlugin varchar(max), ---< The full .NET type name of the class implementing the download Plug-In compatible with ETS 4.0 and higher. | |
---< @xmlref Corresponds to XML attribute Static/Extension/EtsDownloadPlugin. | |
EtsUiPlugin varchar(max), ---< The full .NET type name of the class implementing the UI Plug-In compatible with ETS 4.0 and higher. | |
---< @xmlref Corresponds to XML attribute Static/Extension/EtsUiPlugin. | |
EtsDataHandler varchar(max), ---< The full .NET type name of the class implementing the data handler Plug-In compatible with ETS 4.0 and higher. | |
---< @xmlref Corresponds to XML attribute Static/Extension/EtsDataHandler. | |
ReplacesVersions varchar(max), ---< The list of application program versions replaced by this version. | |
---< @xmlref Corresponds to XML attribute ReplacesVersions. | |
ConvertedFromPreEts4Data bit default 0, ---< If true, this is a converted ETS2 or ETS3 application program. This has an effect on the manufacturer tool and the converter (no conversion back to vd3/4/5 allowed). This flag may be different from PreEts4Style only within the manufacturer tool. | |
---< @xmlref Corresponds to XML attribute ConvertedFromPreEts4Data | |
RequiresExternalSoftware bit default 0, ---< If true, the Plug-In requires some external software to be installed. | |
---< @xmlref Corresponds to XML attribute Static/Extension/@RequiresExternalSoftware | |
Broken bit default 0, ---< If true, the application program is a well-known broken shape. | |
---< @xmlref Corresponds to XML attribute @Broken | |
EtsDataHandlerCapabilities varchar(200) default null, ---< The capabilities of a data handler Plug-In (semi-colon seperated list of enumeration values) | |
---< @xmlref Corresponds to XML attribute Static/Extension/@EtsDataHandlerCapabilities | |
IPConfig varchar(20) not null default 'Tool' check (IPConfig in ('Tool', 'Custom')), ---< IP config is set by tool or customer | |
---< @xmlref Corresponds to XML attribute IPConfig | |
AdditionalAddressesCount int default 0, | |
---< @xmlref Corresponds to XML attribute AdditionalAddressesCount | |
DownloadInfoIncomplete bit default 0, | |
---< @xmlref Corresponds to XML attribute DownloadInfoIncomplete | |
CreatedFromLegacySchemaVersion bit default 0, | |
); | |
CREATE NONCLUSTERED INDEX IxApplicationProgram ON dbo.ApplicationProgram( | |
ManufacturerID, ApplicationNumber, ApplicationVersion, OriginalManufacturerID); | |
GRANT DELETE ON dbo.ApplicationProgram TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgram TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgram TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgram TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgram TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgram TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgram TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgram TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgram TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgram TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgram TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgram TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationProgramTranslatedText | |
IF object_id('ApplicationProgramTranslatedText', 'U') IS NOT NULL DROP TABLE ApplicationProgramTranslatedText; | |
/** @brief Contains translated texts for the ApplicationProgram table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ApplicationProgramTranslatedText | |
( | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< Foreign key to the ApplicationProgram table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedName nvarchar(255), ---< Translated Name | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Name']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Description']/\@Text. | |
TranslatedHelpFile nvarchar(255), ---< Translated HelpFile | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='HelpFile']/\@Text. | |
primary key (ApplicationProgramID, [Language]) , | |
); | |
GRANT DELETE ON dbo.ApplicationProgramTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgramTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationProgramDynamic | |
IF object_id('ApplicationProgramDynamic', 'U') IS NOT NULL DROP TABLE ApplicationProgramDynamic; | |
/** @brief Contains the complete XML fragment of the dynamic part of the ApplicationProgram. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Dynamic | |
*/ | |
CREATE TABLE dbo.ApplicationProgramDynamic | |
( | |
ApplicationProgramID varchar(300) not null primary key foreign key references ApplicationProgram(ID) on delete cascade, ---< Foreign key to the ApplicationProgram table | |
---< @xmlref Corresponds to XML attribute ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/\@Id. | |
ApplicationProgramDynamic xml, | |
--< @xmlref Contains the complete dynamic part of the application program. | |
); | |
GRANT DELETE ON dbo.ApplicationProgramDynamic TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramDynamic TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramDynamic TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramDynamic TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramDynamic TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramDynamic TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramDynamic TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramDynamic TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgramDynamic TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamic TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamic TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamic TO ETSWriteProjectAccess; | |
GO | |
-- DeviceCompare | |
IF object_id('DeviceCompare', 'U') IS NOT NULL DROP TABLE DeviceCompare; | |
/** @brief Contains the complete XML fragment of the DeviceCompare part of the ApplicationProgram. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/DeviceCompare | |
*/ | |
CREATE TABLE dbo.DeviceCompare | |
( | |
ApplicationProgramID varchar(300) not null primary key foreign key references ApplicationProgram(ID) on delete cascade, ---< Foreign key to the ApplicationProgram table | |
---< @xmlref Corresponds to XML attribute ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/\@Id. | |
Excludes xml, | |
--< @xmlref Contains the complete DeviceCompare part of the application program. | |
); | |
GRANT DELETE ON dbo.DeviceCompare TO ETSFullAccess; | |
DENY DELETE ON dbo.DeviceCompare TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.DeviceCompare TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.DeviceCompare TO ETSFullAccess; | |
DENY INSERT ON dbo.DeviceCompare TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.DeviceCompare TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.DeviceCompare TO ETSFullAccess; | |
DENY UPDATE ON dbo.DeviceCompare TO ETSReadOnlyAccess; | |
GRANT UPDATE ON dbo.DeviceCompare TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DeviceCompare TO ETSFullAccess; | |
GRANT SELECT ON dbo.DeviceCompare TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.DeviceCompare TO ETSWriteProjectAccess; | |
GO | |
-- ProductAttributeTranslatedText | |
IF object_id('ApplicationProgramDynamicTranslatedText', 'U') IS NOT NULL DROP TABLE ApplicationProgramDynamicTranslatedText; | |
/** @brief Contains translated texts for the ApplicationProgramDynamic table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ApplicationProgramDynamicTranslatedText | |
( | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< Foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/TranslationUnit/\@RefId. | |
ElementID varchar(300) not null, | |
---< @xmlref Corresponds to XML attribute LanguageData_t/TranslationUnit/TranslationElement\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(max), ---< Translated Value | |
---< @xmlref Corresponds to XML attribute LanguageData_t/TranslationUnit/TranslationElement/Translation/@Text. | |
primary key NONCLUSTERED (ApplicationProgramID, ElementID, [Language]), | |
); | |
CREATE CLUSTERED INDEX IxAppPrgDynTransTextElement on dbo.ApplicationProgramDynamicTranslatedText(ElementID); | |
GRANT DELETE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgramDynamicTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramDynamicTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationProgramOption | |
IF object_id('ApplicationProgramOption', 'U') IS NOT NULL DROP TABLE dbo.ApplicationProgramOption; | |
/** @brief Contains the options of ApplicationProgram. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Options | |
*/ | |
CREATE TABLE dbo.ApplicationProgramOption | |
( | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< Foreign key to the ApplicationProgram table | |
---< @xmlref Corresponds to XML ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/\@Id. | |
PreferPartialDownload bit not null default 0, ---< Use partial/differential download if possible even if the user requested full download. | |
---< @xmlref Corresponds to XML attribute PreferPartialDownloadIfApplicationLoaded. | |
EasyControlModeStyle bit not null default 0, ---< Generate communication tables for Easy Ctlr mode (zero-length association table, all CommEnable flags set) if no visible comm objects. | |
---< @xmlref Corresponds to XML attribute EasyCtrlModeModeStyleEmptyGroupComTables. | |
ObjectTableLengthAlwaysOne bit not null default 0, ---< Set object table length to 1. | |
---< @xmlref Corresponds to XML attribute SetObjectTableLengthAlwaysToOne. | |
TextParameterEncoding varchar(100) not null default 'iso-8859-1' | |
check(TextParameterEncoding in ('us-ascii' | |
, 'iso-8859-1' | |
, 'iso-8859-2' | |
, 'iso-8859-3' | |
, 'iso-8859-4' | |
, 'iso-8859-5' | |
, 'iso-8859-6' | |
, 'iso-8859-7' | |
, 'iso-8859-8' | |
, 'iso-8859-9' | |
, 'iso-8859-10' | |
, 'iso-8859-13' | |
, 'iso-8859-15' | |
, 'utf-8')), ---< official encoding name. | |
---< @xmlref Corresponds to XML attribute TextParameterEncoding. | |
TextParameterZeroTerminate bit not null default 0, ---< Determines a terminating 0 is written for all text parameters. | |
---< @xmlref Corresponds to XML attribute TextParameterZeroTerminate. | |
ParameterByteOrder varchar(59) not null default 'BigEndian' check(ParameterByteOrder in('BigEndian', 'LittleEndian')), ---< Byte order for all integer and floating point parameter types. | |
---< @xmlref Corresponds to XML attribute ParameterByteOrder. | |
LegacyNoPartialDownload bit not null default 0, ---< Disables Partial Download for this application program; a full download is performed instead. | |
---< @xmlref Corresponds to XML attribute LegacyNoPartialDownload . | |
LegacyNoMemoryWriteVerify bit not null default 0, ---< Disables use of Memory Verify mode. | |
---< @xmlref Corresponds to XML attribute LegacyNoMemoryVerifyMode . | |
LegacyNoOptimisticWrite bit not null default 0, ---< Default to no optimistic download. | |
---< @xmlref Corresponds to XML attribute LegacyNoOptimisticWrite. | |
LegacyNoPropertyWriteErrors bit not null default 0, ---< Don't report errors if PropWrite fails. | |
---< @xmlref Corresponds to XML attribute LegacyDoNotReportPropertyWriteErrors. | |
LegacyNoBackgroundDownload bit not null default 0, ---< Don't allow download in the background. | |
---< @xmlref Corresponds to XML attribute LegacyNoBackgroundDownload. | |
LegacyDoNotCheckManufacturer bit not null default 0, ---< Don't check manufacturer ID if there is a Plug-In. | |
---< @xmlref Corresponds to XML attribute LegacyDoNotCheckManufacturerId. | |
LegacyAlwaysReloadOnCoVisibilityChange bit not null default 0, ---< If the visibility of a group object changed, always reset the ApplicationProgramLoaded programming flag. | |
---< @xmlref Corresponds to XML attribute LegacyAlwaysReloadAppIfCoVisibilityChanged. | |
LegacyNeverReloadOnCoVisibilityChange bit not null default 0, ---< If the visibility of a group object changed, do not reset the ApplicationProgramLoaded programming flag. | |
---< @xmlref Corresponds to XML attribute LegacyNeverReloadAppIfCoVisibilityChanged. | |
LegacyNoSupportOfUndoDelete bit not null default 0, ---< Undo of a delete operation is not supported. | |
---< @xmlref Corresponds to XML attribute LegacyDoNotSupportUndoDelete. | |
LegacyAllowPartialDownloadOnAp2Mismatch bit not null default 0, ---< Allow partial download even if AP2/PeiProg load state or AppID do not match. | |
---< @xmlref Corresponds to XML attribute LegacyAllowPartialDownloadIfAp2Mismatch . | |
LegacyKeepObjectTableGaps bit not null default 0, ---< Do not fill up gaps in object table image. | |
---< @xmlref Corresponds to XML attribute LegacyKeepObjectTableGaps. | |
PartialDownloadOnlyVisibleParameters bit, ---< if true on partial download only visible parameters will be downloaded. | |
---< @xmlref Corresponds to XML attribute PartialDownloadOnlyVisibleParameters. | |
LegacyProxyCommunicationObjects bit default 0, ---< The LegacyProxyCommunicationObjects | |
---< @xmlref Corresponds to XML attribute Static/Options/@LegacyProxyCommunicationObjects | |
DeviceInfoIgnoreRunState bit default 0, ---< The device compare ignores the run state | |
---< @xmlref Corresponds to XML attribute Static/Options/@DeviceInfoIgnoreRunState | |
DeviceInfoIgnoreLoadedState bit default 0, ---< The device compare ignores the load state | |
---< @xmlref Corresponds to XML attribute Static/Options/@DeviceInfoIgnoreLoadedState | |
DeviceCompareAllowCompatibleManufacturerId bit default 0, ---< The device compare includes devices of the compatible manufacturers | |
---< @xmlref Corresponds to XML attribute Static/Options/@DeviceCompareAllowCompatibleManufacturerId | |
LineCoupler0912NewProgrammingStyle bit default 0, ---< Used to differentiate between application programs for the old and the new style | |
---< @xmlref Corresponds to XML attribute Static/Options/@LineCoupler0912NewProgrammingStyle | |
TextParameterEncodingSelector varchar(50) check(TextParameterEncodingSelector is null or TextParameterEncodingSelector in('UseWindowsAnsiCodePage', 'UseProjectCodePage', 'UseTextParameterEncodingCodePage')), | |
---< @xmlref Corresponds to XML attribute TextParameterEncodingSelector | |
Comparable bit, ---< The device with this application program can be compared with device compare | |
---< @xmlref Corresponds to XML attribute Static/Options/@Comparable | |
Reconstructable bit ---< The state of a device with this application program can be reconstructed | |
---< @xmlref Corresponds to XML attribute Static/Options/@Reconstructable | |
primary key (ApplicationProgramID), | |
); | |
GRANT DELETE ON dbo.ApplicationProgramOption TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramOption TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramOption TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramOption TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramOption TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramOption TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramOption TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramOption TO ETSReadOnlyAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramOption TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramOption TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramOption TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramOption TO ETSWriteProjectAccess; | |
GO | |
-- Hardware2Program | |
IF object_id('Hardware2Program', 'U') IS NOT NULL DROP TABLE Hardware2Program; | |
/** @brief Represents an allowed hardware/software combination. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Hardware/Hardware/Hardware2Programs/Hardware2Program. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref PRODUCT_TO_PROGRAM | |
@additionalrestrictions | |
- Each combination of HardwareID, ApplicationProgramID and ApplicationProgram2ID may occur at most once. | |
(ensured by a unique index) | |
- All referenced entities must belong to the same manufacturer: | |
Hardware[Hardware2Program::HardwareID].ManufacturerID = | |
ApplicationProgram[Hardware2Program::ApplicationProgramID].ManufacturerID = | |
ApplicationProgram[Hardware2Program::ApplicationProgram2ID].ManufacturerID | |
*/ | |
CREATE TABLE dbo.Hardware2Program | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
HardwareID varchar(300) not null foreign key references Hardware(ID) on delete cascade, ---< The hardware; reference to $fkspec. | |
ApplicationProgramID varchar(300) foreign key references ApplicationProgram(ID), ---< Foreign key to $fkspec; NULL for products without application program. | |
---< @xmlref Corresponds to XML attribute ApplicationProgramRef[0]/RefId. | |
ApplicationProgram2ID varchar(300) foreign key references ApplicationProgram(ID), ---< Foreign key to $fkspec; NULL for products without PEI program / application program 2. | |
---< @xmlref Corresponds to XML attribute ApplicationProgramRef[1]/RefId. | |
RegistrationStatus registrationstatus not null check(RegistrationStatus IN('Unregistered', 'Registered', 'Certified' , 'FutureUseNotRecommended' , 'FutureUseNotAllowed' )), ---< Registration status. | |
---< This must be one of: 'Unregistered', 'Registered', 'Certified' , 'FutureUseNotRecommended' , 'FutureUseNotAllowed' | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationStatus. | |
RegistrationNumber nvarchar(max), ---< The registration number | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationNumber. | |
OriginalRegistrationNumber nvarchar(max), ---< The original registration number | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/OriginalRegistrationNumber. | |
RegistrationDate smalldatetime, ---< The registration date | |
---< @xmlref Corresponds to XML attribute RegistrationInfo/RegistrationMediumType. | |
RegistrationSignature varchar(max), ---< The registration signature | |
---< @xmlref Corresponds to XML element Signature. | |
RegistrationKey varchar(max), ---< The registration key | |
---< @xmlref Corresponds to XML element key | |
MediumTypes varchar(max),---< @xmlref Reference to one or more MediumTypes. | |
Hash varchar(max),---< @xmlrefThis element contains the KNX registration relevant data hash for Hardware and ApplicationProgram. | |
CheckSums varbinary(max),---< @xmlrefThe manufacturer can distribute the standard image with the attributes CheckSums. | |
LoadedImage varbinary(max),---< @xmlrefThe manufacturer can distribute the standard image with the attributes LoadedImage | |
); | |
CREATE UNIQUE INDEX IxHardware2Program on dbo.Hardware2Program(HardwareID, ApplicationProgramID, ApplicationProgram2ID); | |
GRANT DELETE ON dbo.Hardware2Program TO ETSFullAccess; | |
DENY DELETE ON dbo.Hardware2Program TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.Hardware2Program TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.Hardware2Program TO ETSFullAccess; | |
DENY INSERT ON dbo.Hardware2Program TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.Hardware2Program TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.Hardware2Program TO ETSFullAccess; | |
DENY UPDATE ON dbo.Hardware2Program TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.Hardware2Program TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Hardware2Program TO ETSFullAccess; | |
GRANT SELECT ON dbo.Hardware2Program TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.Hardware2Program TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationSegment | |
IF object_id('ApplicationSegment', 'U') IS NOT NULL DROP TABLE ApplicationSegment; | |
/** @brief Defines segment data within an application program. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Code/AbsoluteSegment | |
and .../RelativeSegment. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
The MemoryType attribute is not represented because it is for manufacturer use only. | |
@schema6ref S19_BLOCK | |
*/ | |
CREATE TABLE dbo.ApplicationSegment | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, | |
[Name] varchar(50), ---< Name of the segment. | |
---< @xmlref Corresponds to XML attribute Name. | |
AddressSpace smallint not null default 2 check(AddressSpace in(2,3,12)), ---< Address Space. | |
---< One of: | |
---< - 2 Standard memory | |
---< - 3 User memory | |
---< - 12 System B style relative memory | |
---< @xmlref Corresponds to XML child element (AbsoluteSegment or RelativeSegment) and AbsoluteSegment/\@UserMemory. | |
InterfaceObjectRef smallint, ---< If AddressSpace = 12: the interface object index | |
---< @xmlref Corresponds to XML attribute RelativeSegment/LoadStateMachine | |
Address int, ---< Address or Offset | |
---< The meaning depends on the AddressSpace: | |
---< - 2, 3: memory address of the parameter. | |
---< - 12: offset from start of relative memory range. | |
---< @xmlref Corresponds to XML attribute AbsoluteSegment/Address or RelativeSegment/Offset. | |
[Size] int, ---< Segment size in octets | |
LoadStateMachine int check(LoadStateMachine between 0 and 65535), ---< The LSM index providing the allocation service and containing the base pointer. | |
---< @xmlref Corresponds to XML LoadStateMachine. | |
MemoryType varchar(100) check (MemoryType in ('RAM','EEPROM','FLASH')), ---< The memory type if segment is standard oder user memory. | |
---< @xmlref Corresponds to XML attribute MemoryType. | |
Data varbinary(max), ---< The associated data array | |
---< @xmlref Corresponds to XML element Data. | |
Mask varbinary(max) ---< The associated mask array | |
---< @xmlref Corresponds to XML element Mask. | |
); | |
GO | |
-- Now we can complete the definition of ApplicationProgram with the missing foreign key constraints | |
ALTER TABLE dbo.ApplicationProgram | |
ADD CONSTRAINT FK_AddressTableSegmentID foreign key(AddressTableSegmentID) references dbo.ApplicationSegment(ID); | |
ALTER TABLE dbo.ApplicationProgram | |
ADD CONSTRAINT FK_AssociationTableSegmentID foreign key(AssociationTableSegmentID) references dbo.ApplicationSegment(ID); | |
ALTER TABLE dbo.ApplicationProgram | |
ADD CONSTRAINT FK_ComObjectTableSegmentID foreign key(ComObjectTableSegmentID) references dbo.ApplicationSegment(ID) | |
GO | |
GRANT DELETE ON dbo.ApplicationSegment TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationSegment TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationSegment TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationSegment TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationSegment TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationSegment TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationSegment TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationSegment TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationSegment TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationSegment TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationSegment TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationSegment TO ETSWriteProjectAccess; | |
GO | |
-- ParameterType | |
IF object_id('ParameterType', 'U') IS NOT NULL DROP TABLE ParameterType; | |
/** @brief Defines a type for application parameters. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
The InternalDescription attribute is not represented because it is for manufacturer internal use only. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterType | |
( | |
ID varchar(300) primary key nonclustered, ---< Official ID. | |
---< @xmlref Corresponds to XML element Id. | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
[Name] varchar(50) not null, ---< Name of the parameter type. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Plugin] varchar(max) default null, ---< The plugin for editing this parameter type. | |
---< @xmlref Corresponds to XML attribute Plugin. | |
[InternalDescription] varchar(max) default null, ---< The internal description of this this parameter type. | |
---< @xmlref Corresponds to XML attribute InternalDescription. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterType ON dbo.ParameterType( ApplicationProgramID ); | |
--CREATE UNIQUE INDEX IxParameterType ON dbo.ParameterType(ApplicationProgramID,[Name]); | |
GRANT DELETE ON dbo.ParameterType TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterType TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterType TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterType TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterType TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterType TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterType TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterType TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterType TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterType TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterType TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterType TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeTime | |
IF object_id('ParameterTypeTime', 'U') IS NOT NULL DROP TABLE ParameterTypeTime; | |
/** @brief Defines a time parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeTime. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeTime | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
SizeInBit int not null check(SizeInBit >= 8 and SizeInBit <= 64), ---< The size in bits. | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
Unit varchar(40) not null check(Unit in ('Hours', 'Minutes', 'Seconds', 'HundredMilliseconds', 'TenMilliseconds', 'Milliseconds', 'PackedSecondsAndMilliseconds', 'PackedDaysHoursMinutesAndSeconds')), ---< Determines the unit of the time value. | |
---< One of 'Hours', 'Minutes', 'Seconds', 'HundredMilliseconds', 'TenMilliseconds' or 'Milliseconds'. | |
---< @xmlref Corresponds to XML attribute Unit. | |
MinInclusive bigint not null, ---< The minimal included value. | |
---< @xmlref Corresponds to XML attribute minInclusive. | |
MaxInclusive bigint not null, ---< The maximal included value. | |
---< @xmlref Corresponds to XML attribute maxInclusive. | |
UIHint varchar(20) check(UIHint in ('Duration_hhmmssfff', 'Duration_hhmmssff', 'Duration_hhmmssf', 'Duration_hhmmss', 'Duration_hhmm', 'Time_hhmmssfff', | |
'Time_hhmmssff', 'Time_hhmmssf', 'Time_hhmmss', 'Time_hhmm', 'Time_ss', 'Time_ssf', 'Time_ssff', 'Time_ssfff', | |
'Time_dhh', 'Time_dhhmm', 'Time_dhhmmss' )) ---< Hint to the UI how to best present the parameter. | |
---< This can be one of 'Time_hhmm', 'Time_hhmmss', 'Time_hhmmssf', 'Time_hhmmssff', 'Time_hhmmssfff', 'Duration_hhmm', 'Duration_hhmmss', 'Duration_hhmmssf', 'Duration_hhmmssff' or 'Duration_hhmmssfff'. | |
---< @xmlref Corresponds to XML attribute TypeTime/UIHint. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeTime ON dbo.ParameterTypeTime ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeTime TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeTime TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeTime TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeTime TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeTime TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeTime TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeTime TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeTime TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeTime TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeTime TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeTime TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeTime TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeNumber | |
IF object_id('ParameterTypeNumber', 'U') IS NOT NULL DROP TABLE ParameterTypeNumber; | |
/** @brief Defines a numeric parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeNumber. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeNumber | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
SizeInBit int not null, ---< The size in bits. | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
Type varchar(20) not null check(Type in ('signedInt', 'unsignedInt')), ---< Determines whether numeric data type is singned or unsigned. | |
---< One of 'signedInt' or 'unsignedInt'. | |
---< @xmlref Corresponds to XML attribute Type. | |
MinInclusive bigint not null, ---< The minimal included value. | |
---< @xmlref Corresponds to XML attribute minInclusive. | |
MaxInclusive bigint not null, ---< The maximal included value. | |
---< @xmlref Corresponds to XML attribute maxInclusive. | |
UIHint varchar(20) check(UIHint in ('Slider', 'CheckBox')) ---< Hint to the UI how to best present the parameter. | |
---< This can be one of 'Slider', 'CheckBox'. | |
---< @xmlref Corresponds to XML attribute TypeNumber/UIHint. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeNumber ON dbo.ParameterTypeNumber ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeNumber TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeNumber TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeNumber TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeNumber TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeNumber TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeNumber TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeNumber TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeNumber TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeNumber TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeNumber TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeNumber TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeNumber TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeFloat | |
IF object_id('ParameterTypeFloat', 'U') IS NOT NULL DROP TABLE ParameterTypeFloat; | |
/** @brief Defines a floating point parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeFloat. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeFloat | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
Encoding varchar(30) not null check(Encoding in ('DPT 9', 'IEEE-754 Single', 'IEEE-754 Double')), ---< The encoding type of the floating point value. | |
---< This can be one of 'DPT 9', 'IEEE-754 Single', 'IEEE-754 Double'. | |
---< @xmlref Corresponds to XML attribute Encoding. | |
MinInclusive float not null, ---< The minimal included value. | |
---< @xmlref Corresponds to XML attribute minInclusive. | |
MaxInclusive float not null, ---< The maximal included value. | |
---< @xmlref Corresponds to XML attribute maxInclusive. | |
DisplayFormat varchar(100), ---< The format description how the floating point value is represented. | |
---< @xmlref Corresponds to XML attribute DisplayFormat. | |
UIHint varchar(20) check(UIHint is null or UIHint = 'Slider'), ---< Hint to the UI how to best present the parameter | |
---< @xmlref Corresponds to XML attribute UIHint. | |
FormattingScript nvarchar(max) | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeFloat ON dbo.ParameterTypeFloat ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeFloat TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeFloat TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeFloat TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeFloat TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeFloat TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeFloat TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeFloat TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeFloat TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeFloat TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeFloat TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeFloat TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeFloat TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeText | |
IF object_id('ParameterTypeText', 'U') IS NOT NULL DROP TABLE ParameterTypeText; | |
/** @brief Defines a text parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeText. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeText | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
SizeInBit bigint not null, ---< The size in bit. | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
Pattern nvarchar(max) ---< A regular expression. | |
---< @xmlref Corresponds to XML attribute Pattern. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeText ON dbo.ParameterTypeText ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeText TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeText TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeText TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeDate | |
IF object_id('ParameterTypeDate', 'U') IS NOT NULL DROP TABLE ParameterTypeDate; | |
/** @brief Defines a date parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeDate. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeDate | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
Encoding varchar(50) not null check(Encoding in ('DPT 11')), ---< The encoding of the date. Can be one of 'DPT 11'. | |
---< @xmlref Corresponds to XML attribute Encoding. | |
DisplayTheYear bit default 1 | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeDate ON dbo.ParameterTypeDate ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeDate TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeDate TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeDate TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeDate TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeDate TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeDate TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeDate TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeDate TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeDate TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeDate TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeDate TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeDate TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeIPAddress | |
IF object_id('ParameterTypeIPAddress', 'U') IS NOT NULL DROP TABLE ParameterTypeIPAddress; | |
/** @brief Defines a IP address parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeNetAddr. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeIPAddress | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The paramneter type; reference to $fkspec. | |
AddressType varchar(50) not null check(AddressType in ('HostAddress', 'GatewayAddress', 'UnicastAddress', 'BroadcastAddress', 'MulticastAddress', 'SubnetMask')), ---< The type of the net address. | |
---< @xmlref Corresponds to XML attribute AddressType. | |
Version varchar(20) null check(Version in ('IPv4', 'IPv6' )) default ('IPv4') ---< The IP address version. Can be one of 'IPv4', 'IPv6'. | |
---< @xmlref Corresponds to XML attribute Version. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeIPAddress ON dbo.ParameterTypeIPAddress ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeIPAddress TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeIPAddress TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeIPAddress TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeIPAddress TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeIPAddress TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeIPAddress TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeIPAddress TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeIPAddress TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeIPAddress TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeIPAddress TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeIPAddress TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeIPAddress TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypeRestriction | |
IF object_id('ParameterTypeRestriction', 'U') IS NOT NULL DROP TABLE ParameterTypeRestriction; | |
/** @brief Defines a restriction (enumeration) parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeRestriction. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypeRestriction | |
( | |
ID uniqueidentifier primary key NONCLUSTERED default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
SizeInBit bigint not null, ---< The size in bits. | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
Base varchar(20) not null check(Base in ('Value', 'BinaryValue')) ---< Determines whether the Value or BinaryValue is valid. | |
---< This can be one of 'Value', 'BinaryValue'. | |
---< @xmlref Corresponds to XML attribute Base. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypeRestriction ON dbo.ParameterTypeRestriction ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypeRestriction TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypeRestriction TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypeRestriction TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypeRestriction TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypeRestriction TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypeRestriction TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypeRestriction TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypeRestriction TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypeRestriction TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypeRestriction TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypeRestriction TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypeRestriction TO ETSWriteProjectAccess; | |
GO | |
-- ParameterEnumValue | |
IF object_id('ParameterEnumValue', 'U') IS NOT NULL DROP TABLE ParameterEnumValue; | |
/** @brief Contains the list of values for enumeration types. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypeRestriction/Enumeration | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
*/ | |
CREATE TABLE dbo.ParameterEnumValue | |
( | |
ID varchar(300) primary key NONCLUSTERED, ---< Official primary key | |
---< @xmlref Corresponds to XML attribute Id. | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, | |
[Value] bigint not null, ---< The value. | |
---< For enum types, the value to be used for the image. | |
---< For long enum types, just an artificial unique value. | |
---< @xmlref Corresponds to XML attribute Value. | |
[Text] nvarchar(255), ---< Display text. | |
---< Translations are in ParameterEnumValueTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
DisplayOrder smallint, ---< When displayed, the values will be sorted by this attribute. | |
---< @xmlref Corresponds to XML attribute DisplayOrder. | |
---< On XML import, if DisplayOrder is missing, create it according to the order within the XML file. | |
---< On XML export, write DisplayOrder only if ApplicationProgram::PreEts4Style is 1. | |
BinaryValue varbinary(max), ---< For long enum types, the value to be used for the image | |
---< @xmlref Corresponds to XML attribute BinaryValue. | |
AutomaticDisplayOrder bit default 1 ---< The flag whether the display order was auto generated. This one is required for export to decide whether to export attribute DisplayOrder. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterEnumValue ON dbo.ParameterEnumValue ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterEnumValue TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterEnumValue TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterEnumValue TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterEnumValue TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterEnumValue TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterEnumValue TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterEnumValue TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterEnumValue TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterEnumValue TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterEnumValue TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterEnumValue TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterEnumValue TO ETSWriteProjectAccess; | |
GO | |
-- ParameterEnumValueTranslatedText | |
IF object_id('ParameterEnumValueTranslatedText', 'U') IS NOT NULL DROP TABLE ParameterEnumValueTranslatedText; | |
/** @brief Contains translated texts for the ParameterEnumValue table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ParameterEnumValueTranslatedText | |
( | |
ParameterEnumValueID varchar(300) not null foreign key references ParameterEnumValue(ID) on delete cascade, ---< Foreign key to the ParameterEnumValue table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
primary key (ParameterEnumValueID, [Language]) , | |
); | |
GRANT DELETE ON dbo.ParameterEnumValueTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterEnumValueTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterEnumValueTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterEnumValueTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterEnumValueTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterEnumValueTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterEnumValueTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterEnumValueTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterEnumValueTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterEnumValueTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterEnumValueTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterEnumValueTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ParameterCalculation | |
IF object_id('ParameterCalculation', 'U') IS NOT NULL DROP TABLE dbo.ParameterCalculation; | |
/** @brief Specifies a calculation formula for parameters. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterCalculations/ParameterCalculation | |
Note: The LParameters and RParameters sub-elements correspond to | |
ParameterRef::CalculationID, ParameterRef::CalculationSet and ParameterRef::AliasName. | |
*/ | |
CREATE TABLE dbo.ParameterCalculation | |
( | |
ID varchar(300) primary key nonclustered, ---< Official primary key. | |
---< @xmlref Corresponds to XML attribute Id. | |
ProgramID varchar(300) not null references ApplicationProgram(ID), ---< The application program; reference to $fkspec. | |
[Name] varchar(50), ---< Name visible within the manufacturer tool. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Language] varchar(20) not null, ---< The programming language | |
---< @xmlref Corresponds to XML attribute Language. | |
LRTransformation varchar(max), ---< The script for the LR transformation | |
---< @xmlref Corresponds to XML element LRTransformation. | |
RLTransformation varchar(max), ---< The script for the RL transformation | |
---< @xmlref Corresponds to XML element RLTransformation. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterCalculation ON dbo.ParameterCalculation ( ProgramID ); | |
--CREATE UNIQUE INDEX IxParameterCalculation ON dbo.ParameterCalculation(ProgramID,UniqueNumber); | |
GRANT DELETE ON dbo.ParameterCalculation TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterCalculation TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterCalculation TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterCalculation TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterCalculation TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterCalculation TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterCalculation TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterCalculation TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterCalculation TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterCalculation TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterCalculation TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterCalculation TO ETSWriteProjectAccess; | |
GO | |
-- ParameterUnion | |
IF object_id('ParameterUnion', 'U') IS NOT NULL DROP TABLE ParameterUnion; | |
/** @brief Application parameter data. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union | |
@schema6ref PARAMETER | |
*/ | |
CREATE TABLE dbo.ParameterUnion | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key. | |
---< @xmlref Corresponds to XML attribute ParameterRef/Id of the first ParameterRef of trhte union. | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
SizeInBit bigint not null check(SizeInBit between 0 and 4294967295), ---< Size in bits. | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
Type varchar(50) default 'None' check(Type in ('None', 'Memory', 'Property')), ---< The type of the union (Memory base or Property based). | |
---< This is required where the detailed information can be read from (table ParameterMemory or ParameterProperty). | |
---< This can be one of 'None', 'Memory', 'Property'. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterUnion ON dbo.ParameterUnion ( ApplicationProgramID ); | |
GRANT DELETE ON dbo.ParameterUnion TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterUnion TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterUnion TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterUnion TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterUnion TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterUnion TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterUnion TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterUnion TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterUnion TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterUnion TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterUnion TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterUnion TO ETSWriteProjectAccess; | |
GO | |
-- Parameter | |
IF object_id('Parameter', 'U') IS NOT NULL DROP TABLE Parameter; | |
/** @brief Application parameter data. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Parameter | |
and ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Parameter | |
@schema6ref PARAMETER | |
@additionalrestrictions | |
- The parameter type must belong to the same application program: | |
ParameterType[Parameter::ParameterTypeID].ProgramID = Parameter::ProgramID | |
- The segment - if given - must belong to the same application program: | |
ApplicationSegment[Parameter::SegmentID].ProgramID = Parameter::ProgramID | |
- If ParameterUnionID is not null, the location must be within the the union | |
*/ | |
CREATE TABLE dbo.Parameter | |
( | |
ID varchar(300) primary key nonclustered, ---< Offgicial primary key. | |
---< @xmlref Corresponds to XML attribute Id. | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
[Name] varchar(50) not null, ---< Name of the parameter. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< Label text. | |
---< Translations are in ParameterTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID), ---< %Parameter type; foreign key to $fkspec | |
---< @xmlref Corresponds to XML attribute ParameterType. | |
Access varchar(15) not null check(Access in ('none', 'read', 'readWrite')), ---< User access right. | |
---< One of: | |
---< - 'none': no access --> corresponsing numeric value 0 | |
---< - 'read': read-only --> corresponsing numeric value 1 | |
---< - 'readWrite': writable --> corresponsing numeric value 2 | |
---< @xmlref Corresponds to XML attribute Access. | |
Value sql_variant, ---< Default value | |
---< For string parameters, this is in the default language; translations are in ParameterTranslatedText. | |
---< @xmlref Corresponds to XML attribute Value. | |
ValueType varchar(128), ---< value type, redundant from ParameterType, for fast read access | |
Type varchar(50) default 'None' check(Type in ('None', 'Memory', 'Property')), ---< The type of the union (Memory base or Property based). | |
---< This is required where the detailed information can be read from (table ParameterMemory or ParameterProperty). | |
---< This can be one of 'None', 'Memory', 'Property'. | |
LegacyPatchAlways bit, ---< If 1, the value is written into the image independent of the parameter's visibility. | |
---< @xmlref Corresponds to XML attribute LegacyPatchAlways. | |
ParameterUnionOffset int, ---< The offset inside the parameter union. | |
---< @xmlref Corresponds to XML attribute ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Memory/\@Offset or | |
---< ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Memory/\@Offset. | |
ParameterUnionBitOffset smallint,---< The bit offset inside the parameter union. | |
---< @xmlref Corresponds to XML attribute ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Memory/\@BitOffset or | |
---< ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Memory/\@BitOffset. | |
ParameterUnionID varchar(300) foreign key references ParameterUnion(ID), ---< Union reference if part of a union | |
---< @xmlref If non-NULL, parent Union reference. | |
DefaultUnionParameter bit, ---< The flag whether this parameter is default union parameter. | |
---< @xmlref Corresponds to XML attribute DefaultUnionParameter. | |
SuffixText nvarchar(20) ---< @xmlref Corresponds to XML attribute SuffixText | |
); | |
CREATE CLUSTERED INDEX IX_Parameter ON dbo.Parameter ( ApplicationProgramID ); | |
GRANT DELETE ON dbo.Parameter TO ETSFullAccess; | |
DENY DELETE ON dbo.Parameter TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.Parameter TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.Parameter TO ETSFullAccess; | |
DENY INSERT ON dbo.Parameter TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.Parameter TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.Parameter TO ETSFullAccess; | |
DENY UPDATE ON dbo.Parameter TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.Parameter TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Parameter TO ETSFullAccess; | |
GRANT SELECT ON dbo.Parameter TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.Parameter TO ETSWriteProjectAccess; | |
GO | |
-- ParameterMemory | |
IF object_id('ParameterMemory', 'U') IS NOT NULL DROP TABLE dbo.ParameterMemory; | |
/** @brief A memory segment used by a parameter. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Parameter/Memory | |
and ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Parameter/Memory | |
@schema6ref PARAMETER | |
*/ | |
CREATE TABLE dbo.ParameterMemory | |
( | |
ID varchar(300) primary key, | |
ParameterID varchar(300) foreign key references Parameter(ID) on delete cascade, | |
ParameterUnionID varchar(300) foreign key references ParameterUnion(ID), | |
CodeSegmentID varchar(300) not null foreign key references ApplicationSegment(ID), ---< The referenced ApplicationSegment. | |
---< @xmlref Corresponds to XML attribute CodeSegment. | |
Offset bigint not null check(Offset >= 0 and Offset <= 4294967295), ---< The offset inside the segment. | |
---< @xmlref Corresponds to XML attribute Offset. | |
BitOffset smallint not null check(BitOffset >= 0 and BitOffset <= 255), ---< The bit offset inside the segment. | |
---< @xmlref Corresponds to XML attribute BitOffset. | |
); | |
CREATE NONCLUSTERED INDEX IX_ParameterMemory | |
ON [dbo].[ParameterMemory] ([ParameterUnionID]) | |
INCLUDE ([CodeSegmentID],[Offset],[BitOffset]) | |
GRANT DELETE ON dbo.ParameterMemory TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterMemory TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterMemory TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterMemory TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterMemory TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterMemory TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterMemory TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterMemory TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterMemory TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterMemory TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterMemory TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterMemory TO ETSWriteProjectAccess; | |
GO | |
-- ParameterProperty | |
IF object_id('ParameterProperty', 'U') IS NOT NULL DROP TABLE dbo.ParameterProperty; | |
/** @brief A memory segment used by a parameter. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Parameter/Property | |
and ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Parameters/Union/Parameter/Property | |
@schema6ref PARAMETER | |
*/ | |
CREATE TABLE dbo.ParameterProperty | |
( | |
ID varchar(300) primary key, ---< Atrificial primary key. | |
ParameterID varchar(300) foreign key references Parameter(ID) on delete cascade, ---< The ID of the referenced parameter if this property belongs to a parameter. | |
ParameterUnionID varchar(300) foreign key references ParameterUnion(ID), ---< The ID of the referenced parameter union if this property belongs to a parameter union | |
ObjectIndex smallint check((ObjectIndex is null) or (ObjectIndex between 0 and 255)), ---< The object index. | |
---< @xmlref Corresponds to XML attribute ObjectIndex. | |
ObjectType int check((ObjectType is null) or (ObjectType between 0 and 65535)), ---< The object type. | |
---< @xmlref Corresponds to XML attribute ObjectType. | |
Occurrence smallint default 0 check(Occurrence between 0 and 255), ---< The occurrence. | |
---< @xmlref Corresponds to XML attribute Occurrence. | |
PropertyId smallint not null check(PropertyId between 0 and 255), ---< The property ID. | |
---< @xmlref Corresponds to XML attribute PropertyId. | |
Offset bigint not null check(Offset between 0 and 4294967295), ---< The offset inside the property. | |
---< @xmlref Corresponds to XML attribute Offset. | |
BitOffset smallint not null check(BitOffset between 0 and 255), ---< The bit offset inside the property. | |
---< @xmlref Corresponds to XML attribute BitOffset. | |
); | |
GRANT DELETE ON dbo.ParameterProperty TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterProperty TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterProperty TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterProperty TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterProperty TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterProperty TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterProperty TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterProperty TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterProperty TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterProperty TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterProperty TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterProperty TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTranslatedText | |
IF object_id('ParameterTranslatedText', 'U') IS NOT NULL DROP TABLE ParameterTranslatedText; | |
/** @brief Contains translated texts for the Parameter table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ParameterTranslatedText | |
( | |
ParameterID varchar(300) not null foreign key references Parameter(ID) on delete cascade, ---< Foreign key to the Parameter table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
TranslatedDefaultValue nvarchar(max), ---< Translated default value (only for string parameters) | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='DefaultValue']/\@Text. | |
TranslatedSuffixText nvarchar(20), ---< Translated suffix text (only for string parameters) | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='SuffixText']/\@Text. | |
primary key (ParameterID, [Language]) , | |
); | |
GRANT DELETE ON dbo.ParameterTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ParameterRef | |
IF object_id('ParameterRef', 'U') IS NOT NULL DROP TABLE ParameterRef; | |
/** @brief Application parameter data. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterRefs/ParameterRef | |
@schema6ref PARAMETER | |
@additionalrestrictions | |
- The calculation must belong to the same application program as the Parameter: | |
ParameterCalculation[ParameterRef::CalculationID].ProgramID = Parameter[ParameterRef::ParameterID].ProgramID | |
*/ | |
CREATE TABLE dbo.ParameterRef | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID), | |
ParameterID varchar(300) not null foreign key references Parameter(ID) on delete cascade, | |
---< @xmlref Corresponds to XML attribute RefId. | |
--UniqueNumber int not null, ---< Unique identification of the parameter within the application program. | |
---< Encoded within XML attribute Id. | |
[Name] varchar(50), ---< Name of the parameter, if differing from Parameter::Name. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< Label text in the current database language, if differing from Parameter::Text. | |
---< Translations are in ParameterRefTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
DisplayOrder int, ---< For pre-ETS4 application programs, the parameters are presented to the user in increasing order of this attribute. | |
---< @xmlref Corresponds to XML attribute DisplayOrder. | |
Access varchar(15) check(Access in ('none', 'read', 'readWrite')), ---< User access right. | |
---< One of: | |
---< - 'none': no access --> corresponsing numeric value 0 | |
---< - 'read': read-only --> corresponsing numeric value 1 | |
---< - 'readWrite': writable --> corresponsing numeric value 2 | |
---< @xmlref Corresponds to XML attribute Access. | |
Value sql_variant, ---< Default value, if differing from Parameter::DefaultValue. | |
---< For string parameters, this is in the current database language; translations are in ParameterRefTranslatedText. | |
---< @xmlref Corresponds to XML attribute Value. | |
ValueType varchar(128), ---< value type, redundant from ParameterType, for fast read access | |
CalculationID varchar(300) foreign key references ParameterCalculation(ID), ---< Foreign key to $fkspec. NULL if this parameter is not part of a calculation. | |
---< In XML, this is represented in ParameterCalculation/LParameters or ParameterCalculation/RParameters. | |
CalculationSet varchar(1) check(CalculationSet is null or CalculationSet in ('L','R')), ---< "L" or "R" for the left/right set. Must be non-NULL if CalculationID is non-NULL. | |
---< In XML, this is represented in ParameterCalculation/LParameters or ParameterCalculation/RParameters. | |
AliasName varchar(50), ---< The alias name of the parameter for use within calculations. | |
---< Must be a syntactically valid variable name and unique within all parameters in a calculation if CalculationID is non-NULL. | |
---< In XML, this is represented in ParameterCalculation/LParameters or ParameterCalculation/RParameters. | |
AutomaticDisplayOrder bit default 1, ---< The fla whether the display order is auto generated. Export requires this information to determine whether to export display order attribute. | |
Tag nvarchar(max), ---< uninterpreted field to be used by Plug-Ins. | |
---< @xmlref Corresponds to XML attribute Tag. | |
SuffixText nvarchar(20) ---< @xmlref Corresponds to XML attribute SuffixText | |
); | |
CREATE CLUSTERED INDEX IX_ParameterRefAppPrg ON dbo.ParameterRef ( ApplicationProgramID ); | |
CREATE NONCLUSTERED INDEX IX_ParameterRefParam ON dbo.ParameterRef ( ParameterID ); | |
--CREATE UNIQUE INDEX IxParameterRef ON dbo.ParameterRef(ParameterID,UniqueNumber); | |
GRANT DELETE ON dbo.ParameterRef TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterRef TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterRef TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterRef TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterRef TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterRef TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterRef TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterRef TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterRef TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterRef TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterRef TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterRef TO ETSWriteProjectAccess; | |
GO | |
-- ParameterRefTranslatedText | |
IF object_id('ParameterRefTranslatedText', 'U') IS NOT NULL DROP TABLE ParameterRefTranslatedText; | |
/** @brief Contains translated texts for the ParameterRef table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.ParameterRefTranslatedText | |
( | |
ParameterRefID varchar(300) not null foreign key references ParameterRef(ID) on delete cascade, ---< Foreign key to the ParameterRef table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
TranslatedDefaultValue nvarchar(max), ---< Translated default value (only for string parameters) | |
TranslatedSuffixText nvarchar(20), ---< Translated suffix text value (only for string parameters) | |
primary key (ParameterRefID, [Language]) , | |
); | |
GRANT DELETE ON dbo.ParameterRefTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterRefTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterRefTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterRefTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterRefTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterRefTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterRefTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterRefTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterRefTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- ParameterCalculation.LParameter | |
IF object_id('[ParameterCalculation.LParameter]', 'U') IS NOT NULL DROP TABLE [ParameterCalculation.LParameter]; | |
/** @brief The left-side parameters of a parameter calculation. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterCalculations/ParameterCalculation/LParameters/ParameterRefRef | |
@schema6ref PARAMETER_CALCULATION | |
*/ | |
CREATE TABLE dbo.[ParameterCalculation.LParameter] | |
( | |
ParameterCalculationID varchar(300) not null foreign key references ParameterCalculation(ID) on delete cascade, ---< The parameter calculation; reference to $fkspec. | |
ParameterRefID varchar(300) not null foreign key references ParameterRef(ID) on delete cascade, ---< The ParameterRef; reference to $fkspec. | |
AliasName varchar(50), ---< The alias name. | |
---< @xmlref Corresponds to XML attribute AliasName. | |
CONSTRAINT [PK_ParameterCalculation.LParameter] PRIMARY KEY CLUSTERED | |
( | |
[ParameterCalculationID] ASC, | |
[ParameterRefID] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | |
) ON [PRIMARY]; | |
GRANT DELETE ON dbo.[ParameterCalculation.LParameter] TO ETSFullAccess; | |
DENY DELETE ON dbo.[ParameterCalculation.LParameter] TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.[ParameterCalculation.LParameter] TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.[ParameterCalculation.LParameter] TO ETSFullAccess; | |
DENY INSERT ON dbo.[ParameterCalculation.LParameter] TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.[ParameterCalculation.LParameter] TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.[ParameterCalculation.LParameter] TO ETSFullAccess; | |
DENY UPDATE ON dbo.[ParameterCalculation.LParameter] TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.[ParameterCalculation.LParameter] TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.LParameter] TO ETSFullAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.LParameter] TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.LParameter] TO ETSWriteProjectAccess; | |
GO | |
-- ParameterCalculation.RParameter | |
IF object_id('[ParameterCalculation.RParameter]', 'U') IS NOT NULL DROP TABLE dbo.[ParameterCalculation.RParameter]; | |
/** @brief The left-side parameters of a parameter calculation. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterCalculations/ParameterCalculation/RParameters/ParameterRefRef | |
@schema6ref PARAMETER_CALCULATION | |
*/ | |
CREATE TABLE dbo.[ParameterCalculation.RParameter] | |
( | |
ParameterCalculationID varchar(300) not null foreign key references ParameterCalculation(ID) on delete cascade, ---< The parameter calculation; reference to $fkspec. | |
ParameterRefID varchar(300) not null foreign key references ParameterRef(ID) on delete cascade, ---< The ParameterRef; reference to $fkspec. | |
AliasName varchar(50),---< The alias name. | |
---< @xmlref Corresponds to XML attribute AliasName. | |
CONSTRAINT [PK_ParameterCalculation.RParameter] PRIMARY KEY CLUSTERED | |
( | |
[ParameterCalculationID] ASC, | |
[ParameterRefID] ASC | |
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] | |
) ON [PRIMARY]; | |
GRANT DELETE ON dbo.[ParameterCalculation.RParameter] TO ETSFullAccess; | |
DENY DELETE ON dbo.[ParameterCalculation.RParameter] TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.[ParameterCalculation.RParameter] TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.[ParameterCalculation.RParameter] TO ETSFullAccess; | |
DENY INSERT ON dbo.[ParameterCalculation.RParameter] TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.[ParameterCalculation.RParameter] TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.[ParameterCalculation.RParameter] TO ETSFullAccess; | |
DENY UPDATE ON dbo.[ParameterCalculation.RParameter] TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.[ParameterCalculation.RParameter] TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.RParameter] TO ETSFullAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.RParameter] TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.[ParameterCalculation.RParameter] TO ETSWriteProjectAccess; | |
GO | |
-- CommunicationObject | |
IF object_id('CommunicationObject', 'U') IS NOT NULL DROP TABLE CommunicationObject; | |
/** @brief Describes a group communication object in an application program. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ComObjectTable/ComObject. | |
The atttributes ValuePointer and ValuePointerBase are not represented in the database | |
because they are for manufacturer internal use only. | |
because they are | |
@schema6ref COMMUNICATION_OBJECT | |
*/ | |
CREATE TABLE dbo.CommunicationObject | |
( | |
ID varchar(300) primary key nonclustered, ---< Official primary key. | |
---< @xmlref Corresponds to XML attribute Id. | |
ProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
[Name] nvarchar(50), ---< Internal name | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< Text in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
[FunctionText] nvarchar(255), ---< Function name in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute FunctionText. | |
VisibleDescription nvarchar(max), ---< Description in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
Number smallint not null check(Number >= 0), ---< The object number (= index within group object table = ASAP index) | |
---< @xmlref Corresponds to XML attribute Number. | |
ObjectSize varchar(20) not null check(ObjectSize in ('1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData')), ---< Data size of the communciation object. | |
---< This must be one of '1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData' | |
---< @xmlref Corresponds to XML attribute ObjectSize (note that this is encoded differently in XML!) | |
ReadFlag bit not null default 0, ---< ReadEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute ReadFlag. | |
WriteFlag bit not null default 0, ---< WriteEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute WriteFlag. | |
CommunicationFlag bit not null default 0, ---< CommunicationEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute CommunicationFlag. | |
TransmitFlag bit not null default 0, ---< TransmitEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute TransmitFlag. | |
UpdateFlag bit not null default 0, ---< UpdateEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute UpdateFlag. | |
ReadOnInitFlag bit not null default 0, ---< ReadOnInitEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute ReadOnInitFlag. | |
DatapointType varchar(max), ---< The valid data point types/subtypes. | |
---< @xmlref Corresponds to XML attribute DatapointType. | |
Priority varchar(6) not null default 'Low' check(Priority in ('Low', 'High', 'Alert')) ---< Message priority. | |
---< This can be one of 'Low', 'High', 'Alert'. | |
---< @xmlref Corresponds to XML attribute Priority. | |
); | |
CREATE CLUSTERED INDEX IX_CommunicationObject ON dbo.CommunicationObject ( ProgramID ); | |
GRANT DELETE ON dbo.CommunicationObject TO ETSFullAccess; | |
DENY DELETE ON dbo.CommunicationObject TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.CommunicationObject TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CommunicationObject TO ETSFullAccess; | |
DENY INSERT ON dbo.CommunicationObject TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CommunicationObject TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CommunicationObject TO ETSFullAccess; | |
DENY UPDATE ON dbo.CommunicationObject TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CommunicationObject TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CommunicationObject TO ETSFullAccess; | |
GRANT SELECT ON dbo.CommunicationObject TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CommunicationObject TO ETSWriteProjectAccess; | |
GO | |
-- CommunicationObjectTranslatedText | |
IF object_id('CommunicationObjectTranslatedText', 'U') IS NOT NULL DROP TABLE CommunicationObjectTranslatedText; | |
/** @brief Contains translated texts for the CommunicationObject table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.CommunicationObjectTranslatedText | |
( | |
CommunicationObjectID varchar(300) not null foreign key references CommunicationObject(ID) on delete cascade, ---< Foreign key to the CommunicationObject table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
TranslatedFunction nvarchar(255), ---< Translated Function | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='FunctionText']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='VisibleDescription']/\@Text. | |
primary key (CommunicationObjectID, [Language]) , | |
); | |
GRANT DELETE ON dbo.CommunicationObjectTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.CommunicationObjectTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.CommunicationObjectTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CommunicationObjectTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.CommunicationObjectTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CommunicationObjectTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CommunicationObjectTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.CommunicationObjectTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CommunicationObjectTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CommunicationObjectTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.CommunicationObjectTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CommunicationObjectTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- CommunicationObjectRef | |
IF object_id('CommunicationObjectRef', 'U') IS NOT NULL DROP TABLE CommunicationObjectRef; | |
/** @brief Describes a group communication object in an application program. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ComObjectRefs/ComObjectRef | |
@schema6ref COMMUNICATION_OBJECT | |
*/ | |
CREATE TABLE dbo.CommunicationObjectRef | |
( | |
ID varchar(300) primary key nonclustered, ---< Official primary key. | |
---< @xmlref Corresponds to XML attribute Id. | |
CommunicationObjectID varchar(300) not null foreign key references CommunicationObject(ID) on delete cascade, --< Referenced CommunicationObject | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID), --< Referenced ApplicationProgram. | |
[Name] nvarchar(50), ---< Internal name | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< Text in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
[FunctionText] nvarchar(255), ---< Function name in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute FunctionText. | |
VisibleDescription nvarchar(max), ---< Description in the current database language. | |
---< Translations are in CommunicationObjectTranslatedText. | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
ObjectSize varchar(20) check(ObjectSize in ('1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData')), ---< Data size of the communciation object. | |
---< This must be one of '1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData' | |
---< @xmlref Corresponds to XML attribute ObjectSize (note that this is encoded differently in XML!) | |
ReadFlag bit default 0, ---< ReadEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute ReadFlag. | |
WriteFlag bit default 0, ---< WriteEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute WriteFlag. | |
CommunicationFlag bit default 0, ---< CommunicationEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute CommunicationFlag. | |
TransmitFlag bit default 0, ---< TransmitEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute TransmitFlag. | |
UpdateFlag bit default 0, ---< UpdateEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute UpdateFlag. | |
ReadOnInitFlag bit default 0, ---< ReadOnInitEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute ReadOnInitFlag. | |
DatapointType varchar(max), ---< The valid data point types/subtypes. | |
---< @xmlref Corresponds to XML attribute DatapointType. | |
Priority varchar(6) check(Priority in ('Low', 'High', 'Alert')), ---< Message priority. | |
---< This can be one of 'Low', 'High', 'Alert', 'System'. | |
---< @xmlref Corresponds to XML attribute Priority. | |
Tag nvarchar(max) ---< uninterpreted field to be used by Plug-Ins. | |
---< @xmlref Corresponds to XML attribute Tag. | |
); | |
CREATE CLUSTERED INDEX IX_CommunicationObjectRef ON dbo.CommunicationObjectRef ( ApplicationProgramID ); | |
GRANT DELETE ON dbo.CommunicationObjectRef TO ETSFullAccess; | |
DENY DELETE ON dbo.CommunicationObjectRef TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.CommunicationObjectRef TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CommunicationObjectRef TO ETSFullAccess; | |
DENY INSERT ON dbo.CommunicationObjectRef TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CommunicationObjectRef TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CommunicationObjectRef TO ETSFullAccess; | |
DENY UPDATE ON dbo.CommunicationObjectRef TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CommunicationObjectRef TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRef TO ETSFullAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRef TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRef TO ETSWriteProjectAccess; | |
GO | |
-- CommunicationObjectRefTranslatedText | |
IF object_id('CommunicationObjectRefTranslatedText', 'U') IS NOT NULL DROP TABLE CommunicationObjectRefTranslatedText; | |
/** @brief Contains translated texts for the CommunicationObjectRef table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.CommunicationObjectRefTranslatedText | |
( | |
CommunicationObjectRefID varchar(300) not null foreign key references CommunicationObjectRef(ID) on delete cascade, ---< Foreign key to the CommunicationObjectRef table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
TranslatedFunction nvarchar(255), ---< Translated Function | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='FunctionText']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='VisibleDescription']/\@Text. | |
primary key (CommunicationObjectRefID, [Language]) , | |
); | |
GRANT DELETE ON dbo.CommunicationObjectRefTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.CommunicationObjectRefTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.CommunicationObjectRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CommunicationObjectRefTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.CommunicationObjectRefTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CommunicationObjectRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CommunicationObjectRefTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.CommunicationObjectRefTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CommunicationObjectRefTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRefTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRefTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CommunicationObjectRefTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- AddressFixup | |
IF object_id('AddressFixup', 'U') IS NOT NULL DROP TABLE AddressFixup; | |
/** @brief Specifies target-mask dependent fixups. | |
@access EtsInternal | |
@schema6ref ADDRESS_FIXUP | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/FixupsList/Fixup | |
@additionalrestrictions | |
- MaskEntry[AddressFixup::MaskEntryID].MaskID = ApplicationProgram[AddressFixup::ProgramID].MaskID | |
- ApplicationSegment[AddressFixup::SegmentID].ProgramID = AddressFixup::ProgramID | |
*/ | |
CREATE TABLE dbo.AddressFixup | |
( | |
ProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
MaskEntryID varchar(300) not null foreign key references MaskEntry(ID), ---< System function | |
---< @xmlref Corresponds to XML attribute FunctionRef | |
SegmentID varchar(300) not null foreign key references ApplicationSegment(ID), ---< The segment where the call is located. | |
---< @xmlref Corresponds to XML attribute CodeSegment | |
Offset int not null ---< Offset whithin the segemnt where the real address of the system function shall be written to. | |
---< Only 2 octet absolute fixups in big-endian order are supported. | |
---< @xmlref Corresponds to XML element Offset. | |
); | |
CREATE UNIQUE INDEX IxAddressFixup on dbo.AddressFixup(SegmentID,Offset); | |
GRANT DELETE ON dbo.AddressFixup TO ETSFullAccess; | |
DENY DELETE ON dbo.AddressFixup TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.AddressFixup TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.AddressFixup TO ETSFullAccess; | |
DENY INSERT ON dbo.AddressFixup TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.AddressFixup TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.AddressFixup TO ETSFullAccess; | |
DENY UPDATE ON dbo.AddressFixup TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.AddressFixup TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.AddressFixup TO ETSFullAccess; | |
GRANT SELECT ON dbo.AddressFixup TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.AddressFixup TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationBinaryData | |
IF object_id('ApplicationBinaryData', 'U') IS NOT NULL DROP TABLE ApplicationBinaryData; | |
/** @brief Binary data for use by Plug-Ins | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/BinaryData/BinaryData. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
*/ | |
CREATE TABLE dbo.ApplicationBinaryData | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< The application program; reference to $fkspec. | |
[Name] varchar(50) not null, ---< Unique Name within application program. | |
---< @xmlref Corresponds to XML attribute Name. | |
Data varbinary(max), ---< The data. | |
---< @xmlref Corresponds to XML element Data. | |
); | |
CREATE UNIQUE INDEX IxApplicationBinaryData ON dbo.ApplicationBinaryData(ProgramID,[Name]); | |
GRANT DELETE ON dbo.ApplicationBinaryData TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationBinaryData TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationBinaryData TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationBinaryData TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationBinaryData TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationBinaryData TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationBinaryData TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationBinaryData TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationBinaryData TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationBinaryData TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationBinaryData TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationBinaryData TO ETSWriteProjectAccess; | |
GO | |
-- CatalogSection | |
IF object_id('CatalogSection', 'U') IS NOT NULL DROP TABLE CatalogSection; | |
/** @brief Builds up the hierarchical structure within a product catalog. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Catalog//CatalogSection. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref FUNCTIONAL_ENTITY | |
@additionalrestrictions | |
- The referenced ParentCatalogSection must be from the same manufacturer | |
*/ | |
CREATE TABLE dbo.CatalogSection | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
ManufacturerID varchar(300) not null foreign key references dbo.Manufacturer(ID) on delete cascade, | |
ParentCatalogSectionID varchar(300) foreign key references dbo.CatalogSection(ID), ---< NULL for top-level functional entities, otherwise reference to parent functional entities; foreign key to $fkspec. | |
[Name] nvarchar(255), ---< Name in the current database language. | |
---< Translations are in CatalogSectionTranslatedText. | |
---< @xmlref Corresponds to XML attribute Name. | |
Number varchar(20) not null, ---< Functional entity number. | |
---< Must be unique within all children of one parent functional entity, or � for top-level functional entities � between all top-level functional entities. | |
---< @xmlref Corresponds to XML attribute Number. | |
VisibleDescription nvarchar(max), ---< Description in the current database language. | |
---< Translations are in CatalogSectionTranslatedText. | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
DefaultLanguage languageid, ---< Default language for the catalog section if differing from Manufacturer::DefaultLanguage. | |
---< @xmlref Corresponds to XML attribute DefaultLanguage. | |
NonRegRelevantDataVersion int not null default 0, ---< Version of the non registration-relevant data | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
); | |
CREATE CLUSTERED INDEX IX_CatalogSectionManuf ON dbo.CatalogSection ( ManufacturerID); | |
CREATE NONCLUSTERED INDEX IX_CatalogSectionParent ON dbo.CatalogSection ( ParentCatalogSectionID ); | |
GRANT DELETE ON dbo.CatalogSection TO ETSFullAccess; | |
DENY DELETE ON dbo.CatalogSection TO ETSReadOnlyAccess; | |
GRANT DELETE ON dbo.CatalogSection TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CatalogSection TO ETSFullAccess; | |
DENY INSERT ON dbo.CatalogSection TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CatalogSection TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CatalogSection TO ETSFullAccess; | |
DENY UPDATE ON dbo.CatalogSection TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CatalogSection TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CatalogSection TO ETSFullAccess; | |
GRANT SELECT ON dbo.CatalogSection TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CatalogSection TO ETSWriteProjectAccess; | |
GO | |
-- CatalogSectionTranslatedText | |
IF object_id('CatalogSectionTranslatedText', 'U') IS NOT NULL DROP TABLE CatalogSectionTranslatedText; | |
/** @brief Contains translated texts for the CatalogSection table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.CatalogSectionTranslatedText | |
( | |
CatalogSectionID varchar(300) not null foreign key references CatalogSection(ID) on delete cascade, ---< Foreign key to the CatalogSection table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedName nvarchar(255), ---< Translated Name | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Name']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='VisibleDescription']/\@Text. | |
primary key (CatalogSectionID, [Language]), | |
); | |
--CREATE CLUSTERED INDEX IX_CatalogSectionTranslatedText ON dbo.CatalogSectionTranslatedText ( CatalogSectionID ); | |
GRANT DELETE ON dbo.CatalogSectionTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.CatalogSectionTranslatedText TO ETSReadOnlyAccess; | |
GRANT DELETE ON dbo.CatalogSectionTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CatalogSectionTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.CatalogSectionTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CatalogSectionTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CatalogSectionTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.CatalogSectionTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CatalogSectionTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CatalogSectionTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.CatalogSectionTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CatalogSectionTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- CatalogItem | |
IF object_id('CatalogItem', 'U') IS NOT NULL DROP TABLE CatalogItem; | |
/** @brief Represents a product entry in the product catalog. | |
@access EtsInternal (delete also by EtsProject) | |
@xmlref ManufacturerData/Manufacturer/Catalog//CatalogSection/CatalogItem. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref VIRTUAL_DEVICE | |
@additionalrestrictions | |
- Hardware2Program.HardwareID = Product[CatalogItem.ProductID].HardwareID | |
- CatalogSection[CatalogItem::CatalogSectionID].ManufacturerID must be equal to Product[CatalogItem::ProductID].ManufacturerID. | |
*/ | |
CREATE TABLE dbo.CatalogItem | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
CatalogSectionID varchar(300) not null foreign key references CatalogSection(ID) on delete cascade, ---< The catalog section. | |
[Name] nvarchar(255), ---< Name in the current database language. | |
---< Translations are in CatalogItemTranslatedText. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Number] int not null, ---< Unique identification between CatalogItems with the same product and application program. | |
---< If more than one entry with the same combination of catalog entry, application program and PEI program occurs (e.g. in different branches of the catalog structure), this is used to distinguish them. | |
---< @xmlref Corresponds to XML attribute Number. | |
VisibleDescription nvarchar(max), ---< Description in the current database language. | |
---< Translations are in CatalogItemTranslatedText. | |
---< @xmlref Corresponds to XML attribute VisibleDescription. | |
ProductID varchar(300) not null foreign key references [Product](ID), | |
---< @xmlref Corresponds to XML attribute ProductRefId. | |
Hardware2ProgramID varchar(300) foreign key references Hardware2Program(ID), ---< The assigned hardware and application program(s); foreign key to $fkspec | |
---< This may be NULL only for accessory products. | |
---< @xmlref Corresponds to XML attribute Hardware2ProgramRefId. | |
DefaultLanguage languageid, ---< Default language for the catalog item if differing from Manufacturer::DefaultLanguage. | |
---< @xmlref Corresponds to XML attribute DefaultLanguage. | |
NonRegRelevantDataVersion int not null default 0, ---< Version of the non registration-relevant data | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
MediumTypes varchar(max), ---< The assigned medium types. | |
---< @xmlref Corresponds to XML attribute NonRegRelevantDataVersion. | |
); | |
CREATE CLUSTERED INDEX IX_CatalogItem ON dbo.CatalogItem ( CatalogSectionID ); | |
GRANT DELETE ON dbo.CatalogItem TO ETSFullAccess; | |
DENY DELETE ON dbo.CatalogItem TO ETSReadOnlyAccess; | |
GRANT DELETE ON dbo.CatalogItem TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CatalogItem TO ETSFullAccess; | |
DENY INSERT ON dbo.CatalogItem TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CatalogItem TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CatalogItem TO ETSFullAccess; | |
DENY UPDATE ON dbo.CatalogItem TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CatalogItem TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CatalogItem TO ETSFullAccess; | |
GRANT SELECT ON dbo.CatalogItem TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CatalogItem TO ETSWriteProjectAccess; | |
GO | |
-- CatalogItemTranslatedText | |
IF object_id('CatalogItemTranslatedText', 'U') IS NOT NULL DROP TABLE dbo.CatalogItemTranslatedText; | |
/** @brief Contains translated texts for the CatalogItem table. | |
@access EtsInternal | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref TEXT_ATTRIBUTE | |
*/ | |
CREATE TABLE dbo.CatalogItemTranslatedText | |
( | |
CatalogItemID varchar(300) not null foreign key references CatalogItem(ID) on delete cascade, ---< Foreign key to the CatalogItem table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedName nvarchar(255), ---< Translated Name | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Name']/\@Text. | |
TranslatedDescription nvarchar(max), ---< Translated Description | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='VisibleDescription']/\@Text. | |
primary key (CatalogItemID, [Language]) , | |
); | |
GRANT DELETE ON dbo.CatalogItemTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.CatalogItemTranslatedText TO ETSReadOnlyAccess; | |
GRANT DELETE ON dbo.CatalogItemTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.CatalogItemTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.CatalogItemTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.CatalogItemTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.CatalogItemTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.CatalogItemTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.CatalogItemTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.CatalogItemTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.CatalogItemTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.CatalogItemTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- Baggage | |
IF object_id('Baggage', 'U') IS NOT NULL DROP TABLE Baggage; | |
/** @brief Contains baggage data. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Baggages/Baggage. | |
@schema6ref BAGGAGE | |
*/ | |
create table dbo.Baggage | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
ManufacturerID varchar(300) not null foreign key references Manufacturer(ID) on delete cascade, ---< References the manufacturer this data belongs to; foreign key to $fkspec | |
TargetPath varchar(255) not null, ---< Optional directory, relative to manufacturer subdirectory. | |
---< @xmlref Corresponds to XML attribute TargetPath. | |
Name varchar(255) not null, ---< File name | |
---< @xmlref Corresponds to XML attribute FileInfo/\@Name. | |
Hidden bit default 0, ---< File attribute hidden is set. | |
---< @xmlref Corresponds to XML attribute FileInfo/\@Hidden. | |
ReadOnly bit default 0, ---< File attribute read-onlyis set. | |
---< @xmlref Corresponds to XML attribute FileInfo/\@ReadOnly. | |
TimeInfo datetime, ---< The creation time stamp | |
---< @xmlref Corresponds to XML attribute FileInfo/\@TimeInfo. | |
Version varchar(50), ---< file version in string representation (e.g. '1.2.543.1209') or NULL | |
---< @xmlref Corresponds to XML attribute FileInfo/\@Version. | |
---< This (or LocalFileTime if LocalFileVersion is NULL) is used by ETS import to prevent overwriting of newer entries by older entries. | |
Compression varchar(1) default 'N' check (Compression in('N', 'Z','C')), ---< Compression. Not used so far. | |
---< One of: | |
---< - 'N'=None | |
---< - 'Z'=ZIP | |
---< - 'C'=CAB (reserved) | |
---< @xmlref In XML, data is always uncompressed. | |
Data varbinary(max), ---< Arbitrary binary data | |
---< @xmlref Corresponds to XML element Data (compressed / uncompressed on the fly). | |
LastUsed datetime, ---< Timestamp of last access, may in the future be used to discard files | |
---< @xmlref Not transported via XML. | |
InstallOnImport bit not null default 0, ---< If set, the baggage file will be installed immediately after import of product or project data. | |
---< This is meant to be used to install USB INF files. | |
---< @xmlref Corresponds to XML attribute InstallOnImport. | |
GroupAddresses16BitEnabled bit default 0, | |
); | |
CREATE CLUSTERED INDEX IX_Baggage ON dbo.Baggage ( ManufacturerID ); | |
GRANT DELETE ON dbo.Baggage TO ETSFullAccess; | |
DENY DELETE ON dbo.Baggage TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.Baggage TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.Baggage TO ETSFullAccess; | |
DENY INSERT ON dbo.Baggage TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.Baggage TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.Baggage TO ETSFullAccess; | |
DENY UPDATE ON dbo.Baggage TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.Baggage TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Baggage TO ETSFullAccess; | |
GRANT SELECT ON dbo.Baggage TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.Baggage TO ETSWriteProjectAccess; | |
GO | |
-- ApplicationProgramBaggage | |
IF object_id('ApplicationProgramBaggage', 'U') IS NOT NULL DROP TABLE ApplicationProgramBaggage; | |
/** @brief This table provides a n:m relation between an application program and the corresponding baggage entries. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/Extension/Baggage | |
*/ | |
create table dbo.ApplicationProgramBaggage | |
( | |
ApplicationProgramID varchar(300) not null foreign key references ApplicationProgram(ID) on delete cascade, ---< Reference to ApplicationProgram | |
BaggageID varchar(300) not null foreign key references Baggage(ID), ---< Reference to Baggage. | |
primary key nonclustered (ApplicationProgramID, BaggageID) | |
); | |
CREATE CLUSTERED INDEX IX_ApplicationProgramBaggage ON dbo.ApplicationProgramBaggage ( ApplicationProgramID ); | |
GRANT DELETE ON dbo.ApplicationProgramBaggage TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramBaggage TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramBaggage TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramBaggage TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramBaggage TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramBaggage TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramBaggage TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramBaggage TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgramBaggage TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramBaggage TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramBaggage TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramBaggage TO ETSWriteProjectAccess; | |
GO | |
-- ProductBaggage | |
IF object_id('ProductBaggage', 'U') IS NOT NULL DROP TABLE ProductBaggage; | |
/** @brief This table provides a n:m relation between a catalog entry and the corresponding baggage entries. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/Hardware/Hardware/Products/Product/Baggages/Baggage | |
*/ | |
create table dbo.ProductBaggage | |
( | |
ProductID varchar(300) not null foreign key references [Product](ID) on delete cascade, ---< Reference to Product | |
BaggageID varchar(300) not null foreign key references Baggage(ID), ---< Reference to Baggage | |
primary key nonclustered (ProductID, BaggageID) | |
); | |
CREATE CLUSTERED INDEX IX_ProductBaggage ON dbo.ProductBaggage ( ProductID ); | |
GRANT DELETE ON dbo.ProductBaggage TO ETSFullAccess; | |
DENY DELETE ON dbo.ProductBaggage TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ProductBaggage TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ProductBaggage TO ETSFullAccess; | |
DENY INSERT ON dbo.ProductBaggage TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ProductBaggage TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ProductBaggage TO ETSFullAccess; | |
DENY UPDATE ON dbo.ProductBaggage TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ProductBaggage TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProductBaggage TO ETSFullAccess; | |
GRANT SELECT ON dbo.ProductBaggage TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ProductBaggage TO ETSWriteProjectAccess; | |
GO | |
-- ProductBaggage | |
IF object_id('ApplicationProgramLanguageVersion', 'U') IS NOT NULL DROP TABLE dbo.ApplicationProgramLanguageVersion; | |
/** @brief This table contains the current versions of languages contained in the database. | |
@access EtsInternal | |
*/ | |
create table dbo.ApplicationProgramLanguageVersion | |
( | |
ApplicationProgramID varchar(300) not null foreign key references [ApplicationProgram](ID) on delete cascade, ---< Reference to ApplicationProgram | |
[Language] languageid not null, ---< The language identifier. | |
CurrentVersion int check(CurrentVersion >= 0) --< The current version of this language for the application program. | |
primary key nonclustered (ApplicationProgramID, Language) | |
); | |
CREATE CLUSTERED INDEX IX_ApplicationProgramLanguageVersiont ON dbo.ApplicationProgramLanguageVersion ( ApplicationProgramID ); | |
GRANT DELETE ON dbo.ApplicationProgramLanguageVersion TO ETSFullAccess; | |
DENY DELETE ON dbo.ApplicationProgramLanguageVersion TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ApplicationProgramLanguageVersion TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ApplicationProgramLanguageVersion TO ETSFullAccess; | |
DENY INSERT ON dbo.ApplicationProgramLanguageVersion TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ApplicationProgramLanguageVersion TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ApplicationProgramLanguageVersion TO ETSFullAccess; | |
DENY UPDATE ON dbo.ApplicationProgramLanguageVersion TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ApplicationProgramLanguageVersion TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ApplicationProgramLanguageVersion TO ETSFullAccess; | |
GRANT SELECT ON dbo.ApplicationProgramLanguageVersion TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ApplicationProgramLanguageVersion TO ETSWriteProjectAccess; | |
GO | |
-- ParameterTypePicture -- | |
IF object_id('ParameterTypePicture', 'U') IS NOT NULL DROP TABLE ParameterTypePicture; | |
/** @brief Defines a picture parameter type for application parameters This extends ParameterType. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer/ApplicationPrograms/ApplicationProgram/Static/ParameterTypes/ParameterType/TypePicture. | |
@schema6ref PARAMETER_TYPE | |
*/ | |
CREATE TABLE dbo.ParameterTypePicture | |
( | |
ID uniqueidentifier primary key nonclustered default newid(), ---< Artificial primary key | |
ParameterTypeID varchar(300) not null foreign key references ParameterType(ID) on delete cascade, ---< The parameter type; reference to $fkspec. | |
BaggageId varchar(300) not null foreign key references Baggage(ID), ---< The ref id to the baggage. | |
---< @xmlref Corresponds to XML attribute refId. | |
HorizontalAlignment varchar(10) ---< The horizontal alignement of the picture | |
---< @xmlref Corresponds to XML attribute HorizontalAlignment. | |
); | |
CREATE CLUSTERED INDEX IX_ParameterTypePicture ON dbo.ParameterTypePicture ( ParameterTypeID ); | |
GRANT DELETE ON dbo.ParameterTypePicture TO ETSFullAccess; | |
DENY DELETE ON dbo.ParameterTypePicture TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ParameterTypePicture TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ParameterTypePicture TO ETSFullAccess; | |
DENY INSERT ON dbo.ParameterTypePicture TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ParameterTypePicture TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ParameterTypePicture TO ETSFullAccess; | |
DENY UPDATE ON dbo.ParameterTypePicture TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ParameterTypePicture TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ParameterTypePicture TO ETSFullAccess; | |
GRANT SELECT ON dbo.ParameterTypePicture TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ParameterTypePicture TO ETSWriteProjectAccess; | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InitMasterData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Master Data | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- ---------------------------------------------------------------------------- | |
-- Master data | |
-- ---------------------------------------------------------------------------- | |
-- MediumType -- | |
IF object_id('MediumType', 'U') IS NOT NULL DROP TABLE MediumType; | |
/** @brief KNX medium type. | |
@access EtsInternal | |
@xmlref MasterData/MediumTypes/MediumType. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref MEDIUM_TYPE | |
*/ | |
CREATE TABLE dbo.MediumType | |
( | |
ID varchar(300) not null primary key, ---< Artificial primary key. | |
---< @xmlref Corresponds to XML attribute Number. | |
[Number] int not null, ---< Medium type number, allocated by the KNX %Association (0 = TP, 1 = PL). | |
[Name] varchar(20) not null, ---< Abbreviated name of the medium type. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] varchar(50), ---< Full name of the medium type in the current database language. | |
---< @xmlref Corresponds to XML attribute Text. | |
DomainAddressLength smallint ---< This attribute defines the number of significant bits in the Domain Address for a medium. | |
---< It is NULL if the Medium has no Domain Address. | |
---< @xmlref Corresponds to XML attribute DomainAddressLength. | |
); | |
GRANT DELETE ON dbo.MediumType TO ETSFullAccess; | |
DENY DELETE ON dbo.MediumType TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.MediumType TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.MediumType TO ETSFullAccess; | |
DENY INSERT ON dbo.MediumType TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.MediumType TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.MediumType TO ETSFullAccess; | |
DENY UPDATE ON dbo.MediumType TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.MediumType TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.MediumType TO ETSFullAccess; | |
GRANT SELECT ON dbo.MediumType TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.MediumType TO ETSWriteProjectAccess; | |
GO | |
-- MaskVersion -- | |
IF object_id('MaskVersion', 'U') IS NOT NULL DROP TABLE MaskVersion; | |
/** @brief General data about a management model (mask version). | |
@access EtsInternal | |
@xmlref MasterData/MaskVersions/MaskVersion. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref MASK | |
*/ | |
CREATE TABLE dbo.MaskVersion | |
( | |
ID varchar(300) primary key, ---< Artificial primary key. | |
MaskVersion int not null check(MaskVersion between 0 and 0xFFFF), ---< Numeric value of mask version (= device descriptor 0) | |
---< @xmlref Corresponds to XML attribute MaskVersion. | |
MgmtDescriptor01 varchar(20), ---< Value of the MgmtDescriptor01. | |
---< In contrast to DB schema 6, each of the flavours of mask $0300 discriminated by the | |
---< MgmtDescriptor01 gets its own entry in the Mask table. | |
---< @xmlref Corresponds to XML attribute MgmtDescriptor01. | |
[Name] varchar(50), ---< Display name for the mask version (currently not translatable). | |
---< @xmlref Corresponds to XML attribute Name. | |
MediumType varchar(300) foreign key references MediumType(ID), ---< Medium type; foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute MediumTypeRefId. | |
OtherMediumType varchar(300) foreign key references MediumType(ID), ---< For media couplers: second medium type; foreign key to $fkspec | |
---< @xmlref Corresponds to XML attribute OtherMediumTypeRefId. | |
ManagementModel varchar(50) check(ManagementModel in('None','Bcu1','BimM112','Bcu2','PropertyBased','SystemB')), ---< ManagementModel Type. This can be one of 'None','Bcu1','BimM112','Bcu2','PropertyBased' or 'SystemB' | |
---< @xmlref Corresponds to XML attribute ManagementModel. | |
); | |
GRANT DELETE ON dbo.MaskVersion TO ETSFullAccess; | |
DENY DELETE ON dbo.MaskVersion TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.MaskVersion TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.MaskVersion TO ETSFullAccess; | |
DENY INSERT ON dbo.MaskVersion TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.MaskVersion TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.MaskVersion TO ETSFullAccess; | |
DENY UPDATE ON dbo.MaskVersion TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.MaskVersion TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.MaskVersion TO ETSFullAccess; | |
GRANT SELECT ON dbo.MaskVersion TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.MaskVersion TO ETSWriteProjectAccess; | |
GO | |
-- MaskEntry -- | |
IF object_id('MaskEntry', 'U') IS NOT NULL DROP TABLE dbo.MaskEntry; | |
/** @brief List of system function entry points for a mask version. | |
@access EtsInternal | |
@xmlref MasterData/MaskVersions/MaskVersion/MaskEntries/MaskEntry. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref MASK_ENTRY | |
*/ | |
CREATE TABLE dbo.MaskEntry | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
MaskID varchar(300) not null foreign key references MaskVersion(ID) on delete cascade, ---< The mask version; foreign key to $fkspec. | |
[Name] varchar(50) not null, ---< Name of the system function. | |
---< @xmlref Corresponds to XML attribute Name. | |
Address int not null, ---< Entry point address. | |
---< @xmlref Corresponds to XML attribute Address. | |
); | |
CREATE UNIQUE INDEX IxMaskEntry on dbo.MaskEntry(MaskID, [Name]); | |
GRANT DELETE ON dbo.MaskEntry TO ETSFullAccess; | |
DENY DELETE ON dbo.MaskEntry TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.MaskEntry TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.MaskEntry TO ETSFullAccess; | |
DENY INSERT ON dbo.MaskEntry TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.MaskEntry TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.MaskEntry TO ETSFullAccess; | |
DENY UPDATE ON dbo.MaskEntry TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.MaskEntry TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.MaskEntry TO ETSFullAccess; | |
GRANT SELECT ON dbo.MaskEntry TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.MaskEntry TO ETSWriteProjectAccess; | |
GO | |
-- MaskEntry -- | |
IF object_id('HawkConfigurationData', 'U') IS NOT NULL DROP TABLE dbo.HawkConfigurationData; | |
/** @brief List of system function entry points for a mask version. | |
@access EtsInternal | |
@xmlref MasterData/MaskVersions/MaskVersion/HawkConfigurationData. | |
@schema6ref not existing | |
*/ | |
CREATE TABLE dbo.HawkConfigurationData | |
( | |
ID int primary key IDENTITY(1,1), ---< artifical key | |
MaskVersionID varchar(300) foreign key references MaskVersion(ID) on delete cascade, ---< key of corresponding mask version. foreign key to $fkspec | |
LegacyVersion smallint, ---< The legacy version. | |
---< @xmlref Corresponds to XML attribute LegacyVersion. | |
ConfigurationData xml not null, ---< The hawk configuration data XML. | |
---< @xmlref Corresponds to XML MasterData/MaskVersions/MaskVersion/HawkConfigurationData/*. | |
); | |
GRANT DELETE ON dbo.HawkConfigurationData TO ETSFullAccess; | |
DENY DELETE ON dbo.HawkConfigurationData TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.HawkConfigurationData TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.HawkConfigurationData TO ETSFullAccess; | |
DENY INSERT ON dbo.HawkConfigurationData TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.HawkConfigurationData TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.HawkConfigurationData TO ETSFullAccess; | |
DENY UPDATE ON dbo.HawkConfigurationData TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.HawkConfigurationData TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.HawkConfigurationData TO ETSFullAccess; | |
GRANT SELECT ON dbo.HawkConfigurationData TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.HawkConfigurationData TO ETSWriteProjectAccess; | |
GO | |
-- MaskCompatibility -- | |
IF object_id('MaskCompatibility', 'U') IS NOT NULL DROP TABLE MaskCompatibility; | |
/** @brief Compatibility relations about mask versions. | |
An entry in this table states that MaskCompatibility::OldMaskID is upward compatible with MaskCompatibility::NewMaskID | |
i.e. that application programs designed for MaskVersion[MaskCompatibility::OldMaskID] may in | |
principle be downloaded into MaskVersion[MaskCompatibility::NewMaskID] (other restrictions may still prevent this). | |
@access EtsInternal | |
@xmlref MasterData/MaskVersions/MaskVersion/DownwardCompatibleMasks/DownwardCompatibleMask | |
@schema6ref MASK_COMPATIBILITY | |
*/ | |
CREATE TABLE dbo.MaskCompatibility | |
( | |
OldMaskID varchar(300) not null foreign key references MaskVersion(ID), ---< References the older mask version; foreign key to $fkspec. | |
---< @xmlref Corresponds to XML attribute RefId. | |
NewMaskID varchar(300) not null foreign key references MaskVersion(ID), ---< References the newer mask version; foreign key to $fkspec. | |
primary key (OldMaskID, NewMaskID) | |
); | |
GRANT DELETE ON dbo.MaskCompatibility TO ETSFullAccess; | |
DENY DELETE ON dbo.MaskCompatibility TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.MaskCompatibility TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.MaskCompatibility TO ETSFullAccess; | |
DENY INSERT ON dbo.MaskCompatibility TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.MaskCompatibility TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.MaskCompatibility TO ETSFullAccess; | |
DENY UPDATE ON dbo.MaskCompatibility TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.MaskCompatibility TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.MaskCompatibility TO ETSFullAccess; | |
GRANT SELECT ON dbo.MaskCompatibility TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.MaskCompatibility TO ETSWriteProjectAccess; | |
GO | |
-- DatapointType -- | |
IF object_id('DatapointType', 'U') IS NOT NULL DROP TABLE DatapointType | |
/** @brief KNX data point main types. | |
@access EtsInternal | |
@xmlref MasterData/DatapointTypes/DatapointType. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref EIB_DATA_TYPE | |
*/ | |
CREATE TABLE dbo.DatapointType | |
( | |
ID varchar(300) not null primary key, ---< DPT code allocated by the KNX %Association; primary key. | |
[Number] int not null, check( Number > 0), ---< @xmlref Corresponds to XML attribute Number. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Name] varchar(255) not null, ---< Name according to KNX standard | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< User-visible text in the current database language. | |
---< Translations are in DatapointTypeTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
LengthInBit smallint, ---< Data length in bit | |
---< @xmlref Corresponds to XML attribute SizeInBit. | |
[Default] bit ---< Flag indicating if the DatapointType is the default type for the bit size | |
---< @xmlref Corresponds to XML attribute Default. | |
); | |
GRANT DELETE ON dbo.DatapointType TO ETSFullAccess; | |
DENY DELETE ON dbo.DatapointType TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.DatapointType TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.DatapointType TO ETSFullAccess; | |
DENY INSERT ON dbo.DatapointType TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.DatapointType TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.DatapointType TO ETSFullAccess; | |
DENY UPDATE ON dbo.DatapointType TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.DatapointType TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DatapointType TO ETSFullAccess; | |
GRANT SELECT ON dbo.DatapointType TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.DatapointType TO ETSWriteProjectAccess; | |
GO | |
-- DatapointTypeTranslatedText | |
IF object_id('DatapointTypeTranslatedText', 'U') IS NOT NULL DROP TABLE DatapointTypeTranslatedText; | |
/** @brief Contains translated texts for the DatapointType table. | |
@access EtsInternal (delete also by EtsProject) | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref (none) | |
@uniquekey UK(DatapointType[DatapointTypeTranslatedText::DatapointTypeID]) + DatapointTypeTranslatedText::Language + DatapointTypeTranslatedText::Version | |
*/ | |
CREATE TABLE dbo.DatapointTypeTranslatedText | |
( | |
DatapointTypeID varchar(300) not null foreign key references [DatapointType](ID) on delete cascade, ---< Foreign key to the DatapointType table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation. | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
primary key (DatapointTypeID, [Language]), | |
); | |
GRANT DELETE ON dbo.DatapointTypeTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.DatapointTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.DatapointTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.DatapointTypeTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.DatapointTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.DatapointTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.DatapointTypeTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.DatapointTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.DatapointTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DatapointTypeTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.DatapointTypeTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.DatapointTypeTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- DatapointSubtype -- | |
IF object_id('DatapointSubtype', 'U') IS NOT NULL DROP TABLE DatapointSubtype; | |
/** @brief KNX data point sub types. | |
@access EtsInternal | |
@xmlref MasterData/DatapointTypes/DatapointType/DatapointSubtypes/DatapointSubtype. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref EIB_DATA_SUBTYPE | |
*/ | |
CREATE TABLE dbo.DatapointSubtype | |
( | |
ID varchar(300) not null primary key nonclustered, ---< DPT subcode allocated by the KNX %Association | |
DatapointTypeID varchar(300) not null foreign key references DatapointType(ID) on delete cascade, ---< DPT code allocated by the association; foreign key to $fkspec. | |
[Number] int not null check( Number >= 0), ---< @xmlref Corresponds to XML attribute Number | |
[Name] varchar(255) not null, ---< Name according to KNX standard. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< User-visible text. | |
---< Translations are in DatapointSubtypeTranslatedText | |
---< @xmlref Corresponds to XML attribute Text. | |
[Default] bit, ---<Flag indicating if the this DatapointSubtype is the default Subtype for its bit size. | |
); | |
CREATE CLUSTERED INDEX IX_DatapointId ON dbo.DatapointSubtype ( DatapointTypeID ); | |
GRANT DELETE ON dbo.DatapointSubtype TO ETSFullAccess; | |
DENY DELETE ON dbo.DatapointSubtype TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.DatapointSubtype TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.DatapointSubtype TO ETSFullAccess; | |
DENY INSERT ON dbo.DatapointSubtype TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.DatapointSubtype TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.DatapointSubtype TO ETSFullAccess; | |
DENY UPDATE ON dbo.DatapointSubtype TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.DatapointSubtype TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DatapointSubtype TO ETSFullAccess; | |
GRANT SELECT ON dbo.DatapointSubtype TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.DatapointSubtype TO ETSWriteProjectAccess; | |
GO | |
-- DatapointSubtypeTranslatedText | |
IF object_id('DatapointSubtypeTranslatedText', 'U') IS NOT NULL DROP TABLE DatapointSubtypeTranslatedText; | |
/** @brief Contains translated texts for the DatapointSubtype table. | |
@access EtsInternal (delete also by EtsProject) | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref (none) | |
*/ | |
CREATE TABLE dbo.DatapointSubtypeTranslatedText | |
( | |
--DatapointTypeID varchar(300) not null, ---< DPT code allocated by the KNX %Association. | |
--< DatapointTypeID and DatapointSubtypeID are together a foreign key to DatapointSubtype. | |
DatapointSubtypeID varchar(300) not null, ---< DPT subcode allocated by the KNX %Association. | |
--< DatapointTypeID and DatapointSubtypeID are together a foreign key to DatapointSubtype. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
primary key (DatapointSubtypeID, [Language]), | |
foreign key (DatapointSubtypeID) references [DatapointSubtype](ID) on delete cascade | |
); | |
GRANT DELETE ON dbo.DatapointSubtypeTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.DatapointSubtypeTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.DatapointSubtypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.DatapointSubtypeTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.DatapointSubtypeTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.DatapointSubtypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.DatapointSubtypeTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.DatapointSubtypeTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.DatapointSubtypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DatapointSubtypeTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.DatapointSubtypeTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.DatapointSubtypeTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- InterfaceObjectType -- | |
IF object_id('InterfaceObjectType', 'U') IS NOT NULL DROP TABLE InterfaceObjectType | |
/** @brief KNX object types. | |
@access EtsInternal | |
@xmlref MasterData/InterfaceObjectTypes/InterfaceObjectType. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref (none) | |
*/ | |
CREATE TABLE dbo.InterfaceObjectType | |
( | |
ID varchar(300) not null primary key, ---< DPT code allocated by the KNX %Association; primary key. | |
[Number] int not null, check( Number >= 0), ---< @xmlref Corresponds to XML attribute Number. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Name] varchar(255) not null, ---< Name according to KNX standard | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< User-visible text in the current database language. | |
---< Translations are in InterfaceObjectTypeTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
); | |
GRANT DELETE ON dbo.InterfaceObjectType TO ETSFullAccess; | |
DENY DELETE ON dbo.InterfaceObjectType TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.InterfaceObjectType TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.InterfaceObjectType TO ETSFullAccess; | |
DENY INSERT ON dbo.InterfaceObjectType TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.InterfaceObjectType TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.InterfaceObjectType TO ETSFullAccess; | |
DENY UPDATE ON dbo.InterfaceObjectType TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.InterfaceObjectType TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.InterfaceObjectType TO ETSFullAccess; | |
GRANT SELECT ON dbo.InterfaceObjectType TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.InterfaceObjectType TO ETSWriteProjectAccess; | |
GO | |
-- InterfaceObjectTypeTranslatedText -- | |
IF object_id('InterfaceObjectTypeTranslatedText', 'U') IS NOT NULL DROP TABLE InterfaceObjectTypeTranslatedText; | |
/** @brief Contains translated texts for the DatapointType table. | |
@access EtsInternal (delete also by EtsProject) | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref (none) | |
@uniquekey UK(InterfaceObjectType[InterfaceObjectTypeTranslatedText::InterfaceObjectTypeID]) + InterfaceObjectTypeTranslatedText::Language + InterfaceObjectTypeTranslatedText::Version | |
*/ | |
CREATE TABLE dbo.InterfaceObjectTypeTranslatedText | |
( | |
InterfaceObjectTypeID varchar(300) not null foreign key references InterfaceObjectType(ID) on delete cascade, ---< Foreign key to the DatapointType table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation. | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
primary key (InterfaceObjectTypeID, [Language]), | |
); | |
GRANT DELETE ON dbo.InterfaceObjectTypeTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.InterfaceObjectTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.InterfaceObjectTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.InterfaceObjectTypeTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.InterfaceObjectTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.InterfaceObjectTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.InterfaceObjectTypeTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.InterfaceObjectTypeTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.InterfaceObjectTypeTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.InterfaceObjectTypeTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.InterfaceObjectTypeTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.InterfaceObjectTypeTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- PropertyDataType -- | |
IF object_id('PropertyDataType', 'U') IS NOT NULL DROP TABLE PropertyDataType | |
/** @brief KNX property identifier. | |
@access EtsInternal | |
@xmlref MasterData/PropertyDataTypes/PropertyDataType. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref (none) | |
*/ | |
CREATE TABLE dbo.PropertyDataType | |
( | |
ID varchar(300) not null primary key, ---< allocated by the KNX Association; primary key. | |
[Number] int not null, check( Number >= 0), ---< @xmlref Corresponds to XML attribute Number. | |
[Name] varchar(255) not null, | |
---< @xmlref Corresponds to XML attribute Name. | |
Size int, check( Size > 0), | |
---< @xmlRef Corresponds to XML attribute Size. | |
[ReadSize] int, check( [ReadSize] > 0) | |
---< @xmlRef Corresponds to XML attribute Size. | |
); | |
GRANT DELETE ON dbo.PropertyDataType TO ETSFullAccess; | |
DENY DELETE ON dbo.PropertyDataType TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.PropertyDataType TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.PropertyDataType TO ETSFullAccess; | |
DENY INSERT ON dbo.PropertyDataType TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.PropertyDataType TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.PropertyDataType TO ETSFullAccess; | |
DENY UPDATE ON dbo.PropertyDataType TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.PropertyDataType TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.PropertyDataType TO ETSFullAccess; | |
GRANT SELECT ON dbo.PropertyDataType TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.PropertyDataType TO ETSWriteProjectAccess; | |
GO | |
-- InterfaceObjectProperty -- | |
IF object_id('InterfaceObjectProperty', 'U') IS NOT NULL DROP TABLE InterfaceObjectProperty | |
/** @brief KNX property identifier. | |
@access EtsInternal | |
@xmlref MasterData/InterfaceObjectPropertys/InterfaceObjectProperty. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref (none) | |
*/ | |
CREATE TABLE dbo.InterfaceObjectProperty | |
( | |
ID varchar(300) not null primary key, ---< allocated by the KNX Association; primary key. | |
[Number] int not null, check( Number >= 0), ---< @xmlref Corresponds to XML attribute Number. | |
[InterfaceObjectTypeId] varchar(300) foreign key references InterfaceObjectType(ID) on delete cascade, | |
---< @xmlRef Corresponds to XML attribute InterfaceObjectType. | |
[Name] varchar(255) not null, ---< Name according to KNX standard | |
---< @xmlref Corresponds to XML attribute Name. | |
[Text] nvarchar(255), ---< User-visible text in the current database language. | |
---< Translations are in InterfaceObjectPropertyTranslatedText. | |
---< @xmlref Corresponds to XML attribute Text. | |
PropertyDataTypeId varchar(300) foreign key references PropertyDataType(ID) on delete cascade, | |
---< @xmlRef Corresponds to XML attribute PDT. | |
IsArray bit default 0 | |
---< @xmlRef Corresponds to XML attribute Arra<. | |
); | |
GRANT DELETE ON dbo.InterfaceObjectProperty TO ETSFullAccess; | |
DENY DELETE ON dbo.InterfaceObjectProperty TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.InterfaceObjectProperty TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.InterfaceObjectProperty TO ETSFullAccess; | |
DENY INSERT ON dbo.InterfaceObjectProperty TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.InterfaceObjectProperty TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.InterfaceObjectProperty TO ETSFullAccess; | |
DENY UPDATE ON dbo.InterfaceObjectProperty TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.InterfaceObjectProperty TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.InterfaceObjectProperty TO ETSFullAccess; | |
GRANT SELECT ON dbo.InterfaceObjectProperty TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.InterfaceObjectProperty TO ETSWriteProjectAccess; | |
GO | |
-- InterfaceObjectPropertyTranslatedText -- | |
IF object_id('InterfaceObjectPropertyTranslatedText', 'U') IS NOT NULL DROP TABLE InterfaceObjectPropertyTranslatedText; | |
/** @brief Contains translated texts for the DatapointType table. | |
@access EtsInternal (delete also by EtsProject) | |
@xmlref LanguageData_t/Translation/Translation | |
@schema6ref (none) | |
@uniquekey UK(InterfaceObjectType[InterfaceObjectPropertyTranslatedText::InterfaceObjectTypeID]) + InterfaceObjectPropertyTranslatedText::Language + InterfaceObjectPropertyTranslatedText::Version | |
*/ | |
CREATE TABLE dbo.InterfaceObjectPropertyTranslatedText | |
( | |
InterfaceObjectPropertyID varchar(300) not null foreign key references InterfaceObjectType(ID) on delete cascade, ---< Foreign key to the DatapointType table | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/\@RefId. | |
[Language] languageid not null, ---< Specifies the language | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Identifier. | |
[Version] int not null default 0, ---< Specifies the version of the translation. | |
---< This is used by ETS import to prevent overwriting of newer entries by older entries. | |
---< @xmlref Corresponds to XML attribute LanguageData_t/\@Version. | |
TranslatedText nvarchar(255), ---< Translated Text | |
---< @xmlref Corresponds to XML attribute LanguageData_t/Translation/Translation[\@AttributeName='Text']/\@Text. | |
primary key (InterfaceObjectPropertyID , [Language]), | |
); | |
GRANT DELETE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSFullAccess; | |
DENY DELETE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSFullAccess; | |
DENY INSERT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSFullAccess; | |
DENY UPDATE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.InterfaceObjectPropertyTranslatedText TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSFullAccess; | |
GRANT SELECT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.InterfaceObjectPropertyTranslatedText TO ETSWriteProjectAccess; | |
GO | |
-- Manufacturer -- | |
IF object_id('Manufacturer', 'U') IS NOT NULL DROP TABLE Manufacturer; | |
/** @brief Represents a manufacturer. | |
@access EtsInternal | |
@xmlref ManufacturerData/Manufacturer. | |
The Id attribute is not represented explicitely in the database because it can be calculated from | |
other values. | |
@schema6ref MANUFACTURER, MANUFACTURER_COMPATIBILITY | |
*/ | |
CREATE TABLE dbo.Manufacturer | |
( | |
ID varchar(300) not null primary key nonclustered, ---< %Manufacturer ID allocated by the KNX %Association | |
KnxManufacturerID smallint not null check(KnxManufacturerID between 0 and 32767), | |
---< @xmlref Corresponds to XML attribute KnxManufacturerId. | |
[Name] nvarchar(255), ---< %Manufacturer name | |
---< @xmlref Corresponds to XML attribute Name. | |
DefaultLanguage languageid, ---< Default language for all products of the manufacturer, NULL if no default language is defined | |
---< @xmlref Corresponds to XML attribute DefaultLanguage. | |
OrderNumber varchar(max), ---< unused | |
CompatibilityGroup int, ---< Specifies membership in a manufacturer compatibility group. | |
---< All manufacturers with the same value in CompatibilityGroup | |
---< are compatible (appplication programs of one manufacturer may be downloaded into | |
---< devices from another manufacturer in the same compatibility group). | |
---< The numerical value of ManufacturerCompatibilityGroup is allocated by KNX, | |
---< 2 for the only currently existing compatibility group (ABB, BJE, ...). | |
---< @xmlref Corresponds to XML attribute CompatibilityGroup. | |
OrderNumberFormattingScript varchar(max) default null, ---< A script to be used for formatting the manufacturers order number. | |
---< @xmlref Corresponds to XML attribute OrderNumberFormattingScript. | |
PublicKey nvarchar(max) | |
); | |
CREATE CLUSTERED INDEX IX_ManufacturerKnxManuf ON dbo.Manufacturer ( KnxManufacturerID ); | |
GRANT DELETE ON dbo.Manufacturer TO ETSFullAccess; | |
DENY DELETE ON dbo.Manufacturer TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.Manufacturer TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.Manufacturer TO ETSFullAccess; | |
DENY INSERT ON dbo.Manufacturer TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.Manufacturer TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.Manufacturer TO ETSFullAccess; | |
DENY UPDATE ON dbo.Manufacturer TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.Manufacturer TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Manufacturer TO ETSFullAccess; | |
GRANT SELECT ON dbo.Manufacturer TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.Manufacturer TO ETSWriteProjectAccess; | |
GO | |
-- ManufacturerPublicKey -- | |
IF object_id('ManufacturerPublicKey', 'U') IS NOT NULL DROP TABLE ManufacturerPublicKey; | |
/** @brief Represents a ManufacturerPublicKey. | |
@access EtsInternal | |
@xmlref MasterData/Manufactuerer/PublicKey. | |
Public key used to validate the manufacturers project signature | |
*/ | |
CREATE TABLE dbo.ManufacturerPublicKey | |
( | |
ID varchar(300) not null primary key, ---< %Manufacturer ID allocated by the KNX %Association | |
ManufacturerID varchar(300) foreign key references Manufacturer(ID) not null, | |
---< @xmlref Corresponds to XML attribute KnxManufacturerId. | |
[Number] int, check (number > 0), ---< %Ordinal number of the key | |
---< @xmlref Corresponds to XML attribute Number. | |
Revoked bit, ---<If true, the key is no longer valid | |
---< @xmlref Corresponds to XML attribute Revoked. | |
[Key] nvarchar(max), ---< The public key itself | |
---< @xmlref Corresponds to XML attribute Key. | |
); | |
GRANT DELETE ON dbo.ManufacturerPublicKey TO ETSFullAccess; | |
DENY DELETE ON dbo.ManufacturerPublicKey TO ETSReadOnlyAccess; | |
DENY DELETE ON dbo.ManufacturerPublicKey TO ETSWriteProjectAccess; | |
GRANT INSERT ON dbo.ManufacturerPublicKey TO ETSFullAccess; | |
DENY INSERT ON dbo.ManufacturerPublicKey TO ETSReadOnlyAccess; | |
DENY INSERT ON dbo.ManufacturerPublicKey TO ETSWriteProjectAccess; | |
GRANT UPDATE ON dbo.ManufacturerPublicKey TO ETSFullAccess; | |
DENY UPDATE ON dbo.ManufacturerPublicKey TO ETSReadOnlyAccess; | |
DENY UPDATE ON dbo.ManufacturerPublicKey TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ManufacturerPublicKey TO ETSFullAccess; | |
GRANT SELECT ON dbo.ManufacturerPublicKey TO ETSReadOnlyAccess; | |
GRANT SELECT ON dbo.ManufacturerPublicKey TO ETSWriteProjectAccess; | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InitProjectData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - %Project Data | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- ---------------------------------------------------------------------------- | |
-- Project tables | |
-- ---------------------------------------------------------------------------- | |
-- Project | |
IF object_id('Project', 'U') IS NOT NULL DROP TABLE Project; | |
/** @brief Base table for project data. | |
@access EtsProject | |
@xmlref %Project | |
@schema6ref PROJECT | |
*/ | |
CREATE TABLE dbo.Project | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
[Name] nvarchar(50) not null, ---< Name entered by the user. Must be unique within the database. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/Name. | |
IpProjectID smallint check ((IpProjectID IS NULL) OR (IpProjectID BETWEEN 0 AND 4095)), ---< KNXnet/IP related %Project ID. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectId. | |
ProjectNumber nvarchar(50), ---< %Project number entered by the user | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectNumber. | |
ContractNumber nvarchar(50), ---< Contract number entered by the user | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ContractNumber. | |
ProjectStart datetime2(0), ---< Start date entered by the user | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectStart. | |
ProjectEnd datetime2(0), ---< End date entered by the user | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectEnd. | |
LastModified datetime2(0), ---< Set to the current date on import | |
---< @xmlref Corresponds to XML attribute ProjectInformation/LastModified. | |
ImportDate datetime2(0), ---< Set to the current date on import | |
---< @xmlref Not transported via XML. Set to current date on import. | |
ProjectPassword nvarchar(20),---< %Project password | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectPassword. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/CompletionStatus. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute ProjectInformation/Comment. | |
GroupAddressStyle varchar(15) not null check (GroupAddressStyle in ('TwoLevel', 'ThreeLevel', 'Free')), ---< The group address style of the project. This can be one of 'TwoLevel', 'ThreeLevel', 'Free'. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/GroupAddressStyle. | |
ProjectTracingLevel projecttracinglevels check (ProjectTracingLevel in ('None', 'OperationUsed', 'Detailed')), ---< Tracing Level enterd by the user. This can be one of 'None', 'OperationUsed', 'Detailed'. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectTracingLevel. | |
ProjectTracingPassword nvarchar(20),---< %Project tracing level password | |
---< @xmlref Corresponds to XML attribute ProjectInformation/ProjectTracingPassword. | |
Hide16BitGroupsFromLegacyPlugins bit default 0,---< If true, the project will not use 16 bit groups. This will prevent problems with older Plug-Ins that only support 15 bit groups. | |
---< @xmlref Corresponds to XML attribute ProjectInformation/CodePage. | |
[CodePage] varchar(100) check([CodePage] is null or [CodePage] in('us-ascii', 'iso-8859-1', 'iso-8859-2', 'iso-8859-3', 'iso-8859-4', 'iso-8859-5', 'iso-8859-6', 'iso-8859-7', 'iso-8859-8', 'iso-8859-9', 'iso-8859-10', 'iso-8859-13', 'iso-8859-15', 'utf-8') ) | |
); | |
CREATE INDEX IxProject ON dbo.Project([Name]); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Project TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Project TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Project TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Project TO ETSReadOnlyAccess; | |
GO | |
-- ProjectHistory | |
IF object_id('ProjectHistory', 'U') IS NOT NULL DROP TABLE ProjectHistory; | |
/** @brief Contains history comments added by the user. | |
@access EtsProject | |
@xmlref Project/ProjectInformation/HistoryEntries/HistoryEntry | |
@schema6ref PROJECT_HISTORY | |
*/ | |
CREATE Table dbo.ProjectHistory | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProjectID varchar(300) not null foreign key references dbo.Project(ID) on delete cascade, | |
---< Do not change after insert. | |
[Date] datetime2(0) not null, ---< Date and time of the history entry | |
---< @xmlref Corresponds to XML attribute Date. | |
[User] nvarchar(50), ---< Optional user name | |
---< @xmlref Corresponds to XML attribute User. | |
[Text] nvarchar(max), ---< Text entered by the user | |
---< @xmlref Corresponds to XML attribute Text. | |
[Detail] nvarchar(max), ---< Detailed information entered by the user | |
---< @xmlref Corresponds to XML attribute Detail. | |
); | |
CREATE INDEX IxProjectHistory on dbo.ProjectHistory(ProjectID,[Date]); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.ProjectHistory TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.ProjectHistory TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProjectHistory TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.ProjectHistory TO ETSReadOnlyAccess; | |
GO | |
-- ProjectTrace | |
IF object_id('ProjectTrace', 'U') IS NOT NULL DROP TABLE ProjectTrace; | |
/** @brief Contains trace information added by the system. | |
@access EtsProject | |
@xmlref Project/ProjectInformation/TraceEntries/TraceEntry | |
@schema6ref PROJECT_TRACES | |
*/ | |
CREATE TABLE dbo.ProjectTrace | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProjectID varchar(300) not null foreign key references dbo.Project(ID) on delete cascade, | |
---< Do not change after insert. | |
[Date] datetime2(3) not null, ---< Date and time of the traced entry | |
---< @xmlref Corresponds to XML attribute Date. | |
[UserName] nvarchar(50) not null, ---< mandatory user name | |
---< @xmlref Corresponds to XML attribute User. | |
[Description] nvarchar(max) not null, ---< mandatory description defined by the system | |
---< @xmlref Corresponds to XML attribute Comment | |
); | |
CREATE INDEX IxProjectTraces on dbo.ProjectTrace(ProjectID,[Date]); | |
GRANT INSERT, SELECT ON dbo.ProjectTrace TO ETSFullAccess; | |
GRANT INSERT, SELECT ON dbo.ProjectTrace TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ProjectTrace TO ETSReadOnlyAccess; | |
DENY DELETE, UPDATE ON dbo.ProjectTrace TO ETSFullAccess; | |
DENY DELETE, UPDATE ON dbo.ProjectTrace TO ETSWriteProjectAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.ProjectTrace TO ETSReadOnlyAccess; | |
GO | |
-- ToDoItems | |
CREATE TABLE dbo.ToDoItem | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
Description nvarchar(max) NULL, ---< The Description of the task. Must not be changed after insertion. | |
---< @xmlref Corresponds to XML attribute Description | |
ObjectPath varchar(900) NULL, ---< The path of the object the todo item belongs to. | |
---< @xmlref Corresponds to XML attribute ObjectPath | |
ProjectID varchar(300) not null foreign key references dbo.Project(ID) on delete cascade, --< Reference to Project | |
CurrentStatus todoitemstatus check (CurrentStatus in ('Open', 'Accomplished')), ---< The status of the todo item. This can be one of 'Open', 'Accomplished'. | |
---< @xmlref Corresponds to XML attribute Status | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.ToDoItem TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.ToDoItem TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.ToDoItem TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.ToDoItem TO ETSReadOnlyAccess; | |
GO | |
-- Installation | |
IF object_id('Installation', 'U') IS NOT NULL DROP TABLE Installation; | |
/** @brief Base table for project data. | |
@access EtsProject | |
@xmlref Project/Installations/Installation | |
*/ | |
CREATE TABLE dbo.Installation | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
ProjectID varchar(300) foreign key references dbo.Project(ID) on delete cascade, ---< Reference to Project. | |
---< Do not change after insert. | |
[Name] nvarchar(50) not null, ---< Name entered by the user. Must be unique within the installations of the project. | |
---< @xmlref Corresponds to XML attribute Name. | |
InstallationId smallint check((InstallationId IS NULL) OR (InstallationId BETWEEN 0 AND 15)), ---< KNXnet/IP related %Installation ID | |
---< @xmlref Corresponds to XML attribute InstallationId. | |
BCUKey bigint, ---< If not NULL, this will be used as access key for devices supporting authentication. | |
---< @xmlref Corresponds to XML attribute StandardBCUKey. | |
IPRoutingMulticastAddress varchar(50), ---< KNXnet/IP multicast address; if not given, 224.0.23.12 is implied. | |
---< @xmlref Corresponds to XML attribute IPRoutingMulticastAddress. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
DefaultLineID varchar(300) default null, | |
---< @xmlref Corresponds to XML attribute DefaultLine. | |
[BusAccessName] nvarchar(max) default null, ---< Name entered by the user. Must be unique within the installations of the project. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Name. | |
[BusAccessEdi] uniqueidentifier default null, ---< The Falcon EDI Guid. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Edi. | |
[BusAccessParameter] nvarchar(300) default null, ---< The Falcon EDI parameters. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Parameter. | |
[SplitType] varchar(10) default 'None' check (SplitType in ('None', 'Master', 'Split')), ---< The split type if the installation is split. | |
---< @xmlref Corresponds to XML attribute SplitType. | |
); | |
--CREATE UNIQUE INDEX IxInstallation ON dbo.Installation(ProjectID,[Name]); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Installation TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Installation TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Installation TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Installation TO ETSReadOnlyAccess; | |
GO | |
-- Building | |
IF object_id('Building', 'U') IS NOT NULL DROP TABLE Building; | |
/** @brief Contains buildings, rooms and cabinets (distribution panel). | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Buildings//BuildingPart | |
@schema6ref BUIDLING, ROOM | |
*/ | |
CREATE Table dbo.Building | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references dbo.Installation(ID) on delete cascade, ---< Reference to Installation. | |
---< Do not change after insert. | |
ParentID varchar(300), --foreign key references dbo.Building(ID), ---< Parent building; foreign key to $fkspec | |
[Type] varchar(20) check ( [Type] in ('Corridor', 'Stairway', 'Building', 'BuildingPart', 'Floor', 'Room', 'DistributionBoard')), ---< Specifies the building part type. | |
---< One of: | |
---< - 'Corridor' | |
---< - 'Stairway' | |
---< - 'Building' | |
---< - 'BuildingPart' | |
---< - 'Floor' | |
---< - 'Room' | |
---< - 'DistributionBoard' | |
---< @xmlref Corresponds to XML attribute Type. | |
[Name] nvarchar(255), ---< Name entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Number nvarchar(255), ---< Room/DistributionBoard number entered by the user | |
---< @xmlref Corresponds to XML attribute Number. | |
Description nvarchar(max), ---< Description entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
DefaultLineID varchar(300) default null | |
---< @xmlref Corresponds to XML attribute DefaultLine. | |
); | |
--CREATE UNIQUE INDEX IxBuilding On dbo.Building(InstallationID); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Building TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Building TO ETSFullAccess; | |
GRANT SELECT ON dbo.Building TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Building TO ETSReadOnlyAccess; | |
GO | |
-- Trade | |
IF object_id('Trade', 'U') IS NOT NULL DROP TABLE Trade; | |
/** @brief Contains trades. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Trades//Trade | |
@schema6ref FUNCTION | |
*/ | |
CREATE Table dbo.Trade | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references dbo.Installation(ID) on delete cascade, ---< Reference to Installation. | |
---< Do not change after insert. | |
ParentID varchar(300), --foreign key references dbo.Trade(ID), ---< Parent trade; foreign key to $fkspec | |
[Name] nvarchar(255) not null, ---< Name entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Number nvarchar(255), ---< Room/DistributionBoard number entered by the user | |
---< @xmlref Corresponds to XML attribute Number. | |
Description nvarchar(max), ---< Description entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[Comment] nvarchar(max) ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
); | |
--CREATE UNIQUE INDEX IxTrade On dbo.Trade(InstallationID,UniqueName); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Trade TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Trade TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Trade TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Trade TO ETSReadOnlyAccess; | |
GO | |
-- Area | |
IF object_id('Area', 'U') IS NOT NULL DROP TABLE Area; | |
/** @brief Represents an area in the project topology. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology/Area | |
@schema6ref AREA | |
*/ | |
CREATE Table dbo.Area | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references dbo.Installation(ID) on delete cascade, ---< Reference to Installation. | |
ProjectID varchar(300) not null, | |
---< Do not change after insert. | |
[Name] nvarchar(255), ---< %Area name entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), ---< %Area description entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
Address smallint check(Address between 0 and 15), ---< %Area address [0-15] | |
---< @xmlref Corresponds to XML attribute Address. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[Comment] nvarchar(max) ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Area TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Area TO ETSFullAccess; | |
GRANT SELECT ON dbo.Area TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Area TO ETSReadOnlyAccess; | |
GO | |
-- Line | |
IF object_id('Line', 'U') IS NOT NULL DROP TABLE Line; | |
/** @brief Represents a line in the project topology. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology/Area/Line | |
@schema6ref LINE | |
*/ | |
CREATE Table dbo.Line | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
AreaID varchar(300) not null foreign key references dbo.Area(ID) on delete cascade, ---< Reference to Area. | |
[Name] nvarchar(255), ---< %Line name as entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), ---< %Line description as entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
Address smallint check(Address between 0 and 15), ---< %Line address [0�15] | |
---< @xmlref Corresponds to XML attribute Address. | |
DomainAddressIsChecked bit, ---< 1 if the DomainAddress has been successfully scanned | |
---< @xmlref Corresponds to XML attribute DomainAddressIsChecked. | |
DomainAddress bigint, ---< For open media (PL, RF), the Domain Address | |
---< @xmlref Corresponds to XML attribute DomainAddress. | |
MediumTypeID varchar(300) not null foreign key references dbo.MediumType(ID), ---< Assigned medium type; foreign key to $fkspec | |
---< @xmlref Corresponds to XML attribute MediumTypeRefId. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
[BusAccessName] nvarchar(max) default null, ---< Name entered by the user. Must be unique within the installations of the project. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Name. | |
[BusAccessEdi] uniqueidentifier default null, ---< The Falcon EDI Guid. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Edi. | |
[BusAccessParameter] nvarchar(300) default null, ---< The Falcon EDI parameters. | |
---< @xmlref Corresponds to XML attribute BusAccess/@Parameter. | |
IPRoutingMulticastAddress varchar(50) default '224.0.23.12',---< Multicast IP v4 Address for used routing | |
---< @xmlref Corresponds to XML attribute RoutingMCAddress. | |
MulticastTTL smallint default 16---< Multicast TTL for used routing | |
---< @xmlref Corresponds to XML attribute MulticastTTL. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Line TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Line TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.Line TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Line TO ETSReadOnlyAccess; | |
GO | |
-- GroupRange | |
IF object_id('GroupRange', 'U') IS NOT NULL DROP TABLE GroupRange; | |
/** @brief Represents a group range in a project. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/GroupAdresses//GroupRange | |
@schema6ref MAINGROUP,MIDDLEGROUP | |
@additionalrestrictions | |
- MaxAddress >= MinAddress | |
- GroupRamges must not overlap | |
*/ | |
CREATE Table dbo.GroupRange | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references dbo.Installation(ID) on delete cascade, ---< Reference to Installation. | |
---< Do not change after insert. | |
ParentID varchar(300) foreign key references dbo.GroupRange(ID), ---< Parent group range; foreign key to $fkspec | |
[Name] nvarchar(255), ---< Name entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), ---< Description entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
RangeStart int check(RangeStart between 1 and 65535), ---< Lowest address in range [1...65535] | |
---< @xmlref Corresponds to XML attribute MinAddress. | |
RangeEnd int check(RangeEnd between 1 and 65535), ---< Highest address in range [MinAddress...65535] | |
---< @xmlref Corresponds to XML attribute MaxAddress. | |
Unfiltered bit not null default 0, ---< Default for all GroupAddresses in this range | |
---< @xmlref Corresponds to XML attribute Unfiltered. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
); | |
CREATE CLUSTERED INDEX IxGroupRangeInstallation On dbo.GroupRange(InstallationID); | |
CREATE NONCLUSTERED INDEX IxGroupRangeParent On dbo.GroupRange(ParentID); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.GroupRange TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.GroupRange TO ETSFullAccess; | |
GRANT SELECT ON dbo.GroupRange TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.GroupRange TO ETSReadOnlyAccess; | |
GO | |
-- GroupAddress | |
IF object_id('GroupAddress', 'U') IS NOT NULL DROP TABLE GroupAddress; | |
/** @brief Represents a single group address in a project. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/GroupAdresses/GroupAddress | |
@schema6ref SUBGROUP | |
*/ | |
CREATE Table dbo.GroupAddress | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references Installation(ID) on delete cascade, ---< Reference to Installation. | |
GroupRangeID varchar(300) not null foreign key references GroupRange(ID), ---< Reference to GroupRange. | |
---< Do not change after insert. | |
[Name] nvarchar(255), ---< Name entered by the user | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), ---< Description entered by the user | |
---< @xmlref Corresponds to XML attribute Description. | |
Address int check(Address between 1 and 65535), ---< Numerical group address [1...65535] | |
---< @xmlref Corresponds to XML attribute Address. | |
Unfiltered bit not null default 0, ---< Pass this group address through couplers | |
---< @xmlref Corresponds to XML attribute Unfiltered. | |
Central bit not null default 0, ---< This is a central group address | |
---< @xmlref Corresponds to XML attribute Central. | |
[Global] bit not null default 0, ---< This is a global group address | |
---< @xmlref Corresponds to XML attribute Global. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
[DatapointType] nvarchar(max), | |
); | |
CREATE CLUSTERED INDEX IxGroupAddressInstallation On dbo.GroupAddress(InstallationID); | |
CREATE NONCLUSTERED INDEX IxGroupAddressRange On dbo.GroupAddress(GroupRangeID); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.GroupAddress TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.GroupAddress TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.GroupAddress TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.GroupAddress TO ETSReadOnlyAccess; | |
GO | |
-- Device | |
IF object_id('Device', 'U') IS NOT NULL DROP TABLE Device; | |
/** @brief Decribes a device in a project. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance | |
@additionalrestrictions | |
- Product[Device.ProductID].HardwareID = Hardware2Program[Device.HardwareID].ID | |
- If not NULL, Device.LineID, Device.RoomID and Device.TradeID must reference entities in the same project | |
*/ | |
CREATE Table dbo.Device | |
( | |
ID varchar(300) primary key nonclustered, ---< Artificial primary key | |
InstallationID varchar(300) not null foreign key references Installation(ID) on delete cascade, ---< Reference to Installation. | |
---< Do not change after insert. | |
[Name] nvarchar(255), | |
---< @xmlref Corresponds to XML attribute Name. | |
Description nvarchar(max), | |
---< @xmlref Corresponds to XML attribute Description. | |
LineID varchar(300) foreign key references dbo.Line(ID), ---< The line this device is assigned to; foreign key to $fkspec | |
---< In XML this is the parent Line element (NULL for Topology/UnassignedDevices/DeviceInstance). | |
BuildingID varchar(300) foreign key references dbo.Building(ID), ---< The room or cabinet this device is assigned to; foreign key to $fkspec | |
---< In XML this is represented by BuildingPart/DeviceInstanceRef | |
TradeID varchar(300) foreign key references dbo.Trade(ID), ---< The trade this device is assigned to; foreign key to $fkspec | |
---< In XML this is represented by Trade/DeviceInstanceRef | |
ProductID varchar(300) not null foreign key references [Product](ID), ---< The assigned product; foreign key to $fkspec | |
---< @xmlref Corresponds to XML attribute ProductRefId. | |
Hardware2ProgramID varchar(300) foreign key references Hardware2Program(ID), ---< The assigned hardware and application program(s); foreign key to $fkspec | |
---< @xmlref Corresponds to XML attribute Hardware2ProgramRefId. | |
Address smallint check(Address between 0 and 255), ---< %Device part of the individual address (lower 8 bits); must be $check | |
---< @xmlref Corresponds to XML attribute Address. | |
InstallationHints nvarchar(max), ---< %Installation hints entered by the user | |
---< @xmlref Corresponds to XML attribute InstallationHints. | |
CompletionStatus completionstatus check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted') ), ---< Completion status. This can be one of 'Undefined', 'Editing', 'FinishedDesign','FinishedCommissioning','Tested','Accepted'. | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[Comment] nvarchar(max), ---< Comment entered by the user | |
---< @xmlref Corresponds to XML attribute Comment. | |
IndividualAddressLoaded bit, ---< 1 if the individual address has been programmed | |
---< @xmlref Corresponds to XML attribute IndividualAddressLoaded. | |
ApplicationProgramLoaded bit, ---< 1 if the application program has been programmed | |
---< @xmlref Corresponds to XML attribute ApplicationProgramLoaded. | |
ParametersLoaded bit, ---< 1 if the parameters have been programmed | |
---< @xmlref Corresponds to XML attribute ParametersLoaded. | |
CommunicationPartLoaded bit, ---< 1 if the group communication tables have been programmed | |
---< @xmlref Corresponds to XML attribute CommunicationPartLoaded. | |
MediumConfigLoaded bit, ---< 1 if the medium-type specific data has been programmed (PL: repeater flag) | |
---< @xmlref Corresponds to XML attribute MediumConfigLoaded. | |
LastModified datetime2(3), ---< Date/time of last modification | |
---< @xmlref Corresponds to XML attribute LastModified. | |
LastDownload datetime2(3), ---< Date/time of last download | |
---< @xmlref Corresponds to XML attribute LastDownload. | |
LoadedImage varbinary(max), ---< Used for differential download: Image data written to the device the last time. | |
---< Serialization format (all data stored in little-endian format): | |
---< - DWORD SerializationVersion (currently 0x00010001) | |
---< - DWORD SegmentCount (number of segments) | |
---< - then, for each segment: | |
---< - RESOURCE_LOCATION Location (Segment start) | |
---< - DWORD Size (Segment length) | |
---< - BYTE Flags (Bit#0 set if segment has data, Bit#1 set if segment has mask) | |
---< - BYTE Data[Size] (Segment data if present) | |
---< - BYTE Mask[Size] (Segment mask if present) | |
---< | |
---< @xmlref Corresponds to XML attribute LoadedImage. | |
CheckSums varbinary(max), ---< Used for differential download: Values of the checksums. | |
---< Serialization format (all data stored in little-endian format): | |
---< - DWORD SerializationVersion (currently 0x00010001) | |
---< - DWORD Flavour (1 for System B / $0705 MCB format = the only one currently supported) | |
---< - If Flavour = 1, the following follows: | |
---< - DWORD ObjectCount (The number of object data following) | |
---< - then, for each object: | |
---< - BYTE ObjectIndex (The interface object index) | |
---< - DWORD SegmentCount (Number of segments in MCB table) | |
---< - then, for each segment: | |
---< - BYTE Valid (1 if the CRC is valid) | |
---< - DWORD Crc (the CRC) | |
---< | |
---< @xmlref Corresponds to XML attribute CheckSums. | |
IsCommunicationObjectVisibilityCalculated bit default 0, ---< Flag whether visibility has already benn calculated. | |
[IPConfigAssign] varchar(10) default null check( [IPConfigAssign] is null or [IPConfigAssign] in ('Auto','Fixed')), ---< The IP config assignment method. This can be one of 'Auto', 'Fixed' | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/IPConfig/@Assign | |
[IPConfigIPAddress] ipv4address default null, ---< The IP address. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/IPConfig/@IPAddress | |
[IPConfigSubnetMask] ipv4address default null,---< The subnet mask. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/IPConfig/@SubnetMask | |
[IPConfigDefaultGateway] ipv4address default null,---< The default gateway. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/IPConfig/@DefaultGateway | |
[IPConfigMACAddress] varchar(50) default null,---< The MAC address. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/IPConfig/@MACAddress | |
[Broken] bit default 0,---< The Broken flag. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/@Broken | |
[SerialNumber] nvarchar(max),---< The Serialnumber. | |
---< @xmlref Corresponds to Project/Installations/Installation/Topology//DeviceInstance/@SerialNumber | |
---< @xmlref Corresponds to XML attribute CompletionStatus. | |
[UniqueId] uniqueidentifier, ---< A unique device identifier | |
); | |
CREATE INDEX IxDeviceAddress on dbo.Device(LineID, Address); | |
CREATE CLUSTERED INDEX IX_DeviceInstallationID ON dbo.Device ( InstallationID ); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Device TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Device TO ETSFullAccess; | |
GRANT SELECT ON dbo.Device TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Device TO ETSReadOnlyAccess; | |
GO | |
-- AdditionalDeviceAddress | |
IF object_id('AdditionalDeviceAddress', 'U') IS NOT NULL DROP TABLE AdditionalDeviceAddress; | |
/** @brief Contains additional addresses for a device. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance/AdditionalAddresses/Address | |
*/ | |
CREATE Table dbo.AdditionalDeviceAddress | |
( | |
DeviceID varchar(300) not null foreign key references dbo.Device(ID) on delete cascade, ---< Reference to Device. | |
---< Do not change after insert. | |
Address smallint check(Address between 1 and 255), ---< %Device part of the individual address (lower 8 bits); must be $check | |
---< @xmlref Corresponds to XML element Address. | |
primary key (DeviceID, Address) | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AdditionalDeviceAddress TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AdditionalDeviceAddress TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.AdditionalDeviceAddress TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.AdditionalDeviceAddress TO ETSReadOnlyAccess; | |
GO | |
-- DeviceObject | |
IF object_id('DeviceObject', 'U') IS NOT NULL DROP TABLE DeviceObject; | |
/** @brief Used for communication object instances in the project. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance/ComObjectInstanceRefs/ComObjectInstanceRef. | |
The Id attribute is not represented explicitely in the database (TODO: [for what] is this needed?). | |
@schema6ref DEVICE_OBJECT | |
@additionalrestrictions | |
- There must be exactly one entry in DeviceObject for each CommunicationObject | |
with CommunicationObject[DeviceObject.CommunicationObjectID].ProgramID = Device[DeviceObject.DeviceID].ProgramID | |
*/ | |
CREATE Table dbo.DeviceObject | |
( | |
ID uniqueidentifier primary key NONCLUSTERED, ---< Artificial primary key | |
DeviceID varchar(300) not null foreign key references dbo.Device(ID) on delete cascade, ---< Reference to Device. | |
---< Do not change after insert. | |
CommunicationObjectRefID varchar(300) not null foreign key references CommunicationObjectRef(ID), ---< Reference to CommunicationObjectRef. | |
---< Do not change after insert. | |
---< @xmlref Corresponds to XML attribute RefId. | |
[Text] nvarchar(255), ---< Object name (can be set by Plug-Ins) | |
---< @xmlref Corresponds to XML attribute Text. | |
[FunctionText] nvarchar(255), ---< Object function (can be set by Plug-Ins) | |
---< @xmlref Corresponds to XML attribute FunctionText. | |
[Description] nvarchar(max), ---< Object description | |
---< @xmlref Corresponds to XML attribute Description. | |
IsActive bit default 0, --not null, ---< 1 if this communication object is currently active (by the parameter visibility mechanism) | |
---< @xmlref Not transported via XML. | |
---< On XML export, rows with IsActive = 0 are omitted | |
DatapointType varchar(max), ---< Datapoint main type; foreign key to $fkspec | |
--DatapointSubTypeID varchar(300), ---< Datapoint sub type; foreign key (together with DatapointTypeID) to DatapointSubtype. | |
---< @xmlref Corresponds to XML attribute DatapointType | |
ReadFlag bit , ---< ReadEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute ReadFlag. | |
WriteFlag bit , ---< WriteEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute WriteFlag. | |
CommunicationFlag bit , ---< CommunicationEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute CommunicationFlag. | |
TransmitFlag bit, ---< TransmitEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute TransmitFlag. | |
UpdateFlag bit, ---< UpdateEnabled flag [0 or 1] | |
---< @xmlref Corresponds to XML attribute UpdateFlag. | |
ReadOnInitFlag bit, ---< ReadOnInit flag [0 or 1] (for System B) | |
---< @xmlref Corresponds to XML attribute ReadOnInitFlag. | |
Priority varchar(6) check(Priority in ('Low', 'High', 'Alert')), | |
---< Encoded as in the standard group object table, i.e.: | |
---< - 1 High | |
---< - 2 Alarm | |
---< - 3 Low | |
---< @xmlref Corresponds to XML attribute Priority. | |
ObjectSize varchar(20) not null check(ObjectSize in ('1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData')), ---< Data size of the communciation object. | |
---< This must be one of '1 Bit', '2 Bit','3 Bit','4 Bit','5 Bit','6 Bit','7 Bit','1 Byte','2 Bytes','3 Bytes','4 Bytes','5 Bytes','6 Bytes','7 Bytes','8 Bytes','9 Bytes','10 Bytes','11 Bytes','12 Bytes','14 Bytes', 'LegacyVarData' | |
---< @xmlref Holds a local copy of CommunicationObjectRef.ObjectSize or CommunicationObject.ObjectSize | |
Number bigint not null, ---< @xmlref Holds a local copy of CommunicationObject.Number | |
); | |
CREATE CLUSTERED INDEX IX_DeviceObjectDevice ON dbo.DeviceObject ( DeviceID ); | |
CREATE NONCLUSTERED INDEX IX_DeviceObjectComRef ON dbo.DeviceObject ( CommunicationObjectRefID ); | |
CREATE NONCLUSTERED INDEX IX_IsActive ON dbo.DeviceObject (IsActive); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceObject TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceObject TO ETSFullAccess; | |
GRANT SELECT ON dbo.DeviceObject TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.DeviceObject TO ETSReadOnlyAccess; | |
GO | |
-- DeviceParameter | |
IF object_id('DeviceParameter', 'U') IS NOT NULL DROP TABLE DeviceParameter; | |
/** @brief Used for parameter instances in the project. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance/ParameterInstanceRefs/ParameterInstanceRef | |
The Id attribute is not represented explicitely in the database (TODO: [for what] is this needed?). | |
@schema6ref DEVICE_PARAMETER | |
@additionalrestrictions | |
- There must be exactly one entry in DeviceParameter for each Parameter | |
with Parameter[DeviceParameter.ParameterID].ProgramID = Hardware2Program[Device[DeviceParameter.DeviceID].Hardware2ProgramID].ApplicationProgramID having ProgramType = 0, | |
plus one entry in DeviceParameter for each Parameter | |
with Parameter[DeviceParameter.ParameterID].ProgramID = Hardware2Program[Device[DeviceParameter.DeviceID].Hardware2ProgramID].ApplicationProgram2ID having ProgramType = 1 (if ApplicationProgram2ID is non-NULL). | |
*/ | |
CREATE Table dbo.DeviceParameter | |
( | |
ID uniqueidentifier primary key NONCLUSTERED, ---< Artificial primary key | |
DeviceID varchar(300) not null foreign key references dbo.Device(ID) on delete cascade, ---< Reference to Device. | |
---< Do not change after insert. | |
ParameterRefID varchar(300) not null foreign key references ParameterRef(ID), ---< Reference to ParameterRef. | |
---< Do not change after insert. | |
---< @xmlref Corresponds to XML attribute RefId. | |
IsActive bit, ---< 1 if this parameter is currently active (by the parameter visibility mechanism) | |
---< @xmlref Not transported via XML. | |
---< On XML export, rows with IsActive = 0 are omitted | |
[Value] sql_variant, ---< Current value | |
---< @xmlref Corresponds to XML attribute Value | |
); | |
CREATE CLUSTERED INDEX IX_DeviceParameterDevice ON dbo.DeviceParameter ( DeviceID ); | |
CREATE NONCLUSTERED INDEX IX_DeviceParameterParamRef ON dbo.DeviceParameter ( ParameterRefID ); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceParameter TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceParameter TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DeviceParameter TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.DeviceParameter TO ETSReadOnlyAccess; | |
GO | |
-- Association | |
IF object_id('Connector', 'U') IS NOT NULL DROP TABLE Connector; | |
/** @brief Represents an association between a group object and a group address. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance/ComObjectInstanceRefs/ComObjectInstanceRef/Connectors/Send | |
and .../Receive | |
@schema6ref SUBGROUP_TO_OBJECT | |
*/ | |
CREATE Table dbo.Connector | |
( | |
ID varchar(300) primary key NONCLUSTERED, ---< Artificial primary key | |
GroupAddressID varchar(300) not null foreign key references dbo.GroupAddress(ID), ---< Reference to GroupAddress. | |
---< Do not change after insert. | |
---< @xmlref Corresponds to XML attribute GroupAddressRefId | |
DeviceObjectID uniqueidentifier not null foreign key references dbo.DeviceObject(ID) on delete cascade, ---< Reference to DeviceObject. | |
---< Do not change after insert. | |
[Send] bit not null, ---< 1 if this is the sending association for the referenced device object | |
---< @xmlref Corresponds to XML element Send or Receive | |
Acknowledge bit not null default 0, ---< 1 if this association has the Ack flag (on PL this means that the device shall send a L2 ACK for the group address), | |
---< @xmlref Corresponds to XML attribute Acknowledge. | |
DeviceID varchar(300) not null-- foreign key references dbo.Device(ID), ---< Reference to Device (added for performance reasons). | |
); | |
CREATE CLUSTERED INDEX IX_ConnectorByDeviceObject ON dbo.Connector(DeviceObjectID); | |
CREATE NONCLUSTERED INDEX IX_ConnectorByGroupAddress ON dbo.Connector(GroupAddressID); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Connector TO ETSWriteProjectAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.Connector TO ETSFullAccess; | |
GRANT SELECT ON dbo.Connector TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.Connector TO ETSReadOnlyAccess; | |
GO | |
-- AdditionalGroupAddress | |
IF object_id('AdditionalGroupAddress', 'U') IS NOT NULL DROP TABLE AdditionalGroupAddress; | |
/** @brief Contains group addresses manually added to the filter table. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology/Area/Line/AdditionalGroupAddresses/GroupAddressRef | |
*/ | |
CREATE Table dbo.AdditionalGroupAddress | |
( | |
LineID varchar(300) not null foreign key references dbo.Line(ID), ---< Reference to Line. | |
---< Do not change after insert. | |
InstallationID varchar(300) not null foreign key references dbo.Installation(ID) on delete cascade, ---< Reference to Installation. | |
---< Do not change after insert. | |
GroupAddress int not null, | |
---< Do not change after insert. | |
---< @xmlref Corresponds to XML attribute Address | |
primary key (LineID, GroupAddress) | |
); | |
create unique index IxAdditionalGroupAddress on dbo.AdditionalGroupAddress(LineID,GroupAddress); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AdditionalGroupAddress TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AdditionalGroupAddress TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.AdditionalGroupAddress TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.AdditionalGroupAddress TO ETSReadOnlyAccess; | |
GO | |
-- DeviceBinaryData | |
IF object_id('DeviceBinaryData', 'U') IS NOT NULL DROP TABLE DeviceBinaryData; | |
/** @brief BLOB storage for use by Plug-Ins. | |
@access EtsProject | |
@xmlref Project/Installations/Installation/Topology//DeviceInstance/BinaryData/BinaryData | |
The Id attribute is not represented explicitely in the database (TODO: [for what] is this needed?). | |
@schema6ref DEVICE_EXT_DATA | |
*/ | |
CREATE Table dbo.DeviceBinaryData | |
( | |
ID varchar(300) primary key, ---< Artificial primary key | |
DeviceID varchar(300) not null foreign key references dbo.Device(ID) on delete cascade, ---< Primary key and foreign key to $fkspec. | |
---< Do not change after insert. | |
BinaryDataID varchar(300) foreign key references ApplicationBinaryData(ID), ---< References ApplicationBinaryData | |
---< @xmlref Corresponds to XML attribute RefId. | |
[Name] varchar(50), ---< May identify the data. | |
---< @xmlref Corresponds to XML attribute Name | |
Data varbinary(max) ---< Arbitrary data | |
---< @xmlref Corresponds to XML element Data | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceBinaryData TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.DeviceBinaryData TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.DeviceBinaryData TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.DeviceBinaryData TO ETSReadOnlyAccess; | |
GO | |
-- UserFiles | |
IF object_id('UserFile', 'U') IS NOT NULL DROP TABLE UserFile; | |
/** @brief Base table for project user files. | |
@access EtsProject | |
@xmlref Project/UserFiles/UserFile | |
*/ | |
CREATE TABLE dbo.UserFile | |
( | |
ID varchar(50) primary key, | |
ProjectID varchar(300) foreign key references dbo.Project(ID) on delete cascade, ---< Reference to Project. | |
---< Do not change after insert. | |
[Filename] nvarchar(300) not null, ---< the filename of the file. This must be unique inside the project. | |
---< @xmlref Corresponds to XML attribute Filename. | |
[Comment] nvarchar(max) default null, ---< The comment entered by the user. | |
---< @xmlref Corresponds to XML attribute Comment. | |
[Data] varbinary(max) default null, ---< The binary data of the file. Not existing in schema, because contained as binary file inside PNXPROJ container. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.UserFile TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.UserFile TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.UserFile TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.UserFile TO ETSReadOnlyAccess; | |
GO | |
-- AddinData | |
IF object_id('AddinData', 'U') IS NOT NULL DROP TABLE AddinData; | |
/** @brief Base table for Add-In data files. | |
@access EtsProject | |
@xmlref Project/AddinData/AddinData | |
*/ | |
CREATE TABLE dbo.AddinData | |
( | |
ID varchar(50) primary key, | |
ProjectID varchar(300) foreign key references dbo.Project(ID) on delete cascade,---< Reference to Project. | |
---< Do not change after insert. | |
AddinID nvarchar(max) not null, ---< Unique identifier of the addin. Provided by KNX through Add-In registration. | |
---< @xmlref Corresponds to XML attribute AddinId. | |
[Name] varchar(50) not null, ---< the name of the Add-In data. | |
---< @xmlref Corresponds to XML attribute Name. | |
[Data] varbinary(max) default null, ---< The binary data of the file. Not existing in schema, because contained as binary file inside PNXPROJ container. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AddinData TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.AddinData TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.AddinData TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.AddinData TO ETSReadOnlyAccess; | |
GO | |
-- SplitInfo -- | |
IF object_id('SplitInfo', 'U') IS NOT NULL DROP TABLE SplitInfo; | |
/** @brief Table for split/merge information data files. | |
@access EtsProject | |
@xmlref Project/SplitInfos/SplitInfo | |
*/ | |
CREATE TABLE dbo.SplitInfo | |
( | |
ID varchar(50) primary key, | |
InstallationID varchar(300) foreign key references dbo.Installation(ID) on delete cascade,---< Reference to Project. | |
---< Do not change after insert. | |
Cookie uniqueidentifier not null, ---< Unique identifier identifying the split. The cookie exists in both the master and split installation. | |
---< @xmlref Corresponds to XML attribute Cookie. | |
ObjectPath varchar(max) not null, ---< The unique path identifying the root object of the split. | |
---< @xmlref Corresponds to XML attribute ObjectPath. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.SplitInfo TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.SplitInfo TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.SplitInfo TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.SplitInfo TO ETSReadOnlyAccess; | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InitRoles] | |
-------------------------------------------------------------------------------- | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- EtsInternal has read/write access to all data | |
-- This is used only for import and database maintenance | |
-- CREATE APPLICATION ROLE EtsInternal WITH PASSWORD = '#EtsRoleInternalPwd#'; | |
-- EtsProject has read access to master and product data, | |
-- read/write access to project data (this is the normal ETS role) | |
-- CREATE APPLICATION ROLE EtsProject WITH PASSWORD = '#EtsRoleProjectPwd#'; | |
-- EtsProjectTest has read access to master and product data, | |
-- read/write access to project data (this is the normal ETS role, but unregistered products set to registration status product testing can be used in projects) | |
-- CREATE APPLICATION ROLE EtsProjectTest WITH PASSWORD = '#EtsRoleProjectTestPwd#'; | |
-- EtsReadOnly only has read-only access to all data | |
-- CREATE APPLICATION ROLE EtsReadOnly WITH PASSWORD = '#EtsRoleReadOnlyPwd#'; | |
-- EtsManufacturer has read access to master and product data, | |
-- CREATE APPLICATION ROLE EtsManufacturer WITH PASSWORD = '#EtsRoleManufacturerPwd#'; | |
-- EXEC sp_addrolemember 'EtsReadOnly', N'EtsInternal' | |
-- EXEC sp_addrolemember 'EtsReadOnly', N'EtsReadOnly' | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertAddinData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a area | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertAddinData') | |
BEGIN | |
DROP Procedure dbo.usp_InsertAddinData | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertAddinData | |
( | |
@id varchar(300), | |
@projectId varchar(300), | |
@addinId nvarchar(max), | |
@name nvarchar(255) = null | |
) | |
AS | |
INSERT INTO AddinData (ID,ProjectID,AddinID,[Name]) VALUES (@id,@projectId,@addinId,@name) | |
GO | |
GRANT EXEC ON dbo.usp_InsertAddinData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertAddinData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertAddinData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertAdditionalDeviceAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a additional device address | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertAdditionalDeviceAddress') | |
BEGIN | |
DROP Procedure dbo.usp_InsertAdditionalDeviceAddress | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertAdditionalDeviceAddress | |
( | |
@deviceId varchar(300), | |
@address int | |
) | |
AS | |
insert into AdditionalDeviceAddress (DeviceID, Address) values (@deviceId, @address) | |
GO | |
GRANT EXEC ON dbo.usp_InsertAdditionalDeviceAddress TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertAdditionalDeviceAddress TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertAdditionalDeviceAddress TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertApplicationProgram] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure imports all applicaton program data into database | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertApplicationProgram') | |
BEGIN | |
DROP Procedure dbo.usp_InsertApplicationProgram | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertApplicationProgram | |
( | |
@applicationProgramWildcardId varchar(300) | |
) | |
AS | |
insert into dbo.ApplicationProgram select ID, ManufacturerID, [Name], Description, ApplicationNumber, ApplicationVersion, OriginalManufacturerID, ProgramType, | |
MaskID, MinEtsVersion, HelpFile, HelpTopic, PEIType, Linkable, LoadProcedureStyle, DynamicTableManagement, AddressTableMaxEntries, AssociationTableMaxEntries, | |
PreEts4Style, DefaultLanguage, NonRegRelevantDataVersion, null, AddressTableOffset, null, | |
AssociationTableOffset, null, ComObjectTableOffset, Hash, LoadProcedures, EtsDownloadPlugin, EtsUiPlugin, EtsDataHandler, | |
ReplacesVersions, ConvertedFromPreEts4Data, RequiresExternalSoftware, Broken, EtsDataHandlerCapabilities, IPConfig, AdditionalAddressesCount, DownloadInfoIncomplete, CreatedFromLegacySchemaVersion from #ApplicationProgram | |
insert into dbo.ApplicationProgramDynamic select * from #ApplicationProgramDynamic | |
insert into dbo.DeviceCompare select * from #DeviceCompare | |
insert into dbo.ApplicationProgramOption select * from #ApplicationProgramOption | |
insert into dbo.ApplicationSegment select * from #ApplicationSegment; | |
-- update segment entries in application program table now | |
merge dbo.ApplicationProgram as Target | |
using( select ID, AddressTableSegmentID, AssociationTableSegmentID, ComObjectTableSegmentID from #ApplicationProgram) as Source | |
on ( Target.ID = Source.ID) | |
when matched then | |
update set Target.AddressTableSegmentID = Source.AddressTableSegmentID, Target.AssociationTableSegmentID=Source.AssociationTableSegmentID, Target.ComObjectTableSegmentID=Source.ComObjectTableSegmentID; | |
insert into dbo.ParameterType select * from #ParameterType | |
insert into dbo.ParameterTypeNumber select * from #ParameterTypeNumber | |
insert into dbo.ParameterTypeTime select * from #ParameterTypeTime | |
insert into dbo.ParameterTypeFloat select * from #ParameterTypeFloat | |
insert into dbo.ParameterTypeText select * from #ParameterTypeText | |
insert into dbo.ParameterTypeDate select * from #ParameterTypeDate | |
insert into dbo.ParameterTypePicture select * from #ParameterTypePicture | |
insert into dbo.ParameterTypeIPAddress select * from #ParameterTypeIPAddress | |
insert into dbo.ParameterTypeRestriction select * from #ParameterTypeRestriction | |
insert into dbo.ParameterEnumValue select * from #ParameterEnumValue | |
insert into dbo.ParameterCalculation select * from #ParameterCalculation | |
insert into dbo.ParameterUnion select * from #ParameterUnion | |
insert into dbo.Parameter select * from #Parameter | |
insert into dbo.ParameterMemory select * from #ParameterMemory | |
insert into dbo.ParameterProperty select * from #ParameterProperty | |
insert into dbo.ParameterRef select * from #ParameterRef | |
insert into dbo.[ParameterCalculation.LParameter] select * from #LParameter | |
insert into dbo.[ParameterCalculation.RParameter] select * from #RParameter | |
insert into dbo.CommunicationObject select * from #CommunicationObject | |
insert into dbo.CommunicationObjectRef select * from #CommunicationObjectRef | |
insert into dbo.AddressFixup select * from #AddressFixup | |
insert into dbo.ApplicationBinaryData select * from #ApplicationBinaryData | |
insert into dbo.ApplicationProgramBaggage select * from #ApplicationProgramBaggage | |
--translations | |
insert into dbo.CommunicationObjectRefTranslatedText select * from #CommunicationObjectRefTranslatedText | |
insert into dbo.CommunicationObjectTranslatedText select * from #CommunicationObjectTranslatedText | |
insert into dbo.ParameterRefTranslatedText select * from #ParameterRefTranslatedText | |
insert into dbo.ParameterTranslatedText select * from #ParameterTranslatedText | |
insert into dbo.ParameterEnumValueTranslatedText select * from #ParameterEnumValueTranslatedText | |
insert into dbo.ApplicationProgramTranslatedText select * from #ApplicationProgramTranslatedText | |
insert into dbo.ApplicationProgramDynamicTranslatedText select * from #ApplicationProgramDynamicTranslatedText | |
insert into ApplicationProgramLanguageVersion select * from #ApplicationProgramLanguageVersion | |
-- update also non-reg fields of shapes | |
declare @applicationProgramId varchar(300) = (select ID from #ApplicationProgram) | |
exec dbo.usp_UpdateNonRegFieldsOfApplicationProgramShapes @applicationProgramId, @applicationProgramWildcardId | |
-- cleanup | |
exec dbo.usp_CleanTemporaryApplicationProgramImportTables | |
GO | |
GRANT EXEC ON dbo.usp_InsertApplicationProgram TO ETSFullAccess | |
DENY EXEC ON dbo.usp_InsertApplicationProgram TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertApplicationProgram TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertArea] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a area | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertArea') | |
BEGIN | |
DROP Procedure dbo.usp_InsertArea | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertArea | |
( | |
@id varchar(300), | |
@installationId varchar(300), | |
@projectId varchar(300), | |
@name nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@address smallint = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null | |
) | |
AS | |
INSERT INTO Area (ID,InstallationID,ProjectID,[Name],Description,Address,CompletionStatus,Comment) VALUES (@id,@installationId,@projectId,@name,@description,@address,@completionStatus,@comment ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertArea TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertArea TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertArea TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertBuildingPart] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a building part | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertBuildingPart') | |
BEGIN | |
DROP Procedure dbo.usp_InsertBuildingPart | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertBuildingPart | |
( | |
@id varchar(300), | |
@installationId varchar(300), | |
@parentId varchar(300) = null, | |
@type varchar(20) = null, | |
@name nvarchar(255) = null, | |
@number nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null, | |
@defaultLineId varchar(300) = null | |
) | |
AS | |
INSERT INTO Building (ID,InstallationID,ParentID,Type,[Name],Number,Description,CompletionStatus,Comment, DefaultLineID) VALUES (@id,@installationId,@parentId,@type,@name,@number,@description,@completionStatus,@comment, @defaultLineId ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertBuildingPart TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertBuildingPart TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertBuildingPart TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertCommunicationObjectInstanceReference] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a device object | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertCommunicationObjectInstanceReference') | |
BEGIN | |
DROP Procedure dbo.usp_InsertCommunicationObjectInstanceReference | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertCommunicationObjectInstanceReference | |
( | |
@id varchar(300), | |
@deviceId varchar(300), | |
@communicationObjectRefId varchar(300), | |
@text nvarchar(255) = null, | |
@functionText nvarchar(max) = null, | |
@description nvarchar(max) = null, | |
@datapointType varchar(max) = null, | |
@readFlag bit = null, | |
@writeFlag bit = null, | |
@communicationFlag bit = null, | |
@transmitFlag bit = null, | |
@updateFlag bit = null, | |
@readOnInitFlag bit = null, | |
@priority varchar(6) = null, | |
@IsActive bit = null | |
) | |
AS | |
INSERT INTO DeviceObject (ID,DeviceID,CommunicationObjectRefID,[Text],FunctionText,Description,DatapointType,ReadFlag,WriteFlag,CommunicationFlag,TransmitFlag,UpdateFlag,ReadOnInitFlag,Priority, IsActive) VALUES (@id,@deviceId,@communicationObjectRefId,@text,@functionText,@description,@datapointType,@readFlag,@writeFlag,@communicationFlag,@transmitFlag,@updateFlag,@readOnInitFlag,@priority, @IsActive ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertCommunicationObjectInstanceReference TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertCommunicationObjectInstanceReference TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertCommunicationObjectInstanceReference TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertConnector] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a connector | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertConnector') | |
BEGIN | |
DROP Procedure dbo.usp_InsertConnector | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertConnector | |
( | |
@id varchar(300), | |
@groupAddressId varchar(300), | |
@deviceObjectId varchar(300), | |
@send bit = null, | |
@acknowledge bit = null, | |
@deviceId varchar(300) | |
) | |
AS | |
INSERT INTO Connector (ID,GroupAddressID,DeviceObjectID,Send,Acknowledge, DeviceID) VALUES (@id,@groupAddressId,@deviceObjectId,@send,@acknowledge, @deviceId ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertConnector TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertConnector TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertConnector TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertDevice] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a device | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertDevice') | |
BEGIN | |
DROP Procedure dbo.usp_InsertDevice | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertDevice | |
( | |
@id varchar(300) = null, | |
@installationId varchar(300) = null, | |
@name nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@lineId varchar(300) = null, | |
@buildingId varchar(300) = null, | |
@tradeId varchar(300) = null, | |
@productId varchar(300) = null, | |
@hardware2ProgramId varchar(300) = null, | |
@address smallint = null, | |
@installationHints nvarchar(max) = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null, | |
@individualAddressLoaded bit = null, | |
@applicationProgramLoaded bit = null, | |
@parametersLoaded bit = null, | |
@communicationPartLoaded bit = null, | |
@mediumConfigLoaded bit = null, | |
@lastModified datetime2(0) = null, | |
@lastDownLoad datetime2(0) = null, | |
@checkSums varbinary(max) = null, | |
@IsCommunicationObjectVisibilityCalculated bit = null, | |
@IPConfigAssign varchar(10) = null, | |
@IPConfigIPAddress ipv4address = null, | |
@IPConfigSubnetMask ipv4address = null, | |
@IPConfigDefaultGateway ipv4address = null, | |
@IPConfigMACAddress varchar(50) = null, | |
@Broken bit = null, | |
@SerialNumber nvarchar(max) = null, | |
@UniqueId uniqueidentifier = null | |
) | |
AS | |
INSERT INTO Device (ID,InstallationID,[Name],Description,LineID,BuildingID,TradeID,ProductID,Hardware2ProgramID,Address,InstallationHints | |
,CompletionStatus,Comment,IndividualAddressLoaded,ApplicationProgramLoaded,ParametersLoaded,CommunicationPartLoaded,MediumConfigLoaded | |
,LastModified,LastDownload,CheckSums,IsCommunicationObjectVisibilityCalculated, [IPConfigAssign], [IPConfigIPAddress], [IPConfigSubnetMask] | |
, [IPConfigDefaultGateway], [IPConfigMACAddress], [Broken], [SerialNumber], [UniqueId]) | |
VALUES (@id,@installationId,@name,@description,@lineId,@buildingId,@tradeId,@productId,@hardware2ProgramId,@address,@installationHints | |
,@completionStatus,@comment,@individualAddressLoaded,@applicationProgramLoaded,@parametersLoaded,@communicationPartLoaded,@mediumConfigLoaded | |
,@lastModified,@lastDownLoad,@checkSums,@IsCommunicationObjectVisibilityCalculated,@IPConfigAssign,@IPConfigIPAddress | |
,@IPConfigSubnetMask,@IPConfigDefaultGateway,@IPConfigMACAddress, @Broken, @SerialNumber, @UniqueId) | |
GO | |
GRANT EXEC ON dbo.usp_InsertDevice TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertDevice TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertDevice TO ETSReadOnlyAccess | |
GO | |
/** @file | |
This stored procedure inserts a device | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertDeviceRaw') | |
BEGIN | |
DROP Procedure dbo.usp_InsertDeviceRaw | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertDeviceRaw | |
( | |
@id varchar(300) = null, | |
@installationId varchar(300) = null, | |
@name nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@lineId varchar(300) = null, | |
@buildingId varchar(300) = null, | |
@tradeId varchar(300) = null, | |
@productId varchar(300) = null, | |
@hardware2ProgramId varchar(300) = null, | |
@address smallint = null, | |
@installationHints nvarchar(max) = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null, | |
@individualAddressLoaded bit = 0, | |
@applicationProgramLoaded bit = 0, | |
@parametersLoaded bit = 0, | |
@communicationPartLoaded bit = 0, | |
@mediumConfigLoaded bit = 0, | |
@lastModified datetime2(0) = null, | |
@lastDownLoad datetime2(0) = null, | |
@checkSums varbinary(max) = null, | |
@IsCommunicationObjectVisibilityCalculated bit = null | |
) | |
AS | |
INSERT INTO Device (ID,InstallationID,[Name],Description,LineID,BuildingID,TradeID,ProductID,Hardware2ProgramID,Address,InstallationHints,CompletionStatus,Comment,IndividualAddressLoaded,ApplicationProgramLoaded,ParametersLoaded,CommunicationPartLoaded,MediumConfigLoaded,LastModified,LastDownload,CheckSums,IsCommunicationObjectVisibilityCalculated) | |
VALUES (@id,@installationId,@name,@description,@lineId,@buildingId,@tradeId,@productId,@hardware2ProgramId,@address,@installationHints,@completionStatus,@comment,@individualAddressLoaded,@applicationProgramLoaded,@parametersLoaded,@communicationPartLoaded,@mediumConfigLoaded,@lastModified,@lastDownLoad,@checkSums,@IsCommunicationObjectVisibilityCalculated) | |
if @hardware2ProgramId is not null | |
begin | |
declare @applicationProgramId varchar(300) = ( select ApplicationProgramID from Hardware2Program where Id = @hardware2ProgramId ) | |
declare @applicationProgram2Id varchar(300) = ( select ApplicationProgram2ID from Hardware2Program where Id = @hardware2ProgramId ) | |
if @applicationProgramId is not null | |
begin | |
--exec usp_CopyCommunicationObjectReferencesToDeviceObjects @Id, @applicationProgramId | |
--exec usp_CopyParameterReferencesToDeviceParameter @Id, @applicationProgramId | |
exec usp_CopyApplicationBinaryDataToDeviceBinaryData @Id, @applicationProgramId | |
end | |
if @applicationProgram2Id is not null | |
begin | |
--exec usp_CopyCommunicationObjectReferencesToDeviceObjects @Id, @applicationProgram2Id | |
--exec usp_CopyParameterReferencesToDeviceParameter @Id, @applicationProgram2Id | |
exec usp_CopyApplicationBinaryDataToDeviceBinaryData @Id, @applicationProgram2Id | |
end | |
end | |
GO | |
GRANT EXEC ON dbo.usp_InsertDeviceRaw TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertDeviceRaw TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertDeviceRaw TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertDeviceBinaryData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a device binary data | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertDeviceBinaryData') | |
BEGIN | |
DROP Procedure dbo.usp_InsertDeviceBinaryData | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertDeviceBinaryData | |
( | |
@id varchar(300), | |
@deviceId varchar(300), | |
@binaryDataId varchar(300) = null, | |
@name varchar(50) = null, | |
@data varbinary(max) = null | |
) | |
AS | |
INSERT INTO DeviceBinaryData (ID,DeviceID,BinaryDataID,[Name],[Data]) VALUES (@id, @deviceId,@binaryDataId,@name,@data) | |
GO | |
GRANT EXEC ON dbo.usp_InsertDeviceBinaryData TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertDeviceBinaryData TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertDeviceBinaryData TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertGroupAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a group address | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertGroupAddress') | |
BEGIN | |
DROP Procedure dbo.usp_InsertGroupAddress | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertGroupAddress | |
( | |
@id varchar(300), | |
@installationId varchar(300), | |
@name nvarchar(255), | |
@groupRangeID varchar(300), | |
@description nvarchar(max) = null, | |
@address int = null, | |
@unfiltered bit = null, | |
@central bit = null, | |
@global bit = null, | |
@comment nvarchar(max) = null, | |
@datapointType nvarchar(max) = null | |
) | |
AS | |
INSERT INTO GroupAddress (ID,InstallationID,[Name],Description,Address,Unfiltered,Central,[Global],Comment,DatapointType, GroupRangeID) VALUES (@id,@installationId,@name,@description,@address,@unfiltered,@central,@global,@comment,@datapointType, @GroupRangeID ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertGroupAddress TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertGroupAddress TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertGroupAddress TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertGroupRange] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a group range | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertGroupRange') | |
BEGIN | |
DROP Procedure dbo.usp_InsertGroupRange | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertGroupRange | |
( | |
@id varchar(300), | |
@installationId varchar(300), | |
@parentId varchar(300) = null, | |
@name nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@rangeStart int, | |
@rangeEnd int, | |
@unfiltered bit = 0, | |
@comment nvarchar(max) = null | |
) | |
AS | |
INSERT INTO GroupRange (ID,InstallationID,ParentID,[Name],Description,RangeStart,RangeEnd,Unfiltered,Comment) VALUES (@id,@installationId,@parentId,@name,@description,@rangeStart,@rangeEnd,@unfiltered,@comment ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertGroupRange TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertGroupRange TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertGroupRange TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertInstallation] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a installation | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertInstallation') | |
BEGIN | |
DROP Procedure dbo.usp_InsertInstallation | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertInstallation | |
( | |
@id varchar(300), | |
@projectId varchar(300), | |
@name nvarchar(255), | |
@installationId smallint, | |
@bcuKey bigint = null, | |
@ipRoutingMulticastAddress varchar(50) = null, | |
@completionStatus varchar(50) = null, | |
@DefaultLineId varchar(300) = null, | |
@busAccessName nvarchar(max) = null, | |
@busAccessEdi uniqueidentifier = null, | |
@busAccessParameter nvarchar(max) = null, | |
@splitType varchar(50) = null | |
) | |
AS | |
INSERT INTO Installation (ID,ProjectID,[Name],InstallationID,BCUKey,IPRoutingMulticastAddress,CompletionStatus, DefaultLineID,BusAccessName,BusAccessEdi,BusAccessParameter, SplitType) | |
VALUES (@id,@projectId,@name,@installationId,@bcuKey,@ipRoutingMulticastAddress,@completionStatus, @DefaultLineId,@busAccessName,@busAccessEdi,@busAccessParameter, @SplitType) | |
GO | |
GRANT EXEC ON dbo.usp_InsertInstallation TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertInstallation TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertInstallation TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertLine] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a line | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertLine') | |
BEGIN | |
DROP Procedure dbo.usp_InsertLine | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertLine | |
( | |
@id varchar(300), | |
@areaId varchar(300), | |
@name nvarchar(255), | |
@description nvarchar(max) = null, | |
@address smallint, | |
@domainAddressIsChecked bit = null, | |
@domainAddress bigint = null, | |
@mediumTypeId varchar(300), | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null, | |
@busAccessName nvarchar(max) = null, | |
@busAccessEdi uniqueidentifier = null, | |
@busAccessParameter nvarchar(max) = null, | |
@routingMulticastAddress varchar(20) = null, | |
@multicastTtl smallint = 16 | |
) | |
AS | |
INSERT INTO Line (ID,AreaID,[Name],Description,Address,DomainAddressIsChecked,DomainAddress,MediumTypeID,CompletionStatus,Comment,BusAccessName,BusAccessEdi,BusAccessParameter,IPRoutingMulticastAddress,MulticastTTL) | |
VALUES (@id,@areaId,@name,@description,@address,@domainAddressIsChecked,@domainAddress,@mediumTypeId,@completionStatus,@comment,@busAccessName,@busAccessEdi,@busAccessParameter,@routingMulticastAddress,@multicastTtl) | |
GO | |
GRANT EXEC ON dbo.usp_InsertLine TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertLine TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertLine TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertParameterInstanceReference] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a device parameter | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertParameterInstanceReference') | |
BEGIN | |
DROP Procedure dbo.usp_InsertParameterInstanceReference | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertParameterInstanceReference | |
( | |
@id varchar(300), | |
@deviceId varchar(300), | |
@parameterRefId varchar(300), | |
@value sql_variant = null | |
) | |
AS | |
INSERT INTO DeviceParameter (ID,DeviceID,ParameterRefID,Value) VALUES (@id,@deviceId,@parameterRefId,@value) | |
GO | |
GRANT EXEC ON dbo.usp_InsertParameterInstanceReference TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertParameterInstanceReference TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertParameterInstanceReference TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertProject] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a project | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertProject') | |
BEGIN | |
DROP Procedure dbo.usp_InsertProject | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertProject | |
( | |
@id varchar(300), | |
@name nvarchar(255), | |
@ipProjectId smallint = null, | |
@projectNumber nvarchar(50) = null, | |
@contractNumber nvarchar(50) = null, | |
@projectStart datetime2(0) = null, | |
@projectEnd datetime2(0) = null, | |
@lastModified datetime2(0) = null, | |
@importDate datetime2(0) = null, | |
@projectPassword nvarchar(20) = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null, | |
@groupAddressStyle varchar(15), | |
@projectTracingLevel varchar(50), | |
@ProjectTracingPassword nvarchar(20) = null, | |
@Hide16BitGroupsFromLegacyPlugins bit, | |
@CodePage varchar(100) = null | |
) | |
AS | |
INSERT INTO Project (ID,[Name],IpProjectID,ProjectNumber,ContractNumber,ProjectStart,ProjectEnd,LastModified,ImportDate,ProjectPassword,CompletionStatus,Comment,GroupAddressStyle,ProjectTracingLevel,ProjectTracingPassword,Hide16BitGroupsFromLegacyPlugins,[CodePage]) | |
VALUES (@id,@name,@ipProjectId,@projectNumber,@contractNumber,@projectStart,@projectEnd,@lastModified,@importDate,@projectPassword,@completionStatus,@comment,@groupAddressStyle,@projectTracingLevel,@ProjectTracingPassword, @Hide16BitGroupsFromLegacyPlugins,@CodePage) | |
GO | |
GRANT EXEC ON dbo.usp_InsertProject TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertProject TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertProject TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertProjectHistory] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a project history entry | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertProjectHistory') | |
BEGIN | |
DROP Procedure dbo.usp_InsertProjectHistory | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertProjectHistory | |
( | |
@id varchar(300), | |
@projectId varchar(300), | |
@date datetime2(0) = null, | |
@user nvarchar(50) = null, | |
@text nvarchar(max) = null, | |
@detail nvarchar(max) = null | |
) | |
AS | |
INSERT INTO ProjectHistory (ID,ProjectID,[Date],[User],[Text],[Detail]) VALUES (@id,@projectId,@date,@user,@text,@detail) | |
GO | |
GRANT EXEC ON dbo.usp_InsertProjectHistory TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertProjectHistory TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertProjectHistory TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertProjectTrace] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a project trace entry | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertProjectTrace') | |
BEGIN | |
DROP Procedure dbo.usp_InsertProjectTrace | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertProjectTrace | |
( | |
@id varchar(300), | |
@projectId varchar(300), | |
@date datetime2(3), | |
@username nvarchar(50), | |
@description nvarchar(max) | |
) | |
AS | |
INSERT INTO ProjectTrace (ID,ProjectID,[Date],[UserName],[Description]) VALUES (@id,@projectId,@date,@username,@description) | |
GO | |
GRANT EXEC ON dbo.usp_InsertProjectTrace TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertProjectTrace TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertProjectTrace TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertSplitInfo] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertSplitInfo') | |
BEGIN | |
DROP Procedure dbo.usp_InsertSplitInfo | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertSplitInfo | |
( | |
@Id varchar(300), | |
@installationId varchar(300), | |
@cookie uniqueidentifier, | |
@objectPath varchar(1000) | |
) | |
AS | |
insert into SplitInfo (ID,InstallationID,Cookie,ObjectPath) VALUES (@id,@installationId,@cookie,@objectPath ) | |
GO | |
GRANT EXEC ON dbo.usp_InsertSplitInfo TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertSplitInfo TO ETSReadOnlyAccess | |
GRANT EXEC ON dbo.usp_InsertSplitInfo TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertToDoItem] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a ToDo item | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertToDoItem') | |
BEGIN | |
DROP Procedure dbo.usp_InsertToDoItem | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertToDoItem | |
( | |
@id varchar(300), | |
@description nvarchar(max) = null, | |
@objectPath varchar(900) = null, | |
@projectId varchar(300), | |
@currentStatus varchar(50) | |
) | |
AS | |
INSERT INTO ToDoItem (ID, Description, ObjectPath, ProjectId, CurrentStatus) VALUES (@id,@description,@objectPath,@projectId,@currentStatus) | |
GO | |
GRANT EXEC ON dbo.usp_InsertToDoItem TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertToDoItem TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertToDoItem TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertTrade] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a trade | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertTrade') | |
BEGIN | |
DROP Procedure dbo.usp_InsertTrade | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertTrade | |
( | |
@id varchar(300), | |
@installationId varchar(300), | |
@parentId varchar(300) = null, | |
@name nvarchar(255) = null, | |
@number nvarchar(255) = null, | |
@description nvarchar(max) = null, | |
@completionStatus varchar(50) = null, | |
@comment nvarchar(max) = null | |
) | |
AS | |
INSERT INTO Trade (ID,InstallationId,ParentID,[Name],Number,Description,CompletionStatus,Comment) VALUES (@id,@installationId,@parentId,@name,@number,@description,@completionStatus,@comment) | |
GO | |
GRANT EXEC ON dbo.usp_InsertTrade TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertTrade TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertTrade TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [InsertUserFile] | |
-------------------------------------------------------------------------------- | |
/** @file | |
This stored procedure inserts a user file | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: returns all compatibility manufacturer ids from the compatibility group | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_InsertUserFile') | |
BEGIN | |
DROP Procedure dbo.usp_InsertUserFile | |
END | |
GO | |
CREATE Procedure dbo.usp_InsertUserFile | |
( | |
@id uniqueidentifier, | |
@projectId varchar(300), | |
@filename nvarchar(300), | |
@comment nvarchar(max) = null | |
) | |
AS | |
INSERT INTO UserFile (ID,ProjectID,[Filename],Comment,Data) VALUES (@id,@projectId,@filename,@comment,0x00) | |
GO | |
GRANT EXEC ON dbo.usp_InsertUserFile TO ETSFullAccess | |
GRANT EXEC ON dbo.usp_InsertUserFile TO ETSWriteProjectAccess | |
DENY EXEC ON dbo.usp_InsertUserFile TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [IsApplicationProgramRegistered] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_IsApplicationProgramRegistered') | |
BEGIN | |
DROP PROCEDURE dbo.usp_IsApplicationProgramRegistered | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_IsApplicationProgramRegistered | |
( | |
@applicationProgramId varchar(300), | |
@registered bit output | |
) | |
AS | |
set @registered = 0 | |
if exists (select * from Hardware2Program where (ApplicationProgramID=@applicationProgramId or ApplicationProgram2ID=@applicationProgramId) and (RegistrationStatus='Registered' or RegistrationStatus='Certified')) | |
begin | |
set @registered = 1 | |
end | |
GO | |
GRANT EXEC ON dbo.usp_IsApplicationProgramRegistered TO ETSFullAccess | |
DENY EXEC ON dbo.usp_IsApplicationProgramRegistered TO ETSReadOnlyAccess | |
DENY EXEC ON dbo.usp_IsApplicationProgramRegistered TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [Name1] | |
-------------------------------------------------------------------------------- | |
this is my long string | |
-------------------------------------------------------------------------------- | |
-- [NewTablesInSchema1_1] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - %Project Data coming along with XML schema 1.1 | |
*/ | |
-- SplitInfo | |
IF object_id('SplitInfo', 'U') IS NOT NULL DROP TABLE SplitInfo; | |
/** @brief Table for split/merge information data files. | |
@access EtsProject | |
@xmlref Project/SplitInfos/SplitInfo | |
*/ | |
CREATE TABLE dbo.SplitInfo | |
( | |
ID varchar(50) primary key, | |
InstallationID varchar(300) foreign key references dbo.Installation(ID) on delete cascade,---< Reference to Project. | |
---< Do not change after insert. | |
Cookie uniqueidentifier not null, ---< Unique identifier identifying the split. The cookie exists in both the master and split installation. | |
---< @xmlref Corresponds to XML attribute Cookie. | |
ObjectPath varchar(max) not null, ---< The unique path identifying the root object of the split. | |
---< @xmlref Corresponds to XML attribute ObjectPath. | |
ObjectType varchar(50) not null, ---< The type the root object. | |
---< @xmlref Corresponds to XML attribute ObjectType. | |
); | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.SplitInfo TO ETSFullAccess; | |
GRANT DELETE, INSERT, UPDATE, SELECT ON dbo.SplitInfo TO ETSWriteProjectAccess; | |
GRANT SELECT ON dbo.SplitInfo TO ETSReadOnlyAccess; | |
DENY DELETE, INSERT, UPDATE ON dbo.SplitInfo TO ETSReadOnlyAccess; | |
GO | |
-------------------------------------------------------------------------------- | |
-- [NonRegVersionUpdateRequired] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Contains functions that convert base64 string and binary data (varbinary) | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_NonRegVersionUpdateRequired') | |
BEGIN | |
DROP Function dbo.ufn_NonRegVersionUpdateRequired | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_NonRegVersionUpdateRequired | |
( | |
@dbVersion int, | |
@importVersion int | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @version int = ISNULL(@importVersion,0) | |
if @dbVersion < @version or (@dbVersion = 0 and @version = 0) | |
return 1 | |
return 0 | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_NonRegVersionUpdateRequired TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_NonRegVersionUpdateRequired TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_NonRegVersionUpdateRequired TO ETSReadOnlyAccess | |
GO | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TranslationUpdateRequired') | |
BEGIN | |
DROP Function dbo.ufn_TranslationUpdateRequired | |
END | |
GO | |
CREATE FUNCTION dbo.ufn_TranslationUpdateRequired | |
( | |
@dbVersion int, | |
@importVersion int | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @version int = ISNULL(@importVersion,0) | |
if @dbVersion < @version or (@dbVersion = 0 and @version = 0) | |
return 1 | |
return 0 | |
END | |
GO | |
GRANT EXEC ON dbo.ufn_TranslationUpdateRequired TO ETSFullAccess | |
GRANT EXEC ON dbo.ufn_TranslationUpdateRequired TO ETSWriteProjectAccess | |
GRANT EXEC ON dbo.ufn_TranslationUpdateRequired TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ProgressSchemaVersionDataConversion] | |
-------------------------------------------------------------------------------- | |
Data schema upgrade: Converting the data... | |
-------------------------------------------------------------------------------- | |
-- [ProgressSchemaVersionDataPreparation] | |
-------------------------------------------------------------------------------- | |
Data schema upgrade: Preparing the data... | |
-------------------------------------------------------------------------------- | |
-- [ProgressSchemaVersionDataUpdate] | |
-------------------------------------------------------------------------------- | |
Data schema upgrade: Writing the data... | |
-------------------------------------------------------------------------------- | |
-- [ProgressUpdatingDatabaseSchema] | |
-------------------------------------------------------------------------------- | |
Upgrading database... | |
-------------------------------------------------------------------------------- | |
-- [ProgressUpdatingMasterData] | |
-------------------------------------------------------------------------------- | |
Upgrading master data... | |
-------------------------------------------------------------------------------- | |
-- [ProgressUpdatingProductExtensions] | |
-------------------------------------------------------------------------------- | |
Upgrading product extensions... | |
-------------------------------------------------------------------------------- | |
-- [ProjectTemporaryImportTables] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Temporary tables for project data import | |
*/ | |
IF DB_NAME() = 'master' | |
BEGIN | |
RAISERROR('Script executes against master database',16,1) | |
RETURN | |
END | |
-- Project | |
IF object_id('tempdb..#Project', 'U') IS NOT NULL DROP TABLE #Project; | |
create table #Project | |
( | |
[ID] nVarchar(300) NOT NULL, | |
[Name] [nvarchar](50) NOT NULL, | |
[IpProjectID] [smallint] NULL, | |
[ProjectNumber] [nvarchar](50) NULL, | |
[ContractNumber] [nvarchar](50) NULL, | |
[ProjectStart] [datetime2](0) NULL, | |
[ProjectEnd] [datetime2](0) NULL, | |
[LastModified] [datetime2](0) NULL, | |
[ImportDate] [datetime2](0) NULL, | |
[ProjectPassword] [nvarchar](20) NULL, | |
[CompletionStatus] varchar(100) NULL, | |
[Comment] [nvarchar](max) NULL, | |
GroupAddressStyle varchar(15) NULL, | |
ProjectTracingLevel varchar(100) NULL, | |
ProjectTracingPassword nvarchar(20) NULL, | |
Hide16BitGroupsFromLegacyPlugins bit, | |
[CodePage] varchar(100) NULL | |
); | |
GO | |
IF object_id('tempdb..#ProjectHistory', 'U') IS NOT NULL DROP TABLE #ProjectHistory; | |
CREATE TABLE #ProjectHistory | |
( | |
[ID] [varchar](300) NOT NULL, | |
[ProjectID] [varchar](300) NOT NULL, | |
[Date] [datetime] NOT NULL, | |
[User] [nvarchar](50) NULL, | |
[Text] [nvarchar](max) NULL, | |
[Detail] nvarchar(max) | |
); | |
GO | |
IF object_id('tempdb..#ToDoItem', 'U') IS NOT NULL DROP TABLE #ToDoItem; | |
CREATE TABLE #ToDoItem | |
( | |
[ID] [varchar](300) NOT NULL, | |
[Description] [nvarchar](max) NULL, | |
[ObjectPath] [varchar](900) NULL, | |
[ProjectID] [varchar](300) NOT NULL, | |
[CurrentStatus] [varchar](50) NOT NULL | |
); | |
GO | |
IF object_id('tempdb..#ProjectTrace', 'U') IS NOT NULL DROP TABLE #ProjectTrace; | |
CREATE TABLE #ProjectTrace | |
( | |
[ID] [varchar](300) NOT NULL, | |
[ProjectID] [varchar](300) NOT NULL, | |
[Date] [datetime2](3) NOT NULL, | |
[User] [nvarchar](50) NULL, | |
[Description] [nvarchar](max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#Installation', 'U') IS NOT NULL DROP TABLE #Installation; | |
CREATE TABLE #Installation | |
( | |
ID varchar(300), | |
ProjectID varchar(300), | |
[Name] nvarchar(50) not null, | |
InstallationId smallint check(InstallationId IS NULL OR InstallationId BETWEEN 0 AND 15), | |
BCUKey bigint, | |
IPRoutingMulticastAddress varchar(50), | |
CompletionStatus varchar(100), | |
DefaultLineID varchar(300), | |
[BusAccessName] nvarchar(max), | |
[BusAccessEdi] uniqueidentifier, | |
[BusAccessParameter] nvarchar(max) | |
); | |
GO | |
IF object_id('tempdb..#Device', 'U') IS NOT NULL DROP TABLE #Device; | |
CREATE TABLE #Device | |
( | |
ID varchar(300), | |
InstallationID varchar(300) not null, | |
[Name] nvarchar(255), | |
Description nvarchar(max), | |
LineID varchar(300), | |
BuildingID varchar(300), | |
TradeID varchar(300) , | |
ProductID varchar(300), | |
Hardware2ProgramID varchar(300), | |
Address smallint check(Address between 0 and 255), | |
InstallationHints nvarchar(max), | |
CompletionStatus varchar(100), | |
[Comment] nvarchar(max), | |
IndividualAddressLoaded bit, | |
ApplicationProgramLoaded bit, | |
ParametersLoaded bit, | |
CommunicationPartLoaded bit, | |
MediumConfigLoaded bit, | |
LastModified datetime, | |
LastDownload datetime, | |
LoadedImage varbinary(max), | |
CheckSums varbinary(max), | |
IsCommunicationObjectVisibilityCalculated bit, | |
[IPConfigAssign] varchar(10), | |
[IPConfigIPAddress] varchar(20), | |
[IPConfigSubnetMask] varchar(20), | |
[IPConfigDefaultGateway] varchar(20), | |
[IPConfigMACAddress] varchar(50), | |
[Broken] bit, | |
[SerialNumber] nvarchar(max), | |
[UniqueId] uniqueidentifier | |
); | |
GO | |
IF object_id('tempdb..#DeviceBinaryData', 'U') IS NOT NULL DROP TABLE #DeviceBinaryData; | |
CREATE TABLE #DeviceBinaryData | |
( | |
ID varchar(300), | |
DeviceID varchar(300), | |
BinaryDataID varchar(300), | |
Name nvarchar(50), | |
Data varbinary(max), | |
) | |
GO | |
IF object_id('tempdb..#Area', 'U') IS NOT NULL DROP TABLE #Area; | |
CREATE TABLE #Area | |
( | |
ID varchar(300), | |
InstallationID varchar(300) not null, | |
ProjectID varchar(300) not null , | |
[Name] nvarchar(255), | |
Description nvarchar(max), | |
Address smallint check(Address between 0 and 15), | |
CompletionStatus varchar(100), | |
[Comment] nvarchar(max) | |
); | |
GO | |
IF object_id('tempdb..#Line', 'U') IS NOT NULL DROP TABLE #Line; | |
CREATE TABLE #Line | |
( | |
ID varchar(300), | |
AreaID varchar(300), | |
[Name] nvarchar(255), | |
Description nvarchar(max), | |
Address smallint check(Address between 0 and 15), | |
DomainAddressIsChecked bit, | |
DomainAddress bigint, | |
MediumTypeID varchar(300), | |
CompletionStatus varchar(100) check (CompletionStatus in ('Undefined', 'Editing', 'FinishedDesign','FinishedCommisioning','Tested','Accepted') ), | |
[Comment] nvarchar(max), | |
[BusAccessName] nvarchar(max), | |
[BusAccessEdi] uniqueidentifier, | |
[BusAccessParameter] nvarchar(max), | |
IPRoutingMulticastAddress varchar(20), | |
MulticastTTL smallint default 16 | |
); | |
GO | |
IF object_id('tempdb..#DeviceParameter', 'U') IS NOT NULL DROP TABLE #DeviceParameter; | |
CREATE TABLE #DeviceParameter | |
( | |
[ID] uniqueidentifier NOT NULL, | |
[DeviceID] [varchar](300) NOT NULL, | |
[ParameterRefID] [varchar](300) NOT NULL, | |
[IsActive] [bit] NULL, | |
[Value] sql_variant NULL, | |
); | |
GO | |
IF object_id('tempdb..#DeviceObject', 'U') IS NOT NULL DROP TABLE #DeviceObject; | |
CREATE TABLE #DeviceObject | |
( | |
[ID] uniqueidentifier NOT NULL, | |
[DeviceID] [varchar](300) NOT NULL, | |
[CommunicationObjectRefID] [varchar](300) NOT NULL, | |
[Text] [nvarchar](255) NULL, | |
[FunctionText] [nvarchar](max) NULL, | |
[Description] [nvarchar](max) NULL, | |
[IsActive] [bit] NULL, | |
[DatapointType] [varchar](max) NULL, | |
[ReadFlag] varchar(100) NULL, | |
[WriteFlag] varchar(100) NULL, | |
[CommunicationFlag] varchar(100) NULL, | |
[TransmitFlag] varchar(100) NULL, | |
[UpdateFlag] varchar(100) NULL, | |
[ReadOnInitFlag] varchar(100)NULL, | |
[Priority] [varchar](6) NULL, | |
[ObjectSize] [varchar](30) NULL, | |
[Number] [smallint] NULL, | |
); | |
GO | |
IF object_id('tempdb..#Connector', 'U') IS NOT NULL DROP TABLE #Connector; | |
CREATE TABLE #Connector | |
( | |
[ID] [varchar](300) NOT NULL, | |
[GroupAddressID] [varchar](300) NOT NULL, | |
[DeviceObjectID] varchar(40) NOT NULL, | |
[Send] [bit] NOT NULL, | |
[Acknowledge] [bit] NOT NULL, | |
[DeviceID] varchar(300), | |
) | |
GO | |
IF object_id('tempdb..#AdditionalDeviceAddress', 'U') IS NOT NULL DROP TABLE #AdditionalDeviceAddress; | |
CREATE TABLE #AdditionalDeviceAddress | |
( | |
[DeviceID] [varchar](300) NOT NULL, | |
[Address] [smallint] NOT NULL, | |
); | |
GO | |
IF object_id('tempdb..#AdditionalGroupAddress', 'U') IS NOT NULL DROP TABLE #AdditionalGroupAddress; | |
CREATE TABLE #AdditionalGroupAddress | |
( | |
[LineID] varchar(300) NOT NULL, | |
[InstallationID] varchar(300) not null, | |
[GroupAddress] int NOT NULL, | |
); | |
GO | |
IF object_id('tempdb..#Building', 'U') IS NOT NULL DROP TABLE #Building; | |
CREATE TABLE #Building( | |
[ID] [varchar](300) NOT NULL, | |
[InstallationID] [varchar](300) NOT NULL, | |
[ParentID] [varchar](300) NULL, | |
[Type] [varchar](20) NULL, | |
[Name] [nvarchar](255) NULL, | |
[Number] [nvarchar](255) NULL, | |
[Description] [nvarchar](max) NULL, | |
[CompletionStatus] varchar(100) NULL, | |
[Comment] [nvarchar](max) NULL, | |
DefaultLineID varchar(300) NULL | |
); | |
GO | |
IF object_id('tempdb..#Trade', 'U') IS NOT NULL DROP TABLE #Trade; | |
CREATE TABLE #Trade( | |
[ID] [varchar](300) NOT NULL, | |
[InstallationID] [varchar](300) NOT NULL, | |
[ParentID] [varchar](300) NULL, | |
[Name] [nvarchar](255) NOT NULL, | |
[Number] [nvarchar](255) NULL, | |
[Description] [nvarchar](max) NULL, | |
[CompletionStatus] varchar(100) NULL, | |
[Comment] [nvarchar](max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#GroupAddress', 'U') IS NOT NULL DROP TABLE #GroupAddress; | |
CREATE TABLE #GroupAddress( | |
[ID] [varchar](300) NOT NULL, | |
[InstallationID] [varchar](300) NOT NULL, | |
[GroupRangeID] varchar(300) not null, | |
[Name] [nvarchar](255) NULL, | |
[Description] [nvarchar](max) NULL, | |
[Address] [int] NULL, | |
[Unfiltered] [bit] NOT NULL, | |
[Central] [bit] NOT NULL, | |
[Global] [bit] NOT NULL, | |
[Comment] [nvarchar](max) NULL, | |
[DatapointType] [nvarchar](max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#GroupRange', 'U') IS NOT NULL DROP TABLE #GroupRange; | |
CREATE TABLE #GroupRange( | |
[ID] [varchar](300) NOT NULL, | |
[InstallationID] [varchar](300) NOT NULL, | |
[ParentID] [varchar](300) NULL, | |
[Name] [nvarchar](255) NULL, | |
[Description] [nvarchar](max) NULL, | |
[RangeStart] [int] NULL, | |
[RangeEnd] [int] NULL, | |
[Unfiltered] [bit] NOT NULL, | |
[Comment] [nvarchar](max) NULL, | |
); | |
GO | |
IF object_id('tempdb..#UserFile', 'U') IS NOT NULL DROP TABLE #UserFile; | |
CREATE TABLE #UserFile | |
( | |
[ID] varchar(50) NOT NULL, | |
[ProjectID] [varchar](300) NOT NULL, | |
[Filename] [nvarchar](300) NOT NULL, | |
[Comment] [nvarchar](max) NOT NULL, | |
[Data] varbinary(max), | |
); | |
GO | |
IF object_id('tempdb..#AddinData', 'U') IS NOT NULL DROP TABLE #AddinData; | |
CREATE TABLE #AddinData | |
( | |
[ID] varchar(50) NOT NULL, | |
[ProjectID] [varchar](300) NOT NULL, | |
[AddinID] nvarchar(max) NOT NULL, | |
[Name] [nvarchar](300) NOT NULL, | |
[Data] varbinary(max), | |
); | |
GO | |
-------------------------------------------------------------------------------- | |
-- [RenewUsersAfterRestore] | |
-------------------------------------------------------------------------------- | |
/** @file | |
ETS 4 Database Schema - Scrtipt for renew user login after database restore of a backup | |
*/ | |
-- add users to newly created database | |
USE [#name#] | |
IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'EtsInternal') | |
begin | |
--EXEC sp_droprolemember 'db_owner', N'EtsInternal' | |
--EXEC sp_droprolemember 'db_datareader', N'EtsInternal' | |
--EXEC sp_droprolemember 'db_datawriter', N'EtsInternal' | |
--EXEC sp_droprolemember 'db_accessadmin', N'EtsInternal' | |
DROP SCHEMA EtsInternal | |
DROP USER [EtsInternal] | |
end | |
--IF EXISTS (SELECT name from sys.database_principals where [name]=N'EtsManufacturer') | |
--begin | |
--EXEC sp_droprolemember 'db_datareader', 'EtsManufacturer' | |
--EXEC sp_droprolemember 'db_datawriter', 'EtsManufacturer' | |
--DROP SCHEMA EtsManufacturer | |
--DROP USER EtsManufacturer | |
--end | |
IF EXISTS (SELECT name from sys.database_principals where [name]=N'EtsProject') | |
begin | |
--EXEC sp_droprolemember 'db_datareader', 'EtsProject' | |
--EXEC sp_droprolemember 'db_datawriter', 'EtsProject' | |
DROP SCHEMA EtsProject | |
DROP USER EtsProject | |
end | |
--IF EXISTS (SELECT name from sys.database_principals where [name]=N'EtsProjectTest') | |
--begin | |
--EXEC sp_droprolemember 'db_datareader', 'EtsProjectTest' | |
--EXEC sp_droprolemember 'db_datawriter', 'EtsProjectTest' | |
--DROP SCHEMA EtsProjectTest | |
--DROP USER EtsProjectTest | |
--end | |
IF EXISTS (SELECT name from sys.database_principals where [name]=N'EtsReadOnly') | |
begin | |
--EXEC sp_addrolemember 'db_datareader', N'EtsReadOnly' | |
DROP SCHEMA EtsReadOnly | |
DROP USER EtsReadOnly | |
end | |
GO | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsInternal', @name_in_db = N'EtsInternal' | |
--EXEC dbo.sp_grantdbaccess @loginame = N'EtsManufacturer', @name_in_db = N'EtsManufacturer' | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsProject', @name_in_db = N'EtsProject' | |
--EXEC dbo.sp_grantdbaccess @loginame = N'EtsProjectTest', @name_in_db = N'EtsProjectTest' | |
EXEC dbo.sp_grantdbaccess @loginame = N'EtsReadOnly', @name_in_db = N'EtsReadOnly' | |
EXEC sp_addrolemember N'ETSFullAccess', N'EtsInternal' | |
GO | |
--EXEC sp_addrolemember N'ETSReadOnlyAccess', N'EtsManufacturer' | |
--GO | |
EXEC sp_addrolemember N'ETSReadOnlyAccess', N'EtsReadOnly' | |
GO | |
EXEC sp_addrolemember N'ETSWriteProjectAccess', N'EtsProject' | |
GO | |
EXEC sp_addrolemember 'db_owner', N'EtsInternal' | |
EXEC sp_addrolemember 'db_datareader', N'EtsInternal' | |
EXEC sp_addrolemember 'db_datawriter', N'EtsInternal' | |
EXEC sp_addrolemember 'db_accessadmin', N'EtsInternal' | |
--EXEC sp_addrolemember 'db_datareader', 'EtsManufacturer' | |
--EXEC sp_addrolemember 'db_datawriter', 'EtsManufacturer' | |
EXEC sp_addrolemember 'db_datareader', 'EtsProject' | |
EXEC sp_addrolemember 'db_datawriter', 'EtsProject' | |
--EXEC sp_addrolemember 'db_datareader', 'EtsProjectTest' | |
--EXEC sp_addrolemember 'db_datawriter', 'EtsProjectTest' | |
EXEC sp_addrolemember 'db_datareader', N'EtsReadOnly' | |
GO | |
REVERT; | |
GO | |
USE master; | |
-------------------------------------------------------------------------------- | |
-- [ReportBuildingOverview] | |
-------------------------------------------------------------------------------- | |
IF OBJECT_ID('usp_ReportBuildingOverview', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportBuildingOverview | |
GO | |
/** @brief Returns all building data for the overview reports | |
@param _a_InstallationId ID of the table Installation | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportBuildingOverview | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
WITH DirectReports (ParentID, BuildingID, BuildingName, InstallationId, BuildingType, Number, Description, Comment, CompletionStatus, Level, Sort) | |
AS | |
( | |
-- Anchor member definition | |
SELECT b.ParentID, b.ID, b.Name, b.InstallationID, b.Type, b.Number, b.Description, b.Comment, b.CompletionStatus, | |
0 AS Level, CAST (b.Name As nvarchar(max)) + CAST('¶' as nvarchar(max)) + CAST (b.ID As nvarchar(max)) As Sort | |
FROM Building AS b | |
WHERE ParentID IS NULL | |
AND InstallationID = @InstallationId | |
UNION ALL | |
-- Recursive member definition | |
SELECT b.ParentID, b.ID, b.Name, b.InstallationID, b.Type, b.Number, b.Description, b.Comment, b.CompletionStatus, | |
Level + 1, CAST (Sort As nvarchar(max)) + CAST('¶' as nvarchar(max)) + CAST (b.Name As nvarchar(max)) + CAST('¶' as nvarchar(max)) + CAST (b.ID As nvarchar(max)) | |
FROM Building AS b | |
INNER JOIN DirectReports AS d | |
ON b.ParentID = d.BuildingID | |
) | |
-- Statement that executes the CTE | |
SELECT ROW_NUMBER() OVER(ORDER BY Sort) AS Row, Sort, BuildingName, Level, BuildingType, ParentID, BuildingID, InstallationId, Number, Description, Comment, | |
CompletionStatus =[dbo].[ufn_CompletionStatus](CompletionStatus), | |
CommentFormat = CASE LEFT(Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END | |
FROM DirectReports | |
WHERE InstallationID = @InstallationId; | |
GO | |
GRANT EXEC ON [dbo].usp_ReportBuildingOverview TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportBuildingOverview TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportBuildingOverview TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportDeviceOverview] | |
-------------------------------------------------------------------------------- | |
IF OBJECT_ID('usp_ReportDeviceOverview', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportDeviceOverview | |
GO | |
/** @brief Returns all device data for the overview reports | |
@param _a_InstallationId ID of the table Installation | |
@param _a_LanguageId Language | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportDeviceOverview | |
( | |
@InstallationId varchar(300), | |
@LanguageId varchar(20) | |
) | |
AS | |
SELECT | |
IndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
Description = D.[Description], | |
InstallationHints = D.InstallationHints, | |
InstallationHintsFormat = CASE LEFT(D.InstallationHints,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
Comment = D.Comment, | |
CommentFormat = CASE LEFT(D.Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
CompletionStatus = [dbo].[ufn_CompletionStatus](D.CompletionStatus), | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
ApplicationProgramName = CASE HP.ApplicationProgramID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_TranslatedApplicationProgramName](A.ID, @LanguageId, NULL) | |
END, | |
ApplicationProgramVersion = [dbo].[ufn_ReportFormatApplicationProgramVersion](A.ApplicationVersion) | |
FROM [Device] AS D | |
LEFT OUTER JOIN [Line] As L ON L.ID = D.LineID | |
LEFT OUTER JOIN [Area] As R ON R.ID = L.AreaID | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
JOIN [Hardware2Program] HP ON HP.ID = D.Hardware2ProgramID | |
LEFT OUTER JOIN [ApplicationProgram] A ON A.ID = HP.ApplicationProgramID | |
WHERE D.InstallationID = @InstallationID | |
ORDER BY R.[Address],L.[Address],D.[Address],D.[ID] | |
GO | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverview TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverview TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverview TO ETSReadOnlyAccess | |
GO | |
IF OBJECT_ID('usp_ReportDeviceOverviewPerLine', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportDeviceOverviewPerLine | |
GO | |
/** @brief Returns device data for one line | |
@param _a_InstallationId ID of the table Installation | |
@param _a_LanguageId Language | |
@param _a_LineId Line ID | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportDeviceOverviewPerLine | |
( | |
@InstallationId varchar(300), | |
@LanguageId varchar(20), | |
@LineId varchar(300) | |
) | |
AS | |
SELECT | |
DeviceID = D.[ID], | |
IndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
Description = D.[Description], | |
InstallationHints = D.InstallationHints, | |
InstallationHintsFormat = CASE LEFT(D.InstallationHints,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
Comment = D.Comment, | |
CommentFormat = CASE LEFT(D.Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
CompletionStatus = [dbo].[ufn_CompletionStatus](D.CompletionStatus), | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
ApplicationProgramName = CASE HP.ApplicationProgramID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_TranslatedApplicationProgramName](A.ID, @LanguageId, NULL) | |
END, | |
ApplicationProgramVersion = [dbo].[ufn_ReportFormatApplicationProgramVersion](A.ApplicationVersion) | |
FROM [Device] AS D | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
JOIN [Hardware2Program] HP ON HP.ID = D.Hardware2ProgramID | |
LEFT OUTER JOIN [ApplicationProgram] A ON A.ID = HP.ApplicationProgramID | |
WHERE D.InstallationID = @InstallationID | |
AND D.LineID = @LineID | |
ORDER BY D.[Address],D.[ID] | |
GO | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerLine TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerLine TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerLine TO ETSReadOnlyAccess | |
GO | |
IF OBJECT_ID('usp_ReportDeviceOverviewPerBuilding', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportDeviceOverviewPerBuilding | |
GO | |
/** @brief Returns device data for one buidling/part | |
@param _a_InstallationId ID of the table Installation | |
@param _a_LanguageId Language | |
@param _a_BuildingId Building ID | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportDeviceOverviewPerBuilding | |
( | |
@InstallationId varchar(300), | |
@LanguageId varchar(20), | |
@BuildingId varchar(300) | |
) | |
AS | |
SELECT | |
DeviceID = D.[ID], | |
IndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
Description = D.[Description], | |
InstallationHints = D.InstallationHints, | |
InstallationHintsFormat = CASE LEFT(D.InstallationHints,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
Comment = D.Comment, | |
CommentFormat = CASE LEFT(D.Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
CompletionStatus = [dbo].[ufn_CompletionStatus](D.CompletionStatus), | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
ApplicationProgramName = CASE HP.ApplicationProgramID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_TranslatedApplicationProgramName](A.ID, @LanguageId, NULL) | |
END, | |
ApplicationProgramVersion = [dbo].[ufn_ReportFormatApplicationProgramVersion](A.ApplicationVersion) | |
FROM [Device] AS D | |
LEFT OUTER JOIN [Line] As L ON L.ID = D.LineID | |
LEFT OUTER JOIN [Area] As R ON R.ID = L.AreaID | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
JOIN [Hardware2Program] HP ON HP.ID = D.Hardware2ProgramID | |
LEFT OUTER JOIN [ApplicationProgram] A ON A.ID = HP.ApplicationProgramID | |
WHERE D.InstallationID = @InstallationID | |
AND D.BuildingID = @BuildingID | |
ORDER BY R.[Address],L.[Address],D.[Address],D.[ID] | |
GO | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerBuilding TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerBuilding TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerBuilding TO ETSReadOnlyAccess | |
GO | |
IF object_id('ufn_ReportBuildingHasDevices', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportBuildingHasDevices; | |
GO | |
/** @brief Returns 1 if the specified building has any device | |
@param _a_buildingId Building ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportBuildingHasDevices | |
( | |
@buildingId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @result bit | |
IF EXISTS(SELECT ID FROM Device WHERE BuildingID=@buildingId) | |
set @result = 1 | |
ELSE | |
set @result = 0 | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportBuildingHasDevices] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportBuildingHasDevices] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportBuildingHasDevices] TO ETSWriteProjectAccess | |
GO | |
IF OBJECT_ID('usp_ReportDeviceOverviewPerTrade', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportDeviceOverviewPerTrade | |
GO | |
/** @brief Returns device data for one trade | |
@param _a_InstallationId ID of the table Installation | |
@param _a_LanguageId Language | |
@param _a_TradeId Trade ID | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportDeviceOverviewPerTrade | |
( | |
@InstallationId varchar(300), | |
@LanguageId varchar(20), | |
@TradeId varchar(300) | |
) | |
AS | |
SELECT | |
DeviceID = D.[ID], | |
IndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
Description = D.[Description], | |
InstallationHints = D.InstallationHints, | |
InstallationHintsFormat = CASE LEFT(D.InstallationHints,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
Comment = D.Comment, | |
CommentFormat = CASE LEFT(D.Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
CompletionStatus = [dbo].[ufn_CompletionStatus](D.CompletionStatus), | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
ApplicationProgramName = CASE HP.ApplicationProgramID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_TranslatedApplicationProgramName](A.ID, @LanguageId, NULL) | |
END, | |
ApplicationProgramVersion = [dbo].[ufn_ReportFormatApplicationProgramVersion](A.ApplicationVersion) | |
FROM [Device] AS D | |
LEFT OUTER JOIN [Line] As L ON L.ID = D.LineID | |
LEFT OUTER JOIN [Area] As R ON R.ID = L.AreaID | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
JOIN [Hardware2Program] HP ON HP.ID = D.Hardware2ProgramID | |
LEFT OUTER JOIN [ApplicationProgram] A ON A.ID = HP.ApplicationProgramID | |
WHERE D.InstallationID = @InstallationID | |
AND D.TradeID = @TradeID | |
ORDER BY R.[Address],L.[Address],D.[Address],D.[ID] | |
GO | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerTrade TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerTrade TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerTrade TO ETSReadOnlyAccess | |
GO | |
IF object_id('ufn_ReportTradeHasDevices', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportTradeHasDevices; | |
GO | |
/** @brief Returns 1 if the specified trade has any device | |
@param _a_tradeId Trade ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportTradeHasDevices | |
( | |
@tradeId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @result bit | |
IF EXISTS(SELECT ID FROM Device WHERE TradeID=@tradeId) | |
set @result = 1 | |
ELSE | |
set @result = 0 | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportTradeHasDevices] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTradeHasDevices] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTradeHasDevices] TO ETSWriteProjectAccess | |
GO | |
IF object_id('ufn_ReportGetBuildingName', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportGetBuildingName; | |
GO | |
/** @brief Returns the name of the Building for Building ID | |
@param _a_buildingId Building ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportGetBuildingName | |
( | |
@buildingId varchar(300) | |
) | |
RETURNS varchar(255) | |
AS | |
BEGIN | |
declare @result varchar(255) = (Select [Name] From Building where ID = @buildingId) | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingName] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingName] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingName] TO ETSWriteProjectAccess | |
GO | |
IF object_id('ufn_ReportGetBuildingPath', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportGetBuildingPath; | |
GO | |
/** @brief Returns the path of the Buildings for Building ID | |
@param _a_buildingId Building ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportGetBuildingPath | |
( | |
@buildingId varchar(300) | |
) | |
RETURNS nvarchar(MAX) | |
AS | |
BEGIN | |
declare @result nvarchar(MAX) | |
declare @name varchar(255) | |
declare @parentId varchar(200) | |
select @name = [Name], @parentId = ParentID | |
from Building where ID = @buildingId | |
set @result = RTRIM(@name) | |
while @parentId Is NOT NULL | |
begin | |
select @buildingId = @parentId | |
select @name = [Name], @parentId = ParentID | |
from Building where ID = @buildingId | |
select @result = RTRIM(@name) + '/' + @result | |
end | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingPath] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingPath] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetBuildingPath] TO ETSWriteProjectAccess | |
GO | |
IF object_id('ufn_ReportGetTradePath', 'FN') IS NOT NULL DROP FUNCTION [dbo].[ufn_ReportGetTradePath]; | |
GO | |
/** @brief Returns the path of the Trades for Trade ID | |
@param _a_tradeId Trade ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportGetTradePath] | |
( | |
@tradeId varchar(300) | |
) | |
RETURNS nvarchar(MAX) | |
AS | |
BEGIN | |
declare @result nvarchar(MAX) | |
declare @name varchar(255) | |
declare @parentId varchar(200) | |
select @name = [Name], @parentId = ParentID | |
from Trade where ID = @tradeId | |
set @result = RTRIM(@name) | |
while @parentId Is NOT NULL | |
begin | |
select @tradeId = @parentId | |
select @name = [Name], @parentId = ParentID | |
from Trade where ID = @tradeId | |
select @result = RTRIM(@name) + '/' + @result | |
end | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportGetTradePath] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTradePath] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTradePath] TO ETSWriteProjectAccess | |
GO | |
IF OBJECT_ID('usp_ReportDeviceOverviewPerDevice', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportDeviceOverviewPerDevice | |
GO | |
/** @brief Returns device data for one device | |
@param _a_LanguageId Language | |
@param _a_DeviceId Device ID | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportDeviceOverviewPerDevice | |
( | |
@LanguageId varchar(20), | |
@DeviceId varchar(300) | |
) | |
AS | |
SELECT | |
IndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
Description = D.[Description], | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
ApplicationProgramName = CASE HP.ApplicationProgramID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_TranslatedApplicationProgramName](A.ID, @LanguageId, NULL) | |
END, | |
ApplicationProgramVersion = [dbo].[ufn_ReportFormatApplicationProgramVersion](A.ApplicationVersion), | |
InstallationHints = D.InstallationHints, | |
InstallationHintsFormat = CASE LEFT(D.InstallationHints,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
Comment = D.Comment, | |
CommentFormat = CASE LEFT(D.Comment,5) | |
WHEN '{\rtf' THEN 'rtf' | |
ELSE 'text' | |
END, | |
CompletionStatus = [dbo].[ufn_CompletionStatus](D.CompletionStatus), | |
BuildingPath = CASE D.BuildingID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_ReportGetBuildingPath](D.BuildingID) | |
END, | |
BuildingName = CASE D.BuildingID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_ReportGetBuildingName](D.BuildingID) | |
END, | |
TradePath = CASE D.TradeID | |
WHEN NULL THEN NULL | |
ELSE [dbo].[ufn_ReportGetTradePath](D.TradeID) | |
END, | |
LastModified = D.LastModified, | |
LastDownload = D.LastDownload, | |
IsPlRepeater = NULL | |
FROM [Device] AS D | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
JOIN [Hardware2Program] HP ON HP.ID = D.Hardware2ProgramID | |
LEFT OUTER JOIN [ApplicationProgram] A ON A.ID = HP.ApplicationProgramID | |
WHERE D.ID = @DeviceID | |
GO | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerDevice TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerDevice TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportDeviceOverviewPerDevice TO ETSReadOnlyAccess | |
GO | |
IF OBJECT_ID('usp_ReportGetCompletionStatus', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportGetCompletionStatus | |
GO | |
/** @brief Returns completion Status | |
@param _a_completionStatus CompletionStatus | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportGetCompletionStatus | |
( | |
@value varchar(50) | |
) | |
AS | |
SELECT | |
CompletionStatus = [dbo].[ufn_CompletionStatus](@value) | |
GO | |
GRANT EXEC ON [dbo].usp_ReportGetCompletionStatus TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportGetCompletionStatus TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportGetCompletionStatus TO ETSReadOnlyAccess | |
GO | |
IF object_id('ufn_ReportCountDevicesInLine', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportCountDevicesInLine; | |
GO | |
/** @brief Returns the number of devices in the specified line | |
@param _a_lineId Line ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportCountDevicesInLine | |
( | |
@lineId varchar(300) | |
) | |
RETURNS int | |
AS | |
BEGIN | |
declare @result int | |
select @result = COUNT(Device.ID) FROM Device WHERE Device.LineID=@lineId | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportCountDevicesInLine] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportCountDevicesInLine] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportCountDevicesInLine] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportFormatApplicationProgramVersion] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Format an application program version for use in reports | |
*/ | |
-- ============================================= | |
-- ufn_ReportFormatApplicationProgramVersion | |
-- ============================================= | |
IF object_id('ufn_ReportFormatApplicationProgramVersion', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportFormatApplicationProgramVersion; | |
GO | |
/** @brief Formats a device address for reports as a.l.d | |
@param _a_DeviceId Device ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportFormatApplicationProgramVersion] | |
( | |
@version smallint | |
) | |
RETURNS varchar(5) | |
AS | |
BEGIN | |
declare @result varchar(5) | |
If @version IS NOT NULL | |
BEGIN | |
set @result = LTrim(Str(@version / 16)) + '.' + LTrim(Str(@version % 16)) | |
END | |
return @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportFormatApplicationProgramVersion] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatApplicationProgramVersion] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatApplicationProgramVersion] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportFormatGroupAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Format a group address for use in reports | |
*/ | |
-- ============================================= | |
-- ufn_ReportFormatGroupAddress | |
-- ============================================= | |
IF object_id('ufn_ReportFormatGroupAddress', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportFormatGroupAddress; | |
GO | |
/** @brief Formats a single group address for reports as x1/x2/../xn. | |
@param _a_GroupAddressId Group Address ID | |
@param _a_freeGAHex true or false: if treu -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportFormatGroupAddress] | |
( | |
@groupAddressId varchar(300), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
RETURNS varchar(200) | |
AS | |
BEGIN | |
declare @address int | |
declare @parentId varchar(200) | |
declare @installationId varchar(300) | |
select @address = [Address], | |
@parentId = GroupRangeID, | |
@installationId = InstallationID | |
from GroupAddress where ID=@groupAddressId | |
declare @projectId varchar(300)=(select ProjectID from Installation where ID=@installationId) | |
declare @groupAddressStyle varchar(15) = (select GroupAddressStyle from Project where ID=@projectId) | |
declare @result varchar(200) | |
declare @tmp int | |
declare @hexAddress varbinary(8) = convert(Varbinary(8), @address) | |
declare @hexString varchar(8) = convert(varchar(8),@hexAddress,2) | |
if @groupAddressStyle = 'Free' | |
begin | |
if @freeGAHex = 0 | |
select @result = LTRIM(STR(@address)) | |
else | |
select @result = LTRIM(@freeGAHexPrefix) + RIGHT(LTRIM(@hexString),4) | |
end | |
else | |
begin | |
if @parentId Is NOT NULL | |
begin | |
declare @rangeStart int = (select RangeStart from GroupRange where ID=@parentId) | |
declare @rangeEnd int = (select RangeEnd from GroupRange where ID=@parentId) | |
if @rangeStart = 1 | |
set @address = @address + 1 | |
select @result = LTRIM(STR(@address - @rangeStart)) | |
set @parentId = (select ParentID from GroupRange where ID=@parentId) | |
while @parentId Is NOT NULL | |
begin | |
declare @rangeStartParent int = (select RangeStart from GroupRange where ID=@parentId) | |
declare @rangeEndParent int = (select RangeEnd from GroupRange where ID=@parentId) | |
select @tmp = (@rangeStart - @rangeStartParent)/(@rangeEnd - @rangeStart) | |
select @result = LTRIM(STR(@tmp)) + '/' + @result | |
set @parentId = (select ParentID from GroupRange where ID=@parentId) | |
set @rangeStart = @rangeStartParent | |
set @rangeEnd = @rangeEndParent | |
end | |
select @tmp = (@rangeStart)/(@rangeEnd - @rangeStart) | |
select @result = LTRIM(STR(@tmp)) + '/' + @result | |
end | |
end | |
return @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupAddress] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupAddress] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupAddress] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportFormatGroupRange] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Format a group Range RangeStart and RangeEnd for use in reports | |
*/ | |
-- ============================================= | |
-- ufn_ReportFormatGroupRange | |
-- ============================================= | |
IF object_id('ufn_ReportFormatGroupRange', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportFormatGroupRange; | |
GO | |
/** @brief Formats a group range for reports | |
- as x1/x2/../xn for GroupAddressStyle TwoLevel or ThreeLevel | |
- as x1.RangeStart...x1.RangeEnd/x2.RangeStart...x2.RangeEnd/.../xn.RangeStart...xn.RangeEnd | |
with xn.ID = @groupRangeId | |
@param _a_GroupRangeId Group Range ID | |
@param _a_freeGAHex true or false: if true -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportFormatGroupRange] | |
( | |
@groupRangeId varchar(300), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
RETURNS varchar(200) | |
AS | |
BEGIN | |
declare @rangeStart int | |
declare @rangeEnd int | |
declare @parentId varchar(200) | |
declare @installationId varchar(300) | |
declare @rangeStartParent int | |
declare @rangeEndParent int | |
declare @result varchar(200) | |
declare @tmp varchar(200) | |
select @rangeStart = RangeStart, | |
@rangeEnd = RangeEnd, | |
@parentId = ParentID, | |
@installationId = InstallationID | |
from GroupRange where ID=@groupRangeId | |
declare @projectId varchar(300)=(select ProjectID from Installation where ID=@installationId) | |
declare @groupAddressStyle varchar(15) = (select GroupAddressStyle from Project where ID=@projectId) | |
select @result = '' | |
if @groupAddressStyle = 'Free' | |
select @result = [dbo].[ufn_ReportFormatFreeStyleGroupRange](@rangeStart, @rangeEnd, @freeGAHex, @freeGAHexPrefix) | |
else | |
begin | |
while @parentId Is NOT NULL | |
begin | |
select @rangeStartParent = RangeStart, | |
@rangeEndParent = RangeEnd | |
from GroupRange where ID=@parentId | |
--if @groupAddressStyle = 'Free' | |
-- select @tmp = [dbo].[ufn_ReportFormatFreeStyleGroupRange](@rangeStart, @rangeEnd, @freeGAHex, @freeGAHexPrefix) | |
--else | |
select @tmp = STR((@rangeStart - @rangeStartParent)/(@rangeEnd - @rangeStart)) | |
if @result <> '' | |
select @result = LTRIM(@tmp) + '/' + @result | |
else | |
select @result = LTRIM(@tmp) | |
set @parentId = (select ParentID from GroupRange where ID=@parentId) | |
set @rangeStart = @rangeStartParent | |
set @rangeEnd = @rangeEndParent | |
end | |
--if @groupAddressStyle = 'Free' | |
--select @tmp = [dbo].[ufn_ReportFormatFreeStyleGroupRange](@rangeStart, @rangeEnd, @freeGAHex, @freeGAHexPrefix) | |
--else | |
select @tmp = STR((@rangeStart)/(@rangeEnd - @rangeStart)) | |
if @result <> '' | |
select @result = LTRIM(@tmp) + '/' + @result | |
else | |
select @result = LTRIM(@tmp) | |
end | |
return @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupRange] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupRange] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatGroupRange] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportFormatFreeStyleGroupRange | |
-- ============================================= | |
IF object_id('ufn_ReportFormatFreeStyleGroupRange', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportFormatFreeStyleGroupRange; | |
GO | |
/** @brief Formats a single group range in freeStyle display for reports | |
as (x.RangeStart...x.RangeEnd) | |
@param _a_rangeStart Range Start | |
@param _a_rangeEnd Range End | |
@param _a_freeGAHex true or false: if true -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportFormatFreeStyleGroupRange] | |
( | |
@rangeStart int, | |
@rangeEnd int, | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
RETURNS varchar(200) | |
AS | |
BEGIN | |
declare @result varchar(200) | |
declare @strStart varchar(20) | |
declare @strEnd varchar(20) | |
if @freeGAHex = 0 | |
begin | |
select @strStart = LTRIM(STR(@rangeStart)) | |
select @strEnd = LTRIM(STR(@rangeEnd)) | |
end | |
else | |
begin | |
declare @hexStart varbinary(8) = convert(Varbinary(8), @rangeStart) | |
select @strStart = LTRIM(@freeGAHexPrefix) + RIGHT(LTRIM(convert(varchar(8),@hexStart,2)),4) | |
declare @hexEnd varbinary(8) = convert(Varbinary(8), @rangeEnd) | |
select @strEnd = LTRIM(@freeGAHexPrefix) + RIGHT(LTRIM(convert(varchar(8),@hexEnd,2)),4) | |
end | |
select @result = LTRIM(@strStart) + '...' + LTRIM(@strEnd) | |
return @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportFormatFreeStyleGroupRange] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatFreeStyleGroupRange] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatFreeStyleGroupRange] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportFormatIndividualAddress] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Format an individual address for use in reports | |
*/ | |
-- ============================================= | |
-- ufn_ReportFormatIndividualAddress | |
-- ============================================= | |
IF object_id('ufn_ReportFormatIndividualAddress', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportFormatIndividualAddress; | |
GO | |
/** @brief Formats a device address for reports as a.l.d | |
@param _a_DeviceId Device ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportFormatIndividualAddress] | |
( | |
@deviceId varchar(300) | |
) | |
RETURNS varchar(10) | |
AS | |
BEGIN | |
declare @area int | |
declare @line int | |
declare @dev int | |
select @dev = D.[Address], | |
@line = L.[Address], | |
@area = A.[Address] | |
from [Device] D | |
LEFT OUTER JOIN [Line] L ON L.ID = D.LineID | |
LEFT OUTER JOIN [Area] A ON A.ID = L.AreaID | |
where D.ID=@deviceId | |
declare @areastr varchar(2) | |
declare @linestr varchar(2) | |
declare @devstr varchar(3) | |
IF @area IS NULL | |
set @areastr = '--' | |
ELSE | |
BEGIN | |
set @areastr = Replace(Str(@area, 2), ' ', '0') | |
END | |
IF @line IS NULL | |
set @linestr = '--' | |
ELSE | |
BEGIN | |
set @linestr = Replace(Str(@line, 2), ' ', '0') | |
END | |
IF @dev IS NULL | |
set @devstr = '---' | |
ELSE | |
BEGIN | |
set @devstr = Replace(Str(@dev, 3), ' ', '0') | |
END | |
return @areastr + '.' + @linestr + '.' + @devstr | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportFormatIndividualAddress] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatIndividualAddress] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportFormatIndividualAddress] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetDeviceObjectData] | |
-------------------------------------------------------------------------------- | |
/** @file | |
return translated texts and flags for a device object for use in reports | |
*/ | |
-- ============================================= | |
-- ufn_ReportTranslatedDeviceObjectTextFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportTranslatedDeviceObjectTextFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportTranslatedDeviceObjectTextFromParents; | |
GO | |
/** @brief returns Text from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
@param _a_languageId language Id | |
@param _a_defaultLangId: default language ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents] | |
( | |
@comObjRefId varchar(300), | |
@languageId varchar(20), | |
@defaultLangId varchar(20) | |
) | |
RETURNS nvarchar(255) | |
AS | |
BEGIN | |
declare @text nvarchar(255) | |
declare @comObjId varchar(300) | |
select @text = [Text], @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if (@languageId IS NOT NULL Or @defaultLangId IS NOT NULL) | |
select @text = [dbo].[ufn_TranslatedCommunicationObjectRefText](@comObjRefId, @languageId, @defaultLangId) | |
if @text is null | |
begin | |
if (@languageId IS NOT NULL Or @defaultLangId IS NOT NULL) | |
select @text = [dbo].[ufn_TranslatedCommunicationObjectText](@comObjId, @languageId, @defaultLangId) | |
else | |
select @text = [Text] from CommunicationObject where ID = @comObjId | |
end | |
return @text | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportTranslatedDeviceObjectFunctionTextFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportTranslatedDeviceObjectFunctionTextFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportTranslatedDeviceObjectFunctionTextFromParents; | |
GO | |
/** @brief returns FunctionText from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
@param _a_languageId language Id | |
@param _a_defaultLangId: default language ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents] | |
( | |
@comObjRefId varchar(300), | |
@languageId varchar(20), | |
@defaultLangId varchar(20) | |
) | |
RETURNS nvarchar(MAX) | |
AS | |
BEGIN | |
declare @text nvarchar(MAX) | |
declare @comObjId varchar(300) | |
select @text = FunctionText, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if (@languageId IS NOT NULL Or @defaultLangId IS NOT NULL) | |
select @text = [dbo].[ufn_TranslatedCommunicationObjectRefFunctionText](@comObjRefId, @languageId, @defaultLangId) | |
if @text is null | |
begin | |
if (@languageId IS NOT NULL Or @defaultLangId IS NOT NULL) | |
select @text = [dbo].[ufn_TranslatedCommunicationObjectFunctionText](@comObjId, @languageId, @defaultLangId) | |
else | |
select @text = FunctionText from CommunicationObject where ID = @comObjId | |
end | |
return @text | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectObjectSizeFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectObjectSizeFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectObjectSizeFromParents; | |
GO | |
/** @brief returns ObjectSize from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS varchar(20) | |
AS | |
BEGIN | |
declare @objectSize varchar(20) | |
declare @comObjId varchar(300) | |
select @objectSize = ObjectSize, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @objectSize is null | |
begin | |
select @objectSize = ObjectSize from CommunicationObject where ID = @comObjId | |
end | |
return @objectSize | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectReadFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectReadFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectReadFlagFromParents; | |
GO | |
/** @brief returns readFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectReadFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @readFlag bit | |
declare @comObjId varchar(300) | |
select @readFlag = ReadFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @readFlag is null | |
begin | |
select @readFlag = ReadFlag from CommunicationObject where ID = @comObjId | |
end | |
return @readFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectWriteFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectWriteFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectWriteFlagFromParents; | |
GO | |
/** @brief returns WriteFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @WriteFlag bit | |
declare @comObjId varchar(300) | |
select @WriteFlag = WriteFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @WriteFlag is null | |
begin | |
select @WriteFlag = WriteFlag from CommunicationObject where ID = @comObjId | |
end | |
return @WriteFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectCommunicationFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectCommunicationFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectCommunicationFlagFromParents; | |
GO | |
/** @brief returns CommunicationFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @CommunicationFlag bit | |
declare @comObjId varchar(300) | |
select @CommunicationFlag = CommunicationFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @CommunicationFlag is null | |
begin | |
select @CommunicationFlag = CommunicationFlag from CommunicationObject where ID = @comObjId | |
end | |
return @CommunicationFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectUpdateFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectUpdateFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectUpdateFlagFromParents; | |
GO | |
/** @brief returns UpdateFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @UpdateFlag bit | |
declare @comObjId varchar(300) | |
select @UpdateFlag = UpdateFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @UpdateFlag is null | |
begin | |
select @UpdateFlag = UpdateFlag from CommunicationObject where ID = @comObjId | |
end | |
return @UpdateFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectTransmitFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectTransmitFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectTransmitFlagFromParents; | |
GO | |
/** @brief returns TransmitFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @TransmitFlag bit | |
declare @comObjId varchar(300) | |
select @TransmitFlag = TransmitFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @TransmitFlag is null | |
begin | |
select @TransmitFlag = TransmitFlag from CommunicationObject where ID = @comObjId | |
end | |
return @TransmitFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectReadOnInitFlagFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectReadOnInitFlagFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectReadOnInitFlagFromParents; | |
GO | |
/** @brief returns ReadOnInitFlag from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS bit | |
AS | |
BEGIN | |
declare @ReadOnInitFlag bit | |
declare @comObjId varchar(300) | |
select @ReadOnInitFlag = ReadOnInitFlag, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @ReadOnInitFlag is null | |
begin | |
select @ReadOnInitFlag = ReadOnInitFlag from CommunicationObject where ID = @comObjId | |
end | |
return @ReadOnInitFlag | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectPriorityFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectPriorityFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectPriorityFromParents; | |
GO | |
/** @brief returns Priority from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectPriorityFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS varchar(6) | |
AS | |
BEGIN | |
declare @Priority varchar(6) | |
declare @comObjId varchar(300) | |
select @Priority = Priority, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @Priority is null | |
begin | |
select @Priority = Priority from CommunicationObject where ID = @comObjId | |
end | |
return @Priority | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectPriorityFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectPriorityFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectPriorityFromParents] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportDeviceObjectDatapointTypeFromParents | |
-- ============================================= | |
IF object_id('ufn_ReportDeviceObjectDatapointTypeFromParents', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceObjectDatapointTypeFromParents; | |
GO | |
/** @brief returns DatapointType from parents for a single deviceObject. | |
@param _a_ComObjectRefId device CommunicationObjectRef ID | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents] | |
( | |
@comObjRefId varchar(300) | |
) | |
RETURNS varchar(6) | |
AS | |
BEGIN | |
declare @DatapointType varchar(6) | |
declare @comObjId varchar(300) | |
select @DatapointType = DatapointType, @comObjId = CommunicationObjectID | |
from CommunicationObjectRef where ID = @comObjRefId | |
if @DatapointType is null | |
begin | |
select @DatapointType = DatapointType from CommunicationObject where ID = @comObjId | |
end | |
return @DatapointType | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetDeviceObjects] | |
-------------------------------------------------------------------------------- | |
/** @file | |
detail device object output in reports | |
*/ | |
-- ============================================= | |
-- usp_ReportGetDeviceObjects | |
-- ============================================= | |
IF object_id('usp_ReportGetDeviceObjects', 'P') IS NOT NULL DROP PROCEDURE [dbo].usp_ReportGetDeviceObjects; | |
GO | |
/** @brief Returns the device objects for output as report. | |
The returned table contains the following columns | |
- Number: The object number | |
- Text: The object name | |
- Function: The object function | |
- ObjectSize: The object length | |
- DatapointType: The DatapointType | |
- ReadFlag: The Read flag | |
- WriteFlag: The Write flag | |
- CommunicationFlag: The Communication flag | |
- TransmitFlag: The Transmit flag | |
- UpdateFlag: The Update flag | |
- ReadOnInitFlag: The ReadOnInit flag | |
- Priority: The Transmission priority | |
- GroupAddresses: The list of associated group addresses, sending association first, separated by spaces | |
- DeviceObjectID: The ID (primary key) of table DeviceObject | |
@param _a_DeviceID ID (primary key) of table Device | |
@param _a_LanguageID The Language ID | |
@param _a_freeGAHex 0 or 1: if 1 -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
@return A table with the individual communication objects as rows. | |
*/ | |
CREATE PROCEDURE [dbo].[usp_ReportGetDeviceObjects] | |
( | |
@DeviceID varchar(300), | |
@LanguageID varchar(20), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
-- RETURNS table | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
declare @productID varchar(300) = (Select ProductID from Device where ID = @DeviceID) | |
DECLARE @appdefault varchar(20) = (select Top 1 DefaultLanguage from [Product] where ID = @productID ) | |
SELECT | |
Number = do.Number, | |
Description = do.Description, | |
[Text] = CASE WHEN do.[Text] IS NOT NULL THEN do.[Text] | |
ELSE [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents](coRef.ID, @LanguageID, @appdefault) END, | |
FunctionText = CASE WHEN do.FunctionText IS NOT NULL THEN do.FunctionText | |
ELSE [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents](coRef.ID, @LanguageID, @appdefault) END, | |
ObjectSize = CASE WHEN do.ObjectSize IS NOT NULL THEN do.ObjectSize | |
ELSE [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents](coRef.ID) END, | |
DatapointType = CASE when do.DatapointType IS NOT NULL Then [dbo].[ufn_TranslatedDatapointTypeText](do.DatapointType, @LanguageID, @appdefault) | |
ELSE [dbo].[ufn_TranslatedDatapointTypeText]([dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents](coRef.ID),@LanguageID, @appdefault) END, | |
DatapointSubType = CASE when do.DatapointType IS NOT NULL Then [dbo].[ufn_TranslatedDatapointSubTypeText](do.DatapointType, @LanguageID, @appdefault) | |
ELSE [dbo].[ufn_TranslatedDatapointSubTypeText]([dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents](coRef.ID),@LanguageID, @appdefault) END, | |
ReadFlag = CASE when do.ReadFlag IS NOT NULL Then do.ReadFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectReadFlagFromParents](coRef.ID) END, | |
WriteFlag = CASE when do.WriteFlag IS NOT NULL Then do.WriteFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents](coRef.ID) END, | |
CommunicationFlag = CASE when do.CommunicationFlag IS NOT NULL Then do.CommunicationFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents](coRef.ID) END, | |
TransmitFlag = CASE when do.TransmitFlag IS NOT NULL Then do.TransmitFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents](coRef.ID) END, | |
UpdateFlag = CASE when do.UpdateFlag IS NOT NULL Then do.UpdateFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents](coRef.ID) END, | |
ReadOnInitFlag = CASE when do.ReadOnInitFlag IS NOT NULL Then do.ReadOnInitFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents](coRef.ID) END, | |
Priority = CASE when do.Priority IS NOT NULL Then do.Priority | |
ELSE [dbo].[ufn_ReportDeviceObjectPriorityFromParents](coRef.ID) END, | |
GroupAddresses = (SELECT | |
STUFF((SELECT ' ' + [dbo].[ufn_ReportFormatGroupAddress](s.ID, @freeGAHex, @freeGAHexPrefix) + CASE when conn2.[send] = 'true' THEN 'S ' ELSE ' ' END AS [text()] | |
FROM Connector AS conn2 | |
JOIN GroupAddress As s ON s.ID=conn2.GroupAddressID | |
WHERE conn2.DeviceObjectID=conn1.DeviceObjectID | |
ORDER BY [Send] DESC | |
FOR XML PATH('')), 1, 1, '') | |
FROM Connector AS conn1 | |
WHERE conn1.DeviceObjectID = do.ID | |
GROUP BY DeviceObjectID), | |
DeviceObjectID = do.ID | |
FROM DeviceObject do | |
JOIN CommunicationObjectRef coRef ON coRef.ID=do.CommunicationObjectRefID | |
WHERE do.DeviceID = @DeviceID | |
AND do.IsActive = 'true' | |
ORDER BY do.Number | |
END | |
GO | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceObjects] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceObjects] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceObjects] TO ETSWriteProjectAccess | |
GO | |
IF object_id('ufn_ReportDeviceHasDeviceObjects', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportDeviceHasDeviceObjects; | |
GO | |
/** @brief Returns 1 if the specified device has any active device Object | |
@param _a_deviceId Device ID | |
*/ | |
CREATE FUNCTION [dbo].ufn_ReportDeviceHasDeviceObjects | |
( | |
@deviceId varchar(300) | |
) | |
RETURNS int | |
AS | |
BEGIN | |
declare @result int | |
IF EXISTS(SELECT ID FROM DeviceObject WHERE DeviceID=@deviceId AND IsActive = 'true') | |
set @result = 1 | |
ELSE | |
set @result = 0 | |
RETURN @result | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceHasDeviceObjects] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceHasDeviceObjects] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportDeviceHasDeviceObjects] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetDeviceParameters] | |
-------------------------------------------------------------------------------- | |
/** @file | |
detail device object output in reports | |
*/ | |
-- ============================================= | |
-- usp_ReportGetDeviceParameters | |
-- ============================================= | |
IF object_id('usp_ReportGetDeviceParameters', 'P') IS NOT NULL DROP PROCEDURE [dbo].usp_ReportGetDeviceParameters; | |
GO | |
/** @brief Returns the device parameters for output as report. | |
The returned table contains the following columns | |
- IsPageCaption: 1 if this is a page caption, 0 otherwise | |
- Caption: The label (Parameter.Description) | |
- FormattedValue: The value formatted for display | |
- DeviceParameterID: The ID (primary key) of table DeviceParameter | |
@param _a_DeviceID ID (primary key) of table Device | |
@param _a_LanguageID The Language ID | |
@return A table with the individual parameters as rows. | |
*/ | |
CREATE PROCEDURE [dbo].[usp_ReportGetDeviceParameters] | |
( | |
@DeviceID varchar(300), | |
@LanguageID varchar(20) | |
) | |
-- RETURNS table | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
declare @applProgID varchar(300) = (Select h2p.ApplicationProgramID from Hardware2Program h2p | |
JOIN Device dev ON h2p.ID = dev.Hardware2ProgramID WHERE dev.ID=@DeviceID) | |
declare @appdefault varchar(20) = (select Top 1 DefaultLanguage from ApplicationProgram where ID = @applProgID ) | |
IF (@LanguageID IS NULL AND @appdefault IS NULL) | |
SELECT | |
[Name] = CASE WHEN paramRef.Name IS NOT NULL THEN paramRef.Name ELSE param.Name END, | |
[Text] = CASE WHEN paramRef.Text IS NOT NULL THEN paramRef.Text ELSE param.Text END, | |
[Value] = CASE WHEN dp.Value IS NOT NULL THEN dp.Value ELSE paramRef.Value END, | |
DeviceParameterID = dp.ID | |
FROM DeviceParameter dp | |
JOIN ParameterRef paramRef ON dp.ParameterRefID = paramRef.ID | |
JOIN Parameter param ON paramRef.ParameterID = param.ID | |
WHERE dp.DeviceID=@DeviceID | |
AND dp.IsActive = 'true' | |
ORDER BY paramRef.DisplayOrder; | |
ELSE | |
SELECT | |
[Name] = CASE WHEN paramRef.Name IS NOT NULL THEN paramRef.Name ELSE param.Name END, | |
[Text] = CASE WHEN [dbo].[ufn_TranslatedParameterRefText](paramRef.ID,@LanguageID,@appdefault) IS NOT NULL THEN | |
[dbo].[ufn_TranslatedParameterRefText](paramRef.ID,@LanguageID,@appdefault) | |
ELSE [dbo].[ufn_TranslatedParameterText](p.ID,@LanguageID,@appdefault) END, | |
[Value] = CASE WHEN dp.Value IS NOT NULL THEN dp.Value ELSE paramRef.Value END, | |
DeviceParameterID = dp.ID | |
FROM DeviceParameter dp | |
JOIN ParameterRef paramRef ON dp.ParameterRefID = paramRef.ID | |
JOIN Parameter param ON paramRef.ParameterID = param.ID | |
WHERE dp.DeviceID=@DeviceID | |
AND dp.IsActive = 'true' | |
ORDER BY paramRef.DisplayOrder; | |
END | |
GO | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceParameters] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceParameters] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetDeviceParameters] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetGroupAddressType] | |
-------------------------------------------------------------------------------- | |
/** @file | |
gets the length of a group address for use in reports | |
*/ | |
-- ============================================= | |
-- usp_GroupAddressWithType | |
-- ============================================= | |
IF object_id('usp_ReportGetGroupAddressType', 'P') IS NOT NULL DROP PROCEDURE [dbo].[usp_ReportGetGroupAddressType]; | |
GO | |
/** @brief Extends GroupAddress by data type information. | |
The returned table contains the following columns | |
- ObjectSize just the objectSize encoded as in DeviceObject.ObjectSize or CommunicationObjectRef.ObjectSize | |
- DatapointType just the objectSize encoded as in DeviceObject.DatapointType or CommunicationObjectRef.DatapointType | |
@param _a_GroupAddressID ID (primary key) of table GroupAddress | |
@return A table with | |
- no rows if no association exists | |
- one row containing the most specific data type information of all associated communication objects | |
*/ | |
CREATE PROCEDURE [dbo].[usp_ReportGetGroupAddressType] | |
( | |
@GroupAddressID varchar(300) | |
) | |
-- RETURNS table | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
-- The ORDER BY ensures that the record with the most specific | |
-- data type information is retrieved as first one | |
SELECT TOP(1) | |
ObjectSize = CASE WHEN do.ObjectSize IS NOT NULL THEN do.ObjectSize | |
ELSE [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents](coRef.ID) END, | |
DatapointType = CASE when do.DatapointType IS NOT NULL Then do.DatapointType | |
ELSE [dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents](coRef.ID) END | |
FROM [Connector] conn | |
JOIN DeviceObject do ON do.ID=conn.DeviceObjectID | |
JOIN CommunicationObjectRef coRef ON coRef.ID = do.CommunicationObjectRefID | |
WHERE conn.GroupAddressID=@GroupAddressID | |
ORDER BY ObjectSize DESC, DatapointType DESC | |
END | |
GO | |
GO | |
GRANT EXEC ON [dbo].[usp_ReportGetGroupAddressType] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetGroupAddressType] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[usp_ReportGetGroupAddressType] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetGroupAddresses] | |
-------------------------------------------------------------------------------- | |
/** @file | |
detail group address output in reports | |
*/ | |
-- ============================================= | |
-- usp_ReportGetDeviceObjects | |
-- ============================================= | |
IF object_id('usp_ReportGetGroupAddressesPerGroupRange', 'P') IS NOT NULL DROP PROCEDURE [dbo].usp_ReportGetGroupAddressesPerGroupRange; | |
GO | |
/** @brief Returns GroupAddress data for one groupRange | |
@param _a_GroupRangeId GroupRange.ID | |
@param _a_freeGAHex 0 or 1: if 1 -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportGetGroupAddressesPerGroupRange | |
( | |
@GroupRangeId varchar(300), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
AS | |
SELECT | |
ID = ga.ID, | |
[Name] = ga.[Name], | |
Description = ga.[Description], | |
Address = ga.Address, | |
FormattedAddress = [dbo].[ufn_ReportFormatGroupAddress](ga.ID, @freeGAHex, @freeGAHexPrefix), | |
Unfiltered = ga.Unfiltered, | |
Central = ga.Central, | |
[Global] = ga.[Global], | |
Comment = ga.Comment, | |
DatapointType = ga.DatapointType | |
FROM [GroupAddress] AS ga | |
WHERE GA.GroupRangeID = @GroupRangeId | |
ORDER BY ga.Address | |
GO | |
GRANT EXEC ON [dbo].usp_ReportGetGroupAddressesPerGroupRange TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportGetGroupAddressesPerGroupRange TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportGetGroupAddressesPerGroupRange TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGetGroupRange] | |
-------------------------------------------------------------------------------- | |
/** @file | |
detail group range output in reports | |
*/ | |
-- ============================================= | |
-- usp_ReportGetGroupRange | |
-- ============================================= | |
IF object_id('usp_ReportGetGroupRange', 'P') IS NOT NULL DROP PROCEDURE [dbo].usp_ReportGetGroupRange; | |
GO | |
/** @brief Returns Group Range data for one groupRangeID | |
@param _a_GroupRangeId GroupRange.ID | |
@param _a_freeGAHex 0 or 1: if 1 -> GA in FreeStyle are displayed in HEx format | |
@param _a_freeGAHexPrefix: only for FreeStyle Hex: Prefix | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportGetGroupRange | |
( | |
@GroupRangeId varchar(300), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
AS | |
SELECT | |
ID = gr.ID, | |
[Name] = gr.[Name], | |
Description = gr.[Description], | |
RangeStart = gr.RangeStart, | |
RangeEnd = gr.RangeEnd, | |
FormattedArea = [dbo].[ufn_ReportFormatGroupRange](@GroupRangeId, @freeGAHex, @freeGAHexPrefix), | |
Unfiltered = gr.Unfiltered, | |
Comment = gr.Comment, | |
ParentID = gr.ParentID | |
FROM [GroupRange] AS gr | |
WHERE gr.ID = @GroupRangeId | |
order by RangeStart, RangeEnd | |
GO | |
GRANT EXEC ON [dbo].usp_ReportGetGroupRange TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportGetGroupRange TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportGetGroupRange TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportGroupAddressConnectors] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- usp_ReportGroupAddressConnectors | |
-- ============================================= | |
IF object_id('usp_ReportGroupAddressConnectors', 'P') IS NOT NULL DROP PROCEDURE usp_ReportGroupAddressConnectors; | |
GO | |
/** @brief Returns the objects assigned to a group address for output as report. | |
The returned table contains the following columns | |
- Send: The send flag | |
- Acknowledge: The acknowledge flag | |
- DeviceAddress: The formatted device address | |
- ProductName: The device's product name | |
- DeviceDescription: The device description | |
- RoomName: The device's romm name | |
- ObjectNumber: The object number | |
- ObjectName: The object name | |
- ObjectFunction: The object function | |
- EibDataTypeID: The ID (primary key) of table EibDataType | |
- EibDataSubtypeID: The ID (primary key) of table EibDataSubtype | |
- ReadEnabled: The Read flag | |
- WriteEnabled: The Write flag | |
- CommunicationEnabled: The Communication flag | |
- TransmissionEnabled: The Transmission flag | |
- UpdateEnabled: The Update flag | |
- ReadOnInitEnabled: The ReadOnInit flag | |
- TransmissionPriority: The Transmission priority | |
- GroupAddresses: The list of associated group addresses, sending association first, separated by spaces | |
- AssociationID: The ID (primary key) of table Association | |
@param _a_GroupAddressID The ID (primary key) of table DeviceObject | |
@param _a_LanguageID The Language ID | |
@param _a_freeGAHex If non-zero, the group address is formatted as headecimal number | |
@param _a_freeGAHexPrefix If _a_freeGAHex is set, specifies an optional prefix | |
@return A table with the individual associaions as rows. | |
*/ | |
CREATE PROCEDURE dbo.usp_ReportGroupAddressConnectors | |
( | |
@GroupAddressID varchar(300), | |
@LanguageID varchar(20), | |
@freeGAHex int, | |
@freeGAHexPrefix varchar(10) | |
) | |
-- RETURNS table | |
AS | |
SET NOCOUNT ON; | |
DECLARE @appdefault varchar(20) = @LanguageID | |
SELECT | |
[Send] = conn.[Send], | |
Acknowledge = conn.Acknowledge, | |
DeviceIndividualAddress = [dbo].[ufn_ReportFormatIndividualAddress](D.ID), | |
DeviceDescription = D.[Description], | |
DeviceInstallationHints = D.InstallationHints, | |
DeviceComment = D.Comment, | |
ProductText = [dbo].[ufn_TranslateProductText](D.ProductID, @LanguageId, NULL), | |
RoomName = (SELECT pp.[Name] FROM building pp WHERE pp.ID = d.BuildingID), | |
Number = do.[Number], | |
Description = do.Description, | |
[Text] = CASE WHEN do.[Text] IS NOT NULL THEN do.[Text] | |
ELSE [dbo].[ufn_ReportTranslatedDeviceObjectTextFromParents](coRef.ID, @LanguageID, @appdefault) END, | |
FunctionText = CASE WHEN do.FunctionText IS NOT NULL THEN do.FunctionText | |
ELSE [dbo].[ufn_ReportTranslatedDeviceObjectFunctionTextFromParents](coRef.ID, @LanguageID, @appdefault) END, | |
ObjectSize = CASE WHEN do.ObjectSize IS NOT NULL THEN do.ObjectSize | |
ELSE [dbo].[ufn_ReportDeviceObjectObjectSizeFromParents](coRef.ID) END, | |
DatapointType = CASE when do.DatapointType IS NOT NULL Then [dbo].[ufn_TranslatedDatapointTypeText](do.DatapointType, @LanguageID, NULL) | |
ELSE [dbo].[ufn_TranslatedDatapointTypeText]([dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents](coRef.ID),@LanguageID, NULL) END, | |
DatapointSubType = CASE when do.DatapointType IS NOT NULL Then [dbo].[ufn_TranslatedDatapointSubTypeText](do.DatapointType, @LanguageID, NULL) | |
ELSE [dbo].[ufn_TranslatedDatapointSubTypeText]([dbo].[ufn_ReportDeviceObjectDatapointTypeFromParents](coRef.ID),@LanguageID, NULL) END, | |
ReadFlag = CASE when do.ReadFlag IS NOT NULL Then do.ReadFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectReadFlagFromParents](coRef.ID) END, | |
WriteFlag = CASE when do.WriteFlag IS NOT NULL Then do.WriteFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectWriteFlagFromParents](coRef.ID) END, | |
CommunicationFlag = CASE when do.CommunicationFlag IS NOT NULL Then do.CommunicationFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectCommunicationFlagFromParents](coRef.ID) END, | |
TransmitFlag = CASE when do.TransmitFlag IS NOT NULL Then do.TransmitFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectTransmitFlagFromParents](coRef.ID) END, | |
UpdateFlag = CASE when do.UpdateFlag IS NOT NULL Then do.UpdateFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectUpdateFlagFromParents](coRef.ID) END, | |
ReadOnInitFlag = CASE when do.ReadOnInitFlag IS NOT NULL Then do.ReadOnInitFlag | |
ELSE [dbo].[ufn_ReportDeviceObjectReadOnInitFlagFromParents](coRef.ID) END, | |
Priority = CASE when do.Priority IS NOT NULL Then do.Priority | |
ELSE [dbo].[ufn_ReportDeviceObjectPriorityFromParents](coRef.ID) END, | |
GroupAddresses = (SELECT | |
STUFF((SELECT ' ' + [dbo].[ufn_ReportFormatGroupAddress](s.ID, @freeGAHex, @freeGAHexPrefix) + CASE when conn2.[send] = 'true' THEN 'S ' ELSE ' ' END AS [text()] | |
FROM Connector AS conn2 | |
JOIN GroupAddress As s ON s.ID=conn2.GroupAddressID | |
WHERE conn2.DeviceObjectID=conn1.DeviceObjectID | |
ORDER BY [Send] DESC | |
FOR XML PATH('')), 1, 1, '') | |
FROM Connector AS conn1 | |
WHERE conn1.DeviceObjectID = do.ID | |
GROUP BY DeviceObjectID), | |
ConnectorID = conn.ID | |
FROM Connector conn | |
JOIN DeviceObject do ON do.ID = conn.DeviceObjectID | |
JOIN CommunicationObjectRef coRef ON coRef.ID=do.CommunicationObjectRefID | |
JOIN Device d ON d.ID = do.DeviceID | |
WHERE conn.GroupAddressID = @GroupAddressID | |
ORDER BY conn.[Send] DESC, DeviceIndividualAddress, do.Number | |
GO | |
GRANT EXEC ON [dbo].usp_ReportGroupAddressConnectors TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportGroupAddressConnectors TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportGroupAddressConnectors TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportPartsList] | |
-------------------------------------------------------------------------------- | |
IF OBJECT_ID('usp_ReportPartsList', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportPartsList | |
GO | |
/** @brief Returns all product data for the parts list report | |
@param _a_InstallationId ID of the table Installation | |
@param _a_LanguageId Language | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportPartsList | |
( | |
@InstallationId varchar(300), | |
@LanguageId varchar(20) | |
) | |
AS | |
SELECT | |
ManufacturerId = M.ID, | |
ManufacturerName = M.[Name], | |
OrderNumber = P.OrderNumber, | |
ProductText = [dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
IsRailMounted = P.IsRailMounted, | |
WidthInMillimeter = P.WidthInMillimeter, | |
Colour = [dbo].[ufn_ReportGetTranslatedProductColour](P.ID, @LanguageId), | |
Series = [dbo].[ufn_ReportGetTranslatedProductSeries](P.ID, @LanguageId), | |
COUNT(*) AS ProductCount | |
FROM [Device] AS D | |
JOIN [Product] As P ON P.ID = D.ProductID | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
WHERE D.InstallationID = @InstallationID | |
GROUP BY M.ID, M.[Name], P.OrderNumber, | |
[dbo].[ufn_TranslateProductText](P.ID, @LanguageId, NULL), | |
P.IsRailMounted, P.WidthInMillimeter, | |
[dbo].[ufn_ReportGetTranslatedProductColour](P.ID, @LanguageId), | |
[dbo].[ufn_ReportGetTranslatedProductSeries](P.ID, @LanguageId) | |
ORDER BY OrderNumber | |
GO | |
GRANT EXEC ON [dbo].usp_ReportPartsList TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportPartsList TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportPartsList TO ETSReadOnlyAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportGetTranslatedProductColour | |
-- ============================================= | |
IF object_id('ufn_ReportGetTranslatedProductColour', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportGetTranslatedProductColour; | |
GO | |
/** @brief gets the colour of product | |
@param _a_ProductId Product ID | |
@param _a_LanguageId Language | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportGetTranslatedProductColour] | |
( | |
@productId varchar(300), | |
@LanguageId varchar(20) | |
) | |
RETURNS nvarchar(255) | |
AS | |
BEGIN | |
declare @langdefault varchar(20) = (select Top 1 DefaultLanguage from [Product] where ID = @productId ) | |
declare @value nvarchar(255) | |
declare @paId varchar(300) | |
select @value = [Value], @paId = [ID] | |
from [ProductAttribute] | |
where ProductID=@productId And [Name] ='Colour' | |
return [dbo].[ufn_TranslateProductAttributeValue](@paId, @LanguageId, @langdefault) | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductColour] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductColour] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductColour] TO ETSWriteProjectAccess | |
GO | |
-- ============================================= | |
-- ufn_ReportGetTranslatedProductSeries | |
-- ============================================= | |
IF object_id('ufn_ReportGetTranslatedProductSeries', 'FN') IS NOT NULL DROP FUNCTION [dbo].ufn_ReportGetTranslatedProductSeries; | |
GO | |
/** @brief gets the series of a product | |
@param _a_ProductId Product ID | |
@param _a_LanguageId Language | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportGetTranslatedProductSeries] | |
( | |
@productId varchar(300), | |
@LanguageId varchar(20) | |
) | |
RETURNS nvarchar(255) | |
AS | |
BEGIN | |
declare @langdefault varchar(20) = (select Top 1 DefaultLanguage from [Product] where ID = @productId ) | |
declare @value nvarchar(255) | |
declare @paId varchar(300) | |
select @value = [Value], @paId = [ID] | |
from [ProductAttribute] | |
where ProductID=@productId And [Name] ='Series' | |
return [dbo].[ufn_TranslateProductAttributeValue](@paId, @LanguageId, @langdefault) | |
END | |
GO | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductSeries] TO ETSFullAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductSeries] TO ETSReadOnlyAccess | |
GRANT EXEC ON [dbo].[ufn_ReportGetTranslatedProductSeries] TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportProjectHistoryAndTrace] | |
-------------------------------------------------------------------------------- | |
IF OBJECT_ID('usp_ReportProjectHistoryAndTrace', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportProjectHistoryAndTrace | |
GO | |
/** @brief Returns data of for the report project history from tables ProjectHistory and ProjectTrace | |
@param _a_projectId ID of the table project | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportProjectHistoryAndTrace | |
( | |
@ProjectId varchar(300) | |
) | |
AS | |
SELECT | |
ProjectID = PH.ProjectID, | |
Date = PH.Date, | |
[User] = PH.[User], | |
[TEXT] = PH.[Text], | |
Source = 'ProjectHistory' | |
FROM [ProjectHistory] AS PH | |
Where PH.ProjectID = @ProjectId | |
UNION | |
SELECT | |
ProjectID = PT.ProjectID, | |
Date = Convert(DateTime2(0),PT.Date,0), | |
[User] = PT.UserName, | |
[TEXT] = PT.Description, | |
Source = 'ProjectTrace' | |
FROM [ProjectTrace] AS PT | |
Where PT.ProjectID = @ProjectId | |
GO | |
GRANT EXEC ON [dbo].usp_ReportProjectHistoryAndTrace TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportProjectHistoryAndTrace TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportProjectHistoryAndTrace TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ReportProjectStatistics] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function - Get project statistics, use in reports | |
*/ | |
IF OBJECT_ID('ufn_ReportProjectStatistics', 'FN') IS NOT NULL | |
DROP Function [dbo].ufn_ReportProjectStatistics | |
GO | |
/** @brief Returns different statistics about a project | |
@param _a_InstallationId ID of the table Installation | |
@param _a_StatisticsItem Specifies the kind of statistical information requested, one of | |
- "TotalDevices": total number of devices | |
- "TotalDeviceObjects": total number of visible communication objects | |
- "TotalAreas": total number of areas | |
- "TotalLines": total number of lines | |
- "TotalGroupAddresses": total number of group adresses | |
- "TotalBuildings": total number of buildings | |
- "TotalBuildingParts": total number of building parts | |
- "TotalCorridors": total number of corridors | |
- "TotalFloors": total number of floors | |
- "TotalStairways": total number of stairways | |
- "TotalRooms": total number of rooms | |
- "TotalDistributionBoards": total number of distribution boards | |
- "TotalTrades": total number of trades (top-level and child) | |
*/ | |
CREATE FUNCTION [dbo].[ufn_ReportProjectStatistics] | |
( | |
@InstallationId varchar(300), | |
@StatisticsItem varchar(80) | |
) | |
RETURNS int | |
AS | |
BEGIN | |
IF @StatisticsItem = 'TotalDevices' | |
RETURN(SELECT COUNT(*) FROM [Device] WHERE InstallationID=@InstallationId) | |
ELSE | |
IF @StatisticsItem = 'TotalDeviceObjects' | |
RETURN(SELECT COUNT(*) FROM [DeviceObject] WHERE DeviceId IN (SELECT ID FROM [Device] WHERE InstallationID=@InstallationId) and IsActive = 1) | |
ELSE | |
IF @StatisticsItem = 'TotalConnectors' | |
RETURN(SELECT COUNT(*) FROM [Connector] WHERE GroupAddressID IN (SELECT ID FROM [GroupAddress] WHERE InstallationID=@InstallationId)) | |
ELSE | |
IF @StatisticsItem = 'TotalAreas' | |
RETURN(SELECT COUNT(*) FROM [Area] WHERE InstallationID=@InstallationId) | |
ELSE | |
IF @StatisticsItem = 'TotalLines' | |
RETURN(SELECT COUNT(*) FROM [Line] WHERE AreaID IN (SELECT ID FROM [Area] WHERE InstallationID=@InstallationId)) | |
ELSE | |
IF @StatisticsItem = 'TotalGroupAddresses' | |
RETURN(SELECT COUNT(*) FROM [GroupAddress] WHERE InstallationID=@InstallationId) | |
ELSE | |
IF @StatisticsItem = 'TotalBuildings' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='Building') | |
ELSE | |
IF @StatisticsItem = 'TotalBuildingParts' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='BuildingPart') | |
ELSE | |
IF @StatisticsItem = 'TotalCorridors' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='Corridor') | |
ELSE | |
IF @StatisticsItem = 'TotalFloors' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='Floor') | |
ELSE | |
IF @StatisticsItem = 'TotalStairways' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='Stairway') | |
ELSE | |
IF @StatisticsItem = 'TotalRooms' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='Room') | |
ELSE | |
IF @StatisticsItem = 'TotalDistributionBoards' | |
RETURN(SELECT COUNT(*) FROM [Building] WHERE InstallationID=@InstallationId AND [Type]='DistributionBoard') | |
ELSE | |
IF @StatisticsItem = 'TotalTrades' | |
RETURN(SELECT COUNT(*) FROM [Trade] WHERE InstallationID=@InstallationId AND ParentID IS NULL) | |
RETURN(0) | |
IF @StatisticsItem = 'TotalSubTrades' | |
RETURN(SELECT COUNT(*) FROM [Trade] WHERE InstallationID=@InstallationId AND ParentID IS NOT NULL) | |
RETURN(0) | |
END | |
GO | |
GRANT EXEC ON [dbo].ufn_ReportProjectStatistics TO ETSFullAccess | |
GRANT EXEC ON [dbo].ufn_ReportProjectStatistics TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].ufn_ReportProjectStatistics TO ETSReadOnlyAccess | |
GO | |
IF OBJECT_ID('usp_ReportProductsByManufacturer', 'P') IS NOT NULL | |
DROP PROCEDURE [dbo].usp_ReportProductsByManufacturer | |
GO | |
/** @brief Returns the count of products from each manufacturer in a project | |
@param _a_InstallationId ID of the table Installation | |
*/ | |
CREATE PROCEDURE [dbo].usp_ReportProductsByManufacturer | |
( | |
@InstallationId varchar(300) | |
) | |
AS | |
SELECT M.[Name] AS 'ManufacturerName', COUNT(*) AS 'ProductCount' | |
FROM [Product] AS P | |
JOIN [Manufacturer] AS M ON M.ID = P.ManufacturerID | |
WHERE P.ID IN (SELECT [ProductID] FROM [Device] WHERE InstallationID = @InstallationID) | |
GROUP BY M.[Name] | |
GO | |
GRANT EXEC ON [dbo].usp_ReportProductsByManufacturer TO ETSFullAccess | |
GRANT EXEC ON [dbo].usp_ReportProductsByManufacturer TO ETSWriteProjectAccess | |
GRANT EXEC ON [dbo].usp_ReportProductsByManufacturer TO ETSReadOnlyAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [RethrowException] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_RethrowException') | |
BEGIN | |
DROP PROCEDURE dbo.usp_RethrowException | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_RethrowException | |
AS | |
-- Return if there is no error information to retrieve. | |
IF ERROR_NUMBER() IS NULL | |
RETURN; | |
DECLARE | |
@ErrorMessage NVARCHAR(4000), | |
@ErrorNumber INT, | |
@ErrorSeverity INT, | |
@ErrorState INT, | |
@ErrorLine INT, | |
@ErrorProcedure NVARCHAR(200); | |
-- Assign variables to error-handling functions that | |
-- capture information for RAISERROR. | |
SELECT | |
@ErrorNumber = ERROR_NUMBER(), | |
@ErrorSeverity = ERROR_SEVERITY(), | |
@ErrorState = ERROR_STATE(), | |
@ErrorLine = ERROR_LINE(), | |
@ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-'); | |
-- Build the message string that will contain original | |
-- error information. | |
SELECT @ErrorMessage = | |
N'Error %d, Level %d, State %d, Procedure %s, Line %d, ' + | |
'Message: '+ ERROR_MESSAGE(); | |
-- Raise an error: msg_str parameter of RAISERROR will contain | |
-- the original error information. | |
RAISERROR | |
( | |
@ErrorMessage, | |
@ErrorSeverity, | |
1, | |
@ErrorNumber, -- parameter: original error number. | |
@ErrorSeverity, -- parameter: original error severity. | |
@ErrorState, -- parameter: original error state. | |
@ErrorProcedure, -- parameter: original error procedure name. | |
@ErrorLine -- parameter: original error line number. | |
); | |
GO | |
GRANT EXEC ON dbo.usp_RethrowException TO ETSFullAccess | |
DENY EXEC ON dbo.usp_RethrowException TO ETSReadOnlyAccess | |
DENY EXEC ON dbo.usp_RethrowException TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ShrinkDatabase] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ShrinkDatabase') | |
BEGIN | |
DROP PROCEDURE dbo.usp_ShrinkDatabase | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_ShrinkDatabase | |
AS | |
-- shrink current database | |
DBCC SHRINKDATABASE (0) WITH NO_INFOMSGS | |
GO | |
GRANT EXEC ON dbo.usp_ShrinkDatabase TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ShrinkDatabase TO ETSReadOnlyAccess | |
DENY EXEC ON dbo.usp_ShrinkDatabase TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [ShrinkTransactionLogs] | |
-------------------------------------------------------------------------------- | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_ShrinkTransactionLogs') | |
BEGIN | |
DROP PROCEDURE dbo.usp_ShrinkTransactionLogs | |
END | |
GO | |
CREATE PROCEDURE dbo.usp_ShrinkTransactionLogs | |
AS | |
-- shrink transaction log of our current database | |
declare @fileId int | |
set @fileId=(select file_id from sys.database_files where type=1) | |
DBCC SHRINKFILE(@fileId, 1) | |
GO | |
GRANT EXEC ON dbo.usp_ShrinkTransactionLogs TO ETSFullAccess | |
DENY EXEC ON dbo.usp_ShrinkTransactionLogs TO ETSReadOnlyAccess | |
DENY EXEC ON dbo.usp_ShrinkTransactionLogs TO ETSWriteProjectAccess | |
GO | |
-------------------------------------------------------------------------------- | |
-- [TranslateApplicationProgramDescription] | |
-------------------------------------------------------------------------------- | |
/** @file | |
Function for determine the application program translated description | |
*/ | |
-- ============================================= | |
-- Author: Name | |
-- Create date: | |
-- Description: | |
-- Version: 0.1 | |
-- ============================================= | |
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'FN' AND name = 'ufn_TranslatedApplicationProgramDescription') | |
BEGIN | |
DROP Function dbo.[ufn_TranslatedApplicationProgramDescription] | |
END | |
GO | |
CREATE FUNCTION [dbo].[ufn_TranslatedApplicationProgramDescription] | |
( | |
@ID varchar(300), | |
@language varchar(20), | |
@dbLanguage varchar(20) | |
) | |
RETURNS nvarchar(max) | |
AS | |
BEGIN | |
declare @primaryLanguage varchar(20) | |
set @primaryLanguage = SUBSTRING( @language, 1, 2 ) | |
declare @ResultTable table( Language varchar(20), Text nvarchar(max) ) | |
insert into @ResultTable select Language, TranslatedDescription as Text from ApplicationProgramTranslatedText where ApplicationProgramID = @ID and Language in (@language, @dbLanguage, @primaryLanguage) | |
declare @translation nvarchar(max) | |
-- find direct matching translation | |
set @translation = (select Text from @ResultTable where Language=@language) | |
if @translation is null | |
begin | |
--find translation that matches primary language | |
set @translation = (select Text from @ResultTable where Language=@primaryLanguage) | |
if @translation is null | |
begin | |
-- find translation that best matches primarylanguage | |
set @translation = (select TOP 1 TranslatedDescription from ApplicationProgramTranslatedText where ApplicationProgramID = @ID and Language like @primaryLanguage + '%') | |
if @translation is null | |
begin | |
-- find no translation use entry from table -> default language | |
set @translation = (select Description from ApplicationProgram where ID = @ID ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment