Exemple #1
0
        public string Discover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            //Get Perl
            IExternalTool perl = ExternalToolFactory.GetInstance().CreateExternalTool("Perl",
                "5.0", ExternalToolFactory.VersionCompare.ATLEAST);
            if (perl == null)
                throw new JUnitToolException(
                    "Unable to find Perl v5.0 or later. Please check the installation or contact the administrator");

            //Get all files on the disk
            string tpath = ExportToTemp(eval);

            //Run disco program
            perl.Arguments = "jdisco.pl i";
            perl.Execute(tpath);
            Directory.Delete(tpath, true);

            //Validate XML
            string xmltests = perl.Output;
            XmlWizard xmlwiz = new XmlWizard();
            if (!xmlwiz.ValidateXml(xmltests, Path.Combine(Globals.WWWDirectory, "Xml/testsuite.xsd")))
                throw new JUnitToolException("Invalid JUnit Test Suite. Check to make sure the test suite conforms to FrontDesk standards");

            //Write XML
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile zone = fs.GetFile(eval.ZoneID);
            string tspath = Path.Combine(zone.FullPath, "__testsuite.xml");
            CFile xmldesc = fs.GetFile(tspath);
            if (xmldesc == null)
                xmldesc = fs.CreateFile(tspath, false, null);
            xmldesc.Data = xmltests.ToCharArray();
            fs.Edit(xmldesc);
            fs.Save(xmldesc);

            //Copy disco program over
            CFile.FileList dfiles = new CFile.FileList();
            dfiles.Add(fs.GetFile(@"c:\system\junit\jdisco.pl"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover.class"));
            dfiles.Add(fs.GetFile(@"c:\system\junit\JUnitDiscover$ClassFileFilter.class"));
            fs.CopyFiles(zone, dfiles, true);

            //Get suite metadata
            GetSuiteInfo(xmltests, out points, out time, out count);

            //Punt all previous results
            RemoveResults(eval);

            return xmltests;
        }
        public void LoadFileBrowser()
        {
            int i=0;
            tvFiles.Nodes.Clear();
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            foreach(string droot in m_roots) {
                CFile dirroot = fs.GetFile(droot);

                TreeNode root = new TreeNode();
                root.Text = dirroot.Alias;
                root.ImageUrl = GetFolderIcon(dirroot);
                root.NodeData = dirroot.FullPath;
                root.Expandable = ExpandableValue.Always;
                tvFiles.Nodes.Add(root);

                if (i == 0 && ViewState["gridpath"] == null) {
                    ViewState["gridpath"] = dirroot.FullPath;
                    ExpandTreeNode(root);
                }
                ++i;
            }

            BindFileGrid();
            BindClipBoard();
        }
Exemple #3
0
        public string ReDiscover(AutoEvaluation eval, out double points, out int time, out int count)
        {
            string xmltests;
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            CFile zone = fs.GetFile(eval.ZoneID);
            CFile xmldesc = fs.GetFile(Path.Combine(zone.FullPath, "__testsuite.xml"));
            if (xmldesc == null)
                throw new JUnitToolException("No proper JUnit Test Suite uploaded");

            fs.LoadFileData(xmldesc);
            xmltests = new string(xmldesc.Data);

            GetSuiteInfo(xmltests, out points, out time, out count);

            return xmltests;
        }
        protected void tvFiles_SelectedIndexChange(object sender, TreeViewSelectEventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            TreeNode selnode = tvFiles.GetNodeFromIndex(e.NewNode);
            ViewState["gridpath"] = fs.GetFile(selnode.NodeData).FullPath;

            BindFileGrid();
        }
Exemple #5
0
        protected SubjResult.SubjResultList ParseSubjXmlResults(string xmlresults, Submission sub)
        {
            SubjResult.SubjResultList ress = new SubjResult.SubjResultList();
            XPathNavigator xnav = new XmlWizard().GetXPathNavigator(xmlresults);
            FileSystem fs = new FileSystem(m_ident);
            CFile zone = fs.GetFile(sub.LocationID);

            xnav.MoveToFirstChild(); xnav.MoveToFirstChild();
            XPathNavigator comments = xnav.Clone();
            while (comments.MoveToNext()) {
                SubjResult res = new SubjResult();
                XPathNavigator comment = comments.Clone();
                comment.MoveToFirstChild();

                string subjtype = comment.Value; comment.MoveToNext();
                switch (subjtype) {
                case "Warning":
                    res.SubjType = Rubric.WARNING;
                    break;
                case "Error":
                    res.SubjType = Rubric.ERROR;
                    break;
                case "Good":
                    res.SubjType = Rubric.GOOD;
                    break;
                };

                res.Points = Convert.ToDouble(comment.Value); comment.MoveToNext();
                res.Comment = comment.Value; comment.MoveToNext();

                string filename = comment.Value; comment.MoveToNext();
                if (filename.StartsWith(@".\"))
                    filename = filename.Substring(2, filename.Length-2);
                CFile file = fs.GetFile(Path.Combine(zone.FullPath, filename));
                if (file != null) {
                    res.FileID = file.ID;
                    res.Line = Convert.ToInt32(comment.Value);
                    ress.Add(res);
                }
            }

            return ress;
        }
Exemple #6
0
        /// <summary>
        /// Delete the assignment
        /// </summary>
        public bool Delete(int asstID)
        {
            FileSystem fs = new FileSystem(m_ident);
            Submissions subda = new Submissions(m_ident);
            Evaluations evalda = new Evaluations(m_ident);
            Results resultda = new Results(m_ident);
            Groups groupda = new Groups(m_ident);
            AutoJobs jobda = new AutoJobs(m_ident);

            Assignment asst = GetInfo(asstID);

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

            //Take auto jobs
            IProviderTransaction tran = m_dp.BeginTransaction();
            AutoJob.AutoJobList jobs = GetAutoJobs(asstID, tran);
            foreach (AutoJob job in jobs)
                jobda.Finish(job.ID, tran);
            m_dp.CommitTransaction(tran);

            //Take submissions and results
            Components.Submission.SubmissionList allsubs = GetSubmissions(asstID);
            foreach (Components.Submission sub in allsubs)
                subda.Delete(sub.ID);

            //Take rubric
            Rubric rub = GetRubric(asstID);
            new Rubrics(m_ident).Delete(rub.ID);

            //Take evaluations
            Evaluation.EvaluationList allevals = GetEvals(asstID);
            foreach (Evaluation eval in allevals)
                evalda.Delete(eval.ID);

            //Take groups
            Group.GroupList groups = GetGroups(asstID);
            foreach (Group group in groups)
                groupda.Delete(group.PrincipalID, asstID);

            //Take assignment
            m_dp.DeleteAssignment(asstID);

            //Take content
            CFile content = fs.GetFile(asst.ContentID);
            fs.DeleteFile(content);

            //Log
            Log("Deleted assignment: " + asst.Description, asst.ID);

            return true;
        }
        private bool tb_CreateFolder(object sender, EventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile par = fs.GetFile(GetCurrentFileID());
            string path = par.FullPath + @"\" + "newfolder";

            try {
                CFile fold = fs.CreateDirectory(path, false, null);
                fold.Alias = "New Folder";
                fold.Name = fold.ID + fold.Name;
                fs.UpdateFileInfo(fold, false);
            } catch (FileOperationException er) {
                PageError(er.Message);
                return false;
            }

            TreeNode node = GetCurrentNode();
            LoadNode(node);
            node.Expanded = true;

            return true;
        }
Exemple #8
0
        private void DoDelete(int subID, int locid)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Take results
            Results resultda = new Results(m_ident);
            Result.ResultList ress = GetResults(subID);
            foreach (Result res in ress)
                resultda.Delete(res.ID);

            //Take any tests queued
            AutoJobs jobda = new AutoJobs(m_ident);
            AutoJobTest.AutoJobTestList tests = jobda.GetSubTests(subID);
            foreach (AutoJobTest test in tests)
                jobda.FinishTest(test);

            //Take the submission record
            m_dp.DeleteSubmission(subID);

            //Take the files
            CFile subdir = fs.GetFile(locid);
            if (subdir != null)
                fs.DeleteFile(subdir);
        }
        private void BindData()
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile file = fs.GetFile(GetFileID());

            if (!GetStudentMode()) {
                divPerms.Visible = true;
                ucFilePerms.FileID = file.ID;
                ucFilePerms.BindData();
            } else
                divPerms.Visible = false;

            cmdUpdate.Visible = iDirections.Visible = divUpload.Visible = !GetStudentMode();
            txtName.Text = file.Alias;
            if (file.IsDirectory()) {
                divData.Visible = false;
                txtType.Enabled = false;
                txtType.Text = "Folder";
            }
            else {
                divData.Visible = true;

                txtType.Enabled = true;
                txtType.Text = Path.GetExtension(file.Name);
                txtDesc.Text = file.Description;

                if (txtType.Text == ".url") {
                    fs.LoadFileData(file);
                    string url = new string(file.Data);
                    txtUrl.Text = url;
                    lnkEdit.Attributes.Add("onClick",
                        @"window.open('" + url + "', '"+"Mike"+@"', 'width=800, height=600 " +
                        @", scrollbars=yes, menubar=yes, resizable=yes, status=yes, toolbar=yes')");
                    lnkDownload.Enabled = false;
                    rdbData.Checked = false; rdbLink.Checked = true;
                } else {
                    txtUrl.Text = "";
                    rdbData.Checked = true; rdbLink.Checked = false;
                    lnkEdit.Attributes.Add("onClick",
                        @"window.open('Controls/Filesys/viewfile.aspx?FileID=" + file.ID +
                        @"', '"+file.ID+@"', 'width=770, height=580')");
                    lnkDownload.Attributes.Add("onClick",
                        @"window.open('Controls/Filesys/dlfile.aspx?FileID=" + file.ID +
                        @"', '"+file.ID+@"', 'width=770, height=580')");
                    lnkDownload.Enabled = true;
                }
            }

            txtType.Enabled = txtDesc.Enabled = txtName.Enabled =
                !GetStudentMode();
        }
Exemple #10
0
        private void cmdDataUpload_Click(object sender, EventArgs e)
        {
            if (ufContent.PostedFile.ContentLength > 0) {
                FileSystem fs = new FileSystem(Globals.CurrentIdentity);
                CFile file = fs.GetFile(GetFileID());

                try {
                    fs.Edit(file);

                    byte[] content = Globals.ReadStream(
                        ufContent.PostedFile.InputStream, ufContent.PostedFile.ContentLength);
                    file.RawData = content;
                    fs.Save(file);

                    file.Name = file.ID + Path.GetFileName(ufContent.PostedFile.FileName);
                    fs.UpdateFileInfo(file, false);
                } catch (Exception er) {
                    PageUpError(er.Message);
                }

                if (Refresh != null)
                    Refresh(this, new RefreshEventArgs("", true, false));
            }
            else
                PageUpError("Must specify a local file to upload");

            BindData();
        }
 private CFile.FileList GetFiles(string files)
 {
     string[] tokens = files.Split("|".ToCharArray());
     CFile.FileList flist = new CFile.FileList();
     FileSystem fs = new FileSystem(Globals.CurrentIdentity);
     foreach (string sfile in tokens)
         if (sfile.Length > 0)
             flist.Add(fs.GetFile(Convert.ToInt32(sfile)));
     return flist;
 }
        protected bool cmdPaste_ButtonClick(object sender, EventArgs ea)
        {
            TreeNode destnode;
            ClipBoard cb;
            FileSystem fs;

            cb = (ClipBoard) ViewState["clipboard"];
            if (cb == null) {
                DisplayMessage("Clipboard empty. You must cut/copy files before pasting has an effect");
                return true;
            }

            fs = new FileSystem(Globals.CurrentIdentity);
            destnode = tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex);
            CFile dest = fs.GetFile((string)ViewState["gridpath"]);

            try {
                if (cb.Move)
                    fs.MoveFiles(dest, cb.Files, false);
                else
                    fs.CopyFiles(dest, cb.Files, false);
            }
            catch (FileOperationException e) {
                DisplayMessage(e.Message);
                return false;
            }

            UpdateTreeNode(destnode, true);
            BindFileGrid();
            ViewState["clipboard"] = null;
            BindClipBoard();

            return true;
        }
