Пример #1
0
        private void loadFolders(TreeNode tn)
        {
            User u = NUSNetUser();
            if (u == null)
            {
                return;
            }
            ArtefactClient arclient = new ArtefactClient();
            List<WorkspaceFolders> WrkSpace = arclient.GetWorkSpaceFolders(NUSNetUser(), EventID()).ToList<WorkspaceFolders>();
            arclient.Close();
            if (WrkSpace == null || WrkSpace.Count() == 0)
            {
                return;
            }

            foreach (WorkspaceFolders folder in WrkSpace)
            {
                TreeNode childNode = new TreeNode(folder.FolderName.ToString());
                childNode.ImageUrl = "~/images/folder.gif";
                childNode.ToolTip = folder.FolderDescription.ToString().Trim();
                tn.ChildNodes.Add(childNode);
            }
        }
Пример #2
0
        private void lvlFolderSelected(TreeNode tn)
        {
            ArtefactClient client = new ArtefactClient();
            WorkspaceFolders wrkSpaceFolder = client.GetWorkSpaceFolder(NUSNetUser(), EventID(), tn.Value);
            client.Close();
            hidFolder.Value = tn.Value;

            txtfolderName.Text = tn.Value.Trim();
            txtfolderName.ReadOnly = true;
            txtfolderDesc.Text = wrkSpaceFolder.FolderDescription.Trim();
        }
Пример #3
0
        protected void btnAddFile_Click(object sender, EventArgs e)
        {
            lblMsg.Text = "";

            if (lblSelectedFolder.Text.Trim() != "-")
            {
                if (gvFiles.SelectedIndex < 0)
                {
                    if (!fuFileUpload.HasFile && txtFileURLExt.Text.Trim().Length == 0)
                    {
                        lblMsg.Text = "Please attach your file or specify the file name in the external url text field.";
                        return;
                    }
                    else if (fuFileUpload.HasFile && txtFileURLExt.Text.Trim().Length > 0)
                    {
                        lblMsg.Text = "Please only attach your file OR specify the file name in your external url, not both.";
                        return;
                    }
                }
            }
            else
            {
                lblMsg.Text = "You Cannot Upload file at root Folder!";
                return;
            }

            if (fuFileUpload.HasFile)
            {
                int filesz = fuFileUpload.PostedFile.ContentLength / 1024;
                if (filesz > 10240)
                {
                    lblMsg.Text = "File Size cannot exceed 10MB!";
                    return;
                }
            }

            string filename = null;
            string fileurl = "";

            if (fuFileUpload.HasFile)
            {
                filename = fuFileUpload.FileName.Replace(" ", "_");
            }
            else
            {
                fileurl = txtFileURLExt.Text.Trim();
                filename = fileurl.Substring(fileurl.LastIndexOf("/") + 1);
            }

            if (filename.Length > 250)
            {
                lblMsg.Text = "File Name cannot exceed 250 character!";
                return;
            }

            ArtefactClient arClient = new ArtefactClient();
            try
            {
                if (hidFile.Value == "")
                {
                    //Upload New file
                    arClient.UploadFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), filename, txtFileDesc.Text.Trim(), fileurl);

                    if (fuFileUpload.HasFile)
                    {
                        UploadFile(filename);
                    }

                    loadFiles(lblSelectedFolder.Text.Trim());
                    lblMsg.Text = "Upload Success";
                }
                else
                {
                    WorkspaceFiles wrkFile = arClient.GetWorkSpaceFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), hidFile.Value);

                    arClient.UpdateFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), hidFile.Value, txtFileDesc.Text.Trim(), fileurl);
                    lblMsg.Text = "Update Success";

                }

                txtFileDesc.Text = "";
                txtFileURLExt.Text = "";
                loadFiles(lblSelectedFolder.Text.Trim());
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
                if (hidFile.Value == "")
                    lblMsg.Text = "Upload Failed";
                else
                    lblMsg.Text = "Update Failed";
            }
            finally
            {
                arClient.Close();
            }
        }
Пример #4
0
 private void loadFiles(string folderName = "-")
 {
     ArtefactClient arclient = new ArtefactClient();
     List<WorkspaceFiles> WrkSpaceFile = arclient.GetWorkSpaceFiles(NUSNetUser(), EventID(), folderName).ToList<WorkspaceFiles>();
     arclient.Close();
     gvFiles.DataSource = WrkSpaceFile;
     gvFiles.DataBind();
 }
