AÇIKLAMA:
Emakin'deki formlarda yüklenen dosyalar file tablosunda tutulmaktadır. Bu formlardaki verilere database üzerinden erişilebilir fakat bu kolay bir işlem olmayacaktır. Aşağıda belirttiğimiz sorgu ile kullanıcıların tüm dosyalara kolayca erişmesini sağlayabilirsiniz. İstenilen formatta ve adette formları dizine çıkarmak için kullanılır.
Select CONCAT('EXEC master..xp_cmdshell ''mkdir "C:\Roleve\', frm.Graph.value('string(form[1]/MAGAZA[1]/WSInput[1]/BolgeKodu[1])', 'varchar(max)'),'\', frm.Graph.value('string(form[1]/MAGAZA[1]/MagazaBilgileri[1]/MagazaKodu[1])', 'varchar(max)'),'-\', frm.Graph.value('string(form[1]/MAGAZA[1]/WSInput[1]/MagazaAdi[1])', 'varchar(max)'),'-"''', ' EXEC master..xp_cmdshell ''BCP "SELECT Data FROM ALTIKARE.dbo.wFiles WHERE Id = ''''', Inv.Graph.value('Id[1]', 'varchar(max)'), ''''' " queryout "C:\Roleve\', frm.Graph.value('string(form[1]/MAGAZA[1]/WSInput[1]/BolgeKodu[1])', 'varchar(max)'),'\', frm.Graph.value('string(form[1]/MAGAZA[1]/MagazaBilgileri[1]/MagazaKodu[1])', 'varchar(max)'),'-\', frm.Graph.value('string(form[1]/MAGAZA[1]/WSInput[1]/MagazaAdi[1])', 'varchar(max)'),'-\', replace(Inv.Graph.value('Id[1]/@Caption', 'varchar(max)'), '''', ''), '" -T -N -S AIDCSVEMAKP01\MSSQLSERVERA101''') from wVersions ver with(nolock) left join wInstances ins on ins.ProcessVersionId = ver.Id join wWorkItems wi on wi.Id = (Select top 1 Id from wWorkItems wi2 where wi2.InstanceId = ins.Id and (DataRoot = '' or DataRoot is NULL)) left join wFormData frm on wi.DataId = frm.Id CROSS APPLY frm.Graph.nodes('form/MAGAZA/Dosyalar/RoleveDosya/RoleveDosya') as Inv(Graph) where ver.ProcessId = '2620ce7e-1b14-4f41-a1a8-23bbee1c8b2b' and convert(varchar(38), Inv.Graph.query('Id/text()')) != '' order by wi.Start desc
HATA:
xp_cmdshell varsayılan olarak devre dışı olduğu için yukarıdaki sorgu çalıştırıldığında böyle bir hata ile karşılaşılabilir.
Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.
ÇÖZÜM:
xp_cmdshell aktifleştirmek için kullanılır.
EXEC sp_configure 'show advanced options',1 GO RECONFIGURE GO EXEC sp_configure 'xp_cmdshell',1 GO RECONFIGURE GO