SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IProjectExportJob.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.Security;
18 using erminas.SmartAPI.CMS.ServerManagement;
19 using erminas.SmartAPI.Utils;
20 
21 namespace erminas.SmartAPI.CMS.Project
22 {
24  {
25  bool IsIncludingAdministrationSettings { get; set; }
26  bool IsIncludingArchive { get; set; }
27  bool IsLoggingOffActiveUsersInProject { get; set; }
28  string TargetPath { get; set; }
29  }
30 
31  internal sealed class ProjectExportJob : AbstractAsyncProjectJob, IProjectExportJob
32  {
33  internal ProjectExportJob(IProject project, string targetPath) : base(project)
34  {
35  TargetPath = targetPath;
36  EmailSubject = String.Format("Project: {0}", project.Name);
37  EmailMessage = "Project export finished";
38  IsLoggingOffActiveUsersInProject = true;
39  IsIncludingAdministrationSettings = true;
40  IsIncludingArchive = false;
41  }
42 
43  public bool IsIncludingAdministrationSettings { get; set; }
44  public bool IsIncludingArchive { get; set; }
45  public bool IsLoggingOffActiveUsersInProject { get; set; }
46 
47  public override void RunAsync()
48  {
49  const string EXPORT =
50  @"<ADMINISTRATION><PROJECT action=""export"" projectguid=""{0}"" targetpath=""{1}"" emailnotification=""{2}""
51 editorialserver=""{3}"" includearchive=""{4}"" to=""{5}"" provider="""" subject=""{6}""
52 message=""{7}"" logoutusers=""{8}"" reddotserverguid=""{3}"" includeadmindata=""{9}"" />
53 </ADMINISTRATION>";
54  var query = EXPORT.RQLFormat(Project, SecurityElement.Escape(TargetPath), IsSendingEmailOnCompletion, Server,
55  IsIncludingArchive, EmailReceipient, SecurityElement.Escape(EmailSubject),
56  SecurityElement.Escape(EmailMessage), IsLoggingOffActiveUsersInProject,
57  IsIncludingAdministrationSettings);
58 
59  Session.ExecuteRQL(query, RQL.IODataFormat.LogonGuidOnly);
60  }
61 
62  public override void RunSync(TimeSpan maxWait)
63  {
64  RunAsync();
65  Session.WaitForAsyncProcess(maxWait,
66  p => p.Type == AsynchronousProcessType.XMLExport && Project.Equals(p.Project));
67  }
68 
69  public string TargetPath { get; set; }
70  }
71 }