Пример #5
0
        protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                int index = int.Parse(e.CommandArgument.ToString());

                string fileID = ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text.Replace(" ", "%20");

                string filepath = workSpaceDir(lblSelectedFolder.Text.Trim()) + "\\" + ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text;
                ArtefactClient arClient = new ArtefactClient();
                try
                {
                    arClient.DeleteFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID);

                    if (filepath.Contains("\\WorkSpace\\"))
                    {
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }

                    lblMsg.Text = "File Successfully removed!";
                    loadFiles(lblSelectedFolder.Text.Trim());
                }
                catch (Exception ex)
                {
                    Alert.Show(ex.ToString());
                    lblMsg.Text = "File Failed to remove!";
                }
                finally
                {
                    arClient.Close();
                }

                //loadFiles(classId, folderID);
            }
        }
Пример #6
0
        protected void btnDeleteFolder_Click(object sender, EventArgs e)
        {
            //string classid = txtClassCode.Text.Trim();
            string folderid = hidFolder.Value.Trim();

            if (folderid.Trim().Length == 0)
            {
                lblMsg.Text = "Please select a folder";
                return;
            }

            ArtefactClient arClient = new ArtefactClient();
            try
            {
                arClient.DeleteFolder(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim());
                string dir = workSpaceDir(lblSelectedFolder.Text.Trim());
                DeleteDirectory(dir);
                loadTreeView();
                btnResetFolder_Click(sender, e);
                //Alert.Show("Folder Deleted Successfully!");
                lblMsg.Text = "Folder Deleted Successfully!";
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
                lblMsg.Text = "Folder Failed to Delete!";
            }
            finally
            {
                arClient.Close();
            }
        }
Пример #7
0
        protected void btnAddFolder_Click(object sender, EventArgs e)
        {
            ArtefactClient arClient = new ArtefactClient();
            try
            {
                string foldercode = txtfolderName.Text.ToString().Trim().Replace(" ", "_");

                if (lblSelectedFolder.Text.Trim() != "-")
                {
                    arClient.UpdateFolder(NUSNetUser(), EventID(), foldercode, txtfolderDesc.Text.Trim(), "");
                    Alert.Show("Folder updated Successfully!");
                }
                else
                {
                    //juz add new folder
                    arClient.CreateFolder(NUSNetUser(), EventID(), foldercode, txtfolderDesc.Text.Trim(), "");
                    CreateFolder(foldercode);
                    loadTreeView();
                    Alert.Show("Folder created!");
                }

                btnResetFolder_Click(sender, e);
            }
            catch (Exception ex)
            {
                Alert.Show(ex.ToString());
                lblMsg.Text = "Folder failed to create!";
                //throw;
            }
            finally
            {
                arClient.Close();
            }
        }
Пример #8
0
        private void loadFolders(TreeNode tn)
        {
            User u = NUSNetUser();
            if (u == null)
            {
                return;
            }
            ArtefactClient arclient = new ArtefactClient();
            List<WorkspaceFolders> WrkSpace = null;
            try
            {
                WrkSpace = arclient.GetWorkSpaceFolders(NUSNetUser(), EventID()).ToList<WorkspaceFolders>();
            }
            catch (Exception)
            {
                arclient.Close();
                Alert.Show("You are not authorized to view this workspace!", true, "SelectEventWorkspace.aspx");
                return;
                //throw;
            }

            if (WrkSpace == null || WrkSpace.Count() == 0)
            {
                return;
            }

            foreach (WorkspaceFolders folder in WrkSpace)
            {
                TreeNode childNode = new TreeNode(folder.FolderName.ToString());
                childNode.ImageUrl = "~/images/folder.gif";
                childNode.ToolTip = folder.FolderDescription.ToString().Trim();
                tn.ChildNodes.Add(childNode);
            }
        }
Пример #9
0
        protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                int index = int.Parse(e.CommandArgument.ToString());

                string fileID = ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text.Replace(" ", "%20");

                string filepath = workSpaceDir(lblSelectedFolder.Text.Trim()) + "\\" + ((Label)gvFiles.Rows[index].Cells[2].FindControl("lblFileName")).Text;
                ArtefactClient arClient = new ArtefactClient();
                try
                {
                    WorkspaceFiles wrkFile = arClient.GetWorkSpaceFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID);

                    if (wrkFile.UploadedBy == NUSNetUser().UserID)
                    {
                        arClient.DeleteFile(NUSNetUser(), EventID(), lblSelectedFolder.Text.Trim(), fileID);

                        if (filepath.Contains("\\WorkSpace\\"))
                        {
                            if (System.IO.File.Exists(filepath))
                            {
                                System.IO.File.Delete(filepath);
                            }
                        }
                        lblMsg.Text = "File Successfully removed!";
                        txtFileDesc.Text = "";
                        txtFileURLExt.Text = "";
                        loadFiles(lblSelectedFolder.Text.Trim());
                    }
                    else
                    {
                        lblMsg.Text = "You can only delete what is belong to you!";
                    }
                }
                catch (Exception)
                {
                    lblMsg.Text = "File Failed to remove!";
                }
                finally
                {
                    arClient.Close();
                }

                //loadFiles(classId, folderID);
            }
        }