Acessing ReportService in ReportServer From Windows Application - windows

Here i have a windowsapplication and a SSRS Report where report is implemented in Report server,and herei try to call that report from a windows application.In my button click i add this code:
string reportName = "Crime_Traking_Report";
reportViewer1.ServerReport.ReportServerCredentials =new ReportServerCredentials("isroScientist", "password12345678", "Nasa");
reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
try
{
reportViewer1.ServerReport.ReportServerUrl = new Uri("http://13.88.91.156/ReportServer");
}
catch (UriFormatException)
{
Console.WriteLine("Bad Url format");
}
reportViewer1.ServerReport.ReportPath = "/iSROReportsStandard/" + reportName;
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ServerReport.Refresh();
Here definitely i want to pass the credentials to access ,but when i run my application its giving an error like this "ReportServerCredentials has no constructor Defined", what change i want to make in order to pass the credentials successfully through my code.please explain me through code.

The question is has the same solution as your other qustion Error while accessing report service(remote mode) from Report server with in a windows application. See my answer there. The ServerReport.SetDataSourceCredentials Method should be used.

Related

CMS Open Payments Data Limitation

I've finally got around to getting the code needed to import web API into my SQL environment. However, when I ran the SSIS Script Component package (Script Language: Visual Studio C# 2017) I was only able to retrieve 1000 records out of of millions. A consultant mentioned that I may have to incorporate the App Token into my code in order to access additional records.
Would someone be able to confirm that this true? And if so, how should it be coded?
Here is the code prior to my "ForEach" loop code:
public override void CreateNewOutputRows()
{
//Set Webservice URL
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string wUrl = "https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json";
string appt = "MyAppToken";
try
{
//Call getWebServiceResult to return our Article attributes
List<Payment> outPutResponse = GetWebServiceResult(wUrl);
If there's an alternative method to using the app token (like in the HTTP Connection for example) please let me know.
Figured it out...
https://openpaymentsdata.cms.gov/resource/bqf5-h6wd.json?$limit=10000&$$app_token="MyAppToken"

SSRS Interactive Sorting in rendered html

I have a simple report that displays department number and department name with interactive sorting enabled on those two column headers in the tablix.
I am access this report via URL access from an MVC5 application. The report is being rendered in standard html4.0 correctly. I can see the report html in my page with the sort icons in the headers as expected. However, clicking on either column header and i receive an error page from SSRS of rsReportNotReady.
If I browse directly to the report via URL access by itself, interactive sorting works just fine but not when streamed into an mvc view as raw html.
code to render the report as html via url access:
private string GetReportData(string requestUri)
{
string reportData = string.Empty;
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(requestUri);
request.Credentials = CredentialCache.DefaultNetworkCredentials;
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
if (receiveStream != null)
{
StreamReader readStream = response.CharacterSet == null
? new StreamReader(receiveStream)
: new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
reportData = readStream.ReadToEnd();
response.Close();
readStream.Close();
}
}
return reportData;
}
example URL to access report http://myreportservername/ReportServer?/EmployeeReports/rptDepartments&rc:Toolbar=False&rc:HTMLFragment=False&rs:Format=HTML4.0
report via url access
report rendered in mvc app
error from sorting via mvc app
Does anyone have any insight into making interactive sorting of an SSRS report work in an MVC application via URL access? No, I cannot use the ReportViewer control either.
Thanks in advance.
I no longer need this resolved. What we were trying to do is not the best way, or easily possible. Ultimately, we switched to using amcharts from https://www.amcharts.com/ to build the charts on the fly with full interactivity.

Windows Azure is triggering a RuntimeBinderException when I try to set a ViewBag property

I'm cheking my service's Intellitrace logs and it's recording several RuntimeBinderException when I try to set ViewBag properties:
'System.Dynamic.DynamicObject' does not contain a definition for 'UserInfo'
It works perfectly when I run the MVC project in my machine.
Is there anything I'm missing here? Why is that?
EDIT
Where the ViewBag is set and the exception is thrown:
this.ViewBag.UserInfo = new UserInfo()
{
Id = this.DbUser.Id,
DisplayName = this.DbUser.Person.FullName,
GravatarEmailHash = this.DbUser.Person.EmailGravatarHash,
AdministratorId = this.DbUser.AdministratorId,
IsOwner = this.DbUser.IsOwner,
};

how to programmatically kick off a ssis package in asp.net MVC3 to import excel files

I am having some trouble with a asp.net MVC3 web application that I am developing. I need an upload page which Allows the user to upload excel files and dump them to the file system. I got this to work fine. The next part is the part that I am having trouble with, After I upload the excel files I need to programmatically kick off a SSIS package which I have created already to import the excel files.
Here is what I have so far in code:
//
// POST: /Home/Update/
[HttpPost]
public ActionResult Update(HttpPostedFileBase file)
{
// Verify that the user selected a file
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
// store the file inside ~/App_Data/uploads folder
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
ViewBag.Message = "File Uploaded Successfully";
file.SaveAs(path);
}
//Start the SSIS here
try
{
Application app = new Application();
Package package = null;
package = app.LoadPackage( #"C:\Users\Chris\Documents\Visual Studio
2008\Projects\Integration Services Project1\Integration Services Project1
\bin\Package.dtsx", null);
// Execute Package
DTSExecResult results = package.Execute();
if(results == DTSExecResult.Failure)
{
foreach(DtsError local_DtsError in package.Errors)
{
ViewBag.Message("Package Execution results:{0}",
local_DtsError.Description.ToString());
}
}
}
catch(DtsException ex)
{
//ViewBag.Message("{0} Exception caught.", ex);
}
// redirect back to the index action to show the form once again
return RedirectToAction("Update");
}
When I run the code and upload an excel file I get a DtsException caught, which says:
Failed to open package file "C:\Users\Chris\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\bin\Package.dtsx" due to error 0x80070003 "The system cannot find the path specified.". This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has an incorrect format.
I don't understand why it is giving me this because the file path is right I checked and it is exactly correct. I need some help fixing this issue I would greatly appreciate any help you guys can give.
Permissions I should think. Put the file somewhere where account running IIS can see it. Whereever you were planning on deploying it, would be good.

could not select subreport - .rdlc - VS 2010

I had created many reports with VS 2008. Now starting with VS 2010 for new requirement. Please note I am using .rdlc report
I could add subreport control to the report but could not select the available reports. There is no browse button or a dropdown to choose the available .rdlc report.
When I manually type the report name, the reportviewer doesnt show up any subreport. I dont see any error message on the 'Output' window either.
How do I use subreport with VS 2010? Am I missing anything? Any help is appreciated.
I have SQL 2005/2008 (report services installed), VS 2008, VS 2010 installed on the same PC.
First select sub report from Toolbox and put where you want to show.See the image bellow
Now right click on sub report properties and type your sub report name .
Now You have to create a sub report even handler in your .cs file from where you load your report like that:
public Ctor()
{
string path = HttpContext.Current.Server.MapPath("Your Report path");
ReportViewer1.Reset(); //important
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.SubreportProcessing += Process_Subreport;
LocalReport objReport = ReportViewer1.LocalReport;
objReport.ReportPath = path;
// Add Parameter If you need
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("Name", Value));
ReportViewer1.LocalReport.SetParameters(parameters);
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ShowPromptAreaButton = false;
ReportViewer1.LocalReport.Refresh();
//Add Datasourdce
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "Datasource Name Used due to report design";
reportDataSource.Value = DataSourceValue;
objReport.DataSources.Add(reportDataSource);
objReport.Refresh();
}
Now Create Even Handler Method to load sub report details.
private void Process_Subreport(object sender, SubreportProcessingEventArgs e)
{
//You can get parameter from main report
int paramname = int.Parse(e.Parameters[0].Values[0].ToString());
//You can also add parameter in sub report if you need like main report
//Now add sub report data source
e.DataSources.Add(new ReportDataSource("DataSource Name",DataSourceValue)));
}
I think it will be works for you.Thank you.

Resources