/// <summary>
 /// Refreshes the source tree view.
 /// </summary>
 /// <param name="treeView">The tree view.</param>
 /// <param name="reportingService2005">The reporting service2005.</param>
 private static void RefreshSourceTreeView(TreeView treeView, ReportServerProperties reportingService2005)
 {
     treeView.BeginUpdate();
     treeView.Nodes.Clear();
     treeView.Nodes.Add(TreeViewHandling.GetFolderAsNodes(reportingService2005.ReportsServerInstance2005, false));
     treeView.EndUpdate();
     treeView.Tag = reportingService2005;
 }
        public frmEditProperties(TaskHost taskHost, Connections connections)
        {
            InitializeComponent();

            Closing += frmEditProperties_Closing;

            _isFirstLoad = true;

            Cursor.Current = Cursors.WaitCursor;

            _taskHost    = taskHost;
            _connections = connections;

            if (taskHost == null)
            {
                Cursor.Current = Cursors.Default;
                throw new ArgumentNullException("taskHost");
            }

            cmbSourceVariables.Items.AddRange(LoadVariables("System.String").ToArray());

            LoadConfigFileConnections();
            LoadVariablesForReportName();

            if (_taskHost.Properties[Keys.REPORTSERVER] == null)
            {
                Cursor.Current = Cursors.Default;
                return;
            }

            if (_taskHost.Properties[Keys.REPORTSERVER].GetValue(_taskHost) != null)
            {
                cmbSourceVariables.Text = _taskHost.Properties[Keys.REPORTSERVER].GetValue(_taskHost).ToString();

                string.Format("{0}/ReportService2005.asmx", _taskHost.Properties[Keys.REPORTSERVER].GetValue(_taskHost));
                string.Format("{0}/ReportExecution2005.asmx", _taskHost.Properties[Keys.REPORTSERVER].GetValue(_taskHost));

                try
                {
                    LoadTreeViewPanelsFromSrv();

                    if (_taskHost.Properties[Keys.REPORTNAME].GetValue(_taskHost) != null)
                    {
                        _reportName = _taskHost.Properties[Keys.REPORTNAME].GetValue(_taskHost).ToString();
                        _reportPath = _taskHost.Properties[Keys.REPORTPATH].GetValue(_taskHost).ToString();

                        cmbFileType.Text          = _taskHost.Properties[Keys.OUTPUT_TYPE].GetValue(_taskHost).ToString();
                        cmbConfigurationFile.Text = _taskHost.Properties[Keys.DESTINATION_FILE].GetValue(_taskHost).ToString();
                        cmbReportName.Text        = _taskHost.Properties[Keys.REPORTNAME_EXPRESSION].GetValue(_taskHost).ToString();

                        if (_taskHost.Properties[Keys.CONFIGURATION_TYPE].GetValue(_taskHost).ToString() == ConfigurationType.TASK_VARIABLE)
                        {
                            optChooseVariable.Checked = true;
                        }
                        if (_taskHost.Properties[Keys.CONFIGURATION_TYPE].GetValue(_taskHost).ToString() == ConfigurationType.FILE_CONNECTOR)
                        {
                            optChooseConfigFileConnector.Checked = true;
                        }

                        tvReportServerSource.Scrollable = true;

                        tvReportServerSource.SelectedNode = SourceNode = TreeViewHandling.FindRecursive(tvReportServerSource.Nodes[0], _reportName, _reportPath);

                        tvReportServerSource.SelectedNode.ForeColor = System.Drawing.Color.DarkRed;
                        tvReportServerSource.SelectedNode.EnsureVisible();

                        if (_taskHost.Properties[Keys.OUTPUT_TYPE].GetValue(_taskHost) != null)
                        {
                            cmbFileType.SelectedIndex = Tools.FindStringInComboBox(cmbFileType, _taskHost.Properties[Keys.OUTPUT_TYPE].GetValue(_taskHost).ToString(), -1);
                        }

                        _reportServerProperties2005 = ((ReportServerProperties)(SourceNode.TreeView.Tag)).ReportsServerInstance2005;

                        tvReportServerSource.SelectedNode.EnsureVisible();

                        _reportPath = string.Format("{0}/{1}", _reportPath, _reportName);

                        if (_taskHost.Properties[Keys.SEND_FILE_BY_EMAIL].GetValue(_taskHost) != null)
                        {
                            if (_taskHost.Properties[Keys.SEND_FILE_BY_EMAIL].GetValue(_taskHost).ToString() == Keys.TRUE)
                            {
                                chkEmail.Checked = true;
                                EnableSmtp(chkEmail.Checked);
                            }
                            else
                            {
                                chkEmail.Checked = false;
                                EnableSmtp(chkEmail.Checked);
                            }
                        }
                    }
                }
                catch
                { }
            }
            else
            {
                chkEmail.Checked = false;
                EnableSmtp(chkEmail.Checked);
            }

            Cursor.Current = Cursors.Default;
        }