//---------------------------------------------------------------------------
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; }
}