Private Sub salvaRichiesta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles salvaRichiesta.Click
Dim NuovoTicketAttachmentService As UNIBO_NewTicketAttachment.UNIBO_NewTicketAttachmentService
Dim NuovoTicketService As UNIBO_NewTicket.UNIBO_NewTicketService
Dim Category As String = ConfigurationSettings.AppSettings("Categoria")
Dim Description As String = descrizione.Text
Dim Type As String = Session("AMBITO").ToString
Dim Item As String = Session("PROBLEMA").ToString
Dim Priority As String = cmbPriorita.SelectedValue
Dim Summary As String
Dim Summary2 As String
Dim value() As Byte
Dim fileName As String
Dim Lunghezza As Integer
Dim CodicePostazione As String
Dim fileNumber As Integer
If CodPostazione.Text.ToString = "" Then
CodicePostazione = ""
Else
CodicePostazione = CodPostazione.Text
End If
If Oggetto.Text.ToString = "" Then
Summary = Session("DETTAGLIO").ToString
Summary2 = Summary
Else
Summary = Oggetto.Text
Summary2 = Session("DETTAGLIO").ToString
End If
fileName = MyFile.Value
If (fileName <> "") Then ' Se Esiste il File Attachment
'UPLOAD FILE SUL SERVER
Dim sPath As String
Dim sFile As String
Dim sFullPath As String
Dim sSplit() As String
Dim sPathFriendly As String
Dim estensione As String
'Upload to same path as script
'Internet Anonymous User must have write permissions
sPath = Server.MapPath(".\Allegati") 'C:inetpub\wwroot....\ Directory dove viene Uplodato il File.
If Right(sPath, 1) <> "\" Then
sPathFriendly = sPath 'Friendly path name for display
sPath = sPath & "\" 'Nome del file sul server, come si chiamera il file sul server
Else
sPathFriendly = Left(sPath, Len(sPath) - 1)
End If
'Save as same file name being posted
'The code below resolves the file name
'(removes path info)
sFile = MyFile.PostedFile.FileName 'Percorso client del file
sSplit = Split(sFile, "\") 'Directory dove viene salvato il file
sFile = sSplit(UBound(sSplit)) 'NOME DEL FILE
estensione = Right(sFile, Len(sFile) - InStr(sFile, "."))
sFullPath = sPath + Session.SessionID + "." + estensione
MyFile.PostedFile.SaveAs(sFullPath) 'Copio il File
Lunghezza = FileSystem.FileLen(sFullPath)
ReDim value(Lunghezza - 1)
fileNumber = FileSystem.FreeFile()
FileSystem.FileOpen(fileNumber, sFullPath, OpenMode.Binary)
FileSystem.FileGet(fileNumber, value)
FileSystem.FileClose(fileNumber)
'*** Cancello il file temporaneo creato.
Dim FileToDelete As FileInfo = New FileInfo(sFullPath)
FileToDelete.Delete()
'Gestisco il WebService
Dim authInfo As UNIBO_NewTicketAttachment.AuthenticationInfo
authInfo = New UNIBO_NewTicketAttachment.AuthenticationInfo
authInfo.userName = Session("USER").ToString
authInfo.password = Session("PWD").ToString
NuovoTicketAttachmentService = New UNIBO_NewTicketAttachment.UNIBO_NewTicketAttachmentService
NuovoTicketAttachmentService.AuthenticationInfoValue = authInfo
Select Case cmbPriorita.SelectedValue
Case "NoUrgente"
NuovoTicketAttachmentService.OpCreate(Category, Description, Item, Summary, Summary2, Type, UNIBO_NewTicketAttachment.Request_UrgencyType.Low, MyFile.Value, value, Lunghezza, UNIBO_NewTicketAttachment.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
Case "Seria"
NuovoTicketAttachmentService.OpCreate(Category, Description, Item, Summary, Summary2, Type, UNIBO_NewTicketAttachment.Request_UrgencyType.Medium, MyFile.Value, value, Lunghezza, UNIBO_NewTicketAttachment.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
Case "Bloccante"
NuovoTicketAttachmentService.OpCreate(Category, Description, Item, Summary, Summary2, Type, UNIBO_NewTicketAttachment.Request_UrgencyType.Urgent, MyFile.Value, value, Lunghezza, UNIBO_NewTicketAttachment.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
End Select
' Dim TicketID As String = NuovoTicketAttachmentService.OpCreate(Category, Description, MyFile.Value, value, Lunghezza, Item, Summary, Summary2, Type, UNIBO_NewTicketAttachment.Request_UrgencyType.Low)
Else '***************** NON ESISTE IL FILE Attachment ***************
Dim authInfo As UNIBO_NewTicket.AuthenticationInfo
authInfo = New UNIBO_NewTicket.AuthenticationInfo
authInfo.userName = Session("USER").ToString
authInfo.password = Session("PWD").ToString
NuovoTicketService = New UNIBO_NewTicket.UNIBO_NewTicketService
NuovoTicketService.AuthenticationInfoValue = authInfo
Select Case cmbPriorita.SelectedValue
Case "NoUrgente"
NuovoTicketService.OpCreate(Category, Description, Item, Summary, Type, Summary2, UNIBO_NewTicket.Request_UrgencyType.Low, UNIBO_NewTicket.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
Case "Seria"
NuovoTicketService.OpCreate(Category, Description, Item, Summary, Type, Summary2, UNIBO_NewTicket.Request_UrgencyType.Medium, UNIBO_NewTicket.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
Case "Bloccante"
NuovoTicketService.OpCreate(Category, Description, Item, Summary, Type, Summary2, UNIBO_NewTicket.Request_UrgencyType.Urgent, UNIBO_NewTicket.SourceType.Web, Session("USER").ToString, Session("nome").ToString + " " + Session("cognome").ToString, Session("Email").ToString, CodicePostazione, Session("Telefono").ToString, Session("Qualifica").ToString)
End Select
' NuovoTicketService.OpCreate(Category, Description, Item, Summary, Type, Summary2, cmbPriorita.SelectedValue)
End If
If Err.Number = 0 Or 5 Then
Response.Redirect("esito.aspx")
Else
lblerrore.Text = "Errore nella sottomissione del ticket " & Err.Description & " " & Err.Number & " " & Err.Source
End If
End Sub