From 261a8832c4f8da8e8b787f9f9f252ccd6e4d1c72 Mon Sep 17 00:00:00 2001 From: Thierry Schork Date: Thu, 28 Mar 2024 13:45:35 +0100 Subject: [PATCH] sync --- MIG - e-galexis url change.sql | 19 ++++++ MIG - update medifilm path (userdata).sql | 50 +++++++++++++++ .../1_Configure_InstanceMemory.sql | 2 +- .../dumpDevice.ps1 | 62 +++++++++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 MIG - e-galexis url change.sql create mode 100644 MIG - update medifilm path (userdata).sql create mode 100644 TPDT-268 - ACP in task sequence/dumpDevice.ps1 diff --git a/MIG - e-galexis url change.sql b/MIG - e-galexis url change.sql new file mode 100644 index 0000000..15d2f3f --- /dev/null +++ b/MIG - e-galexis url change.sql @@ -0,0 +1,19 @@ +USE [Arizona] + +SELECT + ou.[OU_subsidiary] + ,s.[SUB_prefix] + ,ou.[OU_code] + ,ou.[OU_short_name] + ,ws.[WSA_code] + ,c.[WSAC_url] +--UPDATE c SET [c].[WSAC_url] = 'https://xml.e-galexis.com:10443/POS/' +FROM [dbo].[WSA_connection] c + JOIN [dbo].[Web_service_access] ws ON ws.[Web_service_access_GUID] = c.[WSAC_web_service_access] + JOIN [dbo].[Organizational_unit] ou ON ou.[Organizational_unit_ID] = c.[WSAC_organizational_unit] + JOIN [dbo].[Subsidiary] s ON s.[Subsidiary_ID] = [ou].[OU_subsidiary] +WHERE ou.[OU_code] LIKE '824' +AND [s].[SUB_prefix]='CVI' +AND [ws].[WSA_code] LIKE 'apswsGalexisPurchase' + + diff --git a/MIG - update medifilm path (userdata).sql b/MIG - update medifilm path (userdata).sql new file mode 100644 index 0000000..9a3b825 --- /dev/null +++ b/MIG - update medifilm path (userdata).sql @@ -0,0 +1,50 @@ +Use ActivePos_server + +BEGIN TRANSACTION + +DECLARE @ou_id INT +EXEC Arizona.dbo.sp_bmc_Bmc_Applic_Default + @in_job_type = 3, + @in_param_int_1 = null, /* Company */ + @in_param_int_2 = null, /* Subsidiary */ + @in_param_varchar_1 = 'cvCurrentOrganizationalUnit', + @out_default_value = @ou_id output, + @out_param_int_1 = NULL + +DECLARE @newVal NVARCHAR(500); + + +/*Save the current value in [HCITools].[tmp].[TT_medifilm_setting]*/ +IF OBJECT_ID('[HCITools].[tmp].[TT_medifilm_setting]') IS NULL +BEGIN + CREATE TABLE [HCITools].[tmp].[TT_medifilm_setting]( + oldValue VARCHAR(MAX) NULL, + dateChange DATETIME2(2) NOT NULL CONSTRAINT df_dateChange DEFAULT GETDATE() + ) +END + +/*dynamic sql to avoid exception because of non existing table while compiling the batch*/ +EXEC(' +INSERT INTO [HCITools].[tmp].[TT_medifilm_setting]([oldValue]) +SELECT [SE].[SettingValue] +FROM [dbo].[Settings] SE +where [SE].[SettingId] = ''Values.Global.SalesImportService.MainDirectory'' +') + +/*Craft the new URI from the OU ofthe pharmacy*/ +SELECT @newVal = REPLACE('\\centralinfra.net\GAL\90_UserData\@ou@\POS\Medifilm', '@ou@', RTRIM(i.[Customer])+LTRIM(o.[OU_code])) +FROM [Arizona].dbo.[Organizational_unit] [o] + CROSS JOIN [master].cfg.[Identity] [i] +WHERE [o].[Organizational_unit_ID] = @ou_id + +/*Update the setting*/ +UPDATE se SET [SE].[SettingValue]= @newVal +FROM [dbo].[Settings] SE (nolock) +where [SE].[SettingId] = 'Values.Global.SalesImportService.MainDirectory' + +/*restart the service to apply the change*/ +EXEC xp_cmdshell 'net stop arizonaServerService' +EXEC xp_cmdshell 'net start arizonaServerService' + +--COMMIT TRANSACTION +ROLLBACK TRANSACTION \ No newline at end of file diff --git a/TPDT-268 - ACP in task sequence/1_Configure_InstanceMemory.sql b/TPDT-268 - ACP in task sequence/1_Configure_InstanceMemory.sql index 3d582fd..19d2cc9 100644 --- a/TPDT-268 - ACP in task sequence/1_Configure_InstanceMemory.sql +++ b/TPDT-268 - ACP in task sequence/1_Configure_InstanceMemory.sql @@ -13,7 +13,7 @@ DECLARE @isX64 BIT = 1; DECLARE @ThreadStackSize INT; DECLARE @osReserved INT; DECLARE @newMaxMem INT; -DECLARE @appReserved INT = 0*1024*1024; --memory reserved for other apps on the server in Kb +DECLARE @appReserved INT = 4*1024*1024; --memory reserved for other apps on the server in Kb SELECT @totSysMemKb = [total_physical_memory_kb] FROM [sys].[dm_os_sys_memory]; diff --git a/TPDT-268 - ACP in task sequence/dumpDevice.ps1 b/TPDT-268 - ACP in task sequence/dumpDevice.ps1 new file mode 100644 index 0000000..cc227c1 --- /dev/null +++ b/TPDT-268 - ACP in task sequence/dumpDevice.ps1 @@ -0,0 +1,62 @@ +<# +TPDT-287 + +Change the dump device location for Arizona DB to a U drive if this drive exists + +TSC 18.03.2024 Creation +#> + +$instance = "(local)\APSSQL" +$target_path = "U:" #This path must NOT have a trailing slash + +if(Test-Path -Path $target_path){ + $query=@" + SELECT * FROM sys.backup_devices + WHERE [name] IN + ( + N'Arizona_Dump', + N'Arizona_dump_SECU' + ) + AND physical_name like 'd:%' +"@ + $ds_dumpDevices = Invoke-Sqlcmd -ServerInstance $instance -Query $query -Database master + + if($ds_dumpDevices.Count -gt 0){ + Write-Output "Path $target_path exists, ensuring Arizona dump devices are set to this drive" + $query = @" + +IF EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_Dump' AND [physical_name] LIKE 'D:%') +BEGIN + EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_Dump',@delfile = NULL; + PRINT 'Dump device Arizona_Dump removed'; +END + +IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_Dump') +BEGIN + EXEC master.dbo.sp_addumpdevice @devtype = N'disk', + @logicalname = N'Arizona_Dump', + @physicalname = N'$target_path\Arizona_Dump.bak'; + PRINT 'Dump device Arizona_Dump created on U drive'; +END + +IF EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU' AND [physical_name] LIKE 'D:%') +BEGIN + EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_dump_SECU',@delfile = NULL + PRINT 'Dump device Arizona_dump_SECU removed'; +END + +IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU') +BEGIN + EXEC master.dbo.sp_addumpdevice @devtype = N'disk', + @logicalname = N'Arizona_dump_SECU', + @physicalname = N'$target_path\Arizona_dump_SECU.bak'; + PRINT 'Dump device Arizona_dump_SECU created on U drive'; + END + +"@ + Invoke-Sqlcmd -ServerInstance $instance -Database master -Query $query + } +} +else{ + Write-Output "Path $target_path does not exists, not touching dump devices" +}