Report compilation error - How to prevent CS file deletion ?

Stimulsoft Reports.WEB discussion
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Report compilation error - How to prevent CS file deletion ?

Post by kgb2013 »

I am getting a compilation error in :

Code: Select all

StiMvcViewer.InteractionResult(HttpContext);
c:\Users\user\AppData\Local\Temp\nbv1eygk.0.cs(124,30) : error CS1002: ; expected
c:\Users\user\AppData\Local\Temp\nbv1eygk.0.cs(124,30) : error CS1525: Invalid expression term ','
c:\Users\user\AppData\Local\Temp\nbv1eygk.0.cs(124,31) : error CS1002: ; expected
Is there a way to prevent the deletion of the .CS file so that I can get an idea of what is going on inside?
Because, right now, I have no clue what's wrong. :(

(I am trying to achieve what I describe here: http://forum.stimulsoft.com/viewtopic.p ... 904#p70904 when I get this error.)
Last edited by kgb2013 on Tue Dec 10, 2013 11:32 am, edited 1 time in total.
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

When I use the report checker everything seems fine, so I guess that it has to do with the list of integers that I feed it.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Report compilation error - How to prevent CS file deleti

Post by HighAley »

Hello.

Please, send us a sample project which reproduces the issue.

Thank you.
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

Hi.

I attach the MRT file.
If you see anything wrong with it, please let me know.

This uses DB data, so I don't know how easy it would be for me to send you a sample with a DB.
Attachments
20 (2).mrt
(23.11 KiB) Downloaded 423 times
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

I also send you some code that I use just in case you see sth wrong:
//---------------------------------------------------------------------------
static void ChangeConenctionString(StiReport report)
{
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(
new StiSqlDatabase(
"Connection",
"Connection",
ConfigurationManager.ConnectionStrings["Docman"].ConnectionString,
false)
);
}
//---------------------------------------------------------------------------
static void SetVariable(StiReport report, string name, int value)
{
report[name] = value;
if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value.ToString(CultureInfo.InvariantCulture);
}
//---------------------------------------------------------------------------
static void SetVariable(StiReport report, string name, string value)
{
report[name] = value;
if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value;
}
//---------------------------------------------------------------------------
static void SetReportParameters(StiReport report, int[] gid)
{
ChangeConenctionString(report);
report.RequestParameters = true;
report.Compile(); // Needed to set the variables in a humane manner (http://support.stimulsoft.com/index.php ... able-value).
var ident = IoC.GetInstance<IIdentityContext>();
SetVariable(report, "usrID", ident.UserId);
SetVariable(report, "grpID", ident.CurrentGroupId);
SetVariable(report, "GrpsLst", string.Join(",", gid));
}
//---------------------------------------------------------------------------
protected static StiReport GetReport(int id, int[] gid = null)
{
var report = new StiReport();

bool requiresBo;
var mrtFile = GetMrtPath(out requiresBo, id);
if (string.IsNullOrWhiteSpace(mrtFile)) return report;

report.Load(mrtFile);
SetReportParameters(report, gid);
return report;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
protected ActionResult GetReportSnapshotB(int id, int[] gid = null)
{
try
{
var obj = Session["gids_rprt" + id];
if (obj != null && obj.GetType() == typeof(int[])) gid = (int[]) obj;
using (var report = GetReport(/*model,*/ id, gid))
{
return StiMvcViewer.GetReportSnapshotResult(HttpContext, report);
}
}
catch { return null; }
}
//---------------------------------------------------------------------------
protected FileResult ExportReportB()
{
try
{
return StiMvcViewer.ExportReportResult(HttpContext);
}
catch { return null; }
}
//---------------------------------------------------------------------------
protected ActionResult InteractionB()
{
try
{
return StiMvcViewer.InteractionResult(HttpContext);
}
catch { return null; }
}
//---------------------------------------------------------------------------
protected ActionResult ViewerEventB()
{
try
{
return StiMvcViewer.ViewerEventResult(HttpContext);
}
catch { return null; }
}
//---------------------------------------------------------------------------
protected ActionResult PrintReportB()
{
try
{
return StiMvcViewer.PrintReportResult(HttpContext);
}
catch { return null; }
}
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

I will try to make a sample project soon.
Thanks.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: Report compilation error - How to prevent CS file deleti

Post by Andrew »

Hello,

Great!

Waiting for your reply.
Thank you.
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

Hello again.

I send you a demo project.
I think I have found what was causing the above compilation error. It disappeared after I made this:

Code: Select all

		static void SetVariable(StiReport report, string name, int value)
		{
			report[name] = value;
			if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value.ToString(CultureInfo.InvariantCulture);
		}
		static void SetVariable(StiReport report, string name, string value)
		{
			report[name] = value;
			if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value;
		}
..into this:

Code: Select all

		static void SetVariable(StiReport report, string name, int value)
		{
			report[name] = value;
			//if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value.ToString(CultureInfo.InvariantCulture);
		}
		static void SetVariable(StiReport report, string name, string value)
		{
			report[name] = value;
			//if (report.Dictionary.Variables.Contains(name)) report.Dictionary.Variables[name].Value = value;
		}
(However, I am not very sure if now the variables actually pass to my query correctly) EDIT: Actually, I now see that the (usrID & grpID) variables do not pass to my query with this change.

But, even like that, again I have problems.
Now I get a "The multi-part identifier "System.Object" could not be bound. Statement(s) could not be prepared." when I submit the user variables.
It seems that, for some reason, it can't turn my object into a string list of integers.

See the attached project.
You just need to add a connection string to a DB in the code of the project (I change it in function ChangeConenctionString) and modify the SQL queries on my data sources in the MRT, preserving the IN ({GrpsLst}) part (and perhaps the rest of the used variables also).
The version of my stimulsoft libraries seems to be 2013.3.1705.0.

Here is the file (it seems that the is a file size limit in your site - I couldn't post it here):
http://speedy.sh/7cAat/TestStimulsoft.zip
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

For some reason, in another MRT, when I set "Connect On Start" to false and connect my datasources on "Before Print" I get an infinite loop of identical SQL queries sent to the DB.
Now that I have undone this, it doesn't get in an infinite loop, but it fails in the insertion of the list of integers metioned above.

When exactly should I connect my datasources on "BeforePrint" ?
Everytime there are user variables required in the MRT ?
This MRT had user variables and it didn't work nice with it. :(
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Report compilation error - How to prevent CS file deleti

Post by kgb2013 »

Hello.
Have you managed to reproduce the problem in my provided project?
Post Reply