/// <summary>
    /// Open the SSRS report based on the name of the report and Report Parameters specified.
    /// </summary>
    /// <param name="reportViewer">ReportViewer
    /// object used to render the SSRS report on screen.</param>
    /// <param name="reportPath">Name of the Report
    /// (.rdl) data uploaded on the server.</param>
    /// <param name="reportParameterList">
    /// List of Report parameters.</param>
    public static void DisplayReport(ReportViewer reportViewer,
                                     String reportPath, List <ReportParameter> reportParameterList)
    {
        try
        {
            reportViewer.ProcessingMode = ProcessingMode.Remote;
            ServerReport serverreport = reportViewer.ServerReport;

            ICredentials            credentials   = CredentialCache.DefaultCredentials;
            ReportServerCredentials rscredentials = serverreport.ReportServerCredentials;
            rscredentials.NetworkCredentials = credentials;
            serverreport.ReportServerUrl     = new Uri(GetReportServerURL());
            serverreport.ReportPath          = reportPath;

            reportViewer.ShowParameterPrompts = false;
            reportViewer.ShowPrintButton      = true;

            if (reportParameterList != null)
            {
                foreach (ReportParameter param in reportParameterList)
                {
                    serverreport.SetParameters(param);
                }
            }

            reportViewer.Refresh();
            reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
        }
        catch (Exception)
        {
            throw;
        }
    }
