<!--#include file="CNCASPPageManager_ResourceDelete.inc" -->

<%
' ************************************************************************
' File:		/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/
'			ResourceBrowser/Management/ResourceDelete.asp
' Author:	Microsoft Corporation.
' Purpose:	Based on the items selected in the ResourceGallery.asp screen,
'			we do a delete on the items that we have selected for deletion.
'			A for loop is used to loop through all the items on the page
'			and picked out the selected on for deletion.
'
' Query String Parameters:
'	IDS_QPARAM_GALLERY: Guid of the gallery selected
'**************************************************************************

' ---- Initialize the ASPPageManager
Dim g_pASPPageManager
Set g_pASPPageManager = New CNCASPPageManager_ResourceDelete
Call g_pASPPageManager.InitManager()

Dim pASPUtils
Set pASPUtils = g_pASPPageManager.ASPUtilsObject
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
	<head>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="expires" content="-1">
	<meta name="Author" content="Microsoft Corporation.">
	<meta name="Description" content="Display the resources delete error report">
	<meta name="robots" content="NOINDEX,NOFOLLOW">
	<meta http-equiv="Content-Type" content="text/html;charset=<%= g_pASPPageManager.Charset %>">
	<title><%= IDS_UI_BROWSER_TITLE %></title>

	<% Call EmbedWBCHeadSection %>

	</head>
<body <%= IDS_BODYSETTING %>>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<!-- Show the Top Title -->
	<tr class="WBC_styclsBackground1">
		<td align=right><img border=0 src="<%=IDS_PATH_IMAGE_LOGO %>"></td>
		<td width=100% valign="middle"  class="WBC_styclsHeaderText">
			<%= IDS_UI_RESOURCE_MANAGER %>
		</td>
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
					width="<%= C_INT_MAIN_MARGIN %>" height="<%=C_INT_HEADER_HEIGHT%>" border="0"></td>
	</tr>

	<!-- Show the breadcrumb trail -->
	<tr class="WBC_styclsBackground2">
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
			width="<%= C_INT_MAIN_MARGIN %>" height="<%=C_INT_SUBHEAD_HEIGHT%>" border="0"></td>
		<td class="WBC_styclsSubheadText">
			<a href="<%= g_pASPPageManager.URLBack2GalleriesLink %>"><%= IDS_UI_SEL_RESOURCE_GALLERY %></a> >
			<a href="<%= g_pASPPageManager.URLBack2ResourcesLink %>"><%= IDS_UI_MANAGE_RESOURCES %></a> >
			<%= IDS_UI_DELETE_RESOURCE_FAILURE %>
		</td>
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
			width="<%= C_INT_MAIN_MARGIN %>" height="<%=C_INT_SUBHEAD_HEIGHT%>" border="0"></td>
	</tr>
	<tr>
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
			width="15" height="<%= C_INT_MAIN_SPACING %>" border="0"></td>
	</tr>

	<!-- Set the margin width for the rest of the page -->
	<tr>
		<td rowspan="999"><img src="<%=IDS_TRANSPARENT_GIF%>"
					width="<%= C_INT_MAIN_MARGIN %>" height="1" border="0"></td>
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
					width="100%" height="1" border="0"></td>
		<td rowspan="999"><img src="<%=IDS_TRANSPARENT_GIF%>"
					width="<%= C_INT_MAIN_MARGIN %>" height="1" border="0"></td>
	</tr>

	<!-- Show area displaying info about current object -->
	<tr>
		<td class="WBC_styclsBackground1">
			<table width="100%" border="0" cellspacing="<%= C_INT_THICK_BORDER %>" cellpadding="5">
				<tr class="WBC_styclsBackground2">
					<td>
						<span class="WBC_styclsHeavyTextColor1"><%= IDS_UI_RESOURCE_GALLERY %>:</span>&nbsp;&nbsp;
						<span class="WBC_styclsTextColor1"><%= pASPUtils.MBCSWrite( pASPUtils.HTMLEncode( g_pASPPageManager.ResourceGallery.Path ), g_pASPPageManager.CodePage ) %></span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td><img src="<%=IDS_TRANSPARENT_GIF%>"
			width="15" height="<%= C_INT_MAIN_SPACING %>" border="0"></td>
	</tr>

	<!-- Show the Content area -->
	<tr>
		<td valign="top" class="WBC_styclsBackground1">
			<table width="100%" border="0" cellspacing="<%= C_INT_THICK_BORDER %>" cellpadding="5" >
				<tr class="WBC_styclsBackground2">
					<td valign="top" >
						<table width="100%" border="0" cellspacing="0" cellpadding="5" >

