private void EditDataSource(TreeView treeView)
        {
            if ((ItemTypeEnum)(treeView.SelectedNode.Tag) != ItemTypeEnum.DataSource)
            {
                MessageBox.Show(@"Please choose a Datasource");
                return;
            }

            ReportServerProperties reportServerProperties = new ReportServerProperties(((ReportServerProperties)(treeView.Tag)).ReportsServerInstance.Url);

            DataSourceDefinition dataSourceDefinition = reportServerProperties.GetDataSourceDefinition(treeView.SelectedNode.FullPath.Replace(treeView.Nodes[0].Text, string.Empty).Replace(@"\", "/"));

            using (var frmDataSourceDetail = new frmDataSourceDetail())
            {
                string[] connectionString = dataSourceDefinition.ConnectString.Split(';');

                foreach (string[] itemDict in connectionString.Select(item => item.Split('=')))
                {
                    if (itemDict[0] == "Data Source")
                    {
                        frmDataSourceDetail.SQLServer = itemDict[1];
                    }
                    if (itemDict[0] == "Initial Catalog")
                    {
                        frmDataSourceDetail.DBName = itemDict[1];
                    }
                }

                frmDataSourceDetail.DataSourceName = treeView.SelectedNode.Text;

                CatalogItem[] catalogItems = reportServerProperties.ReportsServerInstance.ListDependentItems(treeView.SelectedNode.FullPath.Replace(treeView.Nodes[0].Text, string.Empty).Replace(@"\", "/"));

                //frmDataSourceDetail.DependentItems = catalogItems.Select(catalogItem => string.Format("{0}{1}", catalogItem.Path, catalogItem.Name)).ToList();

                if (frmDataSourceDetail.ShowDialog() == DialogResult.OK)
                {
                    string folder = treeView.SelectedNode.FullPath.Replace(treeView.Nodes[0].Text, string.Empty).Replace(@"\", "/").Replace(treeView.SelectedNode.Text, string.Empty);
                    if (ReportServerDestination.DeleteItem(ItemTypeEnum.DataSource, folder.Substring(0, folder.Length - 1), treeView.SelectedNode.Text) &&
                        ReportServerDestination.CreateDataSource(frmDataSourceDetail.DataSourceName, folder.Substring(0, folder.Length - 1), frmDataSourceDetail.SQLServer, frmDataSourceDetail.DBName))
                    {
                        treeView.SelectedNode.Text = frmDataSourceDetail.DataSourceName;
                        MessageBox.Show("DataSource modified succesfully");
                    }
                    else
                    {
                        MessageBox.Show("DataSource WASN'T modified");
                    }
                }
            }
        }
 private static void RefreshSourceTreeView(TreeView treeView, ReportServerProperties reportingService2005)
 {
     if (treeView.InvokeRequired)
     {
         treeView.Invoke(new MethodInvoker(treeView.BeginUpdate));
         treeView.Invoke(new MethodInvoker(() => treeView.Nodes.Clear()));
         treeView.Invoke(new MethodInvoker(() => treeView.Nodes.Add(TreeViewHandling.GetFolderAsNodes(reportingService2005.ReportsServerInstance))));
         treeView.Invoke(new MethodInvoker(treeView.EndUpdate));
         treeView.Tag = reportingService2005;
     }
     else
     {
         treeView.BeginUpdate();
         treeView.Nodes.Clear();
         treeView.Nodes.Add(TreeViewHandling.GetFolderAsNodes(reportingService2005.ReportsServerInstance));
         treeView.EndUpdate();
         treeView.Tag = reportingService2005;
     }
 }
        private void LoadTreeViewPanelsFromSrv()
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                var cmbBoxValue = new string[] { };
                var tagValue    = new List <Project>();

                if (cmbProject.InvokeRequired)
                {
                    cmbProject.Invoke(new MethodInvoker(delegate
                    {
                        cmbBoxValue = ((string)cmbProject.SelectedItem).Split('=');
                    }));
                    cmbProject.Invoke(new MethodInvoker(delegate
                    {
                        tagValue = cmbProject.Tag as List <Project>;
                    }));
                }

                var selectedProject = tagValue.Where(project => project.Server1 == cmbBoxValue[0].Trim() &&
                                                     project.Server2 == cmbBoxValue[1].Trim()).FirstOrDefault();

                if (selectedProject != null)
                {
                    ReportServerSource      = new ReportServerProperties(selectedProject.URL1);
                    ReportServerDestination = new ReportServerProperties(selectedProject.URL2);
                    RefreshSourceTreeView(tvReportServerSource, ReportServerSource);
                    RefreshSourceTreeView(tvReportServerDestination, ReportServerDestination);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            Cursor.Current = Cursors.Arrow;
        }