From 95a5a8f9efef02ddcec5b3f69be99a00d71a802a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 16 Dec 2018 21:19:24 -0600 Subject: Import implementation of IisCA from old repo's scasched/scaexec. --- src/ca/scaiis7.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/ca/scaiis7.cpp (limited to 'src/ca/scaiis7.cpp') diff --git a/src/ca/scaiis7.cpp b/src/ca/scaiis7.cpp new file mode 100644 index 00000000..f0f4a629 --- /dev/null +++ b/src/ca/scaiis7.cpp @@ -0,0 +1,74 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +#define COST_IIS_WRITEKEY 10 + +HRESULT ScaIIS7ConfigTransaction(LPCWSTR wzBackup) +{ + HRESULT hr = S_OK; + + hr = WcaDoDeferredAction(L"StartIIS7ConfigTransaction", wzBackup, COST_IIS_TRANSACTIONS); + ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction"); + + hr = WcaDoDeferredAction(L"RollbackIIS7ConfigTransaction", wzBackup, 0); // rollback cost is irrelevant + ExitOnFailure(hr, "Failed to schedule RollbackIIS7ConfigTransaction"); + + hr = WcaDoDeferredAction(L"CommitIIS7ConfigTransaction", wzBackup, 0); // commit is free + ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction"); + +LExit: + return hr; +} + +HRESULT ScaWriteConfigString(const LPCWSTR wzValue) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteStringToCaData(wzValue, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData"); + + hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY); + ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY); + +LExit: + ReleaseStr(pwzCustomActionData); + + return hr; +} + +HRESULT ScaWriteConfigInteger(DWORD dwValue) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteIntegerToCaData(dwValue, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData"); + + hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY); + ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY); + +LExit: + ReleaseStr(pwzCustomActionData); + + return hr; +} + +HRESULT ScaWriteConfigID(IIS_CONFIG_ACTION emID) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteIntegerToCaData(emID, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add metabase delete key directive to CustomActionData"); + + hr = ScaAddToIisConfiguration(pwzCustomActionData, COST_IIS_WRITEKEY); + ExitOnFailure(hr, "Failed to add ScaWriteMetabaseValue action data: %ls, cost: %d", pwzCustomActionData, COST_IIS_WRITEKEY); + +LExit: + ReleaseStr(pwzCustomActionData); + + return hr; +} + -- cgit v1.2.3-55-g6feb