You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ITSM/.svn/pristine/59/593f33b147676465ce58bd3e726...

146 lines
13 KiB

USE [Vertragsverwaltung_20160404]
GO
/****** Object: StoredProcedure [dbo].[sp_rpt_security] Script Date: 02.12.2016 09:08:53 ******/
DROP PROCEDURE [dbo].[sp_rpt_security]
GO
/****** Object: StoredProcedure [dbo].[sp_rpt_security] Script Date: 02.12.2016 09:08:55 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[sp_rpt_security]
@sqlwhere varchar(1024)
AS
BEGIN
-- SELECT dbo.rolle.rollenr, dbo.rolle.bezeichnung, dbo.SecurityObject.SecurityObjectNr, dbo.SecurityObject.SecurityForm,
-- dbo.SecurityObject.SecurityObjectType, dbo.SecurityObject.SecurityObject, dbo.SecurityObject.SecurityObjectItem, dbo.SecurityObject.SecurityObjectDescriotion,
-- [level]
-- into #tmpa
-- from dbo.securityobject
-- WHERE (dbo.SecurityObject.Aktiv = 1) AND (dbo.SecurityObject.SecurityObjectType LIKE 'menustrip%' OR
-- dbo.SecurityObject.SecurityObjectType LIKE 'toolstrip%' OR
-- dbo.SecurityObject.SecurityObjectType LIKE 'tabpage') AND (dbo.SecurityObject.SecurityObject LIKE 'toolstrip%' OR
-- dbo.SecurityObject.SecurityObject LIKE 'menustrip%' OR
-- dbo.SecurityObject.SecurityObject LIKE 'tab%')
--
--
-- declare @bez varchar(255)
-- declare @xsql varchar(255)
-- declare xc cursor for
-- select bezeichnung from rolle where aktiv=1 order by bezeichnung
-- open xc
-- fetch next from xc into @bez
-- while @@fetch_status=0 begin
-- set @xsql='alter table #tmpa add [' + @bez + '] varchar(255)'
-- exec (@xsql)
-- fetch next from xc into @bez
-- end
-- close xc
-- deallocate xc
SELECT dbo.rolle.rollenr, dbo.rolle.bezeichnung, dbo.SecurityObject.SecurityObjectNr, dbo.SecurityObject.SecurityForm,
dbo.SecurityObject.SecurityObjectType, dbo.SecurityObject.SecurityObject, dbo.SecurityObject.SecurityObjectItem, dbo.SecurityObject.SecurityObjectDescriotion,
[level], ' ' as Erlaubt, 0 as sortkey
into #tmpa
FROM dbo.rolle CROSS JOIN
dbo.SecurityObject
WHERE (dbo.SecurityObject.Aktiv = 1) AND (dbo.rolle.aktiv = 1) AND (dbo.SecurityObject.SecurityObjectType LIKE 'menustrip%' OR
dbo.SecurityObject.SecurityObjectType LIKE 'toolstrip%' OR
dbo.SecurityObject.SecurityObjectType LIKE 'tabpage') AND (dbo.SecurityObject.SecurityObject LIKE 'toolstrip%' OR
dbo.SecurityObject.SecurityObject LIKE 'menustrip%' OR
dbo.SecurityObject.SecurityObject LIKE 'tab%')
order by securityobjectnr
update #tmpa set SecurityObjectItem = securityobject, securityobject=SecurityObjectItem where SecurityObjectItem like 'tab%'
update #tmpa set securityform = substring(securityform,4,len(securityform)-3)
update #tmpa set securityobject = substring(securityobject,1,4) where securityobject like 'Menu%'
update #tmpa set securityobjectitem = substring(securityobjectitem,1,len(securityobjectitem))
update #tmpa set securityobject = substring(securityobject,1,9) where securityobject like 'Toolstrip%'
update #tmpa set securityobjectitem = substring(securityobjectitem,6,len(securityobjectitem)-4) where securityobjectitem like 'tsbtn%'
update #tmpa set securityobjectitem = substring(securityobjectitem,7,len(securityobjectitem)-5) where securityobjectitem like 'ts2btn%'
update #tmpa set securityobjectitem = SecurityObjectDescriotion, SecurityObjectDescriotion='' where securityobject='Menu' and level=0
update #tmpa set securityobjectitem='' where securityobject='menu' and level<>0
update #tmpa set securityobjectitem='Toolstrip', SecurityObjectDescriotion='' where securityobjecttype='toolstrip' and level = 0
update #tmpa set SecurityObjectDescriotion=securityobjectitem where securityobjecttype='toolstrip' and level <> '0'
update #tmpa set securityobjectitem='' where securityobjecttype='toolstrip' and level <> 0
update #tmpa set securityobjectitem=SecurityObjectDescriotion where securityobjecttype='tabpage'
update #tmpa set SecurityObjectDescriotion='' where securityobjecttype='tabpage'
declare @k1 int
declare @k2 int
declare @sk int
declare @read int
declare @inv int
declare @xsql varchar(255)
set @sk=0
declare xc cursor for
select rollenr, SecurityObjectNr from #tmpa
open xc
fetch next from xc into @k1, @k2
while @@fetch_status=0 begin
update #tmpa set sortkey=@sk where SecurityObjectNr=@k2
set @sk=@sk+1
fetch next from xc into @k1, @k2
end
close xc
deallocate xc
declare aa cursor for select rollenr, securityobjectnr, readonly, invisible from rolle_securityobject where aktiv=1
open aa
fetch next from aa into @k1, @k2, @read, @inv
while @@fetch_status=0 begin
if @read=1 and @inv=1 update #tmpa set erlaubt=3 where rollenr=@k1 and securityobjectnr=@k2
if @read=1 and @inv=0 update #tmpa set erlaubt=2 where rollenr=@k1 and securityobjectnr=@k2
if @read=0 and @inv=1 update #tmpa set erlaubt=1 where rollenr=@k1 and securityobjectnr=@k2
fetch next from aa into @k1, @k2, @read, @inv
end
close aa
deallocate aa
--select * from #tmpa where securityform = 'vertragsuebersicht' and bezeichnung like 'systema%' order by sortkey
if @sqlwhere <> '' begin
set @xsql='select * from #tmpa where ' + @sqlwhere + ' order by sortkey'
end else begin
set @xsql='select * from #tmpa order by sortkey'
end
exec(@xsql)
drop table #tmpa
-- select * from #tmpa order by sortkey
--ORDER BY dbo.rolle.bezeichnung, dbo.SecurityObject.SecurityForm, dbo.SecurityObject.SecurityObject
-- SELECT SecurityObjectNr, SecurityForm, SecurityObjectType, SecurityObject, SecurityObjectItem, SecurityObjectDescriotion, 0 as visible, 0 as readonly
-- into #tmpa
-- FROM SecurityObject
-- where securityform = 'frmdummy'
--
-- declare @secform varchar(255)
-- declare xc cursor for
-- select distinct securityform from dbo.securityobject where aktiv=1
-- open xc
-- fetch next from xc into @secform
-- while @@fetch_status = 0 begin
-- insert #tmpa
-- select SecurityObjectNr, SecurityForm, SecurityObjectType, SecurityObject, SecurityObjectItem, SecurityObjectDescriotion,0,0
-- from securityobject
-- where SecurityForm=@secform and aktiv=1 order by securityobjectnr
-- fetch next from xc into @secform
-- end
-- close xc
-- deallocate xc
-- select * from #tmpa
END
GO