Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1570 from SharePoint/dev
Browse files Browse the repository at this point in the history
May 2018 Intermediate Release 1
  • Loading branch information
erwinvanhunen committed May 16, 2018
2 parents 89b970c + 2d32061 commit f03a9b3
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 58 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [2.27.1806.0]
### Added

### Changed

### Deprecated

### Contributors

## [2.26.1805.1]
### Added

- Added -Timeout option to Add-PnPApp
- Added -CollapseSpecification option to Submit-PnPSearchQuery
- Added -InSiteHierarchy to Get-PnPField to search for fields in the site collection

### Changed
- Fix for issue where using Add-PnPFile and setting Created and Modified did not update values

## [2.26.1805.0]
### Added
- Added Enable-PnPPowerShellTelemetry, Disable-PnPPowerShellTelemetry, Get-PnPPowershellTelemetryEnabled
Expand Down
5 changes: 4 additions & 1 deletion Commands/Apps/AddApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class AddApp : PnPCmdlet
[Parameter(Mandatory = false, HelpMessage = "Overwrites the existing app package if it already exists")]
public SwitchParameter Overwrite;

[Parameter(Mandatory = false, HelpMessage = "Specifies the timeout in seconds. Defaults to 200.")]
public int Timeout = 200;

protected override void ExecuteCmdlet()
{
if (!System.IO.Path.IsPathRooted(Path))
Expand All @@ -54,7 +57,7 @@ protected override void ExecuteCmdlet()

var manager = new AppManager(ClientContext);

var result = manager.Add(bytes, fileInfo.Name, Overwrite, Scope);
var result = manager.Add(bytes, fileInfo.Name, Overwrite, Scope, timeoutSeconds: Timeout);

try
{
Expand Down
5 changes: 0 additions & 5 deletions Commands/Base/PnPCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,8 @@ protected override void ProcessRecord()
}
catch (Exception ex)
{
if (SPOnlineConnection.CurrentConnection.TelemetryClient != null)
{
SPOnlineConnection.CurrentConnection.TelemetryClient.TrackException(ex);
}
SPOnlineConnection.CurrentConnection.RestoreCachedContext(SPOnlineConnection.CurrentConnection.Url);
WriteError(new ErrorRecord(ex, "EXCEPTION", ErrorCategory.WriteError, null));
SPOnlineConnection.CurrentConnection.TelemetryClient.Flush();
}
}

Expand Down
15 changes: 15 additions & 0 deletions Commands/Enums/ListItemUpdateType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SharePointPnP.PowerShell.Commands.Enums
{
public enum ListItemUpdateType
{
Update,
SystemUpdate,
UpdateOverwriteVersion
}
}
54 changes: 47 additions & 7 deletions Commands/Fields/GetField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class GetField : PnPWebRetrievalsCmdlet<Field>
[Parameter(Mandatory = false, HelpMessage = "Filter to the specified group")]
public string Group;

[Parameter(Mandatory = false, ValueFromPipeline = false, HelpMessage = "Search site hierarchy for fields")]
public SwitchParameter InSiteHierarchy;

