<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== '| | '| DIFF | '| | '===================================================== %> <% Option explicit ' Good idea to set when using redirect Response.Expires = 0 ' always load the page, dont store %> <% 'To enable the script timeout to 5 mins Server.ScriptTimeout=600 %> <% '------------ ACCESS CONTROL ------------------ %> <% '------------ Variable Definition ------------- Dim rsQry Dim objRelCollectorA Dim objRelCollectorB Dim parRtagA Dim parRtagB Dim parSBOMA Dim parSBOMB Dim dDiffFilter Dim colorA, colorB, ChangeTypeIcon Dim btnMerge, btnRemove Dim rowId Dim FSO Dim NewTextFile Dim pkgA, pkgB, pkgname, delimiter, rsQryA, rsQryB, rsQryCommentsA, rsQryCommentsB, sqlstrA, counterA, sqlstrB, sqlstrC, counterB Dim SSsql, retVal, rsCQ, DEVIiss, TDSEiss, VT5DMiss, VTSUPiss Dim a, b, c, d, pkgversion, errormsg, source_change Dim VersionList Dim fileName, pathName '------------ Variable Init ------------------- parRtagA = Request("rtagA") parRtagB = Request("rtagB") parSBOMA = Request("sbomA") parSBOMB = Request("sbomB") Set objRelCollectorA = CreateObject("Scripting.Dictionary") Set objRelCollectorB = CreateObject("Scripting.Dictionary") Set dDiffFilter = CreateObject("Scripting.Dictionary") '-------------------------------------------------------------------------------------------------------------------------- Sub Javascript() NewTextFile.WriteLine("") End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub GetFixedIssues(pv_id) Set sqlstrC = OraDatabase.DbCreateDynaset("SELECT iss_db, iss_id, iss_state, notes FROM CQ_ISSUES WHERE pv_id="& pv_id &" AND iss_db="& CInt(enumCLEARQUEST_VTSUP_ID) &" AND iss_state = "& enumISSUES_STATE_FIXED, cint(0)) If sqlstrC.RecordCount <> 0 Then NewTextFile.WriteLine() NewTextFile.WriteLine("
Fixed Issues:
") NewTextFile.WriteLine("
") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") While ((NOT sqlstrC.BOF) AND (NOT sqlstrC.EOF)) DEVIiss = "-1" TDSEiss = "-1" VT5DMiss = "-1" VTSUPiss = "-1" If CInt(sqlstrC("iss_db")) = CInt(enumCLEARQUEST_DEVI_ID) Then DEVIiss = DEVIiss &","& sqlstrC("iss_id") ElseIf CInt(sqlstrC("iss_db")) = CInt(enumCLEARQUEST_TDSE_ID) Then TDSEiss = TDSEiss &","& sqlstrC("iss_id") ElseIf CInt(sqlstrC("iss_db")) = CInt(enumCLEARQUEST_VT5DM_ID) Then VT5DMiss = VT5DMiss &","& sqlstrC("iss_id") ElseIf CInt(sqlstrC("iss_db")) = CInt(enumCLEARQUEST_VTSUP_ID) Then VTSUPiss = VTSUPiss &","& sqlstrC("iss_id") End If SSsql = ReadFile( QUERIES_PATH & "\cq_issues.sql" ) SSsql = Replace( SSsql, "/*enumCLEARQUEST_DEVI_ID*/", enumCLEARQUEST_DEVI_ID) SSsql = Replace( SSsql, "/*enumCLEARQUEST_TDSE_ID*/", enumCLEARQUEST_TDSE_ID) SSsql = Replace( SSsql, "/*enumCLEARQUEST_VT5DM_ID*/", enumCLEARQUEST_VT5DM_ID) SSsql = Replace( SSsql, "/*enumCLEARQUEST_VTSUP_ID*/", enumCLEARQUEST_VTSUP_ID) SSsql = Replace( SSsql, "/*DEVIiss*/", DEVIiss) SSsql = Replace( SSsql, "/*TDSEiss*/", TDSEiss) SSsql = Replace( SSsql, "/*VT5DMiss*/", VT5DMiss) SSsql = Replace( SSsql, "/*VTSUPiss*/", VTSUPiss) retVal = Get_CQ_Issues ( SSsql, rsCQ ) NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") '  sqlstrC.MoveNext Wend NewTextFile.WriteLine( "
Issue IdSummaryIssue TypePriorityStatus
"&rsCQ("iss_num")&""&NewLine_To_BR ( To_HTML ( rsCQ("summary") ) )&""&rsCQ("issue_type")&""&rsCQ("priority")&""&rsCQ("Status")&"
") End If sqlstrC.Close() Set sqlstrC = Nothing End Sub '-------------------------------------------------------------------------------------------------------------------------- Function LastPvId(pvId) Dim qryA Set qryA = OraDatabase.DbCreateDynaset("SELECT LAST_PV_ID FROM PACKAGE_VERSIONS WHERE PV_ID="&pvId , cint(0)) LastPvId = pvId If pvId <> qryA("last_pv_id") Then LastPvId = qryA("last_pv_id") Else errormsg = true End If qryA.Close() Set qryA = Nothing End Function '-------------------------------------------------------------------------------------------------------------------------- Sub PreviousVersions(a, b, versionA, versionB) NewTextFile.WriteLine() NewTextFile.WriteLine("Versions Between: "&versionA&" and "&versionB&"") If CLng(a) < CLng(b) Then While CLng(a) < CLng(b) b = LastPvId(b) If CLng(a) < CLng(b) Then VersionList = VersionList + ","& b &"" Call Comments(b) Call GetFixedIssues(b) End If Wend End If If CLng(b) < CLng(a) Then While CLng(b) < CLng(a) a = LastPvId(a) If CLng(b) < CLng(a) Then VersionList = VersionList + ","& a &"" Call Comments(a) Call GetFixedIssues(a) End If Wend End If End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub GetDependencies(pv_id_a, pv_id_b, versionA, versionB) On Error Resume Next Set sqlstrA = OraDatabase.DbCreateDynaset("select distinct dpv_id from package_dependencies where pv_id IN ("& pv_id_b &") and dpv_id NOT IN (SELECT dpv_id from package_dependencies where pv_id ="& pv_id_a &" ) order by dpv_id desc", cint(0)) If sqlstrA.RecordCount <> 0 Then NewTextFile.WriteLine() NewTextFile.WriteLine("Dependencies Changed Between "&versionA&" and "&versionB&":") While ((NOT sqlstrA.BOF) AND (NOT sqlstrA.EOF)) Call dependencyComments(sqlstrA("dpv_id")) Call GetFixedIssues(sqlstrA("dpv_id")) sqlstrA.MoveNext Wend End If sqlstrA.Close() Set sqlstrA = Nothing End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub dependencyComments(pv_id) Set sqlstrB = OraDatabase.DbCreateDynaset("SELECT * FROM PACKAGE_VERSIONS pv, PACKAGES pkg WHERE pkg.pkg_id = pv.pkg_id AND PV_ID ="&pv_id, cint(0)) NewTextFile.WriteLine("
"& sqlstrB("pkg_name") &" "& sqlstrB("pkg_version") &"
") NewTextFile.WriteLine("
Comments:
") NewTextFile.Write("
"& TextToHTML(sqlstrB("comments")) &"
") sqlstrB.Close() Set sqlstrB = nothing End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub pkg_Version(pv) Dim qry Set qry = OraDatabase.DbCreateDynaset("SELECT PKG_VERSION FROM PACKAGE_VERSIONS WHERE PV_ID="&pv , cint(0)) pkgversion = qry("pkg_version") qry.Close() Set qry = Nothing End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub Comments(Pv_Id) Dim comments Set comments = OraDatabase.DbCreateDynaset("SELECT COMMENTS, PKG_VERSION FROM PACKAGE_VERSIONS WHERE PV_ID="&Pv_id , cint(0)) If comments("comments") <> "Rippled Build." Then NewTextFile.WriteLine("
Version: "& comments("pkg_version")&"
") If comments("comments") <> "" Then NewTextFile.WriteLine("
Comments:
") NewTextFile.WriteLine("
"& TextToHTML(comments("comments")) &"
") source_change = true End If End If End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub Release(pvId) Dim release Set release = OraDatabase.DbCreateDynaset("SELECT INSERT_STAMP FROM RELEASE_CONTENT WHERE PV_ID="&pvId , cint(0)) If release("insert_stamp") <> "" Then NewTextFile.Write(release("insert_stamp")) Else NewTextFile.Write("Version Not Used.") End If End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub Header( branchNameA, branchNameB, versionA, versionB ) NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.WriteLine("Difference Report Between "& branchNameA &" "& versionA &" and "& branchNameB &" "& versionB &"") Call Javascript() Call Styles() NewTextFile.WriteLine("") End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub Styles() NewTextFile.WriteLine("") End Sub '-------------------------------------------------------------------------------------------------------------------------- Sub DeleteOldReports() Dim fileList, currentFile Set fileList = FSO.GetFolder(Server.MapPath(pathName)).Files For Each currentFile In fileList '--Force deletion of read-only files-- If InStr(currentFile.Name, objAccessControl.UserName) = 1 Then FSO.DeleteFile Server.MapPath(pathName & currentFile.Name), true End If '--Don't delete read-only files-- 'If (NOT currentFile.Attributes AND 1) AND (InStr(currentFile.Name, objAccessControl.UserName) = 1) Then ' FSO.DeleteFile Server.MapPath(pathName & currentFile.Name) 'End If Next End Sub '--------------------------------------------------------------------------------------------------------------------------- Function Get_CQ_Issues ( SSsql, OOrsCQ ) On Error Resume Next Set OOrsCQ = OraDatabase.DbCreateDynaset( SSsql, cint(0)) Get_CQ_Issues = Err.Number End Function '-------------------------------------------------------------------------------------------------------------------------- Public Function TextToHTML ( sString ) Dim mString If (sString = "") OR IsNull(sString) Then Exit Function mString = Server.HTMLEncode( sString ) mString = Replace(mString, VBNewLine, "
") TextToHTML = mString End Function '-------------------------------------------------------------------------------------------------------------------------- Public Function RandomString () Dim char_count, intRnd, listRnd, min, max char_count = 0 max = Asc("0") min = Asc("z") 'generate a random string to create unique file name randomize While char_count < 10 intRnd = Cint((max - min + 1) * Rnd() + min) 'limit string to 0-9, a-z, A-Z If (intRnd < Asc(":") OR intRnd > Asc("@")) AND (intRnd < Asc("[") OR intRnd > Asc("`")) Then listRnd = listRnd & Chr(intRnd) char_count = char_count + 1 End If Wend RandomString = listRnd End Function '-------------------------------------------------------------------------------------------------------------------------- %> <% '------------ RUN BEFORE PAGE RENDER ---------- pathName = "docs/" fileName = objAccessControl.UserName &"_bom_report_"& RandomString() &".html" '---------------------------------------------- %> "" Then Response.Write("onload="&chr(34)&"window.location='"& pathName & fileName &"'"&chr(34)) End If%>>

Generating Report

<% OraDatabase.Parameters.Add "SBOM_A", parSBOMA, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "SBOM_B", parSBOMB, ORAPARM_INPUT, ORATYPE_NUMBER OraDatabase.Parameters.Add "NO_CHANGE", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "ADDED", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "UPDATED", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 OraDatabase.Parameters.Add "REMOVED", "", ORAPARM_INPUT, ORATYPE_VARCHAR2 Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("BOMDiff.sql"), cint(0)) OraDatabase.Parameters.Remove "SBOM_A" OraDatabase.Parameters.Remove "SBOM_B" OraDatabase.Parameters.Remove "NO_CHANGE" OraDatabase.Parameters.Remove "ADDED" OraDatabase.Parameters.Remove "UPDATED" OraDatabase.Parameters.Remove "REMOVED" Set rsQryA = OraDatabase.DbCreateDynaset( "SELECT pr.PROJ_NAME, br.BRANCH_NAME, b.BOM_VERSION ||'.'||b.BOM_LIFECYCLE AS LOCATION, "&_ " pr.PROJ_ID, b.BOM_ID, br.BRANCH_ID"&_ " FROM BRANCHES br,"&_ " BOMS b,"&_ " DM_PROJECTS pr"&_ " WHERE br.PROJ_ID = pr.PROJ_ID"&_ " AND b.BRANCH_ID = br.BRANCH_ID"&_ " AND b.BOM_ID ="&parSBOMA, cint(0)) Set rsQryB = OraDatabase.DbCreateDynaset( "SELECT pr.PROJ_NAME, br.BRANCH_NAME, b.BOM_VERSION ||'.'||b.BOM_LIFECYCLE AS LOCATION, "&_ " pr.PROJ_ID, b.BOM_ID, br.BRANCH_ID"&_ " FROM BRANCHES br,"&_ " BOMS b,"&_ " DM_PROJECTS pr"&_ " WHERE br.PROJ_ID = pr.PROJ_ID"&_ " AND b.BRANCH_ID = br.BRANCH_ID"&_ " AND b.BOM_ID ="&parSBOMB, cint(0)) Set FSO=Server.CreateObject("Scripting.FileSystemObject") Call DeleteOldReports() Set NewTextFile=FSO.CreateTextFile(Server.MapPath(pathName & fileName), true) Call Header(rsQryA("branch_name"), rsQryB("branch_name"), rsQryA("location"), rsQryB("location")) NewTextFile.WriteLine("") NewTextFile.WriteLine("
Difference Report Between "&rsQryA("branch_name")&" "&rsQryA("location")&" and "&rsQryB("branch_name")&" "&rsQryB("location")&"


") While ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) VersionList = "0" errormsg = false rowId = rsQry("pv_id_a") &"_"& rsQry("pv_id_b") If rsQry("pv_id_a") Then Set rsQryCommentsA = OraDatabase.DbCreateDynaset( "SELECT COMMENTS FROM PACKAGE_VERSIONS WHERE PV_ID="& rsQry("pv_id_a"), cint(0)) End If If rsQry("pv_id_b") Then Set rsQryCommentsB = OraDatabase.DbCreateDynaset( "SELECT COMMENTS FROM PACKAGE_VERSIONS WHERE PV_ID="& rsQry("pv_id_b"), cint(0)) End If pkgA = rsQry("pkg_name_a") pkgB = rsQry("pkg_name_b") If pkgA <> "" then pkgname = pkgA Else pkgname = pkgB End If If rsQry("change_type") = "U" OR rsQry("change_type") = "UW" Then NewTextFile.Write("

"& pkgname &"") NewTextFile.Write(""& pkgname &"") NewTextFile.WriteLine("") NewTextFile.Write(rsQryA("location")&" uses: "&rsQry("pkg_version_a")&" ") NewTextFile.WriteLine("
") NewTextFile.Write(rsQryB("location")&" uses: "&rsQry("pkg_version_b")&" ") a = rsQry("pv_id_a") b = rsQry("pv_id_b") c = rsQry("pv_id_a") d = rsQry("pv_id_b") NewTextFile.WriteLine("

") NewTextFile.WriteLine() NewTextFile.WriteLine(""&rsQryB("location")&"") Call Comments(rsQry("pv_id_b")) Call GetFixedIssues(rsQry("pv_id_b")) Dim rsQryLast Set rsQryLast = OraDatabase.DbCreateDynaset( "SELECT LAST_PV_ID FROM PACKAGE_VERSIONS WHERE PV_ID="& rsQry("pv_id_b"), cint(0)) If rsQryLast("last_pv_id") <> a Then Call PreviousVersions(a, b, rsQry("pkg_version_a"), rsQry("pkg_version_b")) End If a = rsQry("pv_id_a") b = rsQry("pv_id_b") Call GetDependencies(a, VersionList + ","+ b, rsQry("pkg_version_a"), rsQry("pkg_version_b")) NewTextFile.WriteLine("
") rsQryLast.Close() Set rsQryLast = Nothing End If If rsQry("change_type") = "A" AND rsQry("patch_b") = "Y" Then Dim rsQryPatch OraDatabase.Parameters.Add "PV_ID", rsQry("pv_id_b"), ORAPARM_INPUT, ORATYPE_NUMBER Set rsQryPatch = OraDatabase.DbCreateDynaset( GetQuery("pd_patch.sql"), cint(0)) OraDatabase.Parameters.Remove "PV_ID" If NOT IsNull(rsQryPatch("pv_id")) Then NewTextFile.Write("

"& rsQryPatch("pkg_name") &" "& rsQryPatch("pkg_version") &"") NewTextFile.Write(""& rsQryPatch("pkg_name") &" "& rsQryPatch("pkg_version") &"") NewTextFile.WriteLine("") Call Comments(rsQryPatch("pv_id")) Call GetFixedIssues(rsQryPatch("pv_id")) Else NewTextFile.Write("

"& rsQry("pkg_name_b") &" "& rsQry("pkg_version_b") &"") NewTextFile.Write(""& rsQry("pkg_name_b") &" "& rsQry("pkg_version_b") &"") NewTextFile.WriteLine("") Call Comments(rsQry("pv_id_b")) Call GetFixedIssues(rsQry("pv_id_b")) End If NewTextFile.WriteLine("") rsQryPatch.Close Set rsQryPatch = nothing End If rsQry.MoveNext WEnd rsQry.Close Set rsQry = Nothing NewTextFile.WriteLine("") NewTextFile.WriteLine("") NewTextFile.Close Set NewTextFile=Nothing %>