protected bool cmdDelete_ButtonClick(object sender, EventArgs ev) { FileSystem fs = new FileSystem(Globals.CurrentIdentity); TreeNode destnode; string selstr; CFile.FileList selfiles = GetSelectedFiles(); destnode = tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex); selstr = destnode.GetNodeIndex(); if (selfiles.Count == 0) { DisplayMessage("No files selected to delete. Select files by checking the boxes to their left"); return(false); } try { fs.DeleteFiles(selfiles); } catch (FileOperationException e) { DisplayMessage("Error: " + e.Message); return(false); } UpdateTreeNode(destnode, true); tvFiles.SelectedNodeIndex = selstr; BindFileGrid(); return(true); }
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(); }
/// <summary> /// Copy multiple files into a desintation directory /// </summary> public bool DeleteFiles(CFile.FileList files) { foreach (CFile src in files) { DeleteFile(src); } return(true); }
/// <summary> /// Copy multiple files into a desintation directory /// </summary> public bool MoveFiles(CFile dest, CFile.FileList files, bool overwrite) { foreach (CFile src in files) { MoveFile(dest, src, overwrite); } return(true); }
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); }
/// <summary> /// Copy multiple files into a desintation directory /// </summary> public bool CopyFiles(CFile dest, CFile.FileList files, bool overwrite) { ArrayList flocks = new ArrayList(); foreach (CFile src in files) { CopyFile(dest, src, overwrite); } return(true); }
//Copy CS helper code into autoevaluation zone public void CopySupportFiles(AutoEvaluation eval) { FileSystem fs = new FileSystem(Globals.CurrentIdentity); //Get zone CFile zone = fs.GetFile(eval.ZoneID); //Copy CS program over CFile.FileList dfiles = new CFile.FileList(); dfiles.Add(fs.GetFile(@"c:\system\checkstyle\CheckStyle.class")); dfiles.Add(fs.GetFile(@"c:\system\checkstyle\checksubj.xslt")); fs.CopyFiles(zone, dfiles, true); }
/// <summary> /// Transfer a FS into another compatible FS /// </summary> public void CopyFileSystem(IFileSystemProvider dest) { CFile.FileList files = GetAllFiles(); foreach (CFile file in files) { if (!file.IsDirectory()) { dest.CreateFile(file); LoadFileData(file); dest.CommitData(file); } } }
/// <summary> /// Copy a file into another file /// dest must be a directory /// </summary> public bool MoveFile(CFile dest, CFile src, bool overwrite) { //Destination must be a directory if (!dest.IsDirectory()) { throw new FileOperationException("Destination of a copy must be a directory"); } //Check to make sure one is copying onto themselves if (src.ID == dest.ID) { throw new FileOperationException("Destination and source cannot be the same file: " + src.FullPath); } //Cannot move a readonly file if (src.ReadOnly) { throw new FileOperationException("Cannot move a readonly file"); } //Check to make sure a file is not there with same name CFile.FileList dirlist = m_dp.ListDirectory(dest); foreach (CFile dirmem in dirlist) { if (dirmem.Name == src.Name) { if (!overwrite) { throw new FileOperationException("File with same already exists in destination"); } else { DeleteFile(dirmem); } } } //Update the times PercolateModified(src, DateTime.Now); PercolateModified(dest, DateTime.Now); //Get the user User user = new Users(m_ident).GetInfo(m_ident.Name, null); //Do the copy m_dp.MoveFile(dest, src, user.PrincipalID); return(true); }
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); }
private void AddToTreeNode(TreeNode node, CFile.FileList dirlist) { foreach (CFile file in dirlist) { if (file.IsDirectory()) { TreeNode item = new TreeNode(); item.Text = file.Alias; item.ImageUrl = GetFolderIcon(file); item.ExpandedImageUrl = GetExpandedFolderIcon(file); item.Expandable = ExpandableValue.Always; item.NodeData = file.FullPath; node.Nodes.Add(item); } } }
/// <summary> /// Synchronize the file against the system /// </summary> public bool UpdateFileInfo(CFile file, bool modupdate) { //Authorize if (!Authorize(file, FileAction.WRITE)) { throw new FileOperationException("Permission denied on action: WRITE"); } //Check name if (!ValidateFileName(file.Name)) { throw new FileOperationException("Invalid file name: " + file.Name); } //Rename checks CFile ofile = GetFile(file.ID); if (file.FullPath != ofile.FullPath) { //Dup check if (GetFile(file.FullPath) != null) { throw new FileOperationException("Cannot rename file, one already exists with same name"); } } m_dp.SyncFile(file); if (modupdate) { PercolateModified(file, file.FileModified); } //Rename move if (file.FullPath != ofile.FullPath && file.IsDirectory()) { CFile.FileList dirfiles = ListDirectory(ofile); try { MoveFiles(file, dirfiles, false); } catch (FileOperationException er) { //Undo the rename m_dp.SyncFile(ofile); throw er; } } 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); }
/// <summary> /// Copy a file into another file /// dest must be a directory /// </summary> public bool CopyFile(CFile dest, CFile src, bool overwrite) { //Destination must be a directory if (!dest.IsDirectory()) { throw new FileOperationException("Destination of a copy must be a directory"); } //Check to make sure one is copying onto themselves if (src.ID == dest.ID) { throw new FileOperationException("Destination and source cannot be the same file: " + src.FullPath); } //Check to make sure a file is not there with same name CFile.FileList dirlist = m_dp.ListDirectory(dest); foreach (CFile dirmem in dirlist) { if (dirmem.Name == src.Name) { if (!overwrite) { throw new FileOperationException("File with same already exists in destination"); } else { DeleteFile(dirmem); } } } //Update the times PercolateModified(src, DateTime.Now); PercolateModified(dest, DateTime.Now); //Do the copy m_dp.CopyFile(dest, src, m_user.PrincipalID); CopyFileData("", Path.Combine(dest.FullPath, src.Name), src.FullPath); return(true); }
private void DeleteDirData(CFile dir) { if (dir.IsDirectory()) { CFile.FileList dirlist = ListDirectory(dir); foreach (CFile file in dirlist) { if (file.IsDirectory()) { DeleteDirData(file); } else { DeleteFileData(file); } } } else { DeleteFileData(dir); } }
private bool cmdView_ButtonClick(object sender, EventArgs e) { string script = "<script>", filestr = ""; CFile.FileList selfiles = GetSelectedFiles(); int subID, mainID; if (selfiles.Count == 0) { DisplayMessage("No files selected to delete. Select files by checking the boxes to their left"); return(false); } mainID = selfiles[0].ID; foreach (CFile file in selfiles) { filestr += file.ID + "|"; } if (0 > (subID = GetSubID(tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex)))) { script += @"window.open('Controls/Filesys/viewfile.aspx?FileIDs=" + filestr + @"', '" + mainID + @"', 'width=770, height=580')"; } else { script += @"window.open('Controls/Filesys/viewfile.aspx?SubID=" + subID + "&FileIDs=" + filestr + @"', '" + mainID + @"', 'width=770, height=580')"; } script += "</script>"; Page.RegisterClientScriptBlock("mike", script); return(true); }
private void Page_Load(object sender, System.EventArgs e) { string sfiles = Request.Params["FileIDs"]; CFile.FileList files = GetFiles(sfiles); FileWindow window = new FileWindow(); int i, oldtsindex; imgLock.Visible = false; lblError.Visible = lblCommentError.Visible = false; // Setup events ucRubric.RubricSelect += new RubricViewSelectEventHandler(this.ucRubric_RubricSelect); ucRubric.ResultSelect += new RubricViewSelectResultEventHandler(ucRubric_ResultSelect); //Setup initial window //if (!IsPostBack) { window.Low = 0; window.High = Math.Min(MAXFILES, files.Count); window.FileIDs = new int[files.Count]; window.FilePaths = new string[files.Count]; for (i = 0; i < window.High; i++) { window.FileIDs[i] = files[i].ID; window.FilePaths[i] = files[i].FullPath; } ViewState["window"] = window; //} oldtsindex = tsFiles.SelectedIndex; SetupFileWindow(window); tsFiles.SelectedIndex = oldtsindex; ucRubric.RubricSelect += new RubricViewSelectEventHandler(ucRubric_RubricSelect); if (!IsPostBack && Request.Params["SubID"] != null) { int subID = Convert.ToInt32(Request.Params["SubID"]); ViewState["SubID"] = Convert.ToInt32(Request.Params["SubID"]); mpFiles.Height = Unit.Pixel(325); divGrade.Style["TOP"] = "395px"; divGrade.Visible = true; Components.Submission sub = new Submissions(Globals.CurrentIdentity).GetInfo(subID); Rubric rub = new Assignments(Globals.CurrentIdentity).GetRubric(sub.AsstID); ucRubric.RepressAutos = true; ucRubric.InitRubric(rub, subID, "../../"); ucRubric.Width = "53%"; ucRubric.Height = "180px"; } else if (!IsPostBack) { divGrade.Visible = false; } if (!IsPostBack) { BindData(window); } }
/// <summary> /// Export data to the specified external sink /// </summary> public void ExportData(DataSet expdata, string prefix, CFile dir, IExternalSink extsink, bool exportfp, string relpath) { if (!dir.IsDirectory()) { throw new FileOperationException("Cannot export a single file"); } //Authorize if (!Authorize(dir, FileAction.READ)) { throw new FileOperationException("Permission denied for operation: READ"); } CFile.FileList dirlist = ListDirectory(dir); foreach (CFile file in dirlist) { string epath; if (prefix.Length > 0 && prefix[prefix.Length - 1] != '\\') { prefix += @"\"; } if (exportfp) { epath = prefix + GetExportPath(file); } else { epath = prefix + relpath + file.Name; } DataRow dirrow = expdata.Tables["File"].NewRow(); if (!exportfp) { dirrow["path"] = relpath + file.Name; } else { dirrow["path"] = epath; } ExternalFile extfile = new ExternalFile(); extfile.Path = epath; if (file.IsDirectory()) { dirrow["type"] = "dir"; expdata.Tables["File"].Rows.Add(dirrow); //Create the directory extfile.Directory = true; extsink.PutFile(extfile); ExportData(expdata, prefix, file, extsink, exportfp, relpath + file.Name + @"\"); } else { new FileSystem(m_ident).LoadFileData(file); extfile.Size = file.RawData.Length; extfile.DataStream = new MemoryStream(file.RawData, 0, file.RawData.Length); //File row dirrow["type"] = "file"; expdata.Tables["File"].Rows.Add(dirrow); extsink.PutFile(extfile); } } }