public void Provision(ImportBaseElement x, string templateRootFolder, string sharePointSiteUrl, string sharePointUserName, string sharePointPassword) { try { RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration); runspace.Open(); RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace); Pipeline pipeline = runspace.CreatePipeline(); var scriptPath = Path.Combine(templateRootFolder, x.SourceFolder, x.Handler.CustomCommand); Command myCommand = new Command(scriptPath, false); foreach (var p in x.Handler.CustomCommandArguments) { myCommand.Parameters.Add(p.ParameterName, p.ParameterValue); } myCommand.Parameters.Add("SharePointSiteUrl", sharePointSiteUrl); myCommand.Parameters.Add("SharePointSiteUserName", sharePointUserName); myCommand.Parameters.Add("SharePointPassword", sharePointPassword); pipeline.Commands.Add(myCommand); Collection <PSObject> psObjects; psObjects = pipeline.Invoke(); runspace.Close(); } catch (Exception ex) { Console.Error.Write($"##vso[task.logissue type=error] Failed to Execute Powershell script with message {ex.Message}"); } }
public void Provision(ImportBaseElement x, string templateRootFolder, string sharePointSiteUrl, string sharePointUserName, string sharePointPassword) { if (x.Enabled) { var fullPath = Path.Combine(templateRootFolder, x.SourceFolder); var files = templateManger.GetTemplates(fullPath, "*.xml"); var config = files.FirstOrDefault(); provisioningManager.ProvisionSearchSchema(sharePointSiteUrl, sharePointUserName, sharePointPassword, config, x.SearchConfiguration.SearchObjectLevel); } }
internal static ImportBaseElement GetImportElement(bool IsSearchConfig, bool IsEnabled) { var res = new ImportBaseElement { IsSearchConfig = IsSearchConfig, Enabled = IsEnabled, SourceFolder = "Test" }; if (res.IsSearchConfig) { res.SearchConfiguration = new SearchConfiguration { SearchObjectLevel = SearchObjectLevel.SPSite, }; } return(res); }
public void Provision(ImportBaseElement x, string templateRootFolder, string sharePointSiteUrl, string sharePointUserName, string sharePointPassword) { if (x.Enabled) { var fullPath = Path.Combine(templateRootFolder, x.SourceFolder); if (!templateManger.DirectoryExists(fullPath)) { return; } var templates = templateManger.GetTemplates(fullPath); Console.WriteLine($"Deploying from folder : {x.SourceFolder} - Templates found : {templates.Count}"); templates.ForEach(template => { provisioningManager.Provision(sharePointSiteUrl, sharePointUserName, sharePointPassword, template); }); } }
public bool CanHandle(ImportBaseElement x) { return(x.IsCustomScript() && !x.IsSearchConfig); }
public bool CanHandle(ImportBaseElement x) { return(x.IsSearchConfig == true); }
public IComponentImport GetHandlerForElement(ImportBaseElement x) { var handler = container.GetAllInstances <IComponentImport>().Where(el => el.CanHandle(x)).FirstOrDefault(); return(handler); }