private void GetFileAttributes(XmlNode xmlNode, String fileName) { DataSet dataSet = new DataSet(); try { dataSet.ReadXml(_directoryInfo.FullName + "\\data\\gallery.xml"); if (dataSet.Tables["file"] != null) { DataRow[] dataRows = dataSet.Tables["file"].Select("name='" + fileName + "'"); if (dataRows.Length != 0) { CommonXml.SetAttributeValue(xmlNode, "title", dataRows[0]["title"].ToString()); CommonXml.SetAttributeValue(xmlNode, "description", dataRows[0]["description"].ToString()); } } } catch { dataSet = null; } finally { if (dataSet != null) { dataSet.Dispose(); } } }
private void RenameInTree(Page page, string name, string pageName) { name = Common.CleanToSafeString(name); XmlNode newTreeNode = _treeDocument.CreateElement(name); XmlNode parentNode = page.TreeNode.ParentNode; string newPageidentifier = string.Empty; if (parentNode != null) { newPageidentifier = parentNode.Name; } // Copy children and attributes newTreeNode.InnerXml = page.TreeNode.InnerXml; CommonXml.CopyAttributes(page.TreeNode, newTreeNode); CommonXml.SetAttributeValue(newTreeNode, "name", name); CommonXml.SetAttributeValue(newTreeNode, "pagename", pageName); CommonXml.SetAttributeValue(newTreeNode, "pageidentifier", newPageidentifier + "/" + name); // Replace old node with new if (parentNode != null) { parentNode.ReplaceChild(newTreeNode, page.TreeNode); } }
public void GetXml(XmlNode xmlNode, SubFolder subFolder) { XmlNode folderNode = CommonXml.GetNode(xmlNode, "folder", EmptyNodeHandling.ForceCreateNew); CommonXml.SetAttributeValue(folderNode, "name", Name); foreach (FileInfo fileInfo in _directoryInfo.GetFiles()) { XmlNode fileNode = CommonXml.GetNode(folderNode, "file", EmptyNodeHandling.ForceCreateNew); CommonXml.SetAttributeValue(fileNode, "name", fileInfo.Name); CommonXml.SetAttributeValue(fileNode, "extension", fileInfo.Extension); GetFileAttributes(fileNode, fileInfo.Name); } if (subFolder == SubFolder.IncludeSubfolders) { foreach (DirectoryInfo directoryInfo in _directoryInfo.GetDirectories()) { if (Filter(directoryInfo.Name)) { FolderElement folderElement = new FolderElement(directoryInfo.FullName); folderElement.GetXml(folderNode, SubFolder.IncludeSubfolders); } } } }
public void AddMessage(string message, MessageType messageType, string type) { XmlNode xmlNode = CommonXml.GetNode(XmlData.DocumentElement, "messages", EmptyNodeHandling.CreateNew); xmlNode = CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew); xmlNode.InnerText = message; CommonXml.SetAttributeValue(xmlNode, "messagetype", messageType.ToString()); CommonXml.SetAttributeValue(xmlNode, "type", type); }
private void HandleAttributeChange(string name, string value) { switch (name) { case "name": _siteTree.Rename(this, value); break; default: CommonXml.SetAttributeValue(_treeNode, name, value); break; } }
public string this[string name] { get { string attribute = CommonXml.GetAttributeValue(_xmlNode, name); return(attribute); } set { CommonXml.SetAttributeValue(_xmlNode, name, value); } }
/// <summary> /// Loads the folder. /// </summary> /// <param name="value">The value.</param> /// <param name="control">The control.</param> private void LoadFolder(string value, ControlList control) { if (!string.IsNullOrEmpty(value)) { string path = value; if (Tree.FolderExists(path)) { FolderElement folderElement = Tree.GetFolder(path); XmlNode xmlNode = control["folder"]; folderElement.GetXml(xmlNode, SubFolder.OnlyThisFolder); CommonXml.SetAttributeValue(xmlNode, "path", path); } } }
private void HandleLog() { XmlNode messagesNode = CommonXml.GetNode(Process.XmlData, "messages", EmptyNodeHandling.Ignore); if (messagesNode == null) { return; } String logFileName = Process.Settings["errorlog/logpath"]; XmlNodeList items = messagesNode.SelectNodes("item"); if (items != null) { foreach (XmlNode item in items) { bool writtenToLogFile = false; try { if (CommonXml.GetAttributeValue(item, "writtenToLogFile") == "true") { writtenToLogFile = true; } } catch { writtenToLogFile = false; } if (writtenToLogFile) { continue; } if (CommonXml.GetAttributeValue(item, "messagetype") != "Error") { continue; } String errorType = CommonXml.GetAttributeValue(item, "type"); String message = item.InnerText; File.AppendAllText(logFileName, String.Format("{0};{1};{2}\r\n", DateTime.Now.ToUniversalTime(), errorType, message)); CommonXml.SetAttributeValue(item, "writtenToLogFile", "true"); } } }
/// <summary> /// Rebuilds this instance. /// </summary> private void Rebuild() { XmlNodeList xmlNodeList = TreeDocument.SelectNodes("//*[@pageidentifier and not(@pageidentifier = '')]"); if (xmlNodeList != null) { foreach (XmlNode pageNode in xmlNodeList) { string path = CommonXml.GetXPath(pageNode); Page page = GetPage(path); page["pageidentifier"] = path; SavePage(page, false); CommonXml.SetAttributeValue(pageNode, "pageidentifier", path); } } }
private void AddMessage(String message, MessageType messageType, String type) { XmlNode xmlNode = CommonXml.GetNode(XmlData.DocumentElement, "messages", EmptyNodeHandling.CreateNew); xmlNode = CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew); xmlNode.InnerText = message; CommonXml.SetAttributeValue(xmlNode, "messagetype", messageType.ToString()); CommonXml.SetAttributeValue(xmlNode, "type", type); IPlugin plugin = Plugins["ErrorLog"]; if (plugin != null) { plugin.Handle("log"); } }
/// <summary> /// Loads the file. /// </summary> /// <param name="value">The value.</param> /// <param name="control">The control.</param> private void LoadFile(string value, ControlList control) { if (!string.IsNullOrEmpty(value)) { string path = value; if (Tree.FileExists(path)) { XmlNode xmlNode = control["file"]; string extension = Path.GetExtension(path); CommonXml.SetAttributeValue(xmlNode, "extension", extension); string mainMimeType = Common.GetMainMimeType(extension); CommonXml.SetAttributeValue(xmlNode, "mainmimetype", mainMimeType); CommonXml.SetAttributeValue(xmlNode, "path", path); } } }
/// <summary> /// Sets the current page. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <param name="pathArray">The path.</param> private static void SetCurrentPage(XmlNode xmlNode, String[] pathArray) { try { XmlNode currentNode = xmlNode; for (int i = 0; i < pathArray.Length; i++) { String path = pathArray[i]; currentNode = CommonXml.GetNode(currentNode, path, EmptyNodeHandling.Ignore); CommonXml.SetAttributeValue(currentNode, "inpath", "true"); if (i + 1 == pathArray.Length) { CommonXml.SetAttributeValue(currentNode, "currentpage", "true"); } } } catch { } }