Esempio n. 2
0
        private void SsrsViewer_Load(object sender, EventArgs e)
        {
            try
            {
                this.ssrsMainViewer.ProcessingMode = ProcessingMode.Remote;

                ServerReport serverReport = this.ssrsMainViewer.ServerReport;

                //System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("CommonOnly", "123", "DELL-E7240T\\SQL2016"); //SQL LOGON //DELL-E7240T\SQL2016
                System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials; // Get a reference to the default credentials

                ReportServerCredentials rsCredentials = serverReport.ReportServerCredentials;        // Get a reference to the report server credentials
                rsCredentials.NetworkCredentials = credentials;                                      // Set the credentials for the server report

                serverReport.ReportServerUrl = new Uri(this.printViewModel.ReportServerUrl);         //// Set the report server URL and report path
                serverReport.ReportPath      = "/" + this.printViewModel.ReportFolder + "/" + this.printViewModel.ReportPath;

                if (this.printViewModel.ReportParameters != null && this.printViewModel.ReportParameters.Count > 0)
                {
                    this.ssrsMainViewer.ServerReport.SetParameters(this.printViewModel.ReportParameters); // Set the report parameters for the report
                }
                this.ssrsMainViewer.ShowPromptAreaButton = this.printViewModel.ShowPromptAreaButton;

                this.ssrsMainViewer.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        private void SsrsViewer_Load(object sender, EventArgs e)
        {
            try
            {
                this.ssrsMainViewer.ProcessingMode = ProcessingMode.Remote;

                ServerReport serverReport = this.ssrsMainViewer.ServerReport;

                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("Administrator", "Nuti123@#", "SERVER3");
                ////////WINDOWS AUTHENTICATION!!! System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials;// Get a reference to the default credentials

                ReportServerCredentials rsCredentials = serverReport.ReportServerCredentials; // Get a reference to the report server credentials
                rsCredentials.NetworkCredentials = credentials;                               // Set the credentials for the server report

                serverReport.ReportServerUrl = new Uri(this.printViewModel.ReportServerUrl);  //// Set the report server URL and report path
                serverReport.ReportPath      = "/" + this.printViewModel.ReportFolder + "/" + this.printViewModel.ReportPath;

                if (this.printViewModel.ReportParameters != null && this.printViewModel.ReportParameters.Count > 0)
                {
                    this.ssrsMainViewer.ServerReport.SetParameters(this.printViewModel.ReportParameters); // Set the report parameters for the report
                }
                this.ssrsMainViewer.ShowPromptAreaButton = this.printViewModel.ShowPromptAreaButton;

                this.ssrsMainViewer.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        private void Report_Load(object sender, EventArgs e)
        {
            try
            {
                ReportViewer reportViewer1 = new ReportViewer();
                this.Controls.Add(reportViewer1);
                reportViewer1.Dock = DockStyle.Fill;

                reportViewer1.ProcessingMode = ProcessingMode.Remote;


                ServerReport serverReport = reportViewer1.ServerReport;

                // Get a reference to the default credentials
                System.Net.ICredentials credentials =
                    System.Net.CredentialCache.DefaultCredentials;

                // Get a reference to the report server credentials
                ReportServerCredentials rsCredentials =
                    serverReport.ReportServerCredentials;

                // Set the credentials for the server report
                rsCredentials.NetworkCredentials = credentials;

                // Set the report server URL and report path
                serverReport.ReportServerUrl =
                    new Uri("http://192.168.1.27/reportserver/");
                serverReport.ReportPath =
                    "/HcRockstar/HC_TrainingUsage";

                //// Create the sales order number report parameter
                ReportParameter reportParam1 = new ReportParameter();
                reportParam1.Name = "pCounter";
                reportParam1.Values.Add(trainingUsage);
                ReportParameter reportParam2 = new ReportParameter();
                reportParam2.Name = "pWordsEn";
                reportParam2.Values.Add(null);
                ReportParameter reportParam3 = new ReportParameter();
                reportParam3.Name = "pWordsId";
                reportParam3.Values.Add(null);

                reportViewer1.ShowParameterPrompts = false;

                // Set the report parameters for the report
                reportViewer1.ServerReport.SetParameters(
                    new ReportParameter[] { reportParam1, reportParam2, reportParam3 });
                reportViewer1.Name = "Training End Usage";
                reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string ReportPrefix = Request.QueryString["Name"];
                if (ReportPrefix != null)
                {
                    string SSRSusername   = System.Configuration.ConfigurationManager.AppSettings["SSRSUsername"];
                    string SSRSpassword   = System.Configuration.ConfigurationManager.AppSettings["SSRSPassword"];
                    string SSRSdomain     = System.Configuration.ConfigurationManager.AppSettings["SSRSDomain"];
                    string SSRSurl        = System.Configuration.ConfigurationManager.AppSettings["SSRSUrl"];
                    string SSRSreportpath = System.Configuration.ConfigurationManager.AppSettings["SSRSReportPath"];

                    ReportingServicesReportViewModel rptModel = System.Web.HttpContext.Current.Session[string.Format("{0}Params", ReportPrefix)] as ReportingServicesReportViewModel;
                    ReportParameter[] RptParameters           = rptModel.parameters;

                    IReportServerCredentials irsc = new ReportServerCredentials(SSRSusername, SSRSpassword, SSRSdomain);

                    //string ReportServerURL = Request.QueryString["ServerURL"];
                    //if (ReportServerURL == null)
                    //    ReportServerURL = @"http://localhost/reportserver";

                    rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
                    rptViewer.ServerReport.ReportServerCredentials = irsc;

                    rptViewer.ShowToolBar                  = true;
                    rptViewer.AsyncRendering               = true;
                    rptViewer.SizeToReportContent          = true;
                    rptViewer.ShowParameterPrompts         = false;
                    rptViewer.ServerReport.ReportServerUrl = new Uri(SSRSurl);
                    rptViewer.ServerReport.ReportPath      = string.Format("{0}{1}Report", SSRSreportpath, ReportPrefix);

                    // Set report parameters for the report
                    foreach (ReportParameter rpt in RptParameters)
                    {
                        rptViewer.ServerReport.SetParameters(new ReportParameter[] { rpt });
                    }
                }
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                FTReportViewer.ServerReport.ReportServerUrl = new Uri(System.Web.Configuration.WebConfigurationManager.AppSettings["ReportServerURL"]);

                ReportServerCredentials cred = new ReportServerCredentials();
                FTReportViewer.ServerReport.ReportServerCredentials = cred;
            }
            else
            {
                try
                {
                    FTReportViewer.ServerReport.ReportPath = ReportDropDownList.SelectedValue;
                    ReportErrorLabel.Text = "";
                }
                catch
                {
                    ReportErrorLabel.Text = "Go back to the top level of the existing report before trying to navigate to a second report";
                }
            }
        }
        private void ReportViewer_Load(object sender, EventArgs e)
        {
            if (ReportType == "Dataset Report")
            {
                reportViewer1.ProcessingMode         = ProcessingMode.Local;
                reportViewer1.LocalReport.ReportPath = Reportname;
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(Datasetname, Data));
                this.reportViewer1.RefreshReport();
            }
            else
            {
                reportViewer1.ProcessingMode = ProcessingMode.Remote;
                ServerReport serverReport = reportViewer1.ServerReport;

                // Get a reference to the default credentials
                System.Net.ICredentials credentials = System.Net.CredentialCache.DefaultCredentials;

                // Get a reference to the report server credentials
                ReportServerCredentials rsCredentials = serverReport.ReportServerCredentials;

                // Set the credentials for the server report
                rsCredentials.NetworkCredentials = credentials;

                // Set the report server URL and report path
                serverReport.ReportServerUrl = new Uri(Reportserver);
                serverReport.ReportPath      = Reportname;

                // Create the sales order number report parameter
                //ReportParameter salesOrderNumber = new ReportParameter();
                //salesOrderNumber.Name = "SalesOrderNumber";
                //salesOrderNumber.Values.Add("SO43661");

                // Set the report parameters for the report
                //reportViewer1.ServerReport.SetParameters( new ReportParameter[] { salesOrderNumber });

                // Refresh the report
                reportViewer1.RefreshReport();
            }
        }
Esempio n. 8
0
        private void LoadReport()
        {
            if (Model != null &&
                Model.TaskboardService != null &&
                Model.CurrentReport != null &&
                !string.IsNullOrEmpty(Model.TaskboardService.ReportServerUrl) &&
                !string.IsNullOrEmpty(Model.TaskboardService.ReportFolder))
            {
                var reportServerUrl = Model.TaskboardService.ReportServerUrl;
                var cutOffIndex     = reportServerUrl.LastIndexOf("/");
                reportServerUrl = reportServerUrl.Substring(0, cutOffIndex);
                reportServerUrl = reportServerUrl.ToLowerInvariant();

                var reportPath = Model.CurrentReport.Item.Path;

                // Set the processing mode for the ReportViewer to Remote
                viewerInstance.ProcessingMode = ProcessingMode.Remote;
                ServerReport serverReport = viewerInstance.ServerReport;
                // Get a reference to the report server credentials
                ReportServerCredentials rsCredentials = serverReport.ReportServerCredentials;
                // Set the credentials for the server report
                rsCredentials.NetworkCredentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                // Set the report server URL and report path
                serverReport.ReportServerUrl = new Uri(reportServerUrl);
                serverReport.ReportPath      = reportPath;
                var reportParameters = GetReportParameters();
                if (reportParameters != null && reportParameters.Count > 0)
                {
                    serverReport.SetParameters(reportParameters);
                }
                // Refresh the report
                viewerInstance.RefreshReport();
            }
            else
            {
                viewerInstance.Clear();
            }
        }
Esempio n. 9
0
        private void buttonReport_Click(object sender, EventArgs e)
        {
            reportViewer1.Reset();
            string[] admins         = { "FISOGEST\\nhansen", "FISOGEST\\preeff", "FISOGEST\\jhoffmann", "FISOGEST\\cbetti", "FISOGEST\\shansen" };
            string[] secretdossiers = { "3AC001", "3AP001", "AAS001", "BAR002", "DEL001", "FIS001", "KAH001", "KAH002", "KLA003", "MGI001", "HAN006", "PSI001", "RUB001", "SHI003", "SOC007", "TAN002", "TRA002" };
            string   userName       = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

            if (admins.Contains(userName) || !secretdossiers.Contains(cB_Customer.Text.Substring(0, 6)) || (userName.Equals("FISOGEST\\slizardo") && (cB_Customer.Text.Substring(0, 6).Equals("AAS001") || cB_Customer.Text.Substring(0, 6).Equals("3AC001"))))
            {
                Cursor.Current = Cursors.WaitCursor;

                if (cB_Customer.Text.Substring(0, 6).ToUpper() == "FRE001" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "FRE005" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "TAN001" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "ZOE001" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "TOM001" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "SPO002" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "FRE008" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "LDI001" ||
                    cB_Customer.Text.Substring(0, 6).ToUpper() == "DEC002"
                    //|| cB_Customer.Text.Substring(0, 6).ToUpper() == "ING001"
                    )
                {
                }
                else
                {
                    this.label4.Text = "Loading BOB50 data ...";
                    panel1.Show();
                    panel1.Refresh();
                    get_ac_accoun(cB_Customer.Text.Substring(0, 6));
                    upd_Account_Labels(cB_Customer.Text.Substring(0, 6));
                    getData(cB_Customer.Text.Substring(0, 6), dP_period2Start.Value.Year, dP_periodEnd.Value.Year);
                    getLabelData(cB_Customer.Text.Substring(0, 6));
                    panel1.Hide();
                }

                checkBalance();
                reportViewer1.ProcessingMode = ProcessingMode.Remote;
                ServerReport            serverReport  = reportViewer1.ServerReport;
                System.Net.ICredentials credentials   = new NetworkCredential("Administrateur", "F!so2013", "FISOGEST");
                ReportServerCredentials rsCredentials = serverReport.ReportServerCredentials;
                rsCredentials.NetworkCredentials = credentials;
                serverReport.ReportServerUrl     = new Uri("http://srvsql/reportserver");
                //serverReport.ReportPath = "/Bilan 2016/" + cB_Bilan.Text.ToString();
                //serverReport.ReportPath = "/Bilan 2016/Bilan2016vConso";

                if (userName.Equals("FISOGEST\\abartholme"))
                {
                    serverReport.ReportPath = "/Bilan 2016/Bilan2016vFreelanders";
                }
                else
                {
                    serverReport.ReportPath = "/Bilan 2016/Bilan2016v4";
                }
                List <ReportParameter> parameters = new List <ReportParameter>();
                parameters.Add(new ReportParameter("Customer_Code", cB_Customer.Text.Substring(0, 6)));
                //parameters.Add(new ReportParameter("Year", dP_periodStart.Value.Year.ToString()));
                parameters.Add(new ReportParameter("Period1Start", dP_periodStart.Value.Date.ToString()));
                parameters.Add(new ReportParameter("Period1End", dP_periodEnd.Value.Date.ToString()));
                parameters.Add(new ReportParameter("Period2Start", dP_period2Start.Value.Date.ToString()));
                parameters.Add(new ReportParameter("Period2End", dP_period2End.Value.Date.ToString()));

                /*
                 * if (cB_Bilan.Text.Contains("FR")) parameters.Add(new ReportParameter("Language", "FR"));
                 * if (cB_Bilan.Text.Contains("DE")) parameters.Add(new ReportParameter("Language", "DE"));
                 * if (cB_Bilan.Text.Contains("EN")) parameters.Add(new ReportParameter("Language", "EN"));
                 */
                if (radioFR.Checked)
                {
                    parameters.Add(new ReportParameter("Language", "FR"));
                }
                if (radioDE.Checked)
                {
                    parameters.Add(new ReportParameter("Language", "DE"));
                }
                if (radioEN.Checked)
                {
                    parameters.Add(new ReportParameter("Language", "EN"));
                }
                if (checkBoxSituationInt.Checked)
                {
                    parameters.Add(new ReportParameter("SituationIntermédiaire", "true"));
                }
                else
                {
                    parameters.Add(new ReportParameter("SituationIntermédiaire", "false"));
                }

                /*
                 * if (chkPeriode.Checked)
                 * {
                 *  parameters.Add(new ReportParameter("Max_Month", dP_periodEnd.Value.Month.ToString() ));
                 * } else
                 * {
                 *  parameters.Add(new ReportParameter("Max_Month", "12" ));
                 * }
                 */
                reportViewer1.ServerReport.SetParameters(parameters);
                reportViewer1.ShowParameterPrompts = false;
                reportViewer1.ShowPromptAreaButton = false;
                reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                // Set the report parameters for the report
                //reportViewer1.ServerReport.SetParameters(parameters);
                //    new ReportParameter[] { customerCode,periodStart,periodEnd });

                // Refresh the report
                reportViewer1.Refresh();
                Cursor.Current = Cursors.AppStarting;
            }
            else
            {
                MessageBox.Show("Dossier non valide!", "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }