private void ProcessFolder(int iFolder) { string name = ""; string folder = ""; for (int i = 0; i < _Level; i++) { name += " "; } _Level++; bool fl = false; if (fs.CanUserWrite(iFolder)) { if (iFolder == fs.Root.Id) { name += LocRM.GetString("tRoot"); } else { name += fs.GetDirectory(iFolder).Name; } folder = iFolder.ToString(); fl = true; } else { if (iFolder == fs.Root.Id) { name += LocRM.GetString("tRoot"); } else { name += fs.GetDirectory(iFolder).Name; } folder = "*" + iFolder.ToString(); } System.IO.StringWriter writer = new System.IO.StringWriter(); Server.HtmlDecode(name, writer); string decoded = writer.ToString(); ListItem item = new ListItem(decoded, folder); if (!fl) { item.Attributes.Add("style", "COLOR: gray;"); } ddFolder.Items.Add(item); DirectoryInfo[] _di = fs.GetDirectories(iFolder); foreach (DirectoryInfo di in _di) { ProcessFolder(di.Id); _Level--; } }
private void ProcessFolderNode(TreeViewNode CurTreeNode, string ContainerKey, int iFolder, string RootName, bool RenderRoot) { string name = ""; string folder = ""; bool isRoot = false; if (iFolder == fs.Root.Id) { name += RootName; isRoot = true; } else { name += fs.GetDirectory(iFolder).Name; } folder = iFolder.ToString(); bool fl = fs.CanUserWrite(iFolder); DirectoryInfo[] _di = fs.GetDirectories(iFolder); System.IO.StringWriter writer = new System.IO.StringWriter(); Server.HtmlDecode(name, writer); string decoded = writer.ToString(); TreeViewNode childNode; if (isRoot && !RenderRoot) { childNode = CurTreeNode; } else { childNode = new TreeViewNode(); childNode.Text = decoded; } if (iFolder == DisFolderId) { childNode.Selectable = false; childNode.CssClass = "TreeNodeGray"; childNode.HoverCssClass = "TreeNodeGray"; } if (fl) { childNode.ClientSideCommand = "_dtSV('" + decoded + "','" + ContainerKey + "','" + folder + "');"; } else { childNode.Selectable = false; childNode.CssClass = "TreeNodeGray"; childNode.HoverCssClass = "TreeNodeGray"; } if (Mediachase.IBN.Business.Common.IsPop3Folder(iFolder)) { //childNode.ImageUrl="../layouts/images/folder2.gif"; childNode.ImageUrl = "../layouts/images/folder_mailbox.gif"; } if (ContainerKey == txtContainerKey.Value && iFolder.ToString() == txtFolderId.Value) { TreeView1.SelectedNode = childNode; } foreach (DirectoryInfo di in _di) { ProcessFolderNode(childNode, ContainerKey, di.Id, RootName, true); } if (!(isRoot && !RenderRoot)) { CurTreeNode.Nodes.Add(childNode); } }
private void BindStorage() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Id", typeof(int))); dt.Columns.Add(new DataColumn("Weight", typeof(int))); //0- Root, 1- Folder, 2-File dt.Columns.Add(new DataColumn("Icon", typeof(string))); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("sortName", typeof(string))); DataRow dr; CS.DirectoryInfo diCur = fs.GetDirectory(FolderId); if (diCur.ParentDirectoryId > 0) { dr = dt.NewRow(); dr["Id"] = diCur.Id; dr["Weight"] = 0; dr["Icon"] = ResolveUrl("~/layouts/images/blank.gif"); dr["Name"] = String.Format("<a href='{0}'>{1}</a>", GetCurrentLink(diCur.ParentDirectoryId), "[..]"); dr["sortName"] = ""; dt.Rows.Add(dr); } if (fs.CanUserRead(diCur.Id)) { CS.DirectoryInfo[] _di = fs.GetDirectories(FolderId); bool CanWrite = fs.CanUserWrite(diCur.Id); foreach (CS.DirectoryInfo di in _di) { if (!fs.CanUserRead(di.Id)) { continue; } dr = dt.NewRow(); dr["Id"] = di.Id; dr["Weight"] = 1; if (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id)) { dr["Icon"] = ResolveUrl("~/layouts/images/folder_mailbox.gif"); } else { dr["Icon"] = ResolveUrl("~/layouts/images/FileTypes/Folder.gif"); } dr["Name"] = String.Format("<a href='{0}' title='{2}'>{1}</a>", GetCurrentLink(di.Id), (di.Name.Length > 40) ? di.Name.Substring(0, 37) + "..." : di.Name, di.Name); dr["sortName"] = di.Name; dt.Rows.Add(dr); } CS.FileInfo[] _fi = fs.GetFiles(FolderId); foreach (CS.FileInfo fi in _fi) { dr = dt.NewRow(); dr["Id"] = fi.Id; dr["Weight"] = 2; dr["Icon"] = ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId); dr["Name"] = Util.CommonHelper.GetShortFileName(fi.Name, 40); dr["sortName"] = fi.Name; dt.Rows.Add(dr); } } DataView dv = dt.DefaultView; dv.Sort = "Weight, " + pc["fs_Sort1_" + ContainerKey].ToString(); int i = 4; grdMain.Columns[i++].HeaderText = LocRM.GetString("DocTitle"); if (pc["fs_PageSize1_" + ContainerKey] == null) { pc["fs_PageSize1_" + ContainerKey] = "10"; } grdMain.PageSize = int.Parse(pc["fs_PageSize1_" + ContainerKey].ToString()); if (pc["fs_Page1_" + ContainerKey] == null) { pc["fs_Page1_" + ContainerKey] = "0"; } int PageIndex = int.Parse(pc["fs_Page1_" + ContainerKey].ToString()); int ppi = dv.Count / grdMain.PageSize; if (dv.Count % grdMain.PageSize == 0) { ppi = ppi - 1; } if (PageIndex <= ppi) { grdMain.CurrentPageIndex = PageIndex; } else { grdMain.CurrentPageIndex = 0; pc["fs_Page1_" + ContainerKey] = "0"; } grdMain.DataSource = dv; grdMain.DataBind(); /*foreach (DataGridItem dgi in grdMain.Items) * { * }*/ }
private void BindNode(string nodeId, ArrayList parentList) { List <JsonTreeNode> nodes = new List <JsonTreeNode>(); string containerName = Request["ContainerName"]; string containerKey = Request["ContainerKey"]; Mediachase.IBN.Business.ControlSystem.FileStorage fs = Mediachase.IBN.Business.ControlSystem.FileStorage.Create(containerName, containerKey); DirectoryInfo diCur = fs.GetDirectory(int.Parse(nodeId)); if (!fs.CanUserRead(diCur)) { WriteArray(String.Empty); } else { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Id", typeof(string))); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("Count", typeof(int))); DataRow dr; DirectoryInfo[] dMas = fs.GetDirectories(int.Parse(nodeId)); foreach (DirectoryInfo di in dMas) { if (!fs.CanUserRead(di)) { continue; } dr = dt.NewRow(); dr["Id"] = di.Id.ToString(); dr["Name"] = di.Name; int count = 0; DirectoryInfo[] check = fs.GetDirectories(di.Id); foreach (DirectoryInfo dIn in check) { if (fs.CanUserRead(dIn)) { count++; } } dr["Count"] = count; dt.Rows.Add(dr); } DataView dv = dt.DefaultView; dv.Sort = "Name"; foreach (DataRowView drv in dv) { JsonTreeNode node = new JsonTreeNode(); node.leaf = ((int)drv["Count"] == 0); node.cls = "nodeCls"; node.iconCls = "iconStdCls"; node.icon = ResolveClientUrl("~/layouts/images/folder.gif"); node.text = drv["Name"].ToString(); node.id = Guid.NewGuid().ToString("N"); node.itemid = drv["Id"].ToString(); if (parentList.Contains(int.Parse(drv["Id"].ToString()))) { node.expanded = true; BindRecursive(node, parentList); } else { node.expanded = false; } Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("ContainerKey", containerKey); param.Add("FolderId", drv["Id"].ToString()); string cmd = CommandManager.GetCommandString("FL_ChangeFolderTree", param); cmd = cmd.Replace("\"", """); node.href = String.Format("javascript:{0}", cmd); //node.href = ResolveClientUrl("~/Apps/FileLibrary/Pages/FileStorage.aspx?FolderId=" + di.Id); //node.hrefTarget = "right"; nodes.Add(node); } WriteArray(nodes); } }
private DataTable BindStorage() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(string))); dt.Columns.Add(new DataColumn("Id", typeof(int))); dt.Columns.Add(new DataColumn("Weight", typeof(int))); //0- Root, 1- Folder, 2-File dt.Columns.Add(new DataColumn("Icon", typeof(string))); dt.Columns.Add(new DataColumn("BigIcon", typeof(string))); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("sortName", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("ModifiedDate", typeof(string))); dt.Columns.Add(new DataColumn("sortModified", typeof(DateTime))); dt.Columns.Add(new DataColumn("Modifier", typeof(string))); dt.Columns.Add(new DataColumn("sortModifier", typeof(string))); dt.Columns.Add(new DataColumn("Size", typeof(string))); dt.Columns.Add(new DataColumn("sortSize", typeof(int))); DataRow dr; DirectoryInfo diCur = _fs.GetDirectory(_folderId); if (diCur.ParentDirectoryId > 0) { #region Parent Directory dr = dt.NewRow(); dr["Id"] = diCur.Id; dr["Weight"] = 0; dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString()); dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/blank.gif")); dr["BigIcon"] = ""; if (_pc["fs_ViewStyle"] == "Thumbnails") { dr["BigIcon"] = String.Format("<a href=\"{0}\"><img src='{1}' align='absmiddle' border='0' /></a>", GetCurrentLink(diCur.ParentDirectoryId), ResolveClientUrl("/layouts/images/back-up.gif")); } dr["Name"] = String.Format("<a href=\"{0}\">{1}</a>", GetCurrentLink(diCur.ParentDirectoryId), "[..]"); dr["sortName"] = ""; dr["sortSize"] = 0; dt.Rows.Add(dr); #endregion } bool isExternal = Mediachase.IBN.Business.Security.CurrentUser.IsExternal; if (_fs.CanUserRead(diCur.Id)) { DirectoryInfo[] dMas = _fs.GetDirectories(_folderId); bool canWrite = _fs.CanUserWrite(diCur.Id); foreach (DirectoryInfo di in dMas) { #region Children Directories if (!_fs.CanUserRead(di.Id)) { continue; } dr = dt.NewRow(); dr["Id"] = di.Id; dr["Weight"] = 1; dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString()); if (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id)) { dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/folder_mailbox.gif")); } else { dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/FileTypes/Folder.gif")); } dr["BigIcon"] = ""; if (_pc["fs_ViewStyle"] == "Thumbnails") { dr["BigIcon"] = String.Format("<a href=\"{0}\"><img src='{1}' align='absmiddle' border='0' /></a>", GetCurrentLink(di.Id), (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id)) ? ResolveClientUrl("~/layouts/images/mailfolder.gif") : ResolveClientUrl("~/layouts/images/folder1.gif")); dr["Name"] = String.Format("<a href=\"{0}\" title='{2}'>{1}</a>", GetCurrentLink(di.Id), (di.Name.Length > 27) ? di.Name.Substring(0, 24) + "..." : di.Name, di.Name ); } else { dr["Name"] = String.Format("<a href=\"{0}\" title='{2}'>{1}</a>", GetCurrentLink(di.Id), (di.Name.Length > 40) ? di.Name.Substring(0, 37) + "..." : di.Name, di.Name); } dr["sortName"] = di.Name; dr["ModifiedDate"] = di.Modified.ToShortDateString(); dr["sortModified"] = di.Modified; dr["Modifier"] = CommonHelper.GetUserStatus(di.ModifierId); dr["sortModifier"] = CommonHelper.GetUserStatusPureName(di.ModifierId); dr["sortSize"] = 0; dt.Rows.Add(dr); #endregion } FileInfo[] fMas = _fs.GetFiles(_folderId); foreach (FileInfo fi in fMas) { #region Children Files dr = dt.NewRow(); dr["Id"] = fi.Id; dr["Weight"] = 2; dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString()); dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId)); dr["BigIcon"] = ""; string sLink = ""; if (fi.FileBinaryContentType.ToLower().IndexOf("url") >= 0) { sLink = CommonHelper.GetLinkText(_fs, fi); } if (sLink == "") { sLink = CommonHelper.GetAbsoluteDownloadFilePath(fi.Id, fi.Name, _containerName, _containerKey); } string sNameLocked = CommonHelper.GetLockerText(sLink); if (_pc["fs_ViewStyle"] == "Thumbnails") { dr["BigIcon"] = String.Format("<a href=\"{0}\"{2}>{1}</a>", sLink, String.Format("<img src='{0}' align='absmiddle' border='0' />", String.Format(ResolveClientUrl("~/Common/ContentIcon.aspx?Big=1&IconID={0}&ContainerKey={1}&FileId={2}"), fi.FileBinaryContentTypeId, _containerKey, fi.Id)), Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "" ); dr["Name"] = String.Format("<a href=\"{0}\" title='{3}'{2}>{1}</a> {4}", sLink, CommonHelper.GetShortFileName(fi.Name, 27), Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "", fi.Name, sNameLocked ); } else { dr["Name"] = String.Format("<a href='{0}' title='{3}'{2}>{1}</a> {4}", sLink, CommonHelper.GetShortFileName(fi.Name, 40), Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "", fi.Name, sNameLocked ); } dr["sortName"] = fi.Name; dr["Description"] = fi.Description; dr["ModifiedDate"] = fi.Modified.ToShortDateString(); dr["sortModified"] = fi.Modified; dr["Modifier"] = CommonHelper.GetUserStatus(fi.ModifierId); dr["sortModifier"] = CommonHelper.GetUserStatusPureName(fi.ModifierId); dr["Size"] = FormatBytes((long)fi.Length); dr["sortSize"] = fi.Length; dt.Rows.Add(dr); #endregion } } return(dt); }