protected override void Execute(NativeActivityContext context) { var ext = context.GetExtension <ContentWorkflowExtension>(); var parent = Node.LoadNode(ParentPath.Get(context)); if (parent == null) { throw new ApplicationException("Cannot create content because parent does not exist. Path: " + ParentPath.Get(context)); } var name = Name.Get(context); var displayName = ContentDisplayName.Get(context); if (string.IsNullOrEmpty(name)) { name = ContentNamingHelper.GetNameFromDisplayName(displayName); } var node = sn.Content.CreateNew(ContentTypeName.Get(context), parent, name); if (!string.IsNullOrEmpty(displayName)) { node.DisplayName = displayName; } var fieldValues = FieldValues.Get(context); if (fieldValues != null) { foreach (var key in fieldValues.Keys) { node[key] = fieldValues[key]; } } node.ContentHandler.DisableObserver(typeof(WorkflowNotificationObserver)); try { node.Save(); } catch (Exception e) { throw new ApplicationException(String.Concat("Cannot create content. See inner exception. Expected path: " , ParentPath.Get <string>(context), "/", Name.Get(context)), e); } Result.Set(context, new WfContent(node.ContentHandler)); }
protected override string GetContentTypeName(NativeActivityContext context) { var baseContentTypeName = typeof(User).Name; var contentTypeName = ContentTypeName.Get(context); if (String.IsNullOrEmpty(contentTypeName)) { return(baseContentTypeName); } var ct = ContentType.GetByName(contentTypeName); if (ct != null) { if (ct.IsDescendantOf(ContentType.GetByName(baseContentTypeName))) { return(contentTypeName); } throw new InvalidOperationException("Invalid content type: " + contentTypeName); } throw new InvalidOperationException("Unknown content type: " + contentTypeName); }
protected virtual string GetContentTypeName(NativeActivityContext context) { return(ContentTypeName.Get(context)); }