Skip to content

Instantly share code, notes, and snippets.

@reednj
Created November 17, 2009 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reednj/236558 to your computer and use it in GitHub Desktop.
Save reednj/236558 to your computer and use it in GitHub Desktop.
Generate SSRS urls
using System;
using System.Collections.Generic;
using System.Text;
namespace Temp
{
class Program
{
static void Main(string[] args)
{
SSRSReportUrl reportlink = new SSRSReportUrl("murntapp06");
reportlink.ReportPath = "/Ops KPI Reporting - Testing/Ni Tenor Profile - Waterfall Chart";
reportlink.AddParameter("StartDate", "2009-08-01 06:00");
reportlink.AddParameter("Type", "P");
System.Console.WriteLine(reportlink.ToString());
}
}
class SSRSReportUrl
{
string _serverName;
string _reportPath;
List<SSRSReportParameter> _parameters = new List<SSRSReportParameter>();
string _serverCommand = "render";
public string ServerName {get { return _serverName; } set { _serverName = value; }}
public string ReportPath { get { return _reportPath; } set { _reportPath = value; }}
public List<SSRSReportParameter> Parameters { get { return _parameters; } set { _parameters = value; } }
public string ServerCommand { get { return _serverCommand; } set { _serverCommand = value; } }
public SSRSReportUrl()
{
}
public SSRSReportUrl(string ServerName)
{
this.ServerName = ServerName;
}
public SSRSReportUrl(string ServerName, string ReportPath)
{
this.ServerName = ServerName;
this.ReportPath = ReportPath;
}
public void AddParameter(string Name, string Value)
{
this.Parameters.Add(new SSRSReportParameter(Name, Value));
}
public override string ToString()
{
string CommandString = String.Format("rs:command={0}", Uri.EscapeDataString(this.ServerCommand));
string ParamString = this.ParameterString();
string RawUrl = String.Format("http://{0}/ReportServer/?{1}&{2}&rc:parameters=false{3}", this.ServerName, Uri.EscapeDataString(this.ReportPath), CommandString, ParamString);
return RawUrl;
}
private string ParameterString()
{
string result = "";
foreach (SSRSReportParameter curParam in this.Parameters)
{
result += ("&" + curParam.ToString());
}
return result;
}
}
class SSRSReportParameter
{
string _name;
string _value;
public string Name{get { return _name; } set { _name = value; }}
public string Value {get { return _value; } set { _value = value; } }
public SSRSReportParameter()
{
this.Name = "";
this.Value = "";
}
public SSRSReportParameter(string Name, string Value)
{
this.Name = Name;
this.Value = Value;
}
public override string ToString()
{
return String.Format("{0}={1}", this.Name, Uri.EscapeDataString(this.Value));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment