How do I make a report use RDL code that I updated in the ReportServer db - reportingservices-2005

In Reporting Services 2005, I need to update an embedded image file in over 300 reports to use a new image (re-branding).
I was able to come up with a script that changes the RDL to what I want, but when I run the report in Report Manager, it continues to use the old report definition and display the old image. If I download the RDL to a text file, it has my changes. When I re-upload it, the report displays the new image.
I'd like to know if I need to do something else to tell Reporting Services that there is a new definition.
My t-sql statement is below:
-- Pull updated image code from a sample report I updated with new logo
DECLARE #NewImageString VARCHAR(MAX)
SELECT #NewImageString = SUBSTRING(convert(VARCHAR(max), convert(VARBINARY(max), content)), charindex('<EmbeddedImage Name="logo_1">', convert(VARCHAR(max), convert(VARBINARY(max), content)))
--calculate length of new image string
, 15 + charindex('9k=</ImageData>', convert(VARCHAR(max), convert(VARBINARY(max), content))) --endpoint of new image string
- charindex('<EmbeddedImage Name="logo_1">', convert(VARCHAR(max), convert(VARBINARY(max), content))) -- beginning point of new image string
)
FROM reportserver.dbo.CATALOG
WHERE content IS NOT NULL
AND PATH LIKE '%/Live.Reports%'
AND NAME LIKE 'rpt_Triage_new%'
-- Replace <EmbeddedImage> portion of RDL
UPDATE ReportServer.dbo.CATALOG
SET CONTENT = convert(IMAGE, convert(VARBINARY(max), SUBSTRING(convert(VARCHAR(max), convert(VARBINARY(max), content)), 0, charindex('<EmbeddedImage Name="logo">', convert(VARCHAR(max), convert(VARBINARY(max), content)))) + #NewImageString + SUBSTRING(convert(VARCHAR(max), convert(VARBINARY(max), content)), 28 + charindex('53KOZjtohn0ICAA7</ImageData>', convert(VARCHAR(max), convert(VARBINARY(max), content))), 200000)))
WHERE PATH LIKE '%/Test1.Reports%'
AND NAME LIKE 'rptTriage_to_update%'
-- Update <Value> for Image1 reference
UPDATE ReportServer.dbo.CATALOG
SET content = convert(IMAGE, convert(VARBINARY(max), REPLACE(convert(VARCHAR(max), convert(VARBINARY(max), content)), '<Value>logo</Value>', '<Value>logo_1</Value>')))
WHERE content IS NOT NULL
AND PATH LIKE '%/Test1.Reports%'
AND NAME LIKE 'rptTriage_to_update%'
AND convert(VARCHAR(max), convert(VARBINARY(max), content)) LIKE '%<Value>logo</Value>%'

If your reports are not organized in many folders and if you can access your reports as http://server/reports, then delete all existing reports in the folder and upload all the new rdl files. That will make upload rdl files easy.

My final solution involved using the script above to change the report definitions, then use RSScripter to bulk download and upload the reports. I didn't realize it before, but RSScripter automatically generates a command file to re-upload the reports.

Related

Give a name to a pdf printed on screen in Genexus

With a Genexus procedure, setting the call protocol to Http and the output_file rule, you can create a report and show to the user a pdf, basic Genexus tool. My problem is that I can't set the name of this pdf, it ignores the parameter of the output_file rule and if I try to save the pdf manually, it's named as the name of the procedure.
Can I set the name of the pdf somehow? Better if I can send it as parameter
Add this code to the procedure.
// &DocumentFriendlyName is varchar(100)
&HttpResponse.AddHeader(!"Content-Type", !"application/pdf")
&HttpResponse.AddHeader(!"Content-Disposition", !"attachment;filename=" + &DocumentFriendlyName + !".pdf")
If you don't want to download the PDF directly, create the PDF on the server, then use a &Window object to show it.
&Window.Url = &DownloadPdfUrl
&Window.Open()
If you add the rule:
Output_file(&FileName, 'PDF');
It does not generate the file with the value of the variable &FileName?

Send an image from smart device to the server in Genexus

I know there is already a similar question but the answers to that didn't work for me
I'm working with Genexus 16U11 and I have a panel with an image variable (called &sourceImage) with control type as "SD Image Annotation". I need to send this image to the server, in a specific folder. According the documentation if I call a procedure using the image as variable this should go on the server but it's not working. I can't find the image anywhere, I searched also in the PublicTempStorage directory, in the procedure is as the variable is empty.
I tried also to convert the image in base64 to send it as longvarchar to the procedure
&blob = &sourceImage.GetAnnotatedImage()
&longvarchar = ToBase64(&blob)
but in this way I can only get this string ZmlsZTovLy8vc3RvcmFnZS9lbXVsYXRlZC8wL0FuZHJvaWQvZGF0YS9jb20uYXJ0ZWNoLnJpY2hpZXN0YXBlcm1lc3NpMTZ1MTEuc2Zpcm1hL2ZpbGVzL3RyYW5zZm9ybWF0aW9ucy8yMDIyLTAzLTE4LS0xNC00My0yNi02MTQ2NDcyMTA5MjM5NDU3NzgzODAxLnBuZw==
that is the path of the file
file:////storage/emulated/0/Android/data/com.artech.richiestapermessi16u11.sfirma/files/transformations/2022-03-18--14-43-26-6146472109239457783801.png
I tried with file variable, blob, image, extra images, method fromUrl, nothing is working.
What am I doing wrong?
To upload the image to the server you need to call the procedure in the server (Connectivity=Online).
Then the image variable will be send to the server and you can save, copy, etc. there.
For example, save in a Transaction with a code like this:
Call in the panel:
Composite
&resultImage = &ImageA.GetAnnotatedImage()
procSaveImage(&resultImage)
EndComposite
Procedure online:
&TrnData = new()
&TrnData.TrnDataImage = &parmImage
&TrnData.Insert()
if &TrnData.Success()
commit
Working in Genexus v17u8 .

How to rename the title of the HTML Report generated by pytest-html plug in?

I am generating html report using pytest-html plugin. I'm executing the pytest file by giving "pytest --html=report.html" in command line.
So the name and title of the html report generated is report.html. I want to change the title of the generated report.
Please let me know, how to do that?
Since v2.1.0, this plugin exposes a hook called before adding the title to the report. You can add this to conftest.py:
def pytest_html_report_title(report):
report.title = 'your title!'
This is also explained in the plugin's User Guide.
create conftest.py file in the same folder of the test.
this file is used to configure pytest.
put this snippet inside
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend([html.h1("A GOOD TITLE")])
if you need to change the html report file name you can try something like this
# #pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
# to remove environment section
config._metadata = None
if not os.path.exists('reports'):
os.makedirs('reports')
config.option.htmlpath = 'reports/' + datetime.now().strftime("%d-%m-%Y %H-%M-%S") + ".html"
my example will put the report.html file in a folder called reports naming with a date instead of a static name
From what I see in the code there is no mean to change only the report's title yet, it is for now hardcoded as
html.h1(os.path.basename(self.logfile))
So the report title will always be the report file name. I've just pushed a merge request to the project to add a new hook to allow the change of the title without changing the file name, we will see if it is accepted.

SSRS External Images with Dynamic File Extensions

I have a report that needs to show images from a Windows folder on the server, which is working (see here ). Now, I am wondering how to get the report to pull images of differing file types, like jpg & tif. (I am using png by default). Is there a relatively easy way to do this? The image names with file extension are not in the SQL database.
EDIT: I entered this in the Custom Code block, from Daniel's help below.
Public Function GetImage(ByRef Filename As String) As String
' Full image path used for testing if it exists
Dim ImagePath As String
ImagePath = "\\GVSSERVER1\GVSServerD\Acclamare_Images\" + Filename
' Test to see if the file exists as a gif
Try
If System.IO.File.Exists(ImagePath + ".png")
Return "file://" + ImagePath + ".png"
ElseIf System.IO.File.Exists(ImagePath + ".jpg")
Else Return "file://" + ImagePath + ".jpg"
End If
Catch ex As Exception
Return "Hit an Error"
End Try
Return "Hit the end"
End Function
When I run the report, it fetches the .jpg extension even though the image file is a png, and there isn't a jpg file for that item. Any idea on how to correct that?
EDIT 2: I wasn't having success with the updated custom code, but I could have been missing something, as I'm no expert with custom code. I found this question (see here) which is for a function. I tried it and it works, except for some reason .tif files don't display on the report. I installed Microsoft Picture Manager (from the Sharepoint exe download), but it still doesn't display the .tif files.
The good news is that this is definetely possible, however it takes a bit of custom code and server side tweaking to get ready.
General Idea: Create a code behind function that takes the name of our image and then does file existence tests to determine which file extension type actually exists on the network share.
If you right-click outside of the report area and go to properties, you will see the custom code window where you can paste the following function code.
Custom Code:
Public Function GetImage(ByRef Filename As String) As String
' Full image path used for testing if the image exists
Dim ImagePath As String
ImagePath = "\\EM-SSRS\ImageTest\" + Filename
' Test to see if the file exists as a gif
If System.IO.File.Exists(ImagePath + ".gif") THEN
Return "file://" + ImagePath + ".gif"
ElseIf System.IO.File.Exists(ImagePath + ".png") THEN
Return "file://" + ImagePath + ".png"
ElseIf System.IO.File.Exists(ImagePath + ".jpg") THEN
Return "file://" + ImagePath + ".jpg"
ElseIf System.IO.File.Exists(ImagePath + ".jpeg") THEN
Return "file://" + ImagePath + ".jpeg"
End If
Return "No Image Exists"
End Function
You will have to edit the ImagePath variable to contain the network share path for your scenario or even add another parameter to the function to make it more generic if you wish.
Once the code function is created, I would advise creating a dummy textbox expression on the report and using the following value:
=Code.GetImage("Filenmame")
Which will allow you to view the output of the function and tweak things as needed. Note that the "file:// ... " syntax may not work from within report builder or visual studio and may have to be deployed to a report server for testing.
Of course, once it looks like the function is working, add the image, make sure to set the source to external and use the same expression as for the textbox.
Server Side Changes
Upon further testing on my own environment, I've had to make two additional changes to get this to work:
Ensure that the unattended execution account is set to a domain account that has permission to the file share
Edit the SSRS config in the rssrvpolicy.config file to trust custom code and allow the execution of the File.Exists function by specifying "FullTrust"
<CodeGroup
class="UnionCodeGroup"
version="1'
PermissionSetName="FullTrust"
Name="Report_Expressions_Default_Permissions"
Description="This code group grants default permissions for code in report expressions and code element."
...
</CodeGroup>
I did restart the SSRS service after making these changes (I assume that's required, but did it as a precaution)
Note that I am not an SSRS server admin and someone else may be able to add some additional information about the custom policy change. Glancing through the MS documentation, there is a recommendation about using custom assemblies instead so take this part with a grain of salt.

eliminate cache in iframes

I have a financial system where I create pdf forms for tax forms, receipts and etc
I have a printing page where I open the document for the client in an iframe
which suits dynamically the src to the client's pdf -
curUser = usrSrv.getUserFromCookie(cookie);
string formSrc = "UserForms/" + curUser.Id + ".pdf";
ifPdf.Attributes.Add("src", formSrc);
iI my code behind I've inserted the clear cache properties as such:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
but still - in several cases (when the user goes back from the print page for ex') - the pdf file is being saved in the cache and the system is losing its purpose.
I've figured out there might be a way with - server.Mappath() - but when I use it - the location seems fine and the file exists but the browser never finds the actual file or simply don't show it.
If you add a querystring parameter to the end of the frame's URL you will get the result you need, as long as the parameter is generated fresh and unique every time. A common way of doing that is to add something like a timestamp:
url += "?ts=" + DateTime.Ticks;
or:
url += "?ts=" + Date.getTime();

Resources