private void PopulateTreeModule(BbModule module)
        {
            // If module has not been populated with content, don't attempt to create tree.
            if (!module.Initialized)
            {
                return;
            }

            // Create a root node for the module
            TreeNode moduleNode = new TreeNode(module.Name);

            moduleNode.Tag = module;
            Font moduleFont = new Font(new FontFamily("Segoe UI Semibold"), 15, FontStyle.Regular, GraphicsUnit.Pixel);

            moduleNode.NodeFont  = moduleFont;
            moduleNode.BackColor = Color.AliceBlue;

            // Populate module subfolders
            foreach (BbContentDirectory subFolder in module.Content.SubFolders)
            {
                PopulateTreeFolder(moduleNode, subFolder);
            }
            // Populate files in module's main content folder
            foreach (BbContentItem file in module.Content.Files)
            {
                AddTreeFile(moduleNode, file);
            }
            // Add module nodes to tree
            contentTree.Nodes.Add(moduleNode);
            moduleNode.Text = moduleNode.Text; // Forces re-draw to fix text truncating issue
        }
        // DoWork event handler for the file download BackgroundWorker.
        // The selected TreeNode (either a module, folder, or file) is passed in the DoWorkEventArgs e
        private void DownloadBW_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker       = sender as BackgroundWorker;
            TreeNode         selectedNode = e.Argument as TreeNode;

            scraper.DownloadProgress.BeginJob(worker);

            // -- DETERMINE TYPE OF NODE SELECTED --
            // Module selected
            if (selectedNode.Tag.GetType() == typeof(BbModule))
            {
                BbModule module = selectedNode.Tag as BbModule;
                scraper.DownloadProgress.TotalWork = module.Content.CountAllFiles();
                scraper.DownloadModuleFiles(module);
            }
            // Single folder selected
            else if (selectedNode.Tag.GetType() == typeof(BbContentDirectory))
            {
                BbContentDirectory folder = selectedNode.Tag as BbContentDirectory;
                scraper.DownloadProgress.TotalWork = folder.CountAllFiles();
                scraper.DownloadFolder(folder, scraper.OutputDirectory + BbUtils.CleanDirectory(folder.Name) + @"\");
            }
            // Single file selected
            else if (selectedNode.Tag.GetType() == typeof(BbContentItem))
            {
                BbContentItem file = selectedNode.Tag as BbContentItem;
                scraper.DownloadProgress.TotalWork = 1;
                scraper.DownloadFile(file);
            }
        }
 // Return true if other BbModule has the same Url
 public bool Equals(BbModule other)
 {
     if (other == null)
     {
         return false;
     }
     return this.url.Equals(other.Url);
 }
 // Return true if other BbModule has the same Url
 public bool Equals(BbModule other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.url.Equals(other.Url));
 }
Esempio n. 5
0
        // Finds and adds the main content directory to module m.
        public void CreateMainContentDirectory(BbModule m)
        {
            string   pageSource      = http.DownloadString(m.Url.AbsoluteUri);
            HtmlNode mainContentLink = HTMLParser.GetMainContentLink(pageSource);
            Uri      linkURL         = new Uri(new Uri(PORTAL), mainContentLink.Attributes["href"].Value);

            m.InitContentDirectory(linkURL);
        }
        // Event Handler for the content treeview. Changes information displayed
        private void contentTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ClearInfoBox();

            // Change what's displayed in the Information Box depending on type of node selected
            // File selected
            if (contentTree.SelectedNode.Tag.GetType() == typeof(BbContentItem))
            {
                BbContentItem file = contentTree.SelectedNode.Tag as BbContentItem;
                infoLabel1.Text   = "Name";
                infoText1.Text    = file.Name;
                infoLabel2.Text   = "Filename";
                infoText2.Text    = file.Filename;
                infoLabel3.Text   = "Link Type";
                infoText3.Text    = file.LinkType;
                infoLabel4.Text   = "URL";
                infoTextLink.Text = file.Url.AbsoluteUri;
            }
            // Folder selected
            else if (contentTree.SelectedNode.Tag.GetType() == typeof(BbContentDirectory))
            {
                BbContentDirectory folder = contentTree.SelectedNode.Tag as BbContentDirectory;
                infoLabel1.Text   = "Name";
                infoText1.Text    = folder.Name;
                infoLabel2.Text   = "Files";
                infoText2.Text    = folder.CountAllFiles().ToString();
                infoLabel3.Text   = "Subfolders";
                infoText3.Text    = folder.SubFolders.Count.ToString();
                infoLabel4.Text   = "URL";
                infoTextLink.Text = folder.Url.AbsoluteUri;
            }

            // Module selected
            else if (contentTree.SelectedNode.Tag.GetType() == typeof(BbModule))
            {
                BbModule module = contentTree.SelectedNode.Tag as BbModule;
                infoLabel1.Text   = "Name";
                infoText1.Text    = module.Name;
                infoLabel2.Text   = "Files";
                infoText2.Text    = module.Content.CountAllFiles().ToString();
                infoLabel3.Text   = "Subfolders";
                infoText3.Text    = module.Content.SubFolders.Count.ToString();
                infoLabel4.Text   = "URL";
                infoTextLink.Text = module.Url.AbsoluteUri;
            }
        }
