Beispiel #1
0
HRESULT ScaWebErrorRead(
                        SCA_WEB_ERROR **ppsweList,
                        __inout LPWSTR *ppwzCustomActionData
                        )
{
//    AssertSz(0, "Debug ScaWebErrorRead here");
    HRESULT hr = S_OK;
    MSIHANDLE hRec;
    LPWSTR pwzData = NULL;
    SCA_WEB_ERROR* pswe;
    WCA_WRAPQUERY_HANDLE hWrapQuery = NULL;

    ExitOnNull(ppsweList, hr, E_INVALIDARG, "Failed to read web error, because no web error was provided to read");

    hr = WcaBeginUnwrapQuery(&hWrapQuery, ppwzCustomActionData);
    ExitOnFailure(hr, "Failed to unwrap query for ScaAppPoolRead");

    if (0 == WcaGetQueryRecords(hWrapQuery))
    {
        WcaLog(LOGMSG_VERBOSE, "Skipping ScaWebErrorRead() - required tables not present.");
        ExitFunction1(hr = S_FALSE);
    }

    // loop through all the web errors
    while (S_OK == (hr = WcaFetchWrappedRecord(hWrapQuery, &hRec)))
    {
        hr = AddWebErrorToList(ppsweList);
        ExitOnFailure(hr, "failed to add web error to list");

        pswe = *ppsweList;

        hr = WcaGetRecordInteger(hRec, weqErrorCode, &(pswe->iErrorCode));
        ExitOnFailure(hr, "failed to get IIsWebError.ErrorCode");

        hr = WcaGetRecordInteger(hRec, weqSubCode, &(pswe->iSubCode));
        ExitOnFailure(hr, "failed to get IIsWebError.SubCode");

        hr = WcaGetRecordInteger(hRec, weqParentType, &(pswe->iParentType));
        ExitOnFailure(hr, "failed to get IIsWebError.ParentType");

        hr = WcaGetRecordString(hRec, weqParentValue, &pwzData);
        ExitOnFailure(hr, "Failed to get IIsWebError.ParentValue");
        hr = ::StringCchCopyW(pswe->wzParentValue, countof(pswe->wzParentValue), pwzData);
        ExitOnFailure(hr, "Failed to copy IIsWebError.ParentValue");

        hr = WcaGetRecordString(hRec, weqFile, &pwzData);
        ExitOnFailure(hr, "Failed to get IIsWebError.File");
        hr = ::StringCchCopyW(pswe->wzFile, countof(pswe->wzFile), pwzData);
        ExitOnFailure(hr, "Failed to copy IIsWebError.File");

        hr = WcaGetRecordString(hRec, weqURL, &pwzData);
        ExitOnFailure(hr, "Failed to get IIsWebError.URL");
        hr = ::StringCchCopyW(pswe->wzURL, countof(pswe->wzURL), pwzData);
        ExitOnFailure(hr, "Failed to copy IIsWebError.URL");

        // If they've specified both a file and a URL, that's invalid
        if (*(pswe->wzFile) && *(pswe->wzURL))
            ExitOnFailure2(hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA), "Both File and URL specified for web error.  File: %ls, URL: %ls", pswe->wzFile, pswe->wzURL);
    }

    if (E_NOMOREITEMS == hr)
    {
        hr = S_OK;
    }
    ExitOnFailure(hr, "Failure while processing web errors");

LExit:
    WcaFinishUnwrapQuery(hWrapQuery);

    ReleaseStr(pwzData);

    return hr;
}
Beispiel #2
0
HRESULT ScaWebErrorRead(SCA_WEB_ERROR **ppsweList)
{
//	AssertSz(0, "Debug ScaWebErrorRead here");
	Assert(ppsweList);

	HRESULT hr = S_OK;
	UINT er = 0;
	PMSIHANDLE hView, hRec;
	LPWSTR pwzData = NULL;
	SCA_WEB_ERROR* pswe;

	// bail quickly if the IIsWebError table isn't around
	if (S_OK != WcaTableExists(L"IIsWebError"))
	{
		WcaLog(LOGMSG_VERBOSE, "Skipping ScaGetWebErrors() - required tables not present.");
		ExitFunction1(hr = S_FALSE);
	}

	// loop through all the mimemappings
	hr = WcaOpenExecuteView(vcsWebErrorQuery, &hView);
	ExitOnFailure(hr, "Failed to open view on IIsMimeMap table");
	while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
	{
		hr = AddWebErrorToList(ppsweList);
		ExitOnFailure(hr, "failed to add mime map to list");

		pswe = *ppsweList;

		hr = WcaGetRecordInteger(hRec, weqErrorCode, &(pswe->iErrorCode));
		ExitOnFailure(hr, "failed to get IIsWebError.ErrorCode");

		hr = WcaGetRecordInteger(hRec, weqSubCode, &(pswe->iSubCode));
		ExitOnFailure(hr, "failed to get IIsWebError.SubCode");

		hr = WcaGetRecordInteger(hRec, weqParentType, &(pswe->iParentType));
		ExitOnFailure(hr, "failed to get IIsWebError.ParentType");

		hr = WcaGetRecordString(hRec, weqParentValue, &pwzData);
		ExitOnFailure(hr, "Failed to get IIsWebError.ParentValue");
		hr = StringCchCopyW(pswe->wzParentValue, countof(pswe->wzParentValue), pwzData);
		ExitOnFailure(hr, "Failed to copy IIsWebError.ParentValue");

		hr = WcaGetRecordFormattedString(hRec, weqFile, &pwzData);
		ExitOnFailure(hr, "Failed to get IIsWebError.File");
		hr = StringCchCopyW(pswe->wzFile, countof(pswe->wzFile), pwzData);
		ExitOnFailure(hr, "Failed to copy IIsWebError.File");

		hr = WcaGetRecordFormattedString(hRec, weqURL, &pwzData);
		ExitOnFailure(hr, "Failed to get IIsWebError.URL");
		hr = StringCchCopyW(pswe->wzURL, countof(pswe->wzURL), pwzData);
		ExitOnFailure(hr, "Failed to copy IIsWebError.URL");

		// If they've specified both a file and a URL, that's invalid
		if (*(pswe->wzFile) && *(pswe->wzURL))
			ExitOnFailure2(hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA), "Both File and URL specified for web error.  File: %S, URL: %S", pswe->wzFile, pswe->wzURL);
	}

	if (E_NOMOREITEMS == hr)
		hr = S_OK;
	ExitOnFailure(hr, "Failure while processing web errors");

LExit:
	ReleaseNullStr(pwzData);

	return hr;
}