예제 #1
0
        private async Task Unpack(string name, string chauffeurFolder)
        {
            var fileLocation = fileSystem.Path.Combine(chauffeurFolder, name + ".xml");

            if (!fileSystem.File.Exists(fileLocation))
            {
                await Out.WriteLineAsync(string.Format("The package '{0}' is not found in the Chauffeur folder", name));

                return;
            }

            using (var stream = fileSystem.File.OpenRead(fileLocation))
            {
                var xml = XDocument.Load(stream);

                var documentNode = xml.Root.Element("Documents");

                if (documentNode == null)
                {
                    await Out.WriteLineAsync(string.Format("No documents found in package '{0}'. Moving on", name));

                    return;
                }

                var documentSets = documentNode.Elements("DocumentSet");

                var content = documentSets.Select(ds => packagingService.ImportContent(ds));

                await Out.WriteLineAsync(string.Format("{0} documents have been imported from '{1}'. You'll need to publish from the back office to make the content live.", content.Count(), name));
            }
        }
        private IEnumerable <IContent> InstallDocuments(XElement documentsElement, int userId = 0)
        {
            if ((string.Equals(Constants.Packaging.DocumentSetNodeName, documentsElement.Name.LocalName) == false) &&
                (string.Equals(Constants.Packaging.DocumentsNodeName, documentsElement.Name.LocalName) == false))
            {
                throw new ArgumentException("Must be \"" + Constants.Packaging.DocumentsNodeName + "\" as root",
                                            "documentsElement");
            }

            if (string.Equals(Constants.Packaging.DocumentSetNodeName, documentsElement.Name.LocalName))
            {
                return(_packagingService.ImportContent(documentsElement, -1, userId));
            }

            return
                (documentsElement.Elements(Constants.Packaging.DocumentSetNodeName)
                 .SelectMany(documentSetElement => _packagingService.ImportContent(documentSetElement, -1, userId))
                 .ToArray());
        }
예제 #3
0
 public IEnumerable <IContent> ImportContent(XElement element, int parentId = -1, int userId = 0, bool raiseEvents = true)
 {
     return(realPackagingService.ImportContent(element, parentId, userId, raiseEvents));
 }