Page 1 of 1

How to uniquely identify a report

Posted: Fri Sep 09, 2011 12:52 am
by hunter
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?

How to uniquely identify a report

Posted: Mon Sep 12, 2011 4:42 am
by Ivan
Hello,

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"];
Thank you.

How to uniquely identify a report

Posted: Thu Sep 29, 2011 10:14 pm
by hunter
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.

Code: Select all

report.MetaTags.Add("Report_No", -1)
On save, that value -1 or the index is there - great!

Code: Select all

e.Report.MetaTags("Report_No").Tag
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.

Code: Select all

e.Report.MetaTags("Report_No").Tag = intReport_No

How to uniquely identify a report

Posted: Fri Sep 30, 2011 1:57 am
by HighAley
Hello.

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

Posted: Fri Sep 30, 2011 7:37 am
by hunter
The VB test code is a bit messy and may confuse you more. Let me expand on the description:

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
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:

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

Posted: Mon Oct 03, 2011 5:15 am
by HighAley
Hello.

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

Posted: Thu Nov 03, 2011 12:22 am
by hunter
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?

How to uniquely identify a report

Posted: Fri Nov 04, 2011 8:54 am
by Ivan
Hello,

We need some additional time to check the issue.

Thank you.

How to uniquely identify a report

Posted: Tue Nov 08, 2011 1:48 am
by Vladimir
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.