Example #1
0
        public string Backup(string username, int courseID, int asstID, IExternalSink extsink)
        {
            string zfile, wzfile, backdesc = username + ": ";

            //Create our external sink file
            if (extsink == null)
            {
                extsink = ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink;
                zfile   = username + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip";
                wzfile  = Globals.BackupDirectoryName + "/" + zfile;
                zfile   = Path.Combine(Globals.BackupDirectory, zfile);
                extsink.CreateSink(zfile);
            }
            else
            {
                wzfile = zfile = "";                 // In the middle of a backup
            }
            //Backup Results

            //Back up submissions
            FileSystem fs = new FileSystem(m_ident);

            Components.Submission.SubmissionList subs;
            if (asstID < 0)
            {
                if (zfile != "")
                {
                    backdesc += (new Courses(m_ident).GetInfo(courseID)).Name;
                }
                subs = GetCourseSubmissions(username, courseID);
            }
            else
            {
                if (zfile != "")
                {
                    backdesc += new Assignments(m_ident).GetInfo(asstID).Description;
                }
                subs = GetAsstSubmissions(username, asstID);
            }

            foreach (Components.Submission sub in subs)
            {
                fs.ExportData(username, sub.LocationID, extsink, true);
            }

            //If we are doing this not in a batch
            if (zfile != "")
            {
                extsink.CloseSink();
            }

            //Log backup in database
            if (zfile != "")
            {
                new Backups(Globals.CurrentIdentity).Create(
                    backdesc, wzfile, courseID);
            }

            return(zfile);
        }
Example #2
0
        public string Backup(string username, int courseID, int asstID, IExternalSink extsink)
        {
            string zfile, wzfile, backdesc=username+": ";
            //Create our external sink file
            if (extsink == null) {
                extsink = ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink;
                zfile = username+DateTime.Now.Hour+DateTime.Now.Minute+DateTime.Now.Second+".zip";
                wzfile = Globals.BackupDirectoryName + "/" + zfile;
                zfile = Path.Combine(Globals.BackupDirectory, zfile);
                extsink.CreateSink(zfile);
            }
            else {
                wzfile = zfile = ""; // In the middle of a backup
            }
            //Backup Results

            //Back up submissions
            FileSystem fs = new FileSystem(m_ident);
            Components.Submission.SubmissionList subs;
            if (asstID < 0) {
                if (zfile != "")
                    backdesc += (new Courses(m_ident).GetInfo(courseID)).Name;
                subs = GetCourseSubmissions(username, courseID);
            }
            else {
                if (zfile != "")
                    backdesc += new Assignments(m_ident).GetInfo(asstID).Description;
                subs = GetAsstSubmissions(username, asstID);
            }

            foreach (Components.Submission sub in subs)
                fs.ExportData(username, sub.LocationID, extsink, true);

            //If we are doing this not in a batch
            if (zfile != "") extsink.CloseSink();

            //Log backup in database
            if (zfile != "") new Backups(Globals.CurrentIdentity).Create(
                                 backdesc, wzfile, courseID);

            return zfile;
        }
Example #3
0
        public string Backup(int asstID)
        {
            string zfile, wzfile;

            Assignment asst = GetInfo(asstID);

            //Check permission
            Authorize(asst.CourseID, "createbackup", asstID, null);

            //Create our external sink file
            IExternalSink extsink =
                ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink;

            zfile = Globals.PurifyString(asst.Description) +
                    DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip";
            wzfile = Globals.BackupDirectoryName + "/" + zfile;
            zfile  = Path.Combine(Globals.BackupDirectory, zfile);
            extsink.CreateSink(zfile);

            //Backup Info
            //Backup Results

            //Back up submissions
            Users users = new Users(m_ident);

            User.UserList mems = new Courses(m_ident).GetMembers(asst.CourseID, null);

            foreach (User mem in mems)
            {
                users.Backup(mem.UserName, asst.CourseID, asstID, extsink);
            }

            extsink.CloseSink();

            new Backups(m_ident).Create(asst.Description, wzfile, asst.CourseID);

            return(zfile);
        }
Example #4
0
        public string Backup(int courseID)
        {
            string zfile, wzfile;

            Authorize(courseID, Permission.COURSE, "createback", courseID, null);

            //Create our external sink file
            IExternalSink extsink =
                ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink;
            Course course = GetInfo(courseID);

            zfile  = course.Name + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".zip";
            wzfile = Globals.BackupDirectoryName + "/" + zfile;
            zfile  = Path.Combine(Globals.BackupDirectory, zfile);
            extsink.CreateSink(zfile);

            //Backup Info
            //Backup Results

            //Back up submissions
            Users users = new Users(m_ident);

            User.UserList mems = GetMembers(courseID, null);

            foreach (User mem in mems)
            {
                users.Backup(mem.UserName, courseID, extsink);
            }

            extsink.CloseSink();

            //Log in database
            new Backups(m_ident).Create(GetInfo(courseID).Name, wzfile, courseID);

            return(zfile);
        }