-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKeyword.cs
109 lines (99 loc) · 3.69 KB
/
Keyword.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace RustyLogic.RedDotNet
{
public class Keyword : RedDotObject
{
private string _value;
public string Value
{
get { return _value; }
set { _value = value; }
}
protected Keyword(XmlNode xmlNode) : base(xmlNode) { }
protected Keyword(Guid guid) : base(guid) { }
protected override void LoadBasics(XmlNode xmlNode)
{
_value = xmlNode.Attributes.GetNamedItem("value").Value;
}
protected override XmlNode LoadXml()
{
throw new Exception("The method or operation is not implemented.");
}
public static List<Keyword> List()
{
List<Keyword> keywords = new List<Keyword>();
string rqlStatement =
"<IODATA>" +
"<PROJECT>" +
"<CATEGORY>" +
"<KEYWORDS action=\"list\" />" +
"</CATEGORY>" +
"</PROJECT>" +
"</IODATA>";
xmlDoc.LoadXml(Session.Execute(rqlStatement));
XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("KEYWORD");
foreach (XmlNode xmlNode in xmlNodes)
{
keywords.Add(new Keyword(xmlNode));
}
return keywords;
}
internal static List<Keyword> Get(Category category)
{
List<Keyword> keywords = new List<Keyword>();
string rqlStatement =
"<IODATA>" +
"<PROJECT>" +
"<CATEGORY guid=\"" + category.GuidString + "\">" +
"<KEYWORDS action=\"load\" />" +
"</CATEGORY>" +
"</PROJECT>" +
"</IODATA>";
xmlDoc.LoadXml(Session.Execute(rqlStatement));
XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("KEYWORD");
foreach (XmlNode xmlNode in xmlNodes)
{
keywords.Add(new Keyword(xmlNode));
}
return keywords;
}
internal static List<Keyword> Get(Page page)
{
var keywords = new List<Keyword>();
var rqlStatement =
"<IODATA>" +
"<PROJECT>" +
"<PAGE guid=\"" + page.GuidString + "\">" +
"<KEYWORDS action=\"load\" />" +
"</PAGE>" +
"</PROJECT>" +
"</IODATA>";
xmlDoc.LoadXml(Session.Execute(rqlStatement));
XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("KEYWORD");
foreach (XmlNode xmlNode in xmlNodes)
{
keywords.Add(new Keyword(xmlNode));
}
return keywords;
}
internal void UnlinkKeyword(Page page)
{
var rqlXml = new XmlDocument();
var ioDataElement = rqlXml.CreateElement("IODATA");
var projectElement = rqlXml.CreateElement("PROJECT");
var pageElement = rqlXml.CreateElement("PAGE");
var keywordElement = rqlXml.CreateElement("KEYWORD");
pageElement.SetAttribute("action", "unlink");
pageElement.SetAttribute("guid", page.GuidString);
keywordElement.SetAttribute("guid", GuidString);
rqlXml.AppendChild(ioDataElement);
ioDataElement.AppendChild(projectElement);
projectElement.AppendChild(pageElement);
pageElement.AppendChild(keywordElement);
Session.Execute(rqlXml, Session.Info.SessionKey);
}
}
}