diff --git a/App/Controllers/Kit/KitController.asp b/App/Controllers/Kit/KitController.asp index 87d93fa..ea6deab 100644 --- a/App/Controllers/Kit/KitController.asp +++ b/App/Controllers/Kit/KitController.asp @@ -104,7 +104,7 @@ Class KitController End Sub Public Sub SwitchBoardEdit - + Flash.ShowSuccessIfPresent dim id : id = Request.QueryString("Id") set Model = new SwitchBoard_ViewModel_Class @@ -114,13 +114,10 @@ Class KitController HTMLSecurity.SetAntiCSRFToken "KitEditForm" %> <% End Sub - Public Sub DownloadTrackingkitSnailWorksPDF - - dim id : id = Request.QueryString("Id") - dim ExportDirectory:ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\" + Public Sub ExportTrackingLabels(id) dim KitInfo : Set KitInfo = KitRepository.FindByID(id) dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode) - ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep" + ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep" if dev = true Then ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;" @@ -136,32 +133,35 @@ Class KitController ReportManager.SetParamValue "PBKITID", CInt(id) if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then + FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) end if - ReportManager.SaveToPdf ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf",1 - 'ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf",1 - - Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream") - objStream.Type = 1 'adTypeBinary - objStream.Open - objStream.LoadFromFile(Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf") - Response.ContentType = "application/octet-stream" - Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".pdf" - Response.BinaryWrite objStream.Read - objStream.Close - Set objStream = Nothing - - + + + if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf") then + FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf") + end if + ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & " Labels.pdf",1 + FSO.MoveFile Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & " Labels.pdf" , ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf" + End Sub - Public Sub DownloadTrackingkitSnailWorks - dim ExportDirectory:ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\" - dim id : id = Request.QueryString("Id") + Public Sub ExportSnailWorksTracking(id) + dim KitInfo : Set KitInfo = KitRepository.FindByID(id) + dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode) + if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then + + FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) + end if + + + if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv") then + FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv") + end if dim export: set export = SnailWorksRepository.GetSnailWorksExportById(id) if export.DetailRecords.Count > 0 Then - If Not Server.CreateObject("Scripting.FileSystemObject").FolderExists(server.mappath("/uploads/")) Then : Server.CreateObject("Scripting.FileSystemObject").CreateFolder(server.mappath("/uploads/")):End If - dim objExportFile: Set objExportFile = Server.CreateObject("Scripting.FileSystemObject").CreateTextFile(server.mappath("/uploads/" & id & ".csv"),2) + dim objExportFile: Set objExportFile = FSO.CreateTextFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv",2) With objExportFile .Write """" & export.Header.RecordType & """," .Write """" & export.Header.Version & """," @@ -223,19 +223,12 @@ Class KitController .Write """" & records.IMTB & """" & vbCRLF Wend End With - objExportFile.Close - Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream") - objStream.Type = 1 'adTypeBinary - objStream.Open - objStream.LoadFromFile(server.mappath("/uploads/" & id & ".csv")) - Response.ContentType = "application/octet-stream" - Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".csv" - Response.BinaryWrite objStream.Read - objStream.Close - Set objStream = Nothing End If + + End Sub + Public Sub Edit dim id : id = Request.QueryString("Id") @@ -302,7 +295,6 @@ Class KitController 'Else ' set Model = new Create_ViewModel_Class 'End If - HTMLSecurity.SetAntiCSRFToken "KitCreateForm" %> <% @@ -326,6 +318,8 @@ Class KitController KitRepository.AddNew new_Kit_model KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount") ' FormCache.ClearForm "NewKit" + ExportTrackingLabels(new_Kit_model.ID) + ExportSnailWorksTracking(new_Kit_model.ID) Flash.Success = "Kit added." MVC.RedirectToAction "Index" 'End If diff --git a/App/app.config.asp b/App/app.config.asp index 3c99a21..d3bb919 100644 --- a/App/app.config.asp +++ b/App/app.config.asp @@ -8,6 +8,7 @@ tabulatorCss = "/dist/css/tabulator_bootstrap5.css" appBootStrapJs = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js' integrity='sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM' crossorigin='anonymous" jqueryJs = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js' integrity='sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==' crossorigin='anonymous' referrerpolicy='no-referrer" dev = true +dim ExportDirectory:ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\" '======================================================================================================================= ' Set Global Variables Here '======================================================================================================================= diff --git a/MVC/activeXdepedancies.asp b/MVC/activeXdepedancies.asp index 0dcf78b..543276c 100644 --- a/MVC/activeXdepedancies.asp +++ b/MVC/activeXdepedancies.asp @@ -18,7 +18,7 @@ dim m_FSO Private Function FSO if not isobject(m_FSO) then - set m_FSO = server.CreateObject(CreateObject("Scripting.FileSystemObject") + set m_FSO = server.CreateObject("Scripting.FileSystemObject") end if set FSO = m_FSO End Function