Beispiel #1
0
        // ---

        public static IEnumerable <IDownloadableResourceFileCollection> enumerateResourceFileCollections(String studentUsername, String studentPassword, Func <Boolean> cancellationRequestedChecker, TextWriter logTextWriter)
        {
            try {
                XmlDocument          signedInXmlDocument;
                OuSignedInWebSession ouSignedInWebSession = OuSignedInWebSession.signIn(studentUsername, studentPassword, out signedInXmlDocument);
                if (null == ouSignedInWebSession || null == signedInXmlDocument)
                {
                    Console.Error.WriteLine("Error: could not sign-in student: {0}", studentUsername);
                    return(Enumerable.Empty <IDownloadableResourceFileCollection>());
                }
                signedInXmlDocument.preserve("SignedIn.xml");
                using (ouSignedInWebSession) {
                    // note: using block will attempt to sign-out if an exception is thrown

                    OuDownloader ouDownloader = new OuDownloader(ouSignedInWebSession);

                    IEnumerable <IDownloadableResourceFileCollection> findings = ouDownloader.enumerateResourceFileCollections(cancellationRequestedChecker, logTextWriter);

                    // attempt to sign-out normally:

                    XmlDocument signedOutXmlDocument;
                    ouSignedInWebSession.signOut(out signedOutXmlDocument);
                    if (null == signedOutXmlDocument)
                    {
                        Console.Error.WriteLine("Error: could not sign-out");
                    }
                    else
                    {
                        signedOutXmlDocument.preserve("SignedOut.xml");
                    }

                    return(findings);
                }
            }
            catch (Exception exception) {
                Console.Error.WriteLine("Error: exception: {0}", exception);
                return(Enumerable.Empty <IDownloadableResourceFileCollection>());
            }
        }
 public OuStudentWebModuleResourceFileFinder(OuSignedInWebSession ouSignedInWebSession, Func <Boolean> cancellationRequestedChecker, TextWriter logTextWriter) :
     base(ouSignedInWebSession, cancellationRequestedChecker, logTextWriter)
 {
 }
 public OuStudentWebModuleVisitor(OuSignedInWebSession ouSignedInWebSession, Func <Boolean> cancellationRequestedChecker, TextWriter logTextWriter)
 {
     this.ouSignedInWebSession         = ouSignedInWebSession;
     this.cancellationRequestedChecker = cancellationRequestedChecker;
     this.log = new IndentedWriter(logTextWriter, "  ");
 }
Beispiel #4
0
 public OuDownloader(OuSignedInWebSession ouSignedInWebSession)
 {
     this.ouSignedInWebSession = ouSignedInWebSession;
 }