コード例 #1
0
        protected virtual void visitStudentModuleResourceDownloadsInFormat(OuStudentModule ouStudentModule, String formatName, String formatUriString)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            log.WriteLine("Inspecting module resource downloads in format: {0}", (Object)(formatName));
            XmlDocument xmlDocument = ouSignedInWebSession.get(formatUriString);

            if (null == xmlDocument)
            {
                log.WriteLine("Error: failed to download: {0}", formatUriString);
                return;
            }
            xmlDocument.preserve(ouStudentModule.name + "_resource_downloads_in_" + formatName + ".xml");
            visitStudentModuleResourceDownloadsInFormat(ouStudentModule, formatName, xmlDocument);
        }
コード例 #2
0
        protected virtual void visitStudentModuleResourceDownloads(OuStudentModule ouStudentModule, String downloadsUri)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            log.WriteLine("Inspecting module resource downloads");
            XmlDocument xmlDocument = ouSignedInWebSession.get(downloadsUri);

            if (null == xmlDocument)
            {
                log.WriteLine("Error: failed to download: {0}", downloadsUri);
                return;
            }
            xmlDocument.preserve(ouStudentModule.name + "_resource_downloads.xml");
            visitStudentModuleResourceDownloads(ouStudentModule, xmlDocument);
        }
コード例 #3
0
        protected virtual void visitStudentModuleResources(OuStudentModule ouStudentModule, XmlDocument xmlDocument)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            XmlNode downloadsAXmlNode = xmlDocument.SelectSingleNode(".//a[normalize-space(./span/span/span/text())='Downloads' and @href]");

            if (null == downloadsAXmlNode)
            {
                onCouldNotLocateDownloadsLink(ouStudentModule);
                return;
            }
            String downloadsUri = downloadsAXmlNode.Attributes["href"].Value;

            using (new WritingIndentation(log)) {
                visitStudentModuleResourceDownloads(ouStudentModule, downloadsUri);
            }
        }
コード例 #4
0
        protected override void visitStudentModule(OuStudentModule ouStudentModule, XmlDocument xmlDocument)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            XmlNode resourcesAXmlNode = xmlDocument.SelectSingleNode(".//a[normalize-space(text())='Resources' and @href]");

            if (null == resourcesAXmlNode)
            {
                onCouldNotLocateResourcesLink(ouStudentModule);
                return;
            }
            String resourcesUri = resourcesAXmlNode.Attributes["href"].Value;

            using (new WritingIndentation(log)) {
                visitStudentModuleResources(ouStudentModule, resourcesUri);
            }
        }
コード例 #5
0
 protected virtual void visitStudentModuleResourceDownloads(OuStudentModule ouStudentModule, XmlNodeList aXmlNodeList)
 {
     if (cancellationRequestedChecker())
     {
         return;
     }
     using (new WritingIndentation(log)) {
         foreach (XmlNode aXmlNode in aXmlNodeList)
         {
             if (cancellationRequestedChecker())
             {
                 return;
             }
             String formatUriString = aXmlNode.Attributes["href"].Value;
             String formatName      = aXmlNode.InnerText.Trim();
             visitStudentModuleResourceDownloadsInFormat(ouStudentModule, formatName, formatUriString);
         }
     }
 }
コード例 #6
0
        protected virtual void visitStudentModuleResourceMediaDownloads(OuStudentModule ouStudentModule, XmlDocument xmlDocument)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            XmlNode mediaDownloadsUlXmlNode = xmlDocument.SelectSingleNode(".//h3[normalize-space(text())='Media downloads']/following-sibling::ul");

            if (null == mediaDownloadsUlXmlNode)
            {
                onCouldNotLocateMediaDownloadsList(ouStudentModule);
                return;
            }
            XmlNodeList aXmlNodeList = mediaDownloadsUlXmlNode.SelectNodes(".//li//a[@href]");

            if (0 == aXmlNodeList.Count)
            {
                onNoMediaFormatsAvailable(ouStudentModule);
                return;
            }
            visitStudentModuleResourceDownloads(ouStudentModule, aXmlNodeList);
        }
コード例 #7
0
        protected virtual void visitStudentModule(OuStudentModule ouStudentModule)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            log.WriteLine("Inspecting module: {0}", ouStudentModule);
            String uri = String.Format(moduleHomePatternUriString, ouStudentModule.shortName);

            try {
                XmlDocument xmlDocument = ouSignedInWebSession.get(uri);
                if (null == xmlDocument)
                {
                    log.WriteLine("Error: failed to download: {0}", uri);
                    return;
                }
                xmlDocument.preserve(ouStudentModule.name + ".xml");
                visitStudentModule(ouStudentModule, xmlDocument);
            }
            catch (Exception exception) {
                log.WriteLine("Unable to access module: {0}, exception: {1}", ouStudentModule.shortName, exception);
            }
        }