protected override void ExecuteCmdlet()
{
if (List != null)
Expand Down Expand Up @@ -67,8 +70,10 @@ protected override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(Group))
{
WriteObject(fieldCollection.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)),true);
} else {
WriteObject(fieldCollection.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)), true);
}
else
{
WriteObject(fieldCollection, true);
}
}
Expand All @@ -81,27 +86,62 @@ protected override void ExecuteCmdlet()
{
if (Identity.Id == Guid.Empty && string.IsNullOrEmpty(Identity.Name))
{
ClientContext.Load(SelectedWeb.Fields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
if (InSiteHierarchy.IsPresent)
{
ClientContext.Load(SelectedWeb.AvailableFields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
}
else
{
ClientContext.Load(SelectedWeb.Fields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
}
ClientContext.ExecuteQueryRetry();
if (!string.IsNullOrEmpty(Group))
{
WriteObject(SelectedWeb.Fields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)), true);
if (InSiteHierarchy.IsPresent)
{
WriteObject(SelectedWeb.AvailableFields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)).OrderBy(f => f.Title), true);
}
else
{
WriteObject(SelectedWeb.Fields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)).OrderBy(f => f.Title), true);
}
}
else
{
WriteObject(SelectedWeb.Fields, true);
if (InSiteHierarchy.IsPresent)
{
WriteObject(SelectedWeb.AvailableFields.OrderBy(f => f.Title), true);
}
else
{
WriteObject(SelectedWeb.Fields.OrderBy(f => f.Title), true);
}
}
}
else
{
Field field = null;
if (Identity.Id != Guid.Empty)
{
field = SelectedWeb.Fields.GetById(Identity.Id);
if (InSiteHierarchy.IsPresent)
{
field = SelectedWeb.AvailableFields.GetById(Identity.Id);
}
else
{
field = SelectedWeb.Fields.GetById(Identity.Id);
}
}
else if (!string.IsNullOrEmpty(Identity.Name))
{
field = SelectedWeb.Fields.GetByInternalNameOrTitle(Identity.Name);
if (InSiteHierarchy.IsPresent)
{
field = SelectedWeb.AvailableFields.GetByInternalNameOrTitle(Identity.Name);
}
else
{
field = SelectedWeb.Fields.GetByInternalNameOrTitle(Identity.Name);
}
}
ClientContext.Load(field, RetrievalExpressions);
ClientContext.ExecuteQueryRetry();
Expand Down
10 changes: 8 additions & 2 deletions Commands/Files/AddFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Collections.Generic;
using Microsoft.SharePoint.Client.Taxonomy;
using SharePointPnP.PowerShell.Commands.Utilities;
using SharePointPnP.PowerShell.Commands.Enums;

namespace SharePointPnP.PowerShell.Commands.Files
{
Expand Down Expand Up @@ -187,7 +188,7 @@ protected override void ExecuteCmdlet()
{
var item = file.ListItemAllFields;

ListItemHelper.UpdateListItem(item, Values, true,
ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.UpdateOverwriteVersion,
(warning) =>
{
WriteWarning(warning);
Expand All @@ -201,7 +202,11 @@ protected override void ExecuteCmdlet()
{
var item = file.ListItemAllFields;
item["ContentTypeId"] = targetContentType.Id.StringValue;
#if !ONPREMISES
item.UpdateOverwriteVersion();
#else
item.Update();
#endif
ClientContext.ExecuteQueryRetry();
}

Expand All @@ -214,7 +219,8 @@ protected override void ExecuteCmdlet()

if (Approve)
SelectedWeb.ApproveFile(fileUrl, ApproveComment);

ClientContext.Load(file);
ClientContext.ExecuteQueryRetry();
WriteObject(file);
}
}
Expand Down
3 changes: 2 additions & 1 deletion Commands/Lists/AddListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OfficeDevPnP.Core.Utilities;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using SharePointPnP.PowerShell.Commands.Enums;
using SharePointPnP.PowerShell.Commands.Taxonomy;
using SharePointPnP.PowerShell.Commands.Utilities;

Expand Down Expand Up @@ -120,7 +121,7 @@ protected override void ExecuteCmdlet()

if (Values != null)
{
item = ListItemHelper.UpdateListItem(item, Values, false,
item = ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.Update,
(warning) =>
{
WriteWarning(warning);
Expand Down
10 changes: 8 additions & 2 deletions Commands/Lists/SetListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.SharePoint.Client.Taxonomy;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using SharePointPnP.PowerShell.Commands.Enums;
using SharePointPnP.PowerShell.Commands.Utilities;
// IMPORTANT: If you make changes to this cmdlet, also make the similar/same changes to the Add-PnPListItem Cmdlet

Expand Down Expand Up @@ -108,7 +109,12 @@ protected override void ExecuteCmdlet()
if (Values != null)
{
#if !ONPREMISES
item = ListItemHelper.UpdateListItem(item, Values, SystemUpdate, (warning) =>
var updateType = ListItemUpdateType.Update;
if(SystemUpdate.IsPresent)
{
updateType = ListItemUpdateType.SystemUpdate;
}
item = ListItemHelper.UpdateListItem(item, Values, updateType, (warning) =>
{
WriteWarning(warning);
},
Expand All @@ -118,7 +124,7 @@ protected override void ExecuteCmdlet()
}
);
#else
item = ListItemHelper.UpdateListItem(item, Values, false, (warning) =>
item = ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.Update, (warning) =>
{
WriteWarning(warning);
},
Expand Down
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.26.1805.0")]
[assembly: AssemblyFileVersion("2.26.1805.0")]
[assembly: AssemblyVersion("2.26.1805.1")]
[assembly: AssemblyFileVersion("2.26.1805.1")]
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]
69 changes: 38 additions & 31 deletions Commands/Provisioning/ApplyProvisioningTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using OfficeDevPnP.Core.Framework.Provisioning.Providers;
using SharePointPnP.PowerShell.Commands.Components;
using System.Collections.Generic;

namespace SharePointPnP.PowerShell.Commands.Provisioning
{
Expand Down Expand Up @@ -119,7 +120,7 @@ protected override void ExecuteCmdlet()
{
Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path);
}
if(!System.IO.File.Exists(Path))
if (!System.IO.File.Exists(Path))
{
throw new FileNotFoundException($"File not found");
}
Expand Down Expand Up @@ -278,30 +279,45 @@ protected override void ExecuteCmdlet()
WriteProgress(progressRecord);
};

var warningsShown = new List<string>();

applyingInformation.MessagesDelegate = (message, type) =>
{
switch (type)
{
case ProvisioningMessageType.Warning:
{
WriteWarning(message);
break;
}
{
if (!warningsShown.Contains(message))
{
WriteWarning(message);
warningsShown.Add(message);
}
break;
}
case ProvisioningMessageType.Progress:
{
var activity = message;
if (message.IndexOf("|") > -1)
{
var messageSplitted = message.Split('|');
if (messageSplitted.Length == 4)
var activity = message;
if (message.IndexOf("|") > -1)
{
var current = double.Parse(messageSplitted[2]);
var total = double.Parse(messageSplitted[3]);
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.Activity = messageSplitted[0];
subProgressRecord.StatusDescription = messageSplitted[1];
subProgressRecord.PercentComplete = Convert.ToInt32((100/total)*current);
WriteProgress(subProgressRecord);
var messageSplitted = message.Split('|');
if (messageSplitted.Length == 4)
{
var current = double.Parse(messageSplitted[2]);
var total = double.Parse(messageSplitted[3]);
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.Activity = messageSplitted[0];
subProgressRecord.StatusDescription = messageSplitted[1];
subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current);
WriteProgress(subProgressRecord);
}
else
{
subProgressRecord.Activity = "Processing";
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.StatusDescription = activity;
subProgressRecord.PercentComplete = 0;
WriteProgress(subProgressRecord);
}
}
else
{
Expand All @@ -311,23 +327,14 @@ protected override void ExecuteCmdlet()
subProgressRecord.PercentComplete = 0;
WriteProgress(subProgressRecord);
}
break;
}
else
{
subProgressRecord.Activity = "Processing";
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.StatusDescription = activity;
subProgressRecord.PercentComplete = 0;
WriteProgress(subProgressRecord);
}
break;
}
case ProvisioningMessageType.Completed:
{
{
WriteProgress(new ProgressRecord(1, message, " ") {RecordType = ProgressRecordType.Completed});
break;
}
WriteProgress(new ProgressRecord(1, message, " ") { RecordType = ProgressRecordType.Completed });
break;
}
}
};

Expand Down
4 changes: 4 additions & 0 deletions Commands/Search/SubmitSearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class SubmitSearchQuery : PnPWebCmdlet
[Parameter(Mandatory = false, HelpMessage = "Specifies the name of the client which issued the query.", ParameterSetName = ParameterAttribute.AllParameterSets)]
public string ClientType = "ContentSearchLow";

[Parameter(Mandatory = false, HelpMessage = "Limit the number of items per the collapse specification. See https://docs.microsoft.com/en-us/sharepoint/dev/general-development/customizing-search-results-in-sharepoint#collapse-similar-search-results-using-the-collapsespecification-property for more information.", ParameterSetName = ParameterAttribute.AllParameterSets)]
public string CollapseSpecification;

[Parameter(Mandatory = false, HelpMessage = "The keyword query’s hidden constraints.", ParameterSetName = ParameterAttribute.AllParameterSets)]
public string HiddenConstraints;

Expand Down Expand Up @@ -217,6 +220,7 @@ private KeywordQuery CreateKeywordQuery()
if (MyInvocation.BoundParameters.ContainsKey("SourceId")) keywordQuery.SourceId = SourceId;
if (MyInvocation.BoundParameters.ContainsKey("ProcessBestBets")) keywordQuery.ProcessBestBets = ProcessBestBets;
if (MyInvocation.BoundParameters.ContainsKey("ProcessPersonalFavorites")) keywordQuery.ProcessPersonalFavorites = ProcessPersonalFavorites;
if (MyInvocation.BoundParameters.ContainsKey("CollapseSpecification")) keywordQuery.CollapseSpecification = CollapseSpecification;

if (SortList != null)
{
Expand Down
1 change: 1 addition & 0 deletions Commands/SharePointPnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@
<Compile Include="Base\PipeBinds\SitePipeBind.cs" />
<Compile Include="Base\PipeBinds\TenantSiteScriptPipeBind.cs" />
<Compile Include="Base\PipeBinds\TenantSiteDesignPipeBind.cs" />
<Compile Include="Enums\ListItemUpdateType.cs" />
<Compile Include="Enums\StorageEntityScope.cs" />
<Compile Include="Model\ServicePrincipalPermissionGrant.cs" />
<Compile Include="Navigation\GetNavigationNode.cs" />
Expand Down
Loading

0 comments on commit f03a9b3

Please sign in to comment.