Rev 6643 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%@LANGUAGE="VBSCRIPT"%><%'====================================================='| |'| XML BOM Gen |'| |'=====================================================%><%Option explicitResponse.Expires = 0 ' always load the page, dont store%><!--#include file="common/globals.asp"--><!--#include file="common/config.asp"--><!--#include file="common/common_subs.asp"--><!--#include file="common/_popup_window_common.asp"--><%'------------ VARIABLE DEFINITION -------------Dim objWSH'------------ CONSTANTS DECLARATION -----------'------------ VARIABLE INIT -------------------'------------ CONDITIONS ----------------------'----------------------------------------------%><%'--------------------------------------------------------------------------------------------------------------------------'--------------------------------------------------------------------------------------------------------------------------%><%Function DateReversed ( dDate )' Ensures Reverse Date format YYYY-MM-DDIf IsNull(dDate) Then Exit FunctionDateReversed = Year(dDate) &"-"& Month(dDate) &"-"& Day(dDate)End Function'**************************** M A I N ******************************If Request("bom_id") <> "" ThenSet objWSH = createWscriptShell()objWSH.Run "cmd.exe /c cscript.exe //B //NoLogo "& APP_ROOT &"\jobs\PostBOMRelease.wsf /bom_id:"& Request("bom_id") , 0, TrueOn Error Resume NextOraDatabase.Parameters.Add "BOM_ID", Request("bom_id"), ORAPARM_INPUT, ORATYPE_NUMBEROraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBERobjEH.TryORA ( OraSession )OraDatabase.ExecuteSQL _"BEGIN pk_Bom.Log_Bom_Trail ( :BOM_ID, 'XML BOM GENERATED', :USER_ID, NULL ); END;"objEH.CatchORA ( OraSession )OraDatabase.Parameters.Remove "BOM_ID"OraDatabase.Parameters.Remove "USER_ID"On Error GoTo 0Dim rsQry, objZIPObjectDim LocalPath, ZipFile, filesys, eMsg, zCountSet rsQry = OraDatabase.DbCreateDynaset( "SELECT bn.BOM_NAME, br.BRANCH_NAME, bn.BOM_NAME ||''|| b.BOM_VERSION ||'.'|| b.BOM_LIFECYCLE AS VERSION FROM BOMS B, BRANCHES BR, BOM_NAMES BN WHERE B.BOM_ID = "& Request("bom_id") &" AND B.BRANCH_ID = BR.BRANCH_ID AND B.BOM_NAME_ID = BN.BOM_NAME_ID", cint(0))LocalPath = Server.MapPath("downloads") & "\" &_NicePath(rsQry("branch_name")) & "\" &_NicePath(rsQry("version")) & "\"&_DateReversed(Date)ZipFile = LocalPath &".zip"Set filesys = CreateObject("Scripting.FileSystemObject")Set objZIPObject = Server.CreateObject("XStandard.Zip")If filesys.FileExists(ZipFile) Thenfilesys.DeleteFile ZipFile, TRUEEnd IfobjZIPObject.Pack LocalPath &"\*.*", ZipFileeMsg = objZIPObject.ErrorDescriptionzCount = objZIPObject.Contents(ZipFile).CountResponse.Write "Files Zipped=" & zCountIf eMsg <> "" ThenResponse.Write " with Error=" & eMsgEnd If'Response.Write("" & ZipFile)'objZIPObject = NothingSet filesys = NothingDim myMailSet myMail=Server.CreateObject("Persits.MailSender")myMail.Host = SMTP_HOSTDim rsTempSet rsTemp = OraDatabase.DbCreateDynaset( "SELECT * FROM BOMS WHERE BOM_ID = "& Request("bom_id"), cint(0))If rsTemp("is_readonly") = "Y" ThenmyMail.Subject="OFFICIAL XML BOMS Generated from Deployment Manager"ElsemyMail.Subject="THESE ARE NOT OFFICIAL XML BOMS!!!"End IfmyMail.From="releasem@vixtechnology.com"myMail.AddAddress objAccessControl.UserEmail' Attach the filemyMail.AddAttachment ZipFilemyMail.Body = "Your requested xml files .."myMail.Sendset myMail = nothingset objWSH = nothingrsTemp.Close()Set rsTemp = NothingrsQry.Close()Set rsQry = nothingElseResponse.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"End If'**********************************************************************Call Destroy_All_Objects%><script language="Javascript">alert("You will be emailed shortly with the XML files generated. Click OK to Redirect to Previous Page...")history.back()</script>