This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,70 @@
DECLARE intezmenytanevekCursor CURSOR LOCAL FOR
SELECT IntezmenyAdatok.C_INTEZMENYID, IntezmenyAdatok.C_TANEVID
FROM T_INTEZMENYADATOK IntezmenyAdatok
INNER JOIN T_TANEV Tanev ON Tanev.ID = C_TANEVID
AND Tanev.TOROLT = 'F'
AND Tanev.C_AKTIV = 'T'
DECLARE @intezmenyId int, @tanevId int
OPEN intezmenytanevekCursor
FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE @KonyvtarosId INT = NULL
SELECT TOP 1 @KonyvtarosId = ID FROM dbo.T_SZEREPKOR WHERE C_SZEREPKORTIPUS = 8824 AND C_INTEZMENYID = @intezmenyId AND C_TANEVID = @tanevId
IF(@KonyvtarosId IS NULL) BEGIN
INSERT INTO [dbo].T_SZEREPKOR
([C_SZEREPKORTIPUS]
,[C_INTEZMENYID]
,[C_TANEVID]
,[SERIAL]
,[LASTCHANGED]
,[CREATED]
,[MODIFIER]
,[CREATOR])
VALUES
(8824 -- Konyvtaros
,@intezmenyId
,@tanevId
,0
,GETDATE()
,GETDATE()
,NULL
,1)
SET @KonyvtarosId = SCOPE_IDENTITY()
END
DECLARE @KonyvtarosJogId INT = NULL
SELECT TOP 1 @KonyvtarosJogId = ID FROM dbo.T_JOGOSULTSAG WHERE C_JOG = 'Konyvtaros' AND C_INTEZMENYID = @intezmenyId AND C_TANEVID = @tanevId
IF(@KonyvtarosJogId IS NULL)
BEGIN
INSERT INTO dbo.T_JOGOSULTSAG
(
C_JOG, C_SZEREPKORTIPUS,[C_INTEZMENYID] , [C_TANEVID], TOROLT, SERIAL, CREATED, CREATOR
)
VALUES
(
N'Konyvtaros', -- C_JOG - nvarchar
8824, -- Konyvtaros
@intezmenyId , @tanevId,
'F', -- TOROLT - char
0, -- SERIAL - int
GETDATE(), -- CREATED - datetime
0 -- CREATOR - int
)
SET @KonyvtarosJogId = SCOPE_IDENTITY()
END
FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END
CLOSE intezmenytanevekCursor
DEALLOCATE intezmenytanevekCursor
GO

View file

@ -0,0 +1,90 @@

DROP TABLE IF EXISTS tmpForSwitchDictionaryItemBase
CREATE TABLE tmpForSwitchDictionaryItemBase(RegiID int, UjID int, TanevID int, C_NAME nvarchar(500), C_TYPE nvarchar(64), Torolni char(1))
DECLARE @TEMP_EnvironmentName nvarchar(1000), @LastTanevSorszam int
SET @LastTanevSorszam = (SELECT MAX(C_SORSZAM) FROM T_TANEV WHERE TOROLT = 'F' AND (C_KOVETKEZO = 'T' OR C_AKTIV = 'T'))
SET @TEMP_EnvironmentName = (SELECT [Value]
FROM dev.EnvironmentInfo WHERE [Key] = 'Dictionary')
IF (@TEMP_EnvironmentName IS NULL OR @TEMP_EnvironmentName NOT IN ('KK','NSZFH','HOI','AZURE'))
BEGIN INSERT INTO T_DICTIONARYITEMBASE(C_VALUE) VALUES('Nincs Dictionary ertek a dev.EnvironmentInfo tablaban') END -- elszall a migracio ha nincs
IF @TEMP_EnvironmentName = 'KK'
BEGIN
----- 8824 ----- Könyvtáros -----
INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni)
SELECT DIB.ID, 8824, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
UPDATE DIB SET
DIB.TOROLT = 'T'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
END
IF @TEMP_EnvironmentName = 'NSZFH'
BEGIN
----- 8824 ----- Könyvtáros -----
INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni)
SELECT DIB.ID, 8824, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
UPDATE DIB SET
DIB.TOROLT = 'T'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
END
IF @TEMP_EnvironmentName = 'HOI'
BEGIN
----- 8824 ----- Könyvtáros -----
INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni)
SELECT DIB.ID, 8824, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
UPDATE DIB SET
DIB.TOROLT = 'T'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
END
IF @TEMP_EnvironmentName = 'AZURE'
BEGIN
----- 8824 ----- Könyvtáros -----
INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni)
SELECT DIB.ID, 8824, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
UPDATE DIB SET
DIB.TOROLT = 'T'
FROM T_DICTIONARYITEMBASE DIB
WHERE DIB.C_DICTIONARYTYPEID = 67 AND DIB.C_NAME = N'Könyvtáros' AND DIB.TOROLT = 'F'
END
;
DISABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;
EXEC [dev].[uspCreateDictionaryItems] NULL, NULL;
ENABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;
EXEC [dev].uspSwitchDictionaryItemBaseFromTmp;
-- ================================================================================================================
-- Ezekhez az újonnan felvett dictionary elemek felvételekor más táblákba is
-- szükséges lehet kapcsolódó rekordokat beszúrni
-- dev.uspSetDictionaryProperties SP-be felejtsd el berakni, ez kell az új intézmény létrehozásához
-- ================================================================================================================
-- 8824 - Könyvtáros
INSERT INTO T_SZEREPKOR (
C_SZEREPKORTIPUS
,C_INTEZMENYID
,C_TANEVID
,TOROLT
,SERIAL
,LASTCHANGED
,CREATED
,MODIFIER
,CREATOR
)
SELECT 8824, i.ID, tv.ID, 'F', 0, GETDATE(), GETDATE(), NULL, NULL
FROM T_INTEZMENY i
INNER JOIN T_TANEV tv ON tv.C_INTEZMENYID = i.ID
WHERE tv.TOROLT = 'F' AND i.TOROLT = 'F' AND tv.C_AKTIV = 'T'