Subversion Repositories DevTools

Rev

Rev 129 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'                 REMOVE Unit Test
'               --- PROCESS FORM ---
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>

<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/common_dbedit.asp"-->
<%
' Set rfile parameter. This is a return page after Login
Call objPMod.StoreParameter ( "rfile", "fixed_issues.asp" )
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
'----------------------------------------------
%>
<%
Sub Attachment_Name ( nTest_id, nPv_id, outPkg_name, outPkg_version, outFullAttachmentName )
   Dim sqlstr, rsTemp
   sqlstr = _
   " SELECT pkg.pkg_name, pv.pkg_version, ( pkg.pkg_name || '\' || pv.pkg_version || '\' || ut.results_attachment_name ) AS filename_path"&_
   "   FROM UNIT_TESTS ut, PACKAGE_VERSIONS pv, PACKAGES pkg"&_
   "  WHERE ut.pv_id = pv.pv_id"&_
   "    AND pv.pkg_id = pkg.pkg_id"&_
   "    AND ut.test_id = "& nTest_id &_
   "    AND ut.pv_id = "& nPv_id &_
   "    AND ut.TEST_TYPES_FK <> "& enumTEST_TYPE_AUTOMATIC

   Set rsTemp = OraDatabase.DbCreateDynaset( sqlstr, cint(0))

   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
      outPkg_name = rsTemp("pkg_name")
      outPkg_version = rsTemp("pkg_version")
      outFullAttachmentName = rsTemp("filename_path")
   Else
      outFullAttachmentName = NULL
      Call Get_Pkg_Short_Info( nPv_id, NULL, outPkg_name, outPkg_version, NULL, NULL, NULL )
   End If

   rsTemp.Close
   Set rsTemp = nothing
End Sub


Sub CleanUp_Folders ( sPath, sPkg_name, sPkg_version )
   Dim currentFolder
   ' Attempt to remove PKG_NAME/PKG_VERSION/DOC folders

   ' Attempting to remove DOC/
   currentFolder = sPath &"\"& sPkg_name &"\"& sPkg_version &"\"& DOC_FOLDER
   If Folder_Is_Empty ( currentFolder  ) Then Call DeleteFolder( currentFolder )

   ' Attempting to remove PKG_VERSION/
   currentFolder = sPath &"\"& sPkg_name &"\"& sPkg_version
   If Folder_Is_Empty ( currentFolder  ) Then Call DeleteFolder( currentFolder )

   ' Attempting to remove PKG_NAME/
   currentFolder = sPath &"\"& sPkg_name
   If Folder_Is_Empty ( currentFolder  ) Then Call DeleteFolder( currentFolder )

End Sub


Sub Remove_Unit_Test ( nTest_id, nPv_Id )
   Dim sPath, Pkg_name, Pkg_version, FullAttachmentName

   objEH.TryORA ( OraSession )
   On Error Resume Next

   Call Attachment_Name ( nTest_id, nPv_id, Pkg_name, Pkg_version, FullAttachmentName )

   sPath = Server.MapPath( TEMP_FOLDER )
   If Not IsNull( FullAttachmentName ) Then Call DeleteFile( sPath &"\"& FullAttachmentName )      ' Delete the file if exists

   Call CleanUp_Folders ( sPath, Pkg_name, Pkg_version )

   OraDatabase.ExecuteSQL "DELETE FROM unit_tests WHERE test_id = "& nTest_id &" AND pv_id = "& nPv_id

   objEH.CatchORA ( OraSession )
End Sub
%>
<%
'-----------------------  MAIN LINE  ---------------------------

'--- Process submition ---
If (Request("pv_id") <> "") AND (Request("test_id") <> "")  Then
   ' All mendatory parameters FOUND
   Call Get_Pkg_Info ( Request("pv_id"), Request("rtag_id") )
   Call Remove_Unit_Test ( Request("test_id"), Request("pv_id") )
   Response.Redirect("fixed_issues.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id") )
Else
   Response.write "Some mendatory parameters are missing!" & "<br>" 'TODO
   Response.write QSTR_All

End If
%>

<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->