#If B4A
Private Sub TestFileAccessBtn_Click
Try
'SELECT TOP 100 Pmp_PictureName FROM PartMasterPics WHERE Pmp_PrintOnTrav = 1;
ProgressDialogShow("Getting picture file name from server.")
Wait For (MP.Ethernet.Getdata("PMPicTest", Null)) Complete (DataRows As List)
If Not(DataRows.Get(0).As(String).EqualsIgnoreCase("Request Failed")) Then
If DataRows.Size > 0 Then
Dim Picmap As Map = DataRows.Get(Rnd(0, DataRows.Size - 1))
If UseSQLForFilesCB.Checked Then
ProgressDialogShow("File(s) found. Attempting to get the file VIA SQL.")
Wait For (MP.Ethernet.Getdata("GetDocFileBinary", Array(Picmap.Get("Pmp_PictureName")))) Complete (DataRows As List)
If Not(DataRows.Get(0).As(String).Contains("Request Failed")) Then
Dim TMap As Map = DataRows.Get(0)
If TMap.Get("Result").As(String).EqualsIgnoreCase("SUCCESS") Then
Dim Buffer() As Byte = TMap.Get("Picture")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
#If B4J
Dim Bmp As Image
Bmp.Initialize2(InputStream1)
#Else
Dim Buffer() As Byte = TMap.Get("Picture")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bmp As Bitmap
Bmp.Initialize2(InputStream1)
InputStream1.Close
#End If
IMV.Bitmap = Bmp
IMV.ResizeMode = "FIT"
IMV.mBase.Visible = True
Wait For(MP.xui.MsgboxAsync($"File ${Picmap.Get("Pmp_PictureName")} was successfully copied from the network and loaded as an image. You should have access to pictures and documents."$, "SUCCESS!")) Msgbox_Result (RW As Int)
IMV.mBase.Visible = False
Else
xui.MsgboxAsync($"SQL Error retrieving Picture File Binary for ${Picmap.Get("Pmp_PictureName")} from Server
The SQL error is:
${TMap.Get("Result")}"$, "Error in TestFileAccessBtn_Click")
End If
Else
xui.MsgboxAsync($"Error retrieving Picture File Binary ${Picmap.Get("Pmp_PictureName")} from Server"$, "Error in TestFileAccessBtn_Click")
End If
Else
ProgressDialogShow("File(s) found. Checking if we can see the file on the network.")
#IF B4i
Main.DocsDir = $"${File.DirLibrary}/Docs"$
File.MakeDir(File.DirLibrary, "Docs")
#Else
Main.DocsDir = $"${File.DirInternal}/Docs"$
File.MakeDir(File.DirInternal, "Docs")
#End If
MP.DCUTs.SMB1.SetCredentials(FileAccessUserName.Text, FileAccessPassword.Text, "")
MP.DCUTs.SMB1.Initialize("SMB1")
Dim FN As String, Pth As String
FN = Picmap.Get("Pmp_PictureName").As(String).Replace("\","/")
Pth = FN.SubString2(0, (FN.LastIndexOf("/") + 1))' & "/"
FN = FN.SubString2(FN.LastIndexOf("/") + 1, FN.Length)
MP.DCUTs.SMB1.ListFiles("smb:" & Pth , FN)
Wait For SMB1_ListCompleted(Url As String, Success As Boolean, Entries() As SMBFile)
If Success Then
If Entries.Length > 0 Then
ProgressDialogShow("File " & Pth & FN & " was found on the network! Attempting to copy the file to the tablet.")
xui.MsgboxAsync("File " & Pth & FN & " was found on the network! Attempting to copy the file to the tablet.", "")
MP.DCUTs.SMB1.DownloadFile("smb:" & Pth , FN, Main.DocsDir, FN)
Wait For SMB1_DownloadCompleted (Url As String, RemoteFile As String, Success As Boolean)
If Success Then
xui.MsgboxAsync($"File " & ${Pth} & ${FN} was successfully copied from the network. You should have access to pictures and documents."$, "SUCCESS!")
Else
xui.MsgboxAsync($"UNABLE to copy File " & ${Pth} & ${FN} locally. Make sure you have all appropriate rights to copy files. Make sure that SMB1 is enabled on your document server."$, "COPY FAILED")
End If
Else
xui.MsgboxAsync($"File " & ${Pth} & ${FN} was NOT found on the network! It is possible that the file does not exist. You can try again and a diferent file will be chosen at randon. If that fails then we don't have appropriate rights to the server. Make sure that SMB1 is enabled on your document server."$, "File not Found")
End If
Else
xui.MsgboxAsync($"There was an error tring to locate the file " & ${Pth} & ${FN} on the network! It is possible that the file does not exist. You can try again and a diferent file will be chosen at randon. If that fails then we don't have appropriate rights to the server. Make sure that SMB1 is enabled on your document server."$, "File not Found")
End If
End If
Else
xui.MsgboxAsync($"No Print On Traveler Picture FileNames found in PartmasterPics"$, "Error in TestFileAccessBtn_Click")
End If
Else
xui.MsgboxAsync($"Error retrieving ANY Picture FileNames from PartmasterPics"$, "Error in TestFileAccessBtn_Click")
End If
ProgressDialogHide
Catch
ProgressDialogHide
xui.MsgboxAsync(LastException.Message.SubString2(0, Min(LastException.Message.Length, 500)), "Error in TestFileAccessBtn_Click")
End Try
End Sub
#Else If B4J
Private Sub TestFileAccessBtn_Click
Try
'Dim SMB1 As SMB
'SELECT TOP 100 Pmp_PictureName FROM PartMasterPics WHERE Pmp_PrintOnTrav = 1;
' ProgressDialogShow("Getting picture file name from server.")
Toast.Show("Getting picture file name from server.", Null)
Wait For (MP.Ethernet.Getdata("PMPicTest", Null)) Complete (DataRows As List)
If Not(DataRows.Get(0).As(String).EqualsIgnoreCase("Request Failed")) Then
If DataRows.Size > 0 Then
Dim Picmap As Map = DataRows.Get(Rnd(0, DataRows.Size - 1))
If UseSQLForFilesCB.Checked Then
Toast.show("File(s) found. Attempting to get the file VIA SQL.", Null)
Wait For (MP.Ethernet.Getdata("GetDocFileBinary", Array(Picmap.Get("Pmp_PictureName")))) Complete (DataRows As List)
If Not(DataRows.Get(0).As(String).Contains("Request Failed")) Then
Dim TMap As Map = DataRows.Get(0)
If TMap.Get("Result").As(String).EqualsIgnoreCase("SUCCESS") Then
Dim Buffer() As Byte = TMap.Get("Picture")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
#If B4J
Dim Bmp As Image
Bmp.Initialize2(InputStream1)
#Else
Dim Buffer() As Byte = TMap.Get("Picture")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bmp As Bitmap
Bmp.Initialize2(InputStream1)
InputStream1.Close
#End If
IMV.Bitmap = Bmp
IMV.ResizeMode = "FIT"
IMV.mBase.Visible = True
Wait For(MP.xui.MsgboxAsync($"File ${Picmap.Get("Pmp_PictureName")} was successfully copied from the network and loaded as an image. You should have access to pictures and documents."$, "SUCCESS!")) Msgbox_Result (RW As Int)
IMV.mBase.Visible = False
Else
xui.MsgboxAsync($"SQL Error retrieving Picture File Binary for ${Picmap.Get("Pmp_PictureName")} from Server
The SQL error is:
${TMap.Get("Result")}"$, "Error in TestFileAccessBtn_Click")
End If
Else
xui.MsgboxAsync($"Error retrieving Picture File Binary ${Picmap.Get("Pmp_PictureName")} from Server"$, "Error in TestFileAccessBtn_Click")
End If
End If
Else
xui.MsgboxAsync($"No Print On Traveler Picture FileNames found in PartmasterPics"$, "Error in TestFileAccessBtn_Click")
End If
Else
xui.MsgboxAsync($"Error retrieving ANY Picture FileNames from PartmasterPics"$, "Error in TestFileAccessBtn_Click")
End If
Catch
xui.MsgboxAsync(LastException.Message.SubString2(0, Min(LastException.Message.Length, 500)), "Error in TestFileAccessBtn_Click")
End Try
End Sub
#End If