How to uniquely identify a report
How to uniquely identify a report
I am loading a report from a database. I am unable to find any identifier which is truly unique and I can set (users can not change).
I read this post: http://forum.stimulsoft.com/Default.aspx?g=posts&t=2185
I tried the ReportFile property, but if a user creates a report of the same name as another report, then the ReportFile will be the same and the original will get overwritten.
I tried ReportGuid. That does not hold its state from Load to Save. Neither does Tag or ViewState(...). Is there any field I can put the database's report ID into (or -1 for new report) and read it back at save time, without the user being able to interfere with it?
I read this post: http://forum.stimulsoft.com/Default.aspx?g=posts&t=2185
I tried the ReportFile property, but if a user creates a report of the same name as another report, then the ReportFile will be the same and the original will get overwritten.
I tried ReportGuid. That does not hold its state from Load to Save. Neither does Tag or ViewState(...). Is there any field I can put the database's report ID into (or -1 for new report) and read it back at save time, without the user being able to interfere with it?
How to uniquely identify a report
Hello,
Please use the MetaTags property of report, for example:
Thank you.
Please use the MetaTags property of report, for example:
Code: Select all
StiReport Report = new StiReport();
Report.MetaTags.Add(new StiMetaTag("Name1", "Value1"));
Report.MetaTags.Add(new StiMetaTag("Name2", "Test"));
Report.MetaTags.Add(new StiMetaTag("Name3", "Blah"));
Report.MetaTags.Add(new StiMetaTag("Name4", "Stuff"));
.....
string Variable1 = Report.MetaTags["Name1"];
string Variable2 = Report.MetaTags["Name2"];
How to uniquely identify a report
I have been using this method, but occasionally have problems. I finally looked into it and it seems to be another bug..
When i load the report i set the database index in a MetaTag. If it is a new report, i set to tag to -1.
On save, that value -1 or the index is there - great!
But if the user is creating a new report, I set the new index into the meta tag, to overwrite the -1. It does set, but it does not seem to persist to the next save. If the user keeps pressing save without reloading the report, then it keep getting -1 in the tag which creates another report.
When i load the report i set the database index in a MetaTag. If it is a new report, i set to tag to -1.
Code: Select all
report.MetaTags.Add("Report_No", -1)
Code: Select all
e.Report.MetaTags("Report_No").Tag
Code: Select all
e.Report.MetaTags("Report_No").Tag = intReport_No
How to uniquely identify a report
Hello.
The cause of the problem doesn't quite understand by your description.
Sorry, can you provide sample project for this issue?
Thank you.
The cause of the problem doesn't quite understand by your description.
Sorry, can you provide sample project for this issue?
Thank you.
How to uniquely identify a report
The VB test code is a bit messy and may confuse you more. Let me expand on the description:
Loading Code: (this works perfectly)
On saving, If i have opened an existing report and save it (once or many times), everything work perfectly.
If I open a new report, so that MetaTags("Report_No").Tag=-1 in the code above, and save, then it saves as a new report perfectly and MetaTags("Report_No").Tag is set to >0.
If after saving, the user hits Save again (without closing the Flash app and reloading), then MetaTags("Report_No").Tag is still set to -1 despite just setting it to >0.
I know the code is working as i have stepped thru and seen the meta update and hold the new figure, for at least a moment.
Saving code:
Loading Code: (this works perfectly)
Code: Select all
Dim intReport As Integer = DataHelper.cInteger(ddlReport.SelectedValue, -1)
Dim drReports As DataRow = AppDatabase.DataRowExec("SELECT FileName, Other_Source FROM Reports WHERE Report_No=" & intReport.ToString)
If IsNothing(drReports) Then General.NotFoundRedirect(ddlReport.SelectedValue, "Report")
report.Load(UTF8Encoding.UTF8.GetBytes(drReports("Other_Source")))
If report.MetaTags.Count = 0 Then
report.MetaTags.Add("Report_No", intReport)
Else
report.MetaTags("Report_No").Tag = intReport
End If
If I open a new report, so that MetaTags("Report_No").Tag=-1 in the code above, and save, then it saves as a new report perfectly and MetaTags("Report_No").Tag is set to >0.
If after saving, the user hits Save again (without closing the Flash app and reloading), then MetaTags("Report_No").Tag is still set to -1 despite just setting it to >0.
I know the code is working as i have stepped thru and seen the meta update and hold the new figure, for at least a moment.
Saving code:
Code: Select all
Dim UpdateReport As New UpdatableTable(AppDatabase)
Dim blnCreating As Boolean
If UpdateReport.Open("SELECT * FROM Reports WHERE Report_No = " & e.Report.MetaTags("Report_No").Tag) < 1 Then
UpdateReport.NewRow()
UpdateReport.DataRow("Company") = UserProfile.Company
UpdateReport.DataRow("FileName") = e.Report.ReportFile
UpdateReport.AddRow()
blnCreating = True
End If
UpdateReport.DataRow("Updated_Date") = Now
UpdateReport.DataRow("Updated_By") = UserProfile.ID_No
UpdateReport.DataRow("Report_Name") = e.Report.ReportName
UpdateReport.DataRow("Other_Source") = e.Report.SaveToString()
UpdateReport.Update()
If blnCreating Then
e.Report.MetaTags("Report_No").Tag = UpdateReport.LastIndex
End If
UpdateReport.Close()
How to uniquely identify a report
Hello.
Your code is not enough to make the reason of your problem.
Sorry, can you provide sample project for this issue?
Thank you.
Your code is not enough to make the reason of your problem.
Sorry, can you provide sample project for this issue?
Thank you.
How to uniquely identify a report
Getting back to this issue. I have stripped down some code and tested it with the latest 2011.3. The attached code shows that the MetaTag is not persisting after the save.
I guess it is because the "e" argument is being passed as a value not a reference. I tried "ByRef" but it is not the same signature as the event. So, how do store the report's primary key at save time?
I guess it is because the "e" argument is being passed as a value not a reference. I tried "ByRef" but it is not the same signature as the event. So, how do store the report's primary key at save time?
- Attachments
-
- 1409.Reports.zip
- (1.57 KiB) Downloaded 194 times
How to uniquely identify a report
Hello,
We need some additional time to check the issue.
Thank you.
We need some additional time to check the issue.
Thank you.
How to uniquely identify a report
Hello,
We have analyzed your project. Unfortunately, currently is no way to change the report in the save event. We have added this feature to our to-do list, and will try to complete it to an official release 2011.3
Thank you.
We have analyzed your project. Unfortunately, currently is no way to change the report in the save event. We have added this feature to our to-do list, and will try to complete it to an official release 2011.3
Thank you.