Example #1
0
 public void CommitData(CFile file)
 {
     FileStream efile = File.Open(Path.Combine(m_localpath, file.ID.ToString()), FileMode.Create);
     efile.Write(file.RawData, 0, file.RawData.Length);
     efile.Flush();
     efile.Close();
 }
Example #2
0
        public void CopyFile(CFile dest, CFile src)
        {
            string dpath = Path.Combine(m_localpath, dest.ID.ToString());
            string spath = Path.Combine(m_localpath, src.ID.ToString());

            File.Copy(spath, dpath, true);
        }
Example #3
0
 public void FetchData(CFile file)
 {
     FileStream efile = File.Open(Path.Combine(m_localpath, file.ID.ToString()), FileMode.Open);
     file.RawData =
         Globals.ReadStream(efile, (int) efile.Length);
     efile.Close();
 }
Example #4
0
        private byte[] GetDirectoryData(CFile dir)
        {
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);

            //Create our external sink (gonna be an archive, so safe cast)
            IMemorySink extsink =
                ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IMemorySink;
            extsink.CreateSink(null);

            //Export data
            fs.ExportData("", dir, extsink, false);
            byte[] data = extsink.GetSinkData();
            extsink.CloseSink();

            return data;
        }
 public string GetFileImage(CFile file)
 {
     if (file.IsDirectory())
         return "../../" + GetFolderIcon(file);
     else {
         ;
         string imgpath;
         try {
             imgpath = FileBrowserImageFactory.GetInstance().GetExtensionImage(
                 Path.GetExtension(file.Name));
         } catch (Exception) {
             imgpath=null;
         }
         if (imgpath == null)
             return "../../attributes/filebrowser/misc.gif";
         else
             return "../../attributes/filebrowser/" + imgpath;
     }
 }
Example #6
0
        public void CreateFile(CFile file)
        {
            SqlConnection myConnection = new SqlConnection(Globals.DataConnectionString);
            SqlCommand myCommand =
                new SqlCommand("INSERT INTO FileData (fileID, data) VALUES (@FileID, @Data)",
                myConnection);

            SqlParameter parameter = new SqlParameter("@FileID", SqlDbType.Int, 4);
            parameter.Value = file.ID;
            myCommand.Parameters.Add(parameter);
            byte[] blank = new byte[1];
            blank[0] = 0x0;
            parameter = new SqlParameter("@Data", SqlDbType.Image, 1);
            parameter.Value = blank;
            myCommand.Parameters.Add(parameter);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }
Example #7
0
        public void CopyFile(CFile dest, CFile src)
        {
            FetchData(src);

            SqlConnection myConnection = new SqlConnection(Globals.DataConnectionString);
            SqlCommand myCommand =
                new SqlCommand("UPDATE FileData SET data=@Data WHERE fileID = @FileID",
                myConnection);

            SqlParameter parameter = new SqlParameter("@FileID", SqlDbType.Int, 4);
            parameter.Value = dest.ID;
            myCommand.Parameters.Add(parameter);
            parameter = new SqlParameter("@Data", SqlDbType.Image);
            parameter.Value = src.RawData;
            myCommand.Parameters.Add(parameter);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }
Example #8
0
        /// <summary>
        /// Commit data for a file object
        /// </summary>
        public void CommitData(CFile file)
        {
            SqlConnection myConnection = new SqlConnection(Globals.DataConnectionString);
            SqlCommand myCommand =
                new SqlCommand("ipbased.fd_UpdateFileData", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter parameter = new SqlParameter("@FileID", SqlDbType.Int, 4);
            parameter.Value = file.ID;
            myCommand.Parameters.Add(parameter);
            parameter = new SqlParameter("@FileData", SqlDbType.Image, file.RawData.Length);
            parameter.Value = file.RawData;
            myCommand.Parameters.Add(parameter);
            parameter = new SqlParameter("@Size", SqlDbType.Int, 4);
            parameter.Value = file.Size;
            myCommand.Parameters.Add(parameter);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }
Example #9
0
        public void LoadFile(CFile file)
        {
            try {
                m_formatter =
                    CodeFormatterFactory.GetInstance().CreateCodeFormatter(Path.GetExtension(file.Name));
            } catch (Exception) {
                m_formatter = new JavaCodeFormatter();
            }

            CodeFormatterInit finit = new CodeFormatterInit();
            finit.KeywordColor = "#000088";
            finit.CommentColor = "#008800";

            new FileSystem(Globals.CurrentIdentity).LoadFileData(file);
            m_formatter.Init(finit);
            m_formatter.InitLineFormat(new String(file.Data));
            txtData.Text = new String(file.Data);

            LoadComments(file);

            ViewState["fileid"] = file.ID;
            BindData();
        }
Example #10
0
 public void CreateFile(CFile file)
 {
     File.Create(Path.Combine(m_localpath, file.ID.ToString())).Close();
 }
Example #11
0
        /// <summary>
        /// Fetch the data for a file object
        /// </summary>
        public void FetchData(CFile file)
        {
            SqlConnection myConnection = new SqlConnection(Globals.DataConnectionString);
            SqlCommand myCommand =
                new SqlCommand("SELECT data FROM FileData WHERE fileID = @FileID", myConnection);

            SqlParameter parameter = new SqlParameter("@FileID", SqlDbType.Int, 4);
            parameter.Value = file.ID;
            myCommand.Parameters.Add(parameter);

            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            if (!reader.Read()) throw new Exception("File Not Found!");

            byte[] data = (byte[]) reader["data"];
            file.RawData = data;

            reader.Close();
            myConnection.Close();
        }
Example #12
0
 private bool CheckLock(CFile file)
 {
     if (new FileSystem(Globals.CurrentIdentity).IsLocked(file)) {
         DisplayLockInfo(file);
         return false;
     } else {
         imgLock.Visible = cmdUnlock.Visible = lblLockInfo.Visible = false;
         return true;
     }
 }
Example #13
0
        private void DisplayLockInfo(CFile file)
        {
            CFileLock flock = new FileSystem(Globals.CurrentIdentity).GetLockInfo(file);

            lblLockInfo.Text = "File Locked: <b>User: </b>" + flock.UserName +
                " <b>Since:</b> " + flock.Creation;

            imgLock.Visible = true;
            lblLockInfo.Visible = true;
            cmdUnlock.Visible = true;
        }
 public void LoadFile(CFile file)
 {
     new FileSystem(Globals.CurrentIdentity).LoadFileData(file);
     ViewState["fileid"] = file.ID;
     txtData.Text = new String(file.Data);
 }
Example #15
0
        private void LoadComments(CFile file)
        {
            Result.ResultList cms =
                new Results(Globals.CurrentIdentity).GetFileResults(file.ID);

            m_comments = new Hashtable(); m_linesaffect = new Hashtable();
            foreach (SubjResult res in cms)  {
                SubjResult.SubjResultList ress = (SubjResult.SubjResultList) m_comments[res.Line];
                if (ress == null)
                    m_comments.Add(res.Line, (ress = new SubjResult.SubjResultList()));
                ress.Add(res);
                foreach (int line in res.LinesAffected)
                    if (m_linesaffect[line] == null)
                        m_linesaffect.Add(line, res);
            }
        }
 private TreeNode AddFolderNode(TreeNodeCollection par, CFile dir)
 {
     return AddNode(par, dir.Alias, "attributes/folder.gif", "attributes/folderopen.gif",
         "Folder " + dir.ID, true);
 }
Example #17
0
        public void DeleteFile(CFile file)
        {
            SqlConnection myConnection = new SqlConnection(Globals.DataConnectionString);
            SqlCommand myCommand =
                new SqlCommand("DELETE FROM FileData WHERE fileID = @FileID",
                myConnection);

            SqlParameter parameter = new SqlParameter("@FileID", SqlDbType.Int, 4);
            parameter.Value = file.ID;
            myCommand.Parameters.Add(parameter);

            myConnection.Open();
            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }
Example #18
0
 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);
         }
     }
 }
Example #19
0
 private string GetFolderIcon(CFile file)
 {
     if (file.SpecType == CFile.SpecialType.SUBMISSION)
         return "attributes/filebrowser/subfolder.gif";
     else
         return "attributes/filebrowser/folder.gif";
 }
Example #20
0
        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();
        }
Example #21
0
 public void DeleteFile(CFile file)
 {
     File.Delete(Path.Combine(m_localpath, file.ID.ToString()));
 }
 private TreeNode AddDocumentNode(TreeNodeCollection par, CFile doc)
 {
     string img = new FileBrowserPagelet().GetFileImage(doc).Substring(6);
     return AddNode(par, doc.Alias, img, img, "Document " + doc.ID, false);
 }