18 using erminas.SmartAPI.Exceptions;
19 using erminas.SmartAPI.Utils;
20 using erminas.SmartAPI.Utils.CachedCollections;
22 namespace erminas.SmartAPI.CMS.Project.Workflows
27 bool CanBeInherited {
get; }
28 bool IsGlobal {
get; }
29 bool IsStructureWorkflow {
get; }
32 internal class Workflow : PartialRedDotProjectObject, IWorkflow
34 private bool _canBeInherited;
35 private bool _isGlobal;
36 private bool _isStructureWorkflow;
38 internal Workflow(
IProject project, XmlElement xmlElement) : base(project, xmlElement)
41 Actions =
new WorkflowActions(
this,
Caching.Enabled);
44 public Workflow(IProject project, Guid guid) : base(project, guid)
46 Actions =
new WorkflowActions(
this,
Caching.Enabled);
50 public IWorkflowActions Actions {
get;
private set; }
52 public bool CanBeInherited
54 get {
return LazyLoad(ref _canBeInherited); }
59 const string DELETE_WORKFLOW =
@"<WORKFLOW sessionkey=""{0}"" action=""delete"" guid=""{1}""/>";
60 var session = Project.Session;
61 var reply = session.ExecuteRQLRaw(DELETE_WORKFLOW.RQLFormat(session,
this), RQL.IODataFormat.LogonGuidOnly);
63 if (!reply.Contains(
"ok"))
65 throw new SmartAPIException(Session.ServerLogin,
string.Format(
"Could not delete workflow {0}",
this));
71 get {
return LazyLoad(ref _isGlobal); }
74 public bool IsStructureWorkflow
76 get {
return LazyLoad(ref _isStructureWorkflow); }
79 protected override void LoadWholeObject()
84 protected override XmlElement RetrieveWholeObject()
86 const string LOAD_WORKFLOW =
@"<WORKFLOW action=""load"" guid=""{0}""/>";
90 Project.ExecuteRQL(String.Format(LOAD_WORKFLOW, Guid.ToRQLString())).GetElementsByTagName(
"WORKFLOW")[0];
93 internal XmlElement RetrieveObjectInternal()
95 return RetrieveWholeObject();
98 private void LoadXml()
100 InitIfPresent(ref _canBeInherited,
"inherit", BoolConvert);
101 if (Project.Session.ServerVersion <
new Version(11, 2))
103 EnsuredInit(ref _isStructureWorkflow,
"structureworkflow", BoolConvert);
107 EnsuredInit(ref _isStructureWorkflow,
"wftype", BoolConvert);
109 InitIfPresent(ref _isGlobal,
"global", BoolConvert);