コード例 #8
0
        protected override void visitStudentModuleResourceDownloadsInFormat(OuStudentModule ouStudentModule, String formatName, XmlDocument xmlDocument)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            XmlNodeList trXmlNodeList = xmlDocument.SelectNodes(".//table/tbody/tr");

            if (0 == trXmlNodeList.Count)
            {
                onNoFilesAvailable(ouStudentModule, formatName);
                return;
            }
            using (new WritingIndentation(log)) {
                foreach (XmlNode trXmlNode in trXmlNodeList)
                {
                    if (cancellationRequestedChecker())
                    {
                        return;
                    }
                    visitStudentModuleResourceDownloadFile(ouStudentModule, formatName, trXmlNode);
                }
            }
        }
コード例 #9
0
 protected abstract void visitStudentModule(OuStudentModule ouStudentModule, XmlDocument xmlDocument);
コード例 #10
0
 protected virtual void onCouldNotLocateDownloadsLink(OuStudentModule ouStudentModule)
 {
     log.WriteLine("Error: could not locate 'Downloads' link");
 }
コード例 #11
0
 protected virtual void onNoDocumentFormatsAvailable(OuStudentModule ouStudentModule)
 {
     Console.Out.WriteLine("Note: no document formats available");
 }
コード例 #12
0
 protected abstract void visitStudentModuleResourceDownloadsInFormat(OuStudentModule ouStudentModule, String formatName, XmlDocument xmlDocument);
コード例 #13
0
 protected virtual void onNoMediaFormatsAvailable(OuStudentModule ouStudentModule)
 {
     Console.Out.WriteLine("Note: no media formats available");
 }
コード例 #14
0
 protected virtual void onCouldNotLocateMediaDownloadsList(OuStudentModule ouStudentModule)
 {
     log.WriteLine("Warning: could not locate 'Media downloads' format list");
 }
コード例 #15
0
 protected virtual void onNoFilesAvailable(OuStudentModule ouStudentModule, String formatName)
 {
     Console.Out.WriteLine("Note: no files available");
 }
コード例 #16
0
 protected virtual void onCouldNotLocateResourcesLink(OuStudentModule ouStudentModule)
 {
     log.WriteLine("Error: could not locate 'Resources' link");
 }
コード例 #17
0
        protected virtual void visitStudentModuleResourceDownloadFile(OuStudentModule ouStudentModule, String formatName, XmlNode trXmlNode)
        {
            if (cancellationRequestedChecker())
            {
                return;
            }
            XmlNode uriAXmlNode = trXmlNode.SelectSingleNode("./td[2]//a[@href]");

            if (null == uriAXmlNode)
            {
                log.WriteLine("Error: link missing");
                return;
            }
            String name = uriAXmlNode.InnerText.Trim();

            if (String.IsNullOrWhiteSpace(name))
            {
                log.WriteLine("Error: name missing");
                return;
            }
            XmlNode sizeTdXmlNode = trXmlNode.SelectSingleNode("./td[3]");
            String  sizeString    = (null == sizeTdXmlNode) ? null : sizeTdXmlNode.InnerText.Trim();

            if (String.IsNullOrWhiteSpace(sizeString))
            {
                log.WriteLine("Error: size missing");
                return;
            }
            long size;

            if (!SiByteMultiples.tryParse(sizeString, out size))
            {
                log.WriteLine("Error: size invalid");
                return;
            }
            XmlNode locationTdXmlNode = trXmlNode.SelectSingleNode("./td[4]");
            String  location          = (null == locationTdXmlNode) ? null : locationTdXmlNode.InnerText.Trim();

            if (String.IsNullOrWhiteSpace(location))
            {
                // note: not all entries have locations
                location = null;
            }

            Uri downloadUri = new Uri(uriAXmlNode.Attributes["href"].Value);

            if (!hasFinalResourceDownloadExtension(downloadUri))
            {
                downloadUri = ouSignedInWebSession.hit(downloadUri);
            }

            findings.getValueOrNew(ouStudentModule).Add(
                new DownloadableResourceFile(
                    downloadUri: downloadUri,
                    name: name,
                    type: formatName,
                    size: size,
                    location: location
                    )
                );
        }
コード例 #18
0
 protected virtual void visitStudentModuleResourceDownloads(OuStudentModule ouStudentModule, XmlDocument xmlDocument)
 {
     visitStudentModuleResourceDocumentDownloads(ouStudentModule, xmlDocument);
     visitStudentModuleResourceMediaDownloads(ouStudentModule, xmlDocument);
 }