SSRS CreateSubscription method - render format - reporting-services

I am trying to set up a website that allows users to add themselves to subscriptions for reports.
The problem is that when I try and make the subscription render the report as "Excel" it sets it too "XML with report data".
The piece of code I use to try and change the render format is below;
extParameters.Add(new ParameterValue() { Name = "RenderFormat", Value = "Excel" });
extParameters.Add(new ParameterValue() { Name = "TO", Value = strEmail });
extParameters.Add(new ParameterValue() { Name = "IncludeReport", Value = "True" });
extParameters.Add(new ParameterValue() { Name = "Subject", Value = "subject - " + " (" + strReportPath + ")" });
Thank you

Solved it now.
I had to put the RenderFormat value as "EXCEL" or "EXCELOPENXML"

Related

d3 variable equals the string "function(d)", not the value the function returns

In some d3js code, I am using an anonymous function(d) to return the value of -importance from a JSON file. I use the returned value, stored in kwdAssbly object, to decide whether or not to render part of a diagram.
where I break on:
kwdAssbly.opt = (function(d){
return d["-importance"];
});
With a watch set on the object kwdAssbly, the debugger shows numerical values for kwdAssbly.width & kwdAssbly.height but shows kwdAssbly.opt = kwdAssbly.opt(d). I'm expecting a string value of either required or optional! If I put a watch on d in the function, it shows -importance:"optional", but this isn't assigned to my kwdAssbly.opt object attribute
Why is the function declaration being returned as the value?
Here's a code snippet of the context:
.attr("nullAttrib", function(d, i) { // calculate the text width and store it
var kwdAssbly = {}; //the keyword group's height and width object
kwdAssbly.width = this.getBoundingClientRect().width + padding;
kwdAssbly.height = this.getBoundingClientRect().height;
kwdAssbly.opt = (function(d){
return d["-importance"];
});
kwdProps[i] = kwdAssbly;
if (i>0){
kwdX += kwdProps[i-1].width;
if (kwdProps[i].opt == "optional"){
OptOffset = 40;
var Lsiding = kwdgrp.append(function(){return sidingL})
.attr("transform","translate(" + kwdX + ", " + (kwdProps[i].height*2/3 + line1y + OptOffset) + ")");
var Rsiding = kwdgrp.append(function(){return sidingR})
.attr("transform","translate(" + kwdX+50 + ", " + (kwdProps[i].height*2/3 + line1y + OptOffset) + ")");
}
else {
OptOffset = 0;
}
}
Working/correct answer by Altocumulus:
You won't need an anonymous function to get the string value.
Just use kwdAssbly.opt = d["-importance"];

MVC - model to a json object

I had a mvc object as my model.
I need to stringfiy my model as a json object type - and then use it in js as i please.
i currently doing something like this
<script type="text/javascript">
$(function () {
var jsonData2 = '#Html.Raw(Json.Encode(Model))';
showBeginDate(jsonData2);
});
</script>
But when i try to acess a json property for exemple as jsonData2.BeginDate I keep getting undefined.
jsonData2 is a json object - why can i "read" from it?
Regards
#riteshmeher 's suggestion is correct
var text = '#Html.Raw(Json.Encode(Model))';
var obj = JSON.parse(text);
I don't know your model so I created a simple model with 2 attributes: Id and Name. In case that the model is a list, you can read it:
// Access to object in position 1
var result = obj[0].Id + " - " + obj[0].Name;
In other case, access right to the property.
var result = obj.Id + " - " + obj.Name;
For more info, check this post:
http://www.w3schools.com/js/js_properties.asp
http://www.w3schools.com/json/tryit.asp?filename=tryjson_parse
UPDATE
like #Stephen Muecke said, better this:
var obj = #Html.Raw(Json.Encode(Model));
var result = obj[0].Id + " - " + obj[0].Name;
thank #Craig for the corrections

How to get dynamic object properties

I'm receiving a Json object from a request and I would like to Iterate over its properties and do something like:
if property is equals to "EN" than get it's value.
The solutions That I saw in the web are all related with GetProperties/GetProperty methods but I tried both and none of them worked.
This should be something "simple" but I think that I'm missing something here.
//Deserializing the object
ExpandoObject deserializedContent = JsonConvert.DeserializeObject<ExpandoObject>(obj.ToString(), new ExpandoObjectConverter());
dynamic deserializedDynamicContent = deserializedContent;
//Tries
var value = deserializedDynamicContent.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
var value = deserializedDynamicContent.GetType().GetProperty("ES").GetValue();
in both cases I get zero properties.
I can only get the values if I do the code below, but this will obly me to code if a new language is added.
deserializedDynamicContent.EN,
deserializedDynamicContent.ES or
deserializedDynamicContent.PT
What Am I doing wrong here?
{
"EN":[{"Id":1,"Name":"One"},{"Id":2,"Name":"Two"},{"Id":3,"Name":"Tree"}],
"ES":[{"Id":1,"Name":"Uno"},{"Id":2,"Name":"Dos"},{"Id":3,"Name":"Tres"}],
"PT":[{"Id":1,"Name":"Um"},{"Id":2,"Name":"Dois"},{"Id":3,"Name":"TrĂªs"}]
}
I'm not sure exactly what you're trying to achieve, but since ExpandoObject implements IDictionary<string,object> you should be able to do something like this:
var expando = JsonConvert.DeserializeObject<ExpandoObject>(yourJson);
var dict = (IDictionary<string, object>)expando;
// look for a particular key...
object value;
if (dict.TryGetValue("EN", out value))
{
Console.WriteLine("Key exists!");
var list = (List<dynamic>)value;
Console.WriteLine(string.Join(",", list.Select(x => "{" + x.Id + "," + x.Name + "}")));
}
// or enumerate the entire dictionary...
foreach (var kvp in dict)
{
var list = (List<dynamic>)kvp.Value;
Console.WriteLine(
kvp.Key + ":" + string.Join(",", list.Select(x => "{" + x.Id + "," + x.Name + "}")));
}

Create SSRS subscriptions from web page

I have Reporting Services running on SQL 2008 R2 and have a handful of reports that I created. I'm able to go into Report Server and set up a subscription and have any of the reports emailed to an email address. So all of that is configured correctly.
What I want to do is have a web page in my application that shows a list of available reports. The user can choose one, choose a schedule frequency, enter an email address, and click a 'save' button. When clicking save it should create the subscription in SSRS. I may need to pass in a couple report parameters depending on the report.
How can I do this in C#?
You can dynamically generate a one time subscription in SSRS for the report. You'll have to use the RS webservice as mentioned by Diego.
Your code would look something like this:
static void generateSubscription()
{
if (SubscriptionRequests.Count < 1) return;
NetworkCredential credentials = new NetworkCredential("user", "pass");
reports.ReportingService2005 rs = new reports.ReportingService2005();
rs.Credentials = credentials;
DateTime topDatetime = DateTime.Now;
topDatetime = topDatetime.AddMinutes(2);
foreach (SubscriptionRequest x in SubscriptionRequests)
{
reports.ExtensionSettings extensionSettings = new reports.ExtensionSettings();
List<reports.ParameterValue> extParameters = new List<reports.ParameterValue>();
List<reports.ParameterValue> parameters = new List<reports.ParameterValue>();
string description = "Email: ";
string eventType = "TimedSubscription";
extensionSettings.Extension = "Report Server Email";
string scheduleXml = "<ScheduleDefinition><StartDateTime>";
scheduleXml += topDatetime.ToShortDateString() + " " + topDatetime.ToShortTimeString();
scheduleXml += "</StartDateTime></ScheduleDefinition>";
parameters.Add(new reports.ParameterValue() { Name = "abc", Value = x.id });
extParameters.Add(new reports.ParameterValue() { Name = "RenderFormat", Value = x.renderFormat });
extParameters.Add(new reports.ParameterValue() { Name = "TO", Value = x.email });
extParameters.Add(new reports.ParameterValue() { Name = "ReplyTo", Value = x.replyTo });
extParameters.Add(new reports.ParameterValue() { Name = "IncludeReport", Value = "True" });
extParameters.Add(new reports.ParameterValue() { Name = "Subject", Value = "subject - " + " (" + x.id.ToString() + ")" });
extParameters.Add(new reports.ParameterValue() { Name = "Comment", Value = x.body });
extensionSettings.ParameterValues = extParameters.ToArray();
description += topDatetime.ToShortDateString() + " " + topDatetime.ToShortTimeString();
description += " (" + x.a + " - " + x.b + " - " + x.c + ")";
string _reportName = "/report";
rs.CreateSubscription(_reportName, extensionSettings, description, eventType, scheduleXml, parameters.ToArray());
topDatetime = topDatetime.AddSeconds(30);
}
}
Easiest way is give access to the user to the report manager under the "Browser" pre-defined role. This is exactly what this role is about, view folders and reports and subscribe to reports.
If that's not possible you can create your own management tool. To do that you need to access the SSRS web methods Using SOAP and the ReportService2005 endpoint
Examples here

Parsing a string, using action script

I am working on a flex site,
I want to parse the string below:
http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download_picture&key=a4fb33241662c35fe0b46c7e40a5b416&session_id=2b7075f175f599b9390dd06f7b724ee7
and remove the &session_id=2b7075f175f599b9390dd06f7b724ee7 from it.
How should i do it.
also later on when i get the url from database without session_id, i will attach the new session_id to it. Please tell me how to do that too.
Regards
Zeeshan
Not the short version but you can use URLVariable to get all the field(name, value) into an object and then add or delete any field you want.
Separate url and query:
var url : String = "http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download%5Fpicture&key=a4fb33241662c35fe0b46c7e40a5b416&session%5Fid=2b7075f175f599b9390dd06f7b724ee7";
var idxQMark : int = url.indexOf("?");
var qry : String = "";
Build url variable from query
var uv : URLVariables = new URLVariables();
if (idxQMark > 0) {
qry = url.substr(idxQMark + 1);
url = url.substr(0, idxQMark);
uv.decode(qry);
}
NOw you can access whatever field you need or delete them
delete uv.session_id;
Rebuild the query when needed
qry = uv.toString();
// get back you new URL
if (qry != "") {
url = url + "?" + qry;
}
For URI parsing check out the URI class provided in as3corelib.
http://code.google.com/p/as3corelib/source/browse/trunk/src/com/adobe/net/URI.as
For your specific case, you can clear the parts of the URI you don't want.
var url : String = "http://virtual.s1.c7beta.com/rpc/raw?c=Pictures&m=download%5Fpicture&key=a4fb33241662c35fe0b46c7e40a5b416&session%5Fid=2b7075f175f599b9390dd06f7b724ee7";
var uri : URI = new URI(url);
uri.query = "";
uri.fragment = "";
var shortenedUrl : String = uri.toString();
Or if you know you want to construct your url from just the scheme, authority, and path (i.e., you don't need to preserve port, username, password, etc.) you can build the url from parts.
var shortenedUrl : String = uri.scheme + "://" + uri.authority + "/" + uri.path;
If you're not sure that sessionid will be last you could split on the & using the as3 string.split functionhttp://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html#split%28%29
then rebuild the string using a for loop leaving out strings that start with session_id using the string.indexOf function http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html#indexOf%28%29 to see if "session_id" is at index 0
You can use regular expressions in Flex ... here's an example.
Assuming the session ID will always be the last variable in the query string:
var newStr:String = myStr.slice(0, myStr.indexOf("&session"));