<%
					Dim g_pResource, g_strResourceGUID
					Dim g_nSuccess, g_nFail, g_strFailureDetails

					g_nSuccess = 0
					g_nFail = 0
					For Each g_strResourceGUID In g_pASPPageManager.FormReader.Form("NC_Resource")
						AutoSession.ClearLastError()
						g_strFailureDetails = ""

						Set g_pResource = AutoSession.Searches.GetByGUID( g_strResourceGUID )
						If (g_pResource Is Nothing) Then
							' -- cannot even retrieve Resource from GUID
							g_nFail = g_nFail + 1
							g_strFailureDetails = "'" & g_pASPPageManager.FormReader.Form("NC_" & g_strResourceGUID) & "'" & IDS_UI_WAS_NOT_DELETED & "<br>" & IDS_UI_RESOURCE_NOT_FOUND
						Elseif g_pResource.CanDelete = False Then
							' -- user lacking rights to delete resource
							g_nFail = g_nFail + 1
							g_strFailureDetails = "'" & g_pASPPageManager.FormReader.Form("NC_" & g_strResourceGUID) & "'" & IDS_UI_WAS_NOT_DELETED & "<br>" & IDS_UI_MISSING_RIGHTS
						Else
							' -- attempt to delete Resource
							Call g_pASPPageManager.DeleteResourceSafe( g_pResource )
							If AutoSession.LastError.ID <> 0 Then
								' -- Delete attempt failed
								g_nFail = g_nFail + 1
								g_strFailureDetails = "'" & g_pASPPageManager.FormReader.Form("NC_" & g_strResourceGUID) & "'" & IDS_UI_WAS_NOT_DELETED & "<br>" & AutoSession.LastError.Description
							Else
								Call AutoSession.CommitAll()
								g_nSuccess = g_nSuccess + 1
							End If
						End If

						' -- show failure string if it is not empty
						If (g_strFailureDetails <> "") Then
%>
							<!-- Show delete failure one at a time -->
							<tr valign="top">
								<td class="WBC_styclsHeavyTextColor1"><%= IDS_UI_DELETE_RESOURCE_FAILURE & " #" & g_nFail %></td>
								<td class="WBC_styclsTextColor1"><%= g_strFailureDetails %>
							</tr>

<%
						End If
					Next

					' -- If everything goes well, redirect back to previous ASP page
					If (g_nFail = 0) Then
						Response.Clear
						Response.Redirect( g_pASPPageManager.URLRefreshResourcesAfterDelete )
					End If
%>

							<!-- Show the separator for the Summary section -->
							<tr valign="middle">
								<td colspan="2">
									<table width=100% border=0 cellspacing=0 cellpadding=0>
										<tr>
											<td width="*"><hr></td>
											<td width="250" align="Center" valign="top" class="WBC_styclsHeavyTextColor1">
												<nobr> <%= IDS_UI_DELETE_RESOURCE_SUMMARY %> </nobr>
											</td>
											<td width="*"><hr></td>
										</tr>
									</table>
								</td>
							</tr>

							<!-- Render delete resource summary -->
							<tr valign="top">
								<td class="WBC_styclsHeavyTextColor1"><nobr><%= IDS_UI_RESOURCES_DELETE_SUCCEEDED %> </nobr></td>
								<td class="WBC_styclsTextColor1"><%= g_nSuccess %></td>
							</tr>
							<tr valign="top">
								<td class="WBC_styclsHeavyTextColor1"><nobr><%= IDS_UI_RESOURCES_DELETE_FAILED %> </nobr></td>
								<td class="WBC_styclsTextColor1"><%= g_nFail %></td>
							</tr>

							<tr>
								<td colspan="2">&nbsp;</td>
							</tr>

						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>

</table>


</body>
</html>