Exemple #13
0
        protected bool CreateZone(IZoneComponent eval)
        {
            FileSystem fs = new FileSystem(m_ident);
            DataSet desc = new DataSet();

            //Create initial zone directory
            string zpath = Path.Combine(TestConfig.LocalZonePath,
                m_prefix + eval.GetZoneID().ToString());
            Directory.CreateDirectory(zpath);

            //Export the zone files into local store
            IExternalSink zdir = new OSFileSystemSink();

            zdir.CreateSink("");
            try {
                desc = fs.ExportData(zpath, fs.GetFile(eval.GetZoneID()), zdir, false);

                //Write XML descriptor
                desc.Tables["Export"].Rows[0]["Mod"] = eval.GetZoneModified().Ticks;
                desc.WriteXml(Path.Combine(zpath, ZONE_FILE));
                m_logger.Log("Zone retrieved successfully");

            } catch (FileOperationException e) {
                m_logger.Log("File error: " + e.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (DataAccessException er) {
                m_logger.Log("Data error: " + er.Message, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            } catch (Exception e) {
                m_logger.Log("Unexpected error: " + e.Message, TestLogger.LogType.ERROR);
                m_logger.Log("Trace: " + e.StackTrace, TestLogger.LogType.ERROR);
                zdir.CloseSink();
                return false;
            }

            return true;
        }
        private void LoadFolderNode(TreeNode par, int fileID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            par.Nodes.Clear();
            CFile.FileList cdir;

            try {
                cdir = fs.ListDirectory(fs.GetFile(fileID));
            } catch (CustomException er) {
                PageError(er.Message); return;
            }

            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }
        }
        private void LoadCourseNode(TreeNode par, int courseID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            Courses courseda = new Courses(Globals.CurrentIdentity);
            Course course = courseda.GetInfo(courseID);

            par.Nodes.Clear();
            //Load announcement folder
            if (!StudentMode)
                AddAnnFolderNode(par.Nodes, courseID);

            //Load content
            CFile.FileList cdir = fs.ListDirectory(fs.GetFile(course.ContentID));
            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }

            //Load assignments
            Assignment.AssignmentList assts;
            if (StudentMode)
                assts = courseda.GetStudentAssignments(courseID);
            else
                assts = courseda.GetAssignments(courseID);
            foreach (Assignment asst in assts)
                AddAsstNode(par.Nodes, asst);

            //Add section folder
            if (!StudentMode) {
                AddBackupsNode(par.Nodes, courseID);
                AddSectionFolderNode(par.Nodes, courseID, "Users and Sections");
                AddPermNode(par.Nodes, courseID);
            }
        }
        private void LoadAsstNode(TreeNode par, int asstID)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            Assignments asstda = new Assignments(Globals.CurrentIdentity);
            Assignment asst = asstda.GetInfo(asstID);

            //Load content
            par.Nodes.Clear();
            CFile.FileList cdir = fs.ListDirectory(fs.GetFile(asst.ContentID));
            foreach (CFile file in cdir) {
                if (file.IsDirectory())
                    AddFolderNode(par.Nodes, file);
                else
                    AddDocumentNode(par.Nodes, file);
            }

            if (StudentMode) {
                AddSubFolderNode(par.Nodes, asstID);
                AddGroupFolderNode(par.Nodes, asstID);
                AddCompetitionNode(par.Nodes, asstID);
                AddResFolderNode(par.Nodes, asstID);
            }
            else {
                //Load rubric
                Rubric rub = asstda.GetRubric(asstID);
                AddRubricNode(par.Nodes, rub);

                AddFeedbackNode(par.Nodes, asstID);
                AddAutoSysNode(par.Nodes, asstID);

                AddSectionFolderNode(par.Nodes, asst.CourseID, "Users and Sections");

                AddPermNode(par.Nodes, asstID);
            }
        }
        private bool tb_Delete(object sender, EventArgs e)
        {
            TreeNode node;
            int ty = GetNodeType(node = GetCurrentNode());

            switch (ty) {
            case USER:
                try {
                    new Courses(Globals.CurrentIdentity).RemoveUser(
                        node.NodeData.Split(" ".ToCharArray())[1], GetCourseID());
                } catch (DataAccessException er) {
                    PageError(er.Message);
                } catch (FileOperationException er) {
                    PageError(er.Message);
                }
                break;
            case USERSUB:
                try {
                    int subID = Convert.ToInt32(node.NodeData.Split(" ".ToCharArray())[2]);
                    new Submissions(Globals.CurrentIdentity).Delete(subID);
                } catch (DataAccessException er) {
                    PageError(er.Message);
                } catch (FileOperationException er) {
                    PageError(er.Message);
                }
                break;
            case ASSIGNMENT:
                try {
                    new Assignments(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
                } catch (DataAccessException er) {
                    PageError(er.Message);
                } catch (FileOperationException er) {
                    PageError(er.Message);
                }
                break;
            case ANNOUNCEMENT:
                try {
                    new Announcements(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
                } catch (DataAccessException er) {
                    PageError(er.Message);
                }
                break;
            case SECTION:
                try {
                    new Sections(Globals.CurrentIdentity).Delete(GetNodeIndex(node));
                } catch (DataAccessException er) {
                    PageError(er.Message);
                }
                break;
            case HEADING:
            case CANNED:
            case AUTOMATIC:
                Rubric rub = new Rubrics(Globals.CurrentIdentity).GetInfo(GetNodeIndex(node));
                if (rub.ParentID < 0)
                    PageError("Cannot delete the root rubric");
                else {
                    try {
                        new Rubrics(Globals.CurrentIdentity).Delete(rub.ID);
                    } catch (DataAccessException er) {
                        PageError(er.Message);
                    } catch (FileOperationException er) {
                        PageError(er.Message);
                    }
                }
                break;
            case FOLDER:
            case DOCUMENT:
                FileSystem fs = new FileSystem(Globals.CurrentIdentity);
                CFile file = fs.GetFile(GetNodeIndex(node));

                try {
                    fs.DeleteFile(file);
                } catch (DataAccessException er) {
                    PageError(er.Message);
                } catch (FileOperationException er) {
                    PageError(er.Message);
                }
                break;
            }

            LoadNode((TreeNode)node.Parent);
            ActivateNodeView((TreeNode)node.Parent);

            return true;
        }
Exemple #18
0
        private string ExportToTemp(AutoEvaluation eval)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            string tpath = Path.Combine(Globals.TempDirectory, Globals.CurrentUserName);
            try { Directory.Delete(tpath); } catch (Exception) { }
            Directory.CreateDirectory(tpath);

            IExternalSink tsink = new OSFileSystemSink();
            tsink.CreateSink("");

            //Export eval files (JUnit test suite)
            try {
                fs.ExportData(tpath, fs.GetFile(eval.ZoneID), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            //Export jdisco program
            try {
                fs.ExportData(tpath, fs.GetFile(@"c:\system\junit"), tsink, false);
            } catch (Exception er) {
                string mike = er.Message;
            }

            return tpath;
        }
        protected void UpdateTreeNode(TreeNode node, bool fullreload)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile dir;

            dir = fs.GetFile(node.NodeData);
            if (fullreload) node.Nodes.Clear();
            if (node.Nodes.Count == 0) {

                CFile.FileList dirlist;
                try {
                    dirlist = fs.ListDirectory(dir);
                } catch (CustomException er) {
                    DisplayMessage(er.Message); return;
                }

                if (dirlist.Count > 0)
                    AddToTreeNode(node, dirlist);
            }
        }
        private void BindData(FileWindow window)
        {
            IFileViewer viewer;
            int curfile = tsFiles.SelectedIndex;
            int i;
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            for (i = window.Low; i < window.High; i++) {
                CFile file = fs.GetFile(window.FileIDs[i]);
                viewer = m_viewers[i-window.Low];

                if (viewer != null)
                    viewer.LoadFile(file);
            }

            viewer = GetCurrentViewer();
            cmdEdit.Enabled = (viewer.Editable);
        }
        private void BindFileGrid()
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            string path = GetCurrentPath();
            if (path == null) return;

            CFile file = fs.GetFile(path);
            CFile.FileList dirlist;
            try {
                dirlist = fs.ListDirectory(file);
            } catch (CustomException er) {
                dirlist = new CFile.FileList();
                DisplayMessage(er.Message);
            }

            dirlist.Insert(0, file);

            m_curdir = file;
            dgFiles.DataSource = dirlist;
            dgFiles.DataBind();
        }
Exemple #22
0
        private void cmdUrlUpload_Click(object sender, System.EventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile file = fs.GetFile(GetFileID());

            try {
                //Save Url data
                fs.Edit(file);
                file.Data = txtUrl.Text.ToCharArray();
                fs.Save(file);
                //Update file
                file.Name = file.ID + ".url";
                fs.UpdateFileInfo(file, false);
            } catch (Exception er) {
                PageLinkError(er.Message);
            }

            BindData();

            if (Refresh != null)
                Refresh(this, new RefreshEventArgs("", true, false));
        }
        private void dgFiles_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            TextBox txtName = e.Item.FindControl("txtName") as TextBox;

            int fileID = (int) dgFiles.DataKeys[e.Item.ItemIndex];
            CFile file = fs.GetFile(fileID);

            if (file.Alias == file.Name)
                file.Name = txtName.Text;
            file.Alias = txtName.Text;

            try {
                fs.UpdateFileInfo(file, false);
            } catch (FileOperationException er) {
                DisplayMessage(er.Message);
            }

            dgFiles.EditItemIndex = -1;
            UpdateTreeNode(tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex), true);
            BindFileGrid();
        }
