Beispiel #1
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            getCheckedButton();
            treeView1.Nodes.Clear();
            btnRetrieve.Enabled     = false;
            lblRetrieve.Visible     = true;
            grpbxCollection.Visible = false;
            if (Env.Equals(String.Empty))
            {
                MessageBox.Show("Select a Environment");
                btnReset_Click(sender, e);
            }

            try
            {
                /*Declare and initialize a variable for the Webs Web service.*/
                WebsWebService.Webs         webs_service     = new WebsWebService.Webs();
                SiteDataWebService.SiteData sitedata_service = new SiteDataWebService.SiteData();

                /*Authenticate the current user by passing their default
                 * credentials to the Web service from the system credential
                 * cache. */
                webs_service.Credentials =
                    System.Net.CredentialCache.DefaultCredentials;
                sitedata_service.Credentials =
                    System.Net.CredentialCache.DefaultCredentials;

                /*Set the Url property of the service for the path to a subsite.
                 * Not setting this property will return the items in the root Web site.*/
                webs_service.Url =
                    "https://edss.iu.edu/sites/" + Env + "/BI-Centers/_vti_bin/Webs.asmx";


                /*Declare an XmlNode object and initialize it with the XML
                 * response from the GetWebCollection method. */
                System.Xml.XmlNode nodeWebCollection = webs_service.GetWebCollection();

                /*Loop through XML response and parse out the value of the
                 * Title attribute for each Web. */
                foreach (System.Xml.XmlNode xmlnode in nodeWebCollection)
                {
                    uint result = 1;
                    SiteDataWebService._sList[] lists = null;
                    String siteName = xmlnode.Attributes["Title"].Value;

                    try
                    {
                        sitedata_service.Url = "https://edss.iu.edu/sites/" + Env + "/BI-Centers/" + siteName + "/_vti_bin/SiteData.asmx";
                        result = sitedata_service.GetListCollection(out lists);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("An error occured while retrieving list names: " + exception.Message);
                    }
                    if (result == 0)
                    {
                        TreeNode[] arrayTreeNode = new TreeNode[lists.Length];
                        for (int i = 0; i < lists.Length; i++)
                        {
                            arrayTreeNode[i] = new TreeNode(lists[i].Title);
                        }
                        TreeNode treeNode = new TreeNode(siteName, arrayTreeNode);
                        treeView1.Nodes.Add(treeNode);
                    }
                    else
                    {
                        MessageBox.Show("Error in aite data get collection");
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occured while getting site names: " + exception.Message);
            }

            grpbxCollection.Visible = true;
            btnRetrieve.Enabled     = true;
            lblRetrieve.Visible     = false;
        }
Beispiel #2
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            getCheckedButton();
            treeView1.Nodes.Clear();
            btnRetrieve.Enabled = false;
            lblRetrieve.Visible = true;
            grpbxCollection.Visible = false;
            if (Env.Equals(String.Empty))
            {
                MessageBox.Show("Select a Environment");
                btnReset_Click(sender, e);
            }

                try
                {
                    /*Declare and initialize a variable for the Webs Web service.*/
                    WebsWebService.Webs webs_service = new WebsWebService.Webs();
                    SiteDataWebService.SiteData sitedata_service = new SiteDataWebService.SiteData();

                    /*Authenticate the current user by passing their default
                    credentials to the Web service from the system credential
                    cache. */
                    webs_service.Credentials =
                       System.Net.CredentialCache.DefaultCredentials;
                    sitedata_service.Credentials =
                        System.Net.CredentialCache.DefaultCredentials;

                    /*Set the Url property of the service for the path to a subsite.
                    Not setting this property will return the items in the root Web site.*/
                    webs_service.Url =
                    "https://edss.iu.edu/sites/"+Env+"/BI-Centers/_vti_bin/Webs.asmx";

                    /*Declare an XmlNode object and initialize it with the XML
                    response from the GetWebCollection method. */
                    System.Xml.XmlNode nodeWebCollection = webs_service.GetWebCollection();

                    /*Loop through XML response and parse out the value of the
                    Title attribute for each Web. */
                    foreach (System.Xml.XmlNode xmlnode in nodeWebCollection)
                    {
                        uint result = 1;
                        SiteDataWebService._sList[] lists = null;
                        String siteName = xmlnode.Attributes["Title"].Value;

                        try
                        {
                            sitedata_service.Url = "https://edss.iu.edu/sites/" + Env + "/BI-Centers/" + siteName + "/_vti_bin/SiteData.asmx";
                            result = sitedata_service.GetListCollection(out lists);
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show("An error occured while retrieving list names: " + exception.Message);
                        }
                        if (result == 0)
                        {

                            TreeNode[] arrayTreeNode = new TreeNode[lists.Length];
                            for (int i = 0; i < lists.Length; i++)
                            {
                                arrayTreeNode[i] = new TreeNode(lists[i].Title);

                            }
                            TreeNode treeNode = new TreeNode(siteName, arrayTreeNode);
                            treeView1.Nodes.Add(treeNode);
                        }
                        else
                            MessageBox.Show("Error in aite data get collection");

                    }

                }
                catch (Exception exception)
                {
                    MessageBox.Show("An error occured while getting site names: " + exception.Message);
                }

                grpbxCollection.Visible = true;
                btnRetrieve.Enabled = true;
                lblRetrieve.Visible = false;
        }