07-17-2022 02:36 AM - last edited on 05-25-2023 06:57 AM by JackLacava
Hi,
I am trying to use the Business Rule API "SaveFileBytesToUserTempFolder" in order to open a file stored as a byte in a datatable.
This is exactly like in the "Reporting Compliance" dashboard, where the file is stored as bytes in a datatable. I am actually using the exact same business rule !
However, there is an issue in my case. My business rule that is used to view the document works fine until the very last step... this is the one causing the error ( I have tested FileName and FileBytes fields and these exist) :
BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, dt(0)("FileName"), dt(0)("FileBytes"))
Error message :
An error occurred while receiving the HTTP response to http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host (Socket Error Number 10054).
The exact same file is used in Reporting Compliance and I can view it. Am I missing something ?
I don't find any documentation on this function ...
Regards,
07-18-2022 09:59 AM
Hi Sergey!
Have you tried browsing to http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc you might find more info.
Also did you check that the extension is on the filename? My understanding is that the fileBytes is already good on your side? Have you tested it? for example using https://base64.guru/converter/decode/file
Or Have you tried with the exact same base64 (byte) than with the other file or see if there is a difference? Have you hard coded the fileName instead to "test.csv" or "test.xls" depending on the filetype?
'Export Register
Dim fileName As String = "Register.csv"
'Export CSV to User Temp Folder
Dim csv As String = Me.CreateRegisterTableCSVText(si, profileName, scenarioName, timeName).ToString
Dim fileBytes As Byte() = Encoding.UTF8.GetBytes(csv)
BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, fileName, fileBytes)
12-14-2022 07:56 PM
We're getting a similar error:
Here's the section of the code that gets the CSV string that is converted to Byte:
Dim ds As New DataSet
Dim csvContent As New Text.StringBuilder
Dim qualifier As String = StageConstants.ParserDefaults.DefaultQuoteCharacter
Dim delimiter As String = StageConstants.ParserDefaults.DefaultDelimiter
csvContent.AppendLine("Intercompany Detail")
csvContent.AppendLine("Workflow Profile: " & WFProfile)
csvContent.AppendLine("Workflow Scenario: " & WFScenario)
csvContent.AppendLine("Workflow Time: " & WFTime)
Dim methodQuery As String = "{" & WFProfile & "}{" & WFScenario & "}{" & WFTime & "}{}{}{V#[YTD]}{True}{}{}{}{}{}"
If Not String.IsNullOrEmpty(WFTime) Then
Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
ds = BRApi.Database.ExecuteMethodCommand(dbConnApp, XFCommandMethodTypeId.ICMatchingForWorkflowUnitMultiPlug, methodQuery, "PlugAccounts", Nothing)
"Get the IC Detail"
'Export the data
Dim fileName As String = "IC_Detail.csv"
'********* debug info *********
brapi.ErrorLog.LogMessage(si, "ADU_SoluitonHelper.Extract_WFU_IC_Matching_Plug_Accounts" & vbCrLf &
"csvContent: " & csvContent.Length)
'******************************
'Export csvContent to User Temp Folder
Dim fileBytes As Byte() = Encoding.UTF8.GetBytes(csvContent.ToString)
' Threading.Thread.Sleep(5000) ' 5000 milliseconds = 5 seconds
BRApi.Utilities.SaveFileBytesToUserTempFolder(si, si.UserName, fileName, fileBytes)
End Using
End If
The application is on the cloud so we can't use http://localhost:50002/OneStreamApp/SVC/XFFileSystem.svc
04-11-2023 09:33 PM
Gideon,
Hope all is well. Did you ever get a resolution to this problem.
I have the same error when i try to download an xlsx from the Public folder with a cloned UTM button that works perfect in UTM but not in my dashboard.
-w
04-07-2023 01:49 PM
Hi All,
Did anybody get any resolution to their .csv export problem? We're facing similar issues, but it affects some users and not others....and we can't see what the common theme is between them.
Thanks
04-11-2023 09:43 PM
Unfortunately, no resolution yet.
04-12-2023 09:08 AM
That is too bad. Maybe we can figure it out next week at Splash.
05-09-2023 06:52 AM
Hi,
We are also facing the same error. If no resolution, do we have any workaround for this issue?
05-09-2023 06:57 AM
What if you try to save it as an application file instead of a temp user file? Does that work?
05-09-2023 07:04 AM
Hi,
In our case, we are posting CSV file to Batch Harvest folder, not user temp folder. Do we have any samples to create application CSV file through BR?
05-11-2023 10:26 AM
All,
We could fix this error. It is essentially occurring when row count is 0 and we are trying to write that datatable content to a CSV file. Check the row count of your datatable, if its 0, just add a blank row to your datatable and then let a blank CSV file with just headers be created and opened by the system
Hope this helps.
05-11-2023 01:46 PM - edited 05-11-2023 01:47 PM
We ended up saving the data to the user's folder instead of the temp folder:
'Export the data
Dim fileName As String = "IC_Detail.csv"
Dim filePath As String = "Documents/Users/" & StringHelper.RemoveSystemCharacters(si.UserName,False,False)
'Export csvContent to User Folder
Dim fileBytes() As Byte = system.Text.Encoding.Unicode.GetBytes(csvContent.ToString)
Dim fileDataInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, fileName, filePath)
Dim fileData As New XFFile(fileDataInfo, String.Empty, fileBytes)
brapi.FileSystem.InsertOrUpdateFile(si, fileData)