////////// ### POPULATING CONTENT ### // Clears all existing data and begins populating content for all modules public void PopulateAllData() { webData.ClearAll(); PopulateModules(); // scrapes list of modules available populateProgress.TotalWork = webData.Modules.Count; foreach (BbModule m in webData.Modules) { PopulateModuleContent(m); populateProgress.IncWorkCounter(); populateProgress.ReportObject(m); // Pass module to GUI for updating the treeview } }
// Downloads a BbContentItem file and saves it to directory. public void DownloadFile(BbContentItem file, string directory) { string shortDir = directory.Substring(outputDirectory.Length, directory.Length - outputDirectory.Length); try { if (file.LinkType == "onedrive") { file.Url = OneDriveURL(file.Url); } if (file.LinkType == "dropbox") { file.Url = DropboxURL(file.Url); } else if (file.LinkType == "website") { log.Write("Linking to website " + file.Url.AbsoluteUri); downloadProgress.ReportStatus("Creating shortcut: " + shortDir + file.Name + file.Url.AbsoluteUri); CreateUrlShortcut(file, directory); return; } else if (file.LinkType == "email") { return; // Don't try to download e-mail } downloadProgress.ReportStatus("Downloading file (" + file.LinkType + "): " + shortDir + file.Name); Directory.CreateDirectory(directory); //Create directory if it doesn't exist already DetectFileName(file); http.DownloadFile(file.Url.AbsoluteUri, directory + file.Filename); } catch (WebException e) { log.WriteException(e); log.Write("ERROR: Cannot download file " + file); log.Write(shortDir); downloadProgress.ReportError("ERROR: Cannot download file " + file); } downloadProgress.IncWorkCounter(); }