protected override void ExecuteCmdlet()
        {
            Microsoft.SharePoint.Client.ContentType ct = null;
            if (string.IsNullOrEmpty(Folder))
            {
                Folder = SessionState.Path.CurrentFileSystemLocation.Path;
            }
            else
            {
                if (!Path.IsPathRooted(Folder))
                {
                    Folder = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Folder);
                }
            }
            if (ContentType != null)
            {
                ct = ContentType.GetContentType(this.SelectedWeb);
            }
            if (TargetFolder == null)
            {
                TargetFolder = new DirectoryInfo(SessionState.Path.CurrentFileSystemLocation.Path).Name;
            }
            if (!string.IsNullOrEmpty(Out))
            {
                if (!Path.IsPathRooted(Out))
                {
                    Out = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Out);
                }
                if (System.IO.File.Exists(Out))
                {
                    if (Force || ShouldContinue(string.Format(Commands.Properties.Resources.File0ExistsOverwrite, Out), Commands.Properties.Resources.Confirm))
                    {
                        var xml = GetFiles(Schema, new FileInfo(Out).DirectoryName, Folder, ct != null ? ct.StringId : null);

                        System.IO.File.WriteAllText(Out, xml, Encoding);
                    }
                }
                else
                {
                    var xml = GetFiles(Schema, new FileInfo(Out).DirectoryName, Folder, ct != null ? ct.StringId : null);

                    System.IO.File.WriteAllText(Out, xml, Encoding);
                }
            }
            else
            {
                var xml = GetFiles(Schema, SessionState.Path.CurrentFileSystemLocation.Path, Folder, ct != null ? ct.StringId : null);

                WriteObject(xml);
            }
        }
Example #2
0
        protected override void ExecuteCmdlet()
        {
            Microsoft.SharePoint.Client.ContentType ct = null;
            if (string.IsNullOrEmpty(Folder))
            {
                Folder = SessionState.Path.CurrentFileSystemLocation.Path;
            }
            else
            {
                if (!Path.IsPathRooted(Folder))
                {
                    Folder = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Folder);
                    Folder = new DirectoryInfo(Folder).FullName.TrimEnd('\\', '/'); // normalize away relative ./ paths
                }
            }
            if (ContentType != null)
            {
                ct = ContentType.GetContentType(SelectedWeb);
            }
            if (TargetFolder == null)
            {
                TargetFolder = new DirectoryInfo(SessionState.Path.CurrentFileSystemLocation.Path).Name;
            }

            if (!string.IsNullOrEmpty(Out))
            {
                if (!ShouldContinue())
                {
                    return;
                }

                if (Path.GetExtension(Out).ToLower() == ".pnp")
                {
                    byte[] pack = CreatePnPPackageFile(ct?.StringId);
                    System.IO.File.WriteAllBytes(Out, pack);
                }
                else
                {
                    var xml = CreateXmlAsStringFrom(ct?.StringId);
                    System.IO.File.WriteAllText(Out, xml, Encoding);
                }
            }
            else
            {
                var xml = CreateXmlAsStringFrom(ct?.StringId);
                WriteObject(xml);
            }
        }
Example #3
0
        protected override void ExecuteCmdlet()
        {
            Microsoft.SharePoint.Client.ContentType ct = null;
            if (string.IsNullOrEmpty(Folder))
            {
                Folder = SessionState.Path.CurrentFileSystemLocation.Path;
            }
            else
            {
                if (!Path.IsPathRooted(Folder))
                {
                    Folder = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Folder);
                }
            }
            if (ContentType != null)
            {
                ct = ContentType.GetContentType(this.SelectedWeb);
            }
            if (TargetFolder == null)
            {
                TargetFolder = new DirectoryInfo(SessionState.Path.CurrentFileSystemLocation.Path).Name;
            }
            if (!string.IsNullOrEmpty(Out))
            {
                if (!Path.IsPathRooted(Out))
                {
                    Out = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Out);
                }
                if (System.IO.File.Exists(Out))
                {
                    if (Force || ShouldContinue(string.Format(Commands.Properties.Resources.File0ExistsOverwrite, Out), Commands.Properties.Resources.Confirm))
                    {
                        var xml = GetFiles(Schema, new FileInfo(Out).DirectoryName, Folder, ct != null ? ct.StringId : null);

                        if (AsIncludeFile)
                        {
                            XElement xElement = XElement.Parse(xml);
                            // Get the Files Element
                            XNamespace pnp = XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12;

                            var filesElement = xElement.Descendants(pnp + "Files").FirstOrDefault();

                            if (filesElement != null)
                            {
                                xml = filesElement.ToString();
                            }
                        }
                        System.IO.File.WriteAllText(Out, xml, Encoding);
                    }
                }
                else
                {
                    var xml = GetFiles(Schema, new FileInfo(Out).DirectoryName, Folder, ct != null ? ct.StringId : null);
                    if (AsIncludeFile)
                    {
                        XElement xElement = XElement.Parse(xml);
                        // Get the Files Element
                        XNamespace pnp = XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12;

                        var filesElement = xElement.Descendants(pnp + "Files").FirstOrDefault();

                        if (filesElement != null)
                        {
                            xml = filesElement.ToString();
                        }
                    }
                    System.IO.File.WriteAllText(Out, xml, Encoding);
                }
            }
            else
            {
                var xml = GetFiles(Schema, SessionState.Path.CurrentFileSystemLocation.Path, Folder, ct != null ? ct.StringId : null);
                if (AsIncludeFile)
                {
                    XElement xElement = XElement.Parse(xml);
                    // Get the Files Element
                    XNamespace pnp = XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12;

                    var filesElement = xElement.Descendants(pnp + "Files").FirstOrDefault();

                    if (filesElement != null)
                    {
                        xml = filesElement.ToString();
                    }
                }
                WriteObject(xml);
            }
        }
Example #4
0
 /// <summary>
 /// Initializes the new instance of <see cref="SPClient.SPClientFieldParentPipeBind"/> class.
 /// </summary>
 /// <param name="contentType">the content type which contains columns.</param>
 public SPClientFieldParentPipeBind(Microsoft.SharePoint.Client.ContentType contentType)
 {
     this.ClientObject = contentType;
 }