SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
ILinkingAndAppearance.cs
Go to the documentation of this file.
1 // SmartAPI - .Net programmatic access to RedDot servers
2 //
3 // Copyright (C) 2013 erminas GbR
4 //
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free Software Foundation,
7 // either version 3 of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 // See the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program.
14 // If not, see <http://www.gnu.org/licenses/>.
15 
16 using System;
17 using System.Xml;
18 using erminas.SmartAPI.CMS.Project.Pages.Elements;
19 using erminas.SmartAPI.Utils;
20 
21 namespace erminas.SmartAPI.CMS.Project.Pages
22 {
23  internal class LinkingAndAppearance : ILinkingAndAppearance
24  {
25  internal LinkingAndAppearance(IPage page, XmlElement element)
26  {
27  Page = page;
28  LoadXml(element);
29  }
30 
31  public DateTime AppearenceEnd { get; private set; }
32  public DateTime AppearenceStart { get; private set; }
33 
34  public Guid Guid
35  {
36  get { return Link.Guid; }
37  }
38 
39  public bool HasAppearenceEnd
40  {
41  get { return AppearenceEnd != DateTime.MaxValue; }
42  }
43 
44  public bool HasAppearenceStart
45  {
46  get { return AppearenceStart != DateTime.MinValue; }
47  }
48 
49  public bool IsActive { get; private set; }
50  public ILinkElement Link { get; private set; }
51 
52  public string Name
53  {
54  get { return Link.Name; }
55  }
56 
57  public IPage Page { get; private set; }
58 
59  public IProject Project
60  {
61  get { return Page.Project; }
62  }
63 
64  public ISession Session
65  {
66  get { return Page.Session; }
67  }
68 
69  private void LoadXml(XmlElement element)
70  {
71  Link = (ILinkElement) PageElement.CreateElement(Project, element);
72 
73  var start = element.GetOADate("startdate");
74  AppearenceStart = !start.HasValue ? DateTime.MinValue : start.Value;
75 
76  var end = element.GetOADate("enddate");
77  AppearenceEnd = !end.HasValue ? DateTime.MaxValue : end.Value;
78 
79  var dateState = element.GetIntAttributeValue("datestate").GetValueOrDefault();
80  IsActive = dateState == 1 || dateState == 3;
81  }
82  }
83 
85  {
86  DateTime AppearenceEnd { get; }
87  DateTime AppearenceStart { get; }
88 
89  bool HasAppearenceEnd { get; }
90  bool HasAppearenceStart { get; }
91 
92  bool IsActive { get; }
93  ILinkElement Link { get; }
94  IPage Page { get; }
95  }
96 }