protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oPage = new Pages(intProfile, dsn); oUser = new Users(intProfile, dsn); oCustomized = new Customized(intProfile, dsn); oVariable = new Variables(intEnvironment); oFunction = new Functions(0, dsn, intEnvironment); string strNavigation = ""; if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "") { intApplication = Int32.Parse(Request.QueryString["applicationid"]); } if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "") { intPage = Int32.Parse(Request.QueryString["pageid"]); } if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "") { intApplication = Int32.Parse(Request.Cookies["application"].Value); } //Menus int intMenuTab = 0; if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "") { intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]); } //Tab oTab = new Tab("", intMenuTab, "divMenu1", true, false); Tab oTab = new Tab(hdnType.ClientID, intMenuTab, "divMenu1", true, false); oTab.AddTab(""" + oUser.GetFullName(intProfile) + "" Documents", ""); oTab.AddTab("Documents Shared by Other Users", ""); strMenuTab1 = oTab.GetTabs(); //End Menus lblTitle.Text = oPage.Get(intPage, "title"); strRedirect = oPage.GetFullLink(intPage); if (lblCurrent.Text == "") { lblCurrent.Text = oVariable.DocumentsFolder() + "user\\" + intProfile.ToString(); if (!Directory.Exists(lblCurrent.Text)) { DirectoryInfo drinfo = new DirectoryInfo(lblCurrent.Text); drinfo.Create(); drinfo.LastAccessTime = DateTime.Now; drinfo.LastWriteTime = DateTime.Now; } } strHome = lblCurrent.Text; strDirectory = strHome; if (strFolder == string.Empty) { strFolder = "\\"; } if (!Page.IsPostBack) { if (Request.QueryString["folder"] != null && Request.QueryString["folder"] != "") { string strFolderTemp = Request.QueryString["folder"]; if (!strFolderTemp.StartsWith("\\")) { strFolderTemp = "\\" + strFolderTemp; } if (Directory.Exists(strHome + strFolderTemp) == true) { strFolder = strFolderTemp; strDirectory = strHome + strFolderTemp; } } dir_info = new DirectoryInfo(strDirectory); if (dir_info.Parent.Parent.Name != "documents") { string strNav = strFolder; while (strNav != "") { strNavigation = " / <a class=\"breadcrumb\" href=\"" + strRedirect + "?folder=" + Server.UrlEncode(strNav) + "\">" + strNav.Substring(strNav.LastIndexOf("\\") + 1) + "</a>" + strNavigation; strNav = strNav.Substring(0, strNav.LastIndexOf("\\")); } strRedirect = oPage.GetFullLink(intPage) + "?folder=" + strFolder.Substring(0, strFolder.LastIndexOf("\\")); strFolder = "<a href=\"" + strRedirect + "\">" + strFolder.Substring(0, strFolder.LastIndexOf("\\")) + "</a>" + strFolder.Substring(strFolder.LastIndexOf("\\")); } DataSet ds = oCustomized.GetDocumentRepositoryUser(intProfile, intApplication, strDirectory); DataView dv = ds.Tables[0].DefaultView; if (Request.QueryString["sort"] != null && Request.QueryString["sort"] != "") { if (Request.QueryString["sort"].ToLower().Contains("desc")) { dv.Sort = "type desc," + Request.QueryString["sort"]; } else { dv.Sort = "type," + Request.QueryString["sort"]; } } else { dv.Sort = "type desc"; } rptDocs.DataSource = dv; rptDocs.DataBind(); lblNoDocs.Visible = rptDocs.Items.Count == 0; DataSet dsOthers = oCustomized.GetDocumentRepositorySharesByUser(intProfile); dsOthers.Relations.Add("relationship", dsOthers.Tables[0].Columns["userid"], dsOthers.Tables[1].Columns["ownerid"], false); DataView dvOthers = dsOthers.Tables[0].DefaultView; rptOthers.DataSource = dvOthers; rptOthers.DataBind(); lblNoShares.Visible = rptOthers.Items.Count == 0; foreach (RepeaterItem ri in rptDocs.Items) { LinkButton btnName = (LinkButton)ri.FindControl("btnName"); Label lblType = (Label)ri.FindControl("lblType"); Label lblDeleted = (Label)ri.FindControl("lblDeleted"); Label lblId = (Label)ri.FindControl("lblId"); Label lblSize = (Label)ri.FindControl("lblSize"); ImageButton imgDelete = (ImageButton)ri.FindControl("imgDelete"); ImageButton imgRename = (ImageButton)ri.FindControl("imgRename"); ImageButton imgShare = (ImageButton)ri.FindControl("imgShare"); imgRename.Attributes.Add("onclick", "return OpenWindow('DOCUMENT_REPOSITORY_RENAME','?id=" + lblId.Text + "');"); imgShare.Attributes.Add("onclick", "return OpenWindow('DOCUMENT_REPOSITORY_SHARE','?id=" + imgShare.CommandArgument + "');"); imgDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this " + (lblType.Text.ToLower() != "folder" ? "File" : lblType.Text) + " ?');"); if (!FileExists(btnName.CommandArgument, lblType.Text)) { btnName.Text = btnName.Text + " (Not Found)"; btnName.Enabled = false; imgRename.Visible = false; imgShare.Visible = false; } else { if (lblType.Text.ToLower() != "folder") { btnName.Text = "<a href=\"" + oVariable.URL() + "/frame/document_repository_permissions.aspx?docid=" + oFunction.encryptQueryString(lblId.Text) + "\" target=\"_blank\">" + btnName.Text + "</a>"; //btnName.Text = "<a href=\"" + btnName.CommandArgument + "\" target=\"_blank\">" + btnName.Text + "</a>"; int intSize = Int32.Parse(lblSize.Text); decimal decSize = intSize / 1024; if (decSize > 1024) { lblSize.Text = (Decimal.Round((decSize / 1024), 1)).ToString() + " MB"; } else { lblSize.Text = (Decimal.Round(decSize, 0)).ToString() + " KB"; } } else { imgShare.Visible = false; } } } foreach (RepeaterItem riOther in rptOthers.Items) { Repeater rptShared = (Repeater)riOther.FindControl("rptShared"); foreach (RepeaterItem ri in rptShared.Items) { LinkButton btnName = (LinkButton)ri.FindControl("btnName"); Label lblType = (Label)ri.FindControl("lblType"); Label lblId = (Label)ri.FindControl("lblId"); Label lblOwnerId = (Label)ri.FindControl("lblOwnerId"); Label lblDeleted = (Label)ri.FindControl("lblDeleted"); Label lblSize = (Label)ri.FindControl("lblSize"); if (!FileExists(btnName.CommandArgument, lblType.Text)) { btnName.Text = btnName.Text + " (Not Found)"; btnName.Enabled = false; } else { if (lblType.Text.ToLower() != "folder") { btnName.Text = "<a href=\"" + oVariable.URL() + "/frame/document_repository_permissions.aspx?docid=" + oFunction.encryptQueryString(lblId.Text) + "\" target=\"_blank\">" + btnName.Text + "</a>"; int intSize = Int32.Parse(lblSize.Text); decimal decSize = intSize / 1024; if (decSize > 1024) { lblSize.Text = (Decimal.Round((decSize / 1024), 1)).ToString() + " MB"; } else { lblSize.Text = (Decimal.Round(decSize, 0)).ToString() + " KB"; } } } } } lblTitle.Text = oPage.Get(intPage, "title"); lblFolder.Text = strFolder != "" ? "<a class=\"breadcrumb\" href=\"" + oPage.GetFullLink(intPage) + "\">Home</a>" + strNavigation : "<a class=\"breadcrumb\" href=\"" + oPage.GetFullLink(intPage) + "\">Home</a>"; hdnDir.Value = dir_info.FullName; btnCreate.Attributes.Add("onclick", "return ValidateText('" + txtDirectory.ClientID + "','Please enter a name for the new directory') && ValidateDirName('" + txtDirectory.ClientID + "') && ProcessButton(this);"); btnUpload.Attributes.Add("onclick", "return ProcessButton(this);"); txtDirectory.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnCreate.ClientID + "').click();return false;}} else {return true}; "); } }