SmartAPI
Open Source .NET RQL library for RedDot CMS / OpenText WSM Management Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IPageCopyAndConnectJob.cs
Go to the documentation of this file.
1 ï»¿using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Web.UI;
6 using erminas.SmartAPI.CMS.Project.Pages.Elements;
7 using erminas.SmartAPI.Exceptions;
8 using erminas.SmartAPI.Utils;
9 
10 namespace erminas.SmartAPI.CMS.Project.Pages
11 {
12  [Flags]
14  {
15  None = 0,
16  AlsoCopyCompleteTree = 1,
17  CopyElementContentsInsteadOfReferencing = 2,
18  AdoptFileNames = 4,
19  AdoptPublicationSettingsOfLinkElements = 8,
20  AdoptAuthorizationsOfLinkElements = 16,
21  AdoptAuthorizationsOfOtherElements = 32,
22  AdoptProjectVariantAssignments = 64,
23  AdoptTargetContainterReferenceFromNewlyCreatedContainer = 128
24  }
25 
30  [Obsolete("This interface is experimental and will change in a future version")]
31  public interface IPageCopyAndConnectJob : IAsyncJob
32  {
33  IPage PageToCopy { get; set; }
34  ILinkElement ConnectionTarget { get; set; }
35  PageCopyAndConnectFlags Flags { get; set; }
36  }
37 
38  internal class PageCopyAndConnectJob : AbstractAsyncProjectJob, IPageCopyAndConnectJob
39  {
40  private PageCopyAndConnectFlags _flags;
41 
42  public PageCopyAndConnectJob(IPage page, ILinkElement linkElement, PageCopyAndConnectFlags flags) : base(page.Project)
43  {
44  PageToCopy = page;
45  ConnectionTarget = linkElement;
46  _flags = flags;
47  }
48 
49  public override void RunAsync()
50  {
51  try
52  {
53  const string QUERY =
54  @"<LINK action=""assign"" guid=""{0}"" reddotcacheguid=""""><PAGE action=""copy"" guid=""{1}"" copymode=""{2}"" /></LINK>";
55  Project.Session.ExecuteRQL(QUERY.RQLFormat(ConnectionTarget, PageToCopy, (int) _flags), RQL.IODataFormat.SessionKeyAndLogonGuid);
56  }
57  catch (RQLException e)
58  {
59  if (e.ErrorCode != ErrorCode.Unknown)
60  {
61  throw;
62  }
63  //The following "error" messages occur for ENG and DEU, as i don't know all messages for all languages, we just ignore all errors for now ...
64 
65  //The copy job is added to the processing queue. The procedure can take some time.
66 
67  //Der Kopiervorgang wird in die Prozesswarteschlange eingefügt. Die Ausführung kann einige Zeit dauern.
68  }
69  }
70 
71  public PageCopyAndConnectFlags Flags { get { return _flags; } set { _flags = value; } }
72 
73  public override void RunSync(TimeSpan maxWait)
74  {
75  throw new NotImplementedException("not yet implemented, please use RunAsync() for now");
76  }
77 
78  public IPage PageToCopy { get; set; }
79  public ILinkElement ConnectionTarget { get; set; }
80  }
81 }