private void btnExportReports_Click(object sender, EventArgs e) { bool defaultCredentials = false; mExportedReports.Clear(); try { if (cboDefaultCredentials.SelectedIndex == 1) defaultCredentials = true; if (defaultCredentials == false) { if (string.IsNullOrEmpty(txtUsername.Text)) throw new ArgumentNullException("Please provide a valid username."); if (string.IsNullOrEmpty(txtDomain.Text)) throw new ArgumentNullException("Please provide a valid domain or computer name."); } if (string.IsNullOrEmpty(txtWebServiceUrl.Text)) throw new ArgumentNullException("Please provide a valid web service url."); if (string.IsNullOrEmpty(txtExportPath.Text)) throw new ArgumentNullException("Please provide an export path."); if (string.IsNullOrEmpty(txtSSRSPath.Text)) txtSSRSPath.Text = "/"; if (lstReports.Items.Count < 1) RefreshReportsList(); SSRSExport oSSRS = new SSRSExport(txtUsername.Text, txtPassword.Text, txtDomain.Text, defaultCredentials, txtWebServiceUrl.Text); // register event handlers oSSRS.ReportExportedSuccess += ReportExportSuccessEventHandler; oSSRS.ReportExportFail += ReportExportFailEventHandler; oSSRS.ReportFound += ReportFoundEventHandler; oSSRS.DataSourceFound += DataSourceFoundEventHandler; oSSRS.DataSourceExportedSuccess += DataSourceExportSuccessEventHandler; oSSRS.DataSourceExportFail += DataSourceExportFailEventHandler; oSSRS.SSRSPath = txtSSRSPath.Text; oSSRS.ExportPath = txtExportPath.Text; List<string> oReportsList = new List<string>(); foreach (ListViewItem oItem in lstReports.Items) { if (oItem.Checked) oReportsList.Add(oItem.SubItems[1].Text); } oSSRS.ReportsList = oReportsList; oSSRS.ExportDataSources(); oSSRS.ExportReportsFromList(); this.CreateReportsExportedListFile(txtExportPath.Text, mExportedReports, mExportedDataSources); lblStatus.Text = string.Format("{0} reports exported to {1}", mExportedReports.Count, txtExportPath.Text); System.Diagnostics.Process.Start(txtExportPath.Text); } catch (Exception er) { lblStatus.Text = string.Format(er.Message); } }
public void DataSourceExportFailEventHandler(SSRSExport sender, DataSourceExportFailEvent e) { string sPath = e.GetSSRSPath(); Console.WriteLine(string.Format("Failed to export data source {0}: {1}", sPath, e.GetErrorMessage())); if (mDebug) { string sMsg = string.Format("Failed to export data source '{0}' to {1}. Path={2}; Exception={3}", sPath, e.GetExportedPath(), sPath, e.GetErrorMessage()); oDebugForm.LogMessage(sMsg, e.GetException()); } }
public void ReportFailEventHandler(SSRSExport sender, ReportFailEvent e) { lblStatus.Text = string.Format("Failed to load report: {0}", e.GetErrorMessage()); if (mDebug) { string sMsg = string.Format("Failed to load report: {1}", e.GetErrorMessage()); oDebugForm.LogMessage(sMsg, e.GetException()); } }
public void ReportFoundEventHandler(SSRSExport sender, ReportFoundEvent e) { Report oReport = e.GetReport(); lblStatus.Text = string.Format("Found report {0}...", oReport.Path); ListViewItem oItem = new ListViewItem(oReport.Name); oItem.Checked = true; oItem.Tag = oReport; oItem.SubItems.Add(oReport.Path); lstReports.Items.Add(oItem); if (mDebug) { string sMsg = string.Format("Found report '{0}'. Path={1}; ID={2}; CreatedBy={3}; CreatedOn={4}", oReport.Name, oReport.Path, oReport.ID, oReport.CreatedBy, oReport.CreationDate); oDebugForm.LogMessage(sMsg); } }
public void ReportExportSuccessEventHandler(SSRSExport sender, ReportExportSuccessEvent e) { Report oReport = e.GetReport(); mExportedReports.Add(oReport.Path); if (mDebug) { string sMsg = string.Format("Exported report '{0}' to {1}. Path={2}; ID={3}; CreatedBy={4}; CreatedOn={5}", oReport.Name, e.GetExportedPath(), oReport.Path, oReport.ID, oReport.CreatedBy, oReport.CreationDate); oDebugForm.LogMessage(sMsg); } }
public void ReportExportFailEventHandler(SSRSExport sender, ReportExportFailEvent e) { Report oReport = e.GetReport(); Console.WriteLine(string.Format("Failed to export report {0}: {1}", oReport.Name, e.GetErrorMessage())); if (mDebug) { string sMsg = string.Format("Failed to export report '{0}' to {1}. Path={2}; Exception={3}", oReport.Name, e.GetExportedPath(), oReport.Path, e.GetErrorMessage()); oDebugForm.LogMessage(sMsg, e.GetException()); } }
public void RefreshReportsList() { bool defaultCredentials = false; lstReports.Items.Clear(); try { lblStatus.Text = "Refreshing reports list..."; if (cboDefaultCredentials.SelectedIndex == 1) defaultCredentials = true; if (defaultCredentials == false) { if (string.IsNullOrEmpty(txtUsername.Text)) throw new ArgumentNullException("Please provide a valid username."); if (string.IsNullOrEmpty(txtDomain.Text)) throw new ArgumentNullException("Please provide a valid domain or computer name."); } if (string.IsNullOrEmpty(txtWebServiceUrl.Text)) throw new ArgumentNullException("Please provide a valid web service url."); if (string.IsNullOrEmpty(txtSSRSPath.Text)) txtSSRSPath.Text = "/"; SSRSExport oSSRS = new SSRSExport(txtUsername.Text, txtPassword.Text, txtDomain.Text, defaultCredentials, txtWebServiceUrl.Text); // register event handlers oSSRS.ReportFail += ReportFailEventHandler; oSSRS.ReportFound += ReportFoundEventHandler; oSSRS.SSRSPath = txtSSRSPath.Text; int reportCount = oSSRS.GetReportsList(); if (reportCount > 0) { lblStatus.Text = string.Format("{0} reports found.", reportCount); } else { lblStatus.Text = "No reports found."; MessageBox.Show("No reports found."); } } catch (Exception er) { lblStatus.Text = string.Format(er.Message); if (mDebug) { oDebugForm.LogMessage(er.Message, er); } } }
public void DataSourceFoundEventHandler(SSRSExport sender, DataSourceFoundEvent e) { string sPath = e.GetSSRSPath(); lblStatus.Text = string.Format("Found data source at {0}...", sPath); if (mDebug) { string sMsg = string.Format("Found data source at '{0}'.", sPath); oDebugForm.LogMessage(sMsg); } }
public void DataSourceExportSuccessEventHandler(SSRSExport sender, DataSourceExportSuccessEvent e) { string sPath = e.GetPath(); mExportedDataSources.Add(e.GetSSRSPath()); if (mDebug) { string sMsg = string.Format("Exported data source to '{0}'. Data={1}", sPath, e.GetDataSourceText()); oDebugForm.LogMessage(sMsg); } }