/// <summary> /// Capture the return results for any commands that return lists /// </summary> /// <param name="action">The command passed</param> /// <param name="outputFromScript">The raw text from the powershell script</param> /// <returns>An array of processed lines</returns> internal static SharePointDeploymentStatus[] ProcessPowerShellOutput(SharePointAction action, string outputFromScript) { var results = new List <SharePointDeploymentStatus>(); switch (action) { case SharePointAction.GetFeature: case SharePointAction.GetSolution: var lines = outputFromScript.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); SharePointDeploymentStatus newItem = null; foreach (var line in lines) { if (!string.IsNullOrEmpty(line)) { var sections = line.Split(':'); if ((sections != null) && (sections.Length == 2)) { switch (sections[0].Trim()) { case "DisplayName": newItem = new SharePointDeploymentStatus(); newItem.Name = sections[1].Trim(); newItem.Deployed = true; // set a default as features don't pass this break; case "Id": newItem.Id = Guid.Parse(sections[1].Trim()); results.Add(newItem); // we need to make sure the ID is the last in the list break; case "Deployed": newItem.Deployed = bool.Parse(sections[1].Trim()); break; } } } } break; } return(results.ToArray()); }
/// <summary> /// Capture the return results for any commands that return lists /// </summary> /// <param name="action">The command passed</param> /// <param name="outputFromScript">The raw text from the powershell script</param> /// <returns>An array of processed lines</returns> internal static SharePointDeploymentStatus[] ProcessPowerShellOutput(SharePointRemoteAction action, string outputFromScript) { var results = new List<SharePointDeploymentStatus>(); switch (action) { case SharePointRemoteAction.GetFeature: case SharePointRemoteAction.GetSolution: var lines = outputFromScript.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); SharePointDeploymentStatus newItem = null; foreach (var line in lines) { if (!string.IsNullOrEmpty(line)) { var sections = line.Split(':'); if (sections.Length == 2) { switch (sections[0].Trim()) { case "DisplayName": newItem = new SharePointDeploymentStatus(); newItem.Name = sections[1].Trim(); newItem.Deployed = true; // set a default as features don't pass this break; case "Id": newItem.Id = Guid.Parse(sections[1].Trim()); results.Add(newItem); // we need to make sure the ID is the last in the list break; case "Deployed": newItem.Deployed = bool.Parse(sections[1].Trim()); break; } } } } break; } return results.ToArray(); }