Exemple #24
0
        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                      sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                        sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");
            if (null == subdir)
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile esubdir;
            string zpath = @"c:\subs\" + sub.ID;
            if (null == (esubdir = fs.GetFile(zpath))) {
                esubdir = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                    name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);

            //Load files
            try {
                fs.ImportData(zpath, files, false, false); //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                    "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            else if (unmarkcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            else if (defunct)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);

            return true;
        }
 private CFile.FileList GetSelectedFiles()
 {
     FileSystem fs = new FileSystem(Globals.CurrentIdentity);
     CheckBox chkSelect;
     CFile.FileList selfiles = new CFile.FileList();
     foreach (DataGridItem item in dgFiles.Items) {
         if (null != (chkSelect = (CheckBox)item.FindControl("chkSelect")))
             if (chkSelect.Checked)
                 selfiles.Add(fs.GetFile((int)dgFiles.DataKeys[item.ItemIndex]));
     }
     return selfiles;
 }
Exemple #26
0
        private void VerifyFormat(int asstID, string zpath)
        {
            FileSystem fs = new FileSystem(m_ident);

            DataSet zonedesc = new DataSet();
            string xmlString = new Assignments(m_ident).GetInfo(asstID).Format;
            if (xmlString == null || xmlString.Length == 0)
                return;
            MemoryStream memstream =
                new MemoryStream(System.Text.Encoding.ASCII.GetBytes(xmlString));
            zonedesc.ReadXml(memstream);
            DataTable inodes = zonedesc.Tables["File"];

            foreach (DataRow row in inodes.Rows){
                string name = (string)row["name"];
                if (name != ".")
                    if (null == fs.GetFile(Path.Combine(zpath, name.Substring(2))))
                        throw new DataAccessException("Error: Your archive was missing the file: "+ name + " that is required by this assignment. You must resubmit with the correct files.");
            }
        }
        private bool tb_CreateDocument(object sender, EventArgs e)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            CFile par = fs.GetFile(GetCurrentFileID());
            string path = par.FullPath + @"\" + "newdoc.txt";

            try {
                CFile doc = fs.CreateFile(path, false, null);
                doc.Alias = "New Document";
                doc.Name = doc.ID + doc.Name;
                fs.UpdateFileInfo(doc, false);
            } catch (FileOperationException er) {
                PageError(er.Message);
                return false;
            }

            TreeNode node = GetCurrentNode();
            LoadNode(node);
            node.Expanded = true;

            return true;
        }