//This method connects to the RS instance based on the RS instance url, and get the permissions for the
        //specified path.
        public void GetExistingPermissions(String rsUrl, String path)
        {
            try
            {
                if (path == "Home")
                {
                    m_strPath = "/";
                }
                else
                {
                    m_strPath = path;
                }

                //Connects the RS Instance
                m_rs = new ReportingService2005();
                m_rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                m_soapUrl = rsUrl + m_wsdl;
                m_rs.Url = m_soapUrl;

                //Add the columns based on the Roles defined
                AddColumnsToGrid();
                //Displays the permissions for the Users
                ShowPermissions();

                this.Text = "Permissions on the Report item :  " + m_strPath;
            }
            catch (UriFormatException ex)
            {
                MessageBox.Show("Not connected to any Reportserver instance.");
                this.Close();
            }
        }
        private void CreateProxy()
        {
            try
            {
                rs = new rsService.ReportingService2005();

                rs.Url = serverTextBox.Text + "ReportService2005.asmx";
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

                rsExec = new rsExecService.ReportExecutionService();
                rsExec.Url = serverTextBox.Text + "ReportExecution2005.asmx";
                rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
                rsExec.RenderCompleted += new rsExecService.RenderCompletedEventHandler(this.RenderCompletedHandler);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(CultureInfo.InvariantCulture, ex.Message));
            }
        }
        private void searchButton_Click(object sender, System.EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            // Clear out the current descripton and path fields
            descriptionTextBox.Clear();
            pathTextBox.Clear();

            // Disable save button on new search
            saveReportButton.Enabled = false;

            // Check to see if the 'Search By' string is valid.
            if (conditionComboBox.SelectedIndex == -1)
            {
                MessageBox.Show(
                    "Please select a valid 'Search By' string by clicking the drop down arrow!",
                    "Invalid 'Search By' String",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // Check to see if a search string is entered
            if (searchTextBox.Text == null || searchTextBox.Text == "")
            {
                MessageBox.Show(
                    Resources.invalidSearchStringErrorMessage,
                    Resources.invalidSearchStringMessageBoxTitle,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            else
            {
                reportListView.Items.Clear();

                // Create a new proxy to the web service
                rs = new rs2005.ReportingService2005();
                rsExec = new rsExecService.ReportExecutionService();

                // Authenticate to the Web service using Windows credentials
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

                // Assign the URL of the Web service
                rs.Url = ConfigurationManager.AppSettings["ReportingService2005"];
                rsExec.Url = ConfigurationManager.AppSettings["ReportExecutionService"];

                rs2005.SearchCondition[] conditions;

                if (conditionComboBox.SelectedIndex == NAME)
                {
                    // Create Name search condition
                    rs2005.SearchCondition condition = new rs2005.SearchCondition();
                    condition.Condition = rs2005.ConditionEnum.Contains;
                    condition.ConditionSpecified = true;
                    condition.Name = "Name";
                    condition.Value = searchTextBox.Text;

                    conditions = new rs2005.SearchCondition[1];
                    conditions[0] = condition;
                }
                else if (conditionComboBox.SelectedIndex == DESC)
                {
                    // Create Description search condition
                    rs2005.SearchCondition condition = new rs2005.SearchCondition();
                    condition.Condition = rs2005.ConditionEnum.Contains;
                    condition.ConditionSpecified = true;
                    condition.Name = "Description";
                    condition.Value = searchTextBox.Text;

                    // Add conditions to the conditions argument to be used for
                    // FindItems
                    conditions = new rs2005.SearchCondition[1];
                    conditions[0] = condition;
                }
                else
                {
                    // Create Name
                    rs2005.SearchCondition nameCondition = new rs2005.SearchCondition();
                    nameCondition.Condition = rs2005.ConditionEnum.Contains;
                    nameCondition.ConditionSpecified = true;
                    nameCondition.Name = "Name";
                    nameCondition.Value = searchTextBox.Text;

                    // Create Desription
                    rs2005.SearchCondition descCondition = new rs2005.SearchCondition();
                    descCondition.Condition = rs2005.ConditionEnum.Contains;
                    descCondition.ConditionSpecified = true;
                    descCondition.Name = "Description";
                    descCondition.Value = searchTextBox.Text;

                    // Add conditions to the conditions argument to be used for
                    // FindItems
                    conditions = new rs2005.SearchCondition[2];
                    conditions[0] = nameCondition;
                    conditions[1] = descCondition;
                }

                try
                {
                    // Return a list of items based on the search conditions that
                    // apply
                    returnedItems = rs.FindItems("/", rs2005.BooleanOperatorEnum.Or,
                        conditions );

                    if (returnedItems != null && returnedItems.Length != 0)
                    {
                        foreach (rs2005.CatalogItem ci in returnedItems)
                        {
                            //Create a ListView item containing a report catalog item
                            if (ci.Type == rs2005.ItemTypeEnum.Report)
                            {
                                // Add the items to the list view
                                CatalogListViewItem newItem = new CatalogListViewItem(ci);
                                reportListView.Items.Add(newItem);
                            }
                        }
                    }
                    else
                        MessageBox.Show(
                            Resources.noItemsFoundInfoMessage,
                            Resources.noItemsFoundMessageBoxTitle,
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                catch (Exception exception)
                {
                    HandleException(exception);
                }

                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
        //The method used to connect to an RS instance specified in the strReportserverurl
        private void InvokeRSInstance(String strReportserverurl)
        {
            try
            {
                if (strReportserverurl == string.Empty || strReportserverurl == null)
                {
                    return;
                }
                m_path = strReportserverurl;
                m_rs = new ReportingService2005();
                m_rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                m_soapUrl = m_path + m_wsdl;
                m_rs.Url = m_soapUrl;

                //This method loads the Catalog contents to the Treeview
                LoadObjectExplorer();

                lvChildren.Columns.Clear();
                lvChildren.Columns.Add("Name");

                lblMessage.Text = "Report Server instance : " + strReportserverurl.ToString();
                lblMessage.TextAlign = ContentAlignment.BottomCenter;
            }
            //Catch the invalid URI format exception
            catch (UriFormatException uriEx)
            {
                MessageBox.Show(uriEx.Message.ToString() + " Please check the Reportserver URL");
            }

            //Catch the report server connectivity exception
            catch (System.Net.WebException webEx)
            {
                MessageBox.Show(webEx.Message.ToString());
            }
        }
 private void ConnectToServer()
 {
     // Init UI
     EnableButtons(true);
     this.Path = Root;
     string serverPath = serverPathTextbox.Text;
     try
     {
         // Connect to Reporting Services
         Cursor.Current = Cursors.WaitCursor;
         rs = new rs2005.ReportingService2005();
         // A production application would perform a complete check on the url path
         this.Connect(serverPath);
         // Display root items
         DisplayItems(Path);
     }
     catch (Exception ex)
     {
         EnableButtons(false);
         this.HandleGeneralException(ex);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
        public void Connect(string url)
        {
            // Create an instance of the Web service proxy and set the Url property
            rs = new rs2005.ReportingService2005();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            soapUrl = url + wsdl;

            rs.Url = soapUrl;
        }