public ReportingServicesMgmt(string url, string username, string password, bool integratedAuth) { var reportServerUrl = url.TrimEnd('/') + ServicesUrl; DataSources = new Dictionary<string, string>(); ReportingService = new ReportingService2005 {Url = reportServerUrl}; if (!integratedAuth) { var nameParts = username.Split('\\', '/'); if (nameParts.Length > 2) { throw new Exception(Resources.Incorrect_destination_user_name); } ReportingService.Credentials = nameParts.Length == 2 ? new System.Net.NetworkCredential(nameParts[1], password, nameParts[0]) : new System.Net.NetworkCredential(username, password); } else { ReportingService.Credentials = System.Net.CredentialCache.DefaultCredentials; } }
private void LoadTreeNode(string path, TreeNodeCollection nodes, ReportingService2005 rs, bool source = false) { CatalogItem[] items; try { items = rs.ListChildren(path, false); } catch (Exception x) { return; } foreach (var item in items) { if(source) lbSourceStatus.Text = String.Format("Source contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine, _countReportsSource, _countFolderSource, _sourceServicesMgmt.DataSources.Count); else lbDestStatus.Text = String.Format("Destination contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine, _countReportsDest, _countFolderDest, _destServicesMgmt.DataSources.Count); Application.DoEvents(); var t = new TreeNode { Text = item.Name, Name = item.Name }; if (item.Type == ItemTypeEnum.DataSource) { if (source) { if (!_sourceServicesMgmt.DataSources.ContainsKey(item.Name)) _sourceServicesMgmt.DataSources.Add(item.Name, item.Path); } else { if (!_destServicesMgmt.DataSources.ContainsKey(item.Name)) _destServicesMgmt.DataSources.Add(item.Name, item.Path); } } if (item.Type != ItemTypeEnum.Model && item.Type != ItemTypeEnum.DataSource) { nodes.Add(t); if (source) _countReportsSource++; else _countReportsDest++; } if (item.Type == ItemTypeEnum.Folder) { LoadTreeNode(item.Path, t.Nodes, rs, source); if (source) _countFolderSource++; else _countFolderDest++; } } }
private void btnDestLoad_Click(object sender, EventArgs e) { destRS = new ReportService.ReportingService2005(); string reportServerURI = "http://localhost:8080/ReportServer"; if (!String.IsNullOrEmpty(txtDestUrl.Text)) { reportServerURI = txtDestUrl.Text; } destRS.Url = reportServerURI + "/ReportService2005.asmx"; if (!String.IsNullOrEmpty(txtDestUser.Text)) { var userName = txtDestUser.Text; var nameParts = userName.Split('\\', '/'); if (nameParts.Length > 2) { MessageBox.Show("Incorrect destination user name","Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (nameParts.Length == 2) { userName = nameParts[1]; destRS.Credentials = new System.Net.NetworkCredential(userName, txtDestPassword.Text, nameParts[0]); } else { destRS.Credentials = new System.Net.NetworkCredential(userName, txtDestPassword.Text); } } else { destRS.Credentials = System.Net.CredentialCache.DefaultCredentials; } try { loadDestTree(); } catch (Exception ex) { MessageBox.Show("Loading failed." + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadTreeNode(string path, TreeNodeCollection nodes, ReportingService2005 rs, Dictionary<string, string> dataSources) { CatalogItem[] items = rs.ListChildren(path, false); foreach (var item in items) { TreeNode t = new TreeNode(); t.Text = item.Name; t.Name = item.Name; if (item.Type == ItemTypeEnum.DataSource) { if(!dataSources.ContainsKey(item.Name)) dataSources.Add(item.Name, item.Path); } if (item.Type != ItemTypeEnum.Model && item.Type != ItemTypeEnum.DataSource) { nodes.Add(t); } if (item.Type == ItemTypeEnum.Folder) loadTreeNode(item.Path, t.Nodes, rs, dataSources); else { } } }
private void btnLoad_Click(object sender, EventArgs e) { try { sourceRS = new ReportService.ReportingService2005(); string reportServerURI = "http://localhost:8080/ReportServer"; if (!String.IsNullOrEmpty(txtSourceUrl.Text)) { reportServerURI = txtSourceUrl.Text; } sourceRS.Url = reportServerURI + "/ReportService2005.asmx"; if (!String.IsNullOrEmpty(txtSourceUser.Text)) { var userName = txtSourceUser.Text; var nameParts = userName.Split('\\', '/'); if(nameParts.Length > 2) { MessageBox.Show("Incorrect source user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (nameParts.Length == 2) { userName = nameParts[1]; sourceRS.Credentials = new System.Net.NetworkCredential(userName, txtSourcePassword.Text, nameParts[0]); } else { sourceRS.Credentials = new System.Net.NetworkCredential(userName, txtSourcePassword.Text); } } else { sourceRS.Credentials = System.Net.CredentialCache.DefaultCredentials; } rptSourceTree.Nodes.Clear(); sourceDS = new Dictionary<string, string>(); loadTreeNode(ROOT_FOLDER, rptSourceTree.Nodes, sourceRS, sourceDS); } catch(Exception ex) { MessageBox.Show("Loading failed." + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }