Ejemplo n.º 1
0
        private void btChangeDataSource_Click(object sender, EventArgs e)
        {
            try
            {
                FileNameAndPath dataSourceMap         = null;
                var             reportsServerInstance = ((ReportServerProperties)(SourceNode.TreeView.Tag)).ReportsServerInstance;
                using (var frmDataSource = new frmDataSource())
                {
                    frmDataSource.FillTreeview(reportsServerInstance);
                    if (frmDataSource.ShowDialog() == DialogResult.OK)
                    {
                        dataSourceMap = frmDataSource.SelectedNode;
                    }
                }

                Cursor.Current = Cursors.WaitCursor;
                if (dataSourceMap == null)
                {
                    Cursor.Current = Cursors.Default;
                    return;
                }

                MessageBox.Show(((ReportServerProperties)(SourceNode.TreeView.Tag)).AttachDataSourceToReport(dataSourceMap.Name,
                                                                                                             dataSourceMap.Path,
                                                                                                             SourceNode.Text,
                                                                                                             SourceNode.FullPath.Replace(SourceNode.TreeView.Nodes[0].Text, string.Empty).Replace(@"\", @"/").Replace(SourceNode.Text, string.Empty).Replace(@"//", @"/"))
                        ? "Report's datasource is updated"
                        : "Cannot update report's datasource");
                lbDataSource.Text = string.Format("Current DataSource: {0}", GetDataSource());
            }
            catch (Exception exception)
            {
                MessageBox.Show(string.Format("Cannot update report's datasource. Error : {0}", exception.Message));
            }
        }
Ejemplo n.º 2
0
        private bool TransferReportNode(TreeNode checkedNode, TreeNode destinationNode)
        {
            try
            {
                FileNameAndPath dataSourceMap = null;
                using (var frmDataSource = new frmDataSource())
                {
                    frmDataSource.FillTreeview(ReportServerDestination.ReportsServerInstance);
                    if (frmDataSource.ShowDialog() == DialogResult.OK)
                    {
                        dataSourceMap = frmDataSource.SelectedNode;
                    }
                }

                Cursor.Current = Cursors.WaitCursor;
                if (dataSourceMap == null)
                {
                    Cursor.Current = Cursors.Default;
                    return(false);
                }

                ((ReportServerProperties)checkedNode.TreeView.Tag).DeployReport(((ReportServerProperties)checkedNode.TreeView.Tag).ReportsServerInstance,
                                                                                checkedNode.Text,
                                                                                checkedNode.FullPath.Replace(checkedNode.TreeView.Nodes[0].Text, string.Empty),
                                                                                destinationNode.FullPath.Replace(destinationNode.TreeView.Nodes[0].Text, string.Empty),
                                                                                dataSourceMap.Name,
                                                                                dataSourceMap.Path);

                destinationNode.Nodes.Add(new TreeNode(checkedNode.Text, 1, 1)
                {
                    Tag = checkedNode.Tag
                });
                return(true);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            return(false);
        }
Ejemplo n.º 3
0
        private void UploadReport(object sender)
        {
            var treeView = (TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;

            try
            {
                if ((ItemTypeEnum)(treeView.SelectedNode.Tag) == ItemTypeEnum.Folder)
                {
                    FileNameAndPath dataSourceMap = null;
                    using (var frmDataSource = new frmDataSource())
                    {
                        frmDataSource.FillTreeview(ReportServerDestination.ReportsServerInstance);
                        if (frmDataSource.ShowDialog() == DialogResult.OK)
                        {
                            dataSourceMap = frmDataSource.SelectedNode;
                        }
                    }

                    openFileDialog1.Filter           = @"*.*|*.*";
                    openFileDialog1.InitialDirectory = @"c:\";
                    openFileDialog1.Multiselect      = false;
                    openFileDialog1.ShowDialog();
                    if (File.Exists(openFileDialog1.FileName))
                    {
                        if (dataSourceMap != null)
                        {
                            if (((ReportServerProperties)(treeView.Tag)).DeployReport(((ReportServerProperties)(treeView.Tag)).ReportsServerInstance,
                                                                                      openFileDialog1.FileName,
                                                                                      treeView.SelectedNode.FullPath.Replace(treeView.Nodes[0].Text, string.Empty).Replace(@"\", @"/"),
                                                                                      dataSourceMap.Name,
                                                                                      dataSourceMap.Path))
                            {
                                FileInfo fileInfo = new FileInfo(openFileDialog1.FileName);

                                string fileName = fileInfo.Name.Replace(fileInfo.Extension, string.Empty);

                                var reportNode = new TreeNode(fileName)
                                {
                                    ImageIndex         = 1,
                                    Tag                = ItemTypeEnum.Report,
                                    Name               = fileName,
                                    SelectedImageIndex = 1
                                };

                                treeView.SelectedNode.Nodes.Add(reportNode);
                                treeView.SelectedNode.Expand();
                            }
                            else
                            {
                                MessageBox.Show(@"The Report wasn't deployed");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(@"Please choose a file");
                    }
                }
                else
                {
                    MessageBox.Show(@"Please choose a folder");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Ejemplo n.º 4
0
        private void TransferItems()
        {
            if (tvReportServerDestination.SelectedNode == null)
            {
                MessageBox.Show(@"Merci de sélectionner le dossier destination");
                return;
            }

            FileNameAndPath dataSourceMap = null;

            using (var frmDataSource = new frmDataSource())
            {
                frmDataSource.FillTreeview(ReportServerDestination.ReportsServerInstance);
                if (frmDataSource.ShowDialog() == DialogResult.OK)
                {
                    dataSourceMap = frmDataSource.SelectedNode;
                }
            }

            Cursor.Current = Cursors.WaitCursor;
            if (dataSourceMap == null)
            {
                return;
            }

            try
            {
                var checkedNodes = TreeViewHandling.GetCheckedNodes(tvReportServerSource.Nodes);

                pbTransfer.Visible = true;
                pbTransfer.Maximum = checkedNodes.Count(node => node.Checked);

                int i = 0;

                foreach (TreeNode checkedNode in checkedNodes.Where(node => node.Checked))
                {
                    try
                    {
                        switch (((ItemTypeEnum)(checkedNode.Tag)))
                        {
                        case ItemTypeEnum.Report:
                            pbTransfer.Value = (i < pbTransfer.Maximum) ? ++i : i;
                            ReportServerDestination.DeployReport(ReportServerSource.ReportsServerInstance,
                                                                 checkedNode.Text,
                                                                 checkedNode.FullPath.Replace(tvReportServerSource.Nodes[0].Text, string.Empty),
                                                                 tvReportServerDestination.SelectedNode.FullPath.Replace(tvReportServerDestination.Nodes[0].Text, string.Empty),
                                                                 dataSourceMap.Name,
                                                                 dataSourceMap.Path);
                            tvReportServerDestination.SelectedNode.Nodes.Add(new TreeNode(checkedNode.Text, 1, 1)
                            {
                                Tag = checkedNode.Tag
                            });
                            break;

                        case ItemTypeEnum.Folder:
                            if (ReportServerDestination.CheckItemExist(ItemTypeEnum.Folder,
                                                                       tvReportServerDestination.SelectedNode.FullPath.Replace(tvReportServerDestination.Nodes[0].Text, string.Empty).Replace(@"\", "/"),
                                                                       checkedNode.Text))
                            {
                                ReportServerDestination.CreateFolder(tvReportServerDestination.SelectedNode.FullPath.Replace(tvReportServerDestination.Nodes[0].Text, string.Empty), checkedNode.Text);
                                tvReportServerDestination.SelectedNode.Nodes.Add(new TreeNode(checkedNode.Text, 0, 0)
                                {
                                    Tag = checkedNode.Tag
                                });
                            }
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }

                tvReportServerDestination.SelectedNode.Expand();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }


            pbTransfer.Visible = false;
            Cursor.Current     = Cursors.Arrow;
        }