17 using System.Collections.Generic;
18 using System.Globalization;
21 using erminas.SmartAPI.CMS.Project.ContentClasses;
22 using erminas.SmartAPI.CMS.Project.Workflows;
23 using erminas.SmartAPI.CMS.ServerManagement;
24 using erminas.SmartAPI.Utils;
26 namespace erminas.SmartAPI.CMS.Project.Pages
30 string Category {
get;
set; }
32 DateTime CreatedFrom {
get;
set; }
33 DateTime CreatedTo {
get;
set; }
34 IEnumerable<IPage> Execute();
35 string Headline {
get;
set; }
36 bool IsMatchingHeadlineExactly {
get;
set; }
37 bool IsMatchingKeywordExactly {
get;
set; }
38 string Keyword {
get;
set; }
39 int MaxRecords {
get;
set; }
40 int PageIdFrom {
get;
set; }
41 int PageIdTo {
get;
set; }
44 string Text {
get;
set; }
45 bool TextExact {
get;
set; }
48 internal class PageSearch : IPageSearch
50 private const int DEFAULT_MAX_RECORDS = 20000;
53 internal PageSearch(
IProject project)
59 public string Category {
get;
set; }
61 public DateTime CreatedFrom {
get;
set; }
63 public DateTime CreatedTo {
get;
set; }
65 public IEnumerable<IPage> Execute()
67 var rqlXml =
new XmlDocument();
68 XmlElement pageElement = rqlXml.CreateElement(
"PAGE");
69 pageElement.SetAttribute(
"action",
"search");
70 pageElement.SetAttribute(
"flags", ((
int)
PageType).ToString(CultureInfo.InvariantCulture));
71 pageElement.SetAttribute(
"maxrecords", MaxRecords.ToString(CultureInfo.InvariantCulture));
74 pageElement.SetAttribute(
"headline", Headline);
75 pageElement.SetAttribute(
"headlinelike", IsMatchingHeadlineExactly ?
"0" :
"-1");
79 pageElement.SetAttribute(
"section", Category);
83 pageElement.SetAttribute(
"keyword", Keyword);
84 pageElement.SetAttribute(
"keywordlike", IsMatchingKeywordExactly ?
"0" :
"-1");
88 pageElement.SetAttribute(
"searchtext", Text);
92 pageElement.SetAttribute(
"pageidfrom", PageIdFrom.ToString(CultureInfo.InvariantCulture));
96 pageElement.SetAttribute(
"pageidto", PageIdTo.ToString(CultureInfo.InvariantCulture));
98 if (CreatedTo != DateTime.MinValue)
100 pageElement.SetAttribute(
"createdateto", (CreatedTo.ToOADate()).ToString(CultureInfo.InvariantCulture));
102 if (CreatedFrom != DateTime.MinValue)
104 pageElement.SetAttribute(
"createdatefrom",
105 (CreatedFrom.ToOADate()).ToString(CultureInfo.InvariantCulture));
107 if (ContentClass != null)
109 pageElement.SetAttribute(
"templateguid", ContentClass.Guid.ToRQLString());
112 XmlDocument xmlDoc = _project.ExecuteRQL(pageElement.OuterXml);
114 return (from XmlElement curNode in xmlDoc.GetElementsByTagName(
"PAGE")
115 let nodeWithLanguageVariantId = AddLanguageVariantId(curNode)
116 select new Page(_project, nodeWithLanguageVariantId)).ToList();
119 public
string Headline {
get;
set; }
121 public bool IsMatchingHeadlineExactly {
get;
set; }
123 public bool IsMatchingKeywordExactly {
get;
set; }
124 public string Keyword {
get;
set; }
125 public int MaxRecords {
get;
set; }
127 public int PageIdFrom {
get;
set; }
129 public int PageIdTo {
get;
set; }
130 public PageType PageType {
get;
set; }
132 public IProject Project
134 get {
return _project; }
137 public ISession Session
139 get {
return _project.Session; }
142 public void SetDefaults()
144 PageType = PageType.All;
149 IsMatchingKeywordExactly =
true;
151 IsMatchingHeadlineExactly =
true;
152 MaxRecords = DEFAULT_MAX_RECORDS;
155 CreatedFrom = DateTime.MinValue;
156 CreatedTo = DateTime.MinValue;
160 public string Text {
get;
set; }
162 public bool TextExact {
get;
set; }
164 private XmlElement AddLanguageVariantId(XmlElement curNode)
166 curNode.SetAttributeValue(
"languagevariantid", _project.LanguageVariants.Current.Abbreviation);
193 public Result(
IPage page, DateTime creationDate,
IUser originalAuthor, DateTime dateOfLastChange,
197 CreationDate = creationDate;
198 OriginalAuthor = originalAuthor;
199 DateOfLastChange = dateOfLastChange;
200 LastEditor = lastEditor;
201 ContentClass = contentClass;
204 public DateTime ReleaseDate {
get;
set; }
210 #region Rejection enum
214 NoReleaseReactionDefined = 0,
216 ToPreviousReleaseLevel = 8,
217 ToAnEligibleLevel = 16,
218 SelectionOfReleaseLevelByRejectingUser = 32
223 #region RejectionSkippableType enum
228 RejectionCannotBeSkipped = 0,
229 RejectionCanBeSkipped = 1
234 #region ReleaseType enum
238 NoWorkflowReactionSet = 0,
239 PageWaitingForReleaseOrPageWasRejected = 1155,
240 WebComplianceManagerRejectedAutomatically = 1156
248 public readonly IEnumerable<INote>
Notes;
259 IEnumerable<INote> notes)
262 ReleaseName = releaseName;
263 RejectionType = rejectionType;
264 WorkflowReactionTypeResponsibleForRejection = workflowReactionTypeResponsibleForRejection;
265 RejectionSkippability = rejectionSkippability;
266 EscalationTimeoutInHours = escalationTimeoutInHours;
269 IsEscalationProcedureSet = EscalationTimeoutInHours > 0;
270 switch (rejectionSkippability)
273 IsRejectionSkippable = null;
276 IsRejectionSkippable =
false;
279 IsRejectionSkippable =
true;
282 throw new ArgumentException(
"Unknown rejection skippability type");
291 public readonly IEnumerable<IIUserInfo>
Users;
293 public ReleaseInfo(
int assentCount,
int requiredAssentCount, IEnumerable<IIUserInfo> users)
295 AssentCount = assentCount;
296 RequiredAssentCount = requiredAssentCount;
302 bool HasUserReleasedPage {
get; }
303 DateTime PageReleaseDate {
get; }
307 internal class UserInfo : IIUserInfo
309 public UserInfo(
IProject project, XmlElement user)
311 User =
new User(project.
Session, user.GetGuid()) {Name = user.GetName()};
312 HasUserReleasedPage = user.GetIntAttributeValue(
"released").GetValueOrDefault() == 1;
313 PageReleaseDate = user.GetOADate().GetValueOrDefault();
316 public bool HasUserReleasedPage {
get;
private set; }
317 public DateTime PageReleaseDate {
get;
private set; }
318 public IUser User {
get;
private set; }