Imports BVSoftware.BVC.Core Imports System.IO Public Class Orders_UPSOnlineTools_Void Inherits BaseAdminPage #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents btnGo As System.Web.UI.WebControls.ImageButton Protected WithEvents TrackingNumberField As System.Web.UI.WebControls.TextBox 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessOrderArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription End If End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGo.Click Dim req As New BVSoftware.UPS.OnlineTools.VoidShipmentRequest req.Settings.UserID = WebAppSettings.ShippingUPSUsername req.Settings.Password = WebAppSettings.ShippingUPSPassword req.Settings.License = WebAppSettings.ShippingUPSLicense req.Settings.ServerUrl = WebAppSettings.ShippingUPSServer req.ShipmentIdentificationNumber = Me.TrackingNumberField.Text.Trim Dim res As BVSoftware.UPS.OnlineTools.VoidShipmentResponse res = BVSoftware.UPS.OnlineTools.XmlTools.SendVoidShipmentRequest(req) If Not res Is Nothing Then If WebAppSettings.ShippingUPSWriteXml = True Then Me.SaveXmlStringToFile("Void_" & req.ShipmentIdentificationNumber & "_Request.xml", req.XmlRequest) Me.SaveXmlStringToFile("Void_" & req.ShipmentIdentificationNumber & "_Response.xml", req.XmlResponse) End If If res.Success = True Then Me.msg.ShowOK("Shipment " & Me.TrackingNumberField.Text.Trim & " was voided.") Me.TrackingNumberField.Text = "1Z" Else Me.msg.ShowWarning("Error " & res.ErrorCode & ": " & res.ErrorMessage) End If Else msg.ShowWarning("Response object was empty") End If End Sub Private Function SaveXmlStringToFile(ByVal filename As String, ByVal data As String) As Boolean Dim result As Boolean = False Dim UPSLabelDirectory As String = Path.Combine(Request.PhysicalApplicationPath, "images\UPS\Xml") Try If Directory.Exists(UPSLabelDirectory) = False Then Directory.CreateDirectory(UPSLabelDirectory) End If Dim writer As New StreamWriter(Path.Combine(UPSLabelDirectory, filename), False) writer.Write(data) writer.Flush() writer.Close() Catch ex As Exception EventLog.LogEvent(ex) End Try Return result End Function End Class