Esempio n. 7
0
 // Searches for content within module m and adding it.
 public void PopulateModuleContent(BbModule m)
 {
     populateProgress.ReportStatus("Populating content for " + m.Name);
     try
     {
         if (!m.Initialized)
         {
             CreateMainContentDirectory(m);
         }
         PopulateContentDirectory(m.Content);
     }
     catch (Exception e)
     {
         populateProgress.ReportStatus("Error populating content for module: " + m.Name);
         populateProgress.ReportError("Error populating content for module: " + m.Name);
         log.Write("Content population error for: " + m.Name);
         log.WriteException(e);
         log.Write(e.StackTrace);
     }
 }
Esempio n. 8
0
        // Create BbModule objects for each module found and add them to webData
        // Does not populate content within the module
        public void PopulateModules()
        {
            NameValueCollection reqParams = new NameValueCollection();

            reqParams.Add("action", "refreshAjaxModule");
            reqParams.Add("modId", MODID);
            reqParams.Add("tabId", "_1_1");
            reqParams.Add("tab_tab_group_id", "_1_1");
            byte[]          pageSourceBytes = http.UploadValues(PORTAL + "/webapps/portal/execute/tabs/tabAction", "POST", reqParams);
            string          pageSource      = Encoding.UTF8.GetString(pageSourceBytes);
            List <HtmlNode> moduleLinks     = HTMLParser.GetModuleLinks(pageSource);

            foreach (HtmlNode link in moduleLinks)
            {
                // for each module link found, create and add a new module
                Uri      moduleURL = new Uri(new Uri(PORTAL), link.Attributes["href"].Value);
                BbModule newModule = new BbModule(link.InnerHtml, moduleURL);
                if (!webData.Modules.Contains(newModule))
                {
                    webData.AddModule(newModule);
                }
            }
        }
Esempio n. 9
0
 // Add a new module
 public void AddModule(BbModule m)
 {
     modules.Add(m);
 }
Esempio n. 10
0
 // Create BbModule objects for each module found and add them to webData
 // Does not populate content within the module
 public void PopulateModules()
 {
     NameValueCollection reqParams = new NameValueCollection();
     reqParams.Add("action", "refreshAjaxModule");
     reqParams.Add("modId", MODID);
     reqParams.Add("tabId", "_1_1");
     reqParams.Add("tab_tab_group_id", "_1_1");
     byte[] pageSourceBytes = http.UploadValues(PORTAL + "/webapps/portal/execute/tabs/tabAction", "POST", reqParams);
     string pageSource = Encoding.UTF8.GetString(pageSourceBytes);
     List<HtmlNode> moduleLinks = HTMLParser.GetModuleLinks(pageSource);
     foreach (HtmlNode link in moduleLinks)
     {
         // for each module link found, create and add a new module
         Uri moduleURL = new Uri(new Uri(PORTAL), link.Attributes["href"].Value);
         BbModule newModule = new BbModule(link.InnerHtml, moduleURL);
         if (!webData.Modules.Contains(newModule))
         {
             webData.AddModule(newModule);
         }
     }
 }
Esempio n. 11
0
 // Searches for content within module m and adding it.
 public void PopulateModuleContent(BbModule m)
 {
     populateProgress.ReportStatus("Populating content for " + m.Name);
     try
     {
         if (!m.Initialized)
         {
             CreateMainContentDirectory(m);
         }
         PopulateContentDirectory(m.Content);
     }
     catch(Exception e)
     {
         populateProgress.ReportStatus("Error populating content for module: " + m.Name);
         populateProgress.ReportError("Error populating content for module: " + m.Name);
         log.Write("Content population error for: " + m.Name);
         log.WriteException(e);
         log.Write(e.StackTrace);
     }
 }
Esempio n. 12
0
 // Downloads all files in a module
 public void DownloadModuleFiles(BbModule m)
 {
     DownloadFolder(m.Content, outputDirectory + BbUtils.CleanDirectory(m.Name) + "\\");
 }
Esempio n. 13
0
 // Finds and adds the main content directory to module m.
 public void CreateMainContentDirectory(BbModule m)
 {
     string pageSource = http.DownloadString(m.Url.AbsoluteUri);
     HtmlNode mainContentLink = HTMLParser.GetMainContentLink(pageSource);
     Uri linkURL = new Uri(new Uri(PORTAL), mainContentLink.Attributes["href"].Value);
     m.InitContentDirectory(linkURL);
 }
Esempio n. 14
0
 // Downloads all files in a module
 public void DownloadModuleFiles(BbModule m)
 {
     DownloadFolder(m.Content, outputDirectory + BbUtils.CleanDirectory(m.Name) + "\\");
 }
Esempio n. 15
0
////////// ### DOWNLOADING CONTENT ###

        //Used in ConsoleUI
        public void DownloadModuleFiles(string moduleName)
        {
            BbModule m = webData.GetModuleByName(moduleName);

            DownloadFolder(m.Content, outputDirectory + BbUtils.CleanDirectory(m.Name) + "\\");
        }