WebOrderAPI: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
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…“) |
Grigor (Diskussion | Beiträge) |
||
Zeile 16: | Zeile 16: | ||
<WebMethod()> _ | <WebMethod()> _ | ||
− | Public Function ListOrders(mandant As String) As String() | + | Public Function ListOrders(mandant As String, key as String) As String() |
Dim allFiles As String() = IO.Directory.GetFiles(Server.MapPath("..\data\" & mandant)) | Dim allFiles As String() = IO.Directory.GetFiles(Server.MapPath("..\data\" & mandant)) | ||
Dim allFilesFilenameonly As List(Of String) = New List(Of String) | Dim allFilesFilenameonly As List(Of String) = New List(Of String) | ||
Zeile 29: | Zeile 29: | ||
<WebMethod()> _ | <WebMethod()> _ | ||
− | Public Function GetOrder(mandant As String, filename As String) As String | + | Public Function GetOrder(mandant As String, key as String, filename As String) As String |
Return IO.File.ReadAllText(Server.MapPath("..\data\" & mandant & "\" + filename)) | Return IO.File.ReadAllText(Server.MapPath("..\data\" & mandant & "\" + filename)) | ||
End Function | End Function | ||
<WebMethod()> _ | <WebMethod()> _ | ||
− | Public Function ConfirmOrder(mandant As String, filename As String, info As String) As Boolean | + | Public Function ConfirmOrder(mandant As String, key as String, filename As String, info As String) As Boolean |
Try | Try | ||
ModuleLog.WriteLog("ConfirmOrder: " & mandant & "; " & filename & "; " & info) | ModuleLog.WriteLog("ConfirmOrder: " & mandant & "; " & filename & "; " & info) | ||
Zeile 40: | Zeile 40: | ||
Dim orderFileConfirmed = Server.MapPath("..\data\" & mandant & "\" + filename) | Dim orderFileConfirmed = Server.MapPath("..\data\" & mandant & "\" + filename) | ||
orderFileConfirmed = orderFileConfirmed.Replace("order_", "confirmed_") | orderFileConfirmed = orderFileConfirmed.Replace("order_", "confirmed_") | ||
− | |||
IO.File.Move(orderFile, orderFileConfirmed) | IO.File.Move(orderFile, orderFileConfirmed) | ||
Return True | Return True | ||
'TODO MAIL SENDEN an KUNDEN | 'TODO MAIL SENDEN an KUNDEN | ||
− | |||
Catch ex As Exception | Catch ex As Exception | ||
ModuleLog.WriteLog("ConfirmOrder Error: " & ex.Message) | ModuleLog.WriteLog("ConfirmOrder Error: " & ex.Message) | ||
Zeile 52: | Zeile 50: | ||
<WebMethod()> _ | <WebMethod()> _ | ||
− | Public Function UploadCatalog(mandant As String, newCatalog As String) As Boolean | + | Public Function UploadCatalog(mandant As String, key as String, newCatalog As String) As Boolean |
Try | Try | ||
Dim target = Server.MapPath("/data/" & mandant) | Dim target = Server.MapPath("/data/" & mandant) | ||
Zeile 58: | Zeile 56: | ||
IO.Directory.CreateDirectory(target) | IO.Directory.CreateDirectory(target) | ||
End If | End If | ||
− | |||
IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog) | IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog) | ||
Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData | Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData | ||
ds.ReadXml(target & "\export.tmp.xml") | ds.ReadXml(target & "\export.tmp.xml") | ||
− | |||
If IO.File.Exists(target & "\export.xml") Then | If IO.File.Exists(target & "\export.xml") Then | ||
IO.File.Move(target & "\export.xml", target & "\export.xml." & Format(Now, "hh24mm")) | IO.File.Move(target & "\export.xml", target & "\export.xml." & Format(Now, "hh24mm")) | ||
End If | End If | ||
− | |||
ds.WriteXml(target & "\export.xml") | ds.WriteXml(target & "\export.xml") | ||
− | |||
Return True | Return True | ||
Catch ex As Exception | Catch ex As Exception | ||
Return False | Return False | ||
End Try | End Try | ||
− | |||
End Function | End Function | ||
<WebMethod()> _ | <WebMethod()> _ | ||
− | Public Function UploadCatalogMedia(mandant As String, newCatalog As Byte()) As Boolean | + | Public Function UploadCatalogMedia(mandant As String, key as String, newCatalog As Byte()) As Boolean |
Try | Try | ||
Dim target = Server.MapPath("/data/" & mandant) | Dim target = Server.MapPath("/data/" & mandant) | ||
Zeile 83: | Zeile 76: | ||
IO.Directory.CreateDirectory(target) | IO.Directory.CreateDirectory(target) | ||
End If | End If | ||
− | |||
Dim targetFilenameTmp = target & "\exportMedia.tmp.xml" | Dim targetFilenameTmp = target & "\exportMedia.tmp.xml" | ||
Dim fs As FileStream = New FileStream(targetFilenameTmp, FileMode.Create, FileAccess.ReadWrite) | Dim fs As FileStream = New FileStream(targetFilenameTmp, FileMode.Create, FileAccess.ReadWrite) | ||
fs.Write(newCatalog, 0, newCatalog.Length) | fs.Write(newCatalog, 0, newCatalog.Length) | ||
fs.Close() | fs.Close() | ||
− | |||
'IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog) | 'IO.File.WriteAllText(target & "\export.tmp.xml", newCatalog) | ||
Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData | Dim ds As IntraSell_Net_Web_Data_DLL.WebOrderData = New IntraSell_Net_Web_Data_DLL.WebOrderData | ||
− | |||
ds.ReadXml(targetFilenameTmp) | ds.ReadXml(targetFilenameTmp) | ||
− | |||
Dim targetFilename = target & "\exportMedia.xml" | Dim targetFilename = target & "\exportMedia.xml" | ||
− | |||
If IO.File.Exists(targetFilename) Then | If IO.File.Exists(targetFilename) Then | ||
IO.File.Delete(targetFilename) | IO.File.Delete(targetFilename) | ||
End If | End If | ||
− | |||
ds.WriteXml(targetFilename) | ds.WriteXml(targetFilename) | ||
− | |||
Return True | Return True | ||
Catch ex As Exception | Catch ex As Exception | ||
Return False | Return False | ||
End Try | End Try | ||
− | |||
End Function | End Function | ||
− | |||
− | |||
End Class | End Class | ||
<code> | <code> |
Version vom 20. August 2019, 21:21 Uhr
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, key 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, key 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, key 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, key 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, key 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