WebOrderAPI
Version vom 20. August 2019, 21:19 Uhr von Grigor (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Folgende Schnittstelle soll implementiert werden: <code> Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel Impor…“)
Folgende Schnittstelle soll implementiert werden:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports IntraSell_DLL
Imports System.IO
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class ServiceWebOrder
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function ListOrders(mandant As String) As String()
Dim allFiles As String() = IO.Directory.GetFiles(Server.MapPath("..\data\" & mandant))
Dim allFilesFilenameonly As List(Of String) = New List(Of String)
For Each f In allFiles
f = IO.Path.GetFileName(f)
If f.Contains("order") Then
allFilesFilenameonly.Add(f)
End If
Next
Return allFilesFilenameonly.ToArray
End Function
<WebMethod()> _
Public Function GetOrder(mandant As String, filename As String) As String
Return IO.File.ReadAllText(Server.MapPath("..\data\" & mandant & "\" + filename))
End Function
<WebMethod()> _
Public Function ConfirmOrder(mandant As String, filename As String, info As String) As Boolean
Try
ModuleLog.WriteLog("ConfirmOrder: " & mandant & "; " & filename & "; " & info)
Dim orderFile = Server.MapPath("..\data\" & mandant & "\" + filename)
Dim orderFileConfirmed = Server.MapPath("..\data\" & mandant & "\" + filename)
orderFileConfirmed = orderFileConfirmed.Replace("order_", "confirmed_")
IO.File.Move(orderFile, orderFileConfirmed)
Return True
'TODO MAIL SENDEN an KUNDEN
Catch ex As Exception
ModuleLog.WriteLog("ConfirmOrder Error: " & ex.Message)
End Try
Return False
End Function
<WebMethod()> _
Public Function UploadCatalog(mandant As String, newCatalog As String) As Boolean
Try
Dim target = Server.MapPath("/data/" & mandant)
If Not IO.Directory.Exists(target) Then
IO.Directory.CreateDirectory(target)
End If
IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog)
Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData
ds.ReadXml(target & "\export.tmp.xml")
If IO.File.Exists(target & "\export.xml") Then
IO.File.Move(target & "\export.xml", target & "\export.xml." & Format(Now, "hh24mm"))
End If
ds.WriteXml(target & "\export.xml")
Return True
Catch ex As Exception
Return False
End Try
End Function
<WebMethod()> _
Public Function UploadCatalogMedia(mandant As String, newCatalog As Byte()) As Boolean
Try
Dim target = Server.MapPath("/data/" & mandant)
If Not IO.Directory.Exists(target) Then
IO.Directory.CreateDirectory(target)
End If
Dim targetFilenameTmp = target & "\exportMedia.tmp.xml"
Dim fs As FileStream = New FileStream(targetFilenameTmp, FileMode.Create, FileAccess.ReadWrite)
fs.Write(newCatalog, 0, newCatalog.Length)
fs.Close()
'IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog)
Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData
ds.ReadXml(targetFilenameTmp)
Dim targetFilename = target & "\exportMedia.xml"
If IO.File.Exists(targetFilename) Then
IO.File.Delete(targetFilename)
End If
ds.WriteXml(targetFilename)
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class