init
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
ALTER PROCEDURE [dbo].[sp_DASUpdateInsert]
|
||||
@DASId int = 0
|
||||
,@SerialNumber nvarchar(50) = null
|
||||
,@Type int
|
||||
,@MaxModules int
|
||||
,@MaxMemory bigint
|
||||
,@MaxSampleRate decimal(18,0)
|
||||
,@MinSampleRate decimal(18,0)
|
||||
,@FirmwareVersion nvarchar(50)
|
||||
,@CalDate datetime
|
||||
,@ProtocolVersion int
|
||||
,@LastModified datetime
|
||||
,@LastModifiedBy nvarchar(50)
|
||||
,@Version int
|
||||
,@LocalOnly bit
|
||||
,@LastUsed datetime
|
||||
,@LastUsedBy nvarchar(50)
|
||||
,@Connection nvarchar(50)
|
||||
,@Channels int
|
||||
,@Position nvarchar(50)
|
||||
,@ChannelTypes nvarchar(255)
|
||||
,@Reprogramable bit
|
||||
,@Reconfigurable bit
|
||||
,@IsModule bit
|
||||
,@PositionOnDistributor smallint
|
||||
,@PositionOnChain smallint
|
||||
,@Port smallint
|
||||
,@ParentDAS nvarchar(50)
|
||||
,@FirstUseDate datetime null
|
||||
,@TestId int null
|
||||
,@GroupId int null
|
||||
,@StandIn bit null
|
||||
,@new_id int OUTPUT
|
||||
,@errorNumber int output
|
||||
,@errorMessage nvarchar(250) output
|
||||
|
||||
AS
|
||||
BEGIN
|
||||
set @errorNumber = 0
|
||||
set @errorMessage = space(0)
|
||||
|
||||
SET NOCOUNT ON;
|
||||
if(@DASId = 0)
|
||||
begin
|
||||
set @DASId = dbo.foo_IdGetDAS(@SerialNumber)
|
||||
end
|
||||
|
||||
if(@DASId != 0)
|
||||
begin
|
||||
exec dbo.sp_DASUpdate @DASId
|
||||
,@SerialNumber
|
||||
,@Type
|
||||
,@MaxModules
|
||||
,@MaxMemory
|
||||
,@MaxSampleRate
|
||||
,@MinSampleRate
|
||||
,@FirmwareVersion
|
||||
,@CalDate
|
||||
,@ProtocolVersion
|
||||
,@LastModified
|
||||
,@LastModifiedBy
|
||||
,@Version
|
||||
,@LocalOnly
|
||||
,@LastUsed
|
||||
,@LastUsedBy
|
||||
,@Connection
|
||||
,@Channels
|
||||
,@Position
|
||||
,@ChannelTypes
|
||||
,@Reprogramable
|
||||
,@Reconfigurable
|
||||
,@IsModule
|
||||
,@PositionOnDistributor
|
||||
,@PositionOnChain
|
||||
,@Port
|
||||
,@ParentDAS
|
||||
,@FirstUseDate
|
||||
,@TestId
|
||||
,@GroupId
|
||||
,@StandIn
|
||||
,@new_id
|
||||
,@errorNumber output, @errorMessage output
|
||||
SET @new_id = @DASId
|
||||
end
|
||||
else
|
||||
begin
|
||||
exec dbo.sp_DASInsert @SerialNumber
|
||||
,@Type
|
||||
,@MaxModules
|
||||
,@MaxMemory
|
||||
,@MaxSampleRate
|
||||
,@MinSampleRate
|
||||
,@FirmwareVersion
|
||||
,@CalDate
|
||||
,@ProtocolVersion
|
||||
,@LastModified
|
||||
,@LastModifiedBy
|
||||
,@Version
|
||||
,@LocalOnly
|
||||
,@LastUsed
|
||||
,@LastUsedBy
|
||||
,@Connection
|
||||
,@Channels
|
||||
,@Position
|
||||
,@ChannelTypes
|
||||
,@Reprogramable
|
||||
,@Reconfigurable
|
||||
,@IsModule
|
||||
,@PositionOnDistributor
|
||||
,@PositionOnChain
|
||||
,@Port
|
||||
,@ParentDAS
|
||||
,@FirstUseDate
|
||||
,@TestId
|
||||
,@GroupId
|
||||
,@StandIn
|
||||
,@new_id output
|
||||
,@errorNumber output, @errorMessage output
|
||||
end
|
||||
END
|
||||
@@ -0,0 +1,22 @@
|
||||
CREATE PROCEDURE [dbo].[sp_ChannelSettingsGet_92]
|
||||
@Id int = NULL,
|
||||
@SettingName NVARCHAR (255) = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
IF (@Id IS NOT NULL) OR (@SettingName IS NOT NULL)
|
||||
BEGIN
|
||||
IF (@Id IS NULL)
|
||||
BEGIN
|
||||
SELECT [Id], [DefaultValue] FROM [dbo].[ChannelSettings] where (SettingName = @SettingName)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT [SettingName] FROM [dbo].[ChannelSettings] where (Id = @Id)
|
||||
END
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT [Id], [SettingName], [DefaultValue] FROM [dbo].[ChannelSettings]
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,44 @@
|
||||
CREATE PROCEDURE [dbo].[sp_SensorsStreamInputUpdateInsert]
|
||||
@Id INT=NULL,
|
||||
@SerialNumber NVARCHAR (255),
|
||||
|
||||
@UDPAddress NVARCHAR (50),
|
||||
|
||||
@LastModified DATETIME,
|
||||
@LastModifiedBy NVARCHAR (50),
|
||||
@UserTags VARBINARY (MAX),
|
||||
@Broken BIT,
|
||||
@DoNotUse BIT,
|
||||
@new_id INT OUTPUT,
|
||||
@errorNumber INT OUTPUT,
|
||||
@errorMessage NVARCHAR (255) OUTPUT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
SET @errorNumber = 0
|
||||
SET @errorMessage = ''
|
||||
|
||||
DECLARE @SensorType AS TINYINT
|
||||
DECLARE @SensorId AS INT
|
||||
|
||||
SELECT @SensorType = [TypeId] FROM [dbo].[SensorsType] WHERE [SensorType]='StreamInput'
|
||||
SELECT @SensorId = A.[Id] from [dbo].[Sensors] AS A INNER JOIN [dbo].SensorsType AS B ON A.SensorType=B.TypeId WHERE B.TypeId=@SensorType AND A.SerialNumber=@SerialNumber
|
||||
|
||||
IF( @SensorId IS NULL)
|
||||
BEGIN
|
||||
INSERT INTO [dbo].[Sensors] ([SensorType], [SerialNumber]) VALUES (@SensorType, @SerialNumber)
|
||||
SELECT @SensorId = SCOPE_IDENTITY()
|
||||
SET @new_id = @SensorId
|
||||
INSERT INTO [dbo].[SensorsStreamInput] ([SensorId], [UDPAddress], [LastModified], [LastModifiedBy], [UserTags], [Broken], [DoNotUse]) VALUES (@SensorId, @UDPAddress, @LastModified, @LastModifiedBy, @UserTags, @Broken, @DoNotUse)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SET @new_id = @SensorId
|
||||
UPDATE [dbo].SensorsStreamInput SET [UDPAddress]=@UDPAddress, [LastModified]=@LastModified, [LastModifiedBy]=@LastModifiedBy, [UserTags]=@UserTags, [Broken]=@Broken, [DoNotUse]=@DoNotUse WHERE [SensorId] = @SensorId
|
||||
END
|
||||
END
|
||||
IF(@@error != 0)
|
||||
BEGIN
|
||||
SET @errorNumber = error_number()
|
||||
SET @errorMessage = error_message()
|
||||
END
|
||||
Binary file not shown.
Reference in New Issue
Block a user