コード例 #1
0
        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}");
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
                });
            }
        }
コード例 #5
0
 public bool CanHandle(ImportBaseElement x)
 {
     return(x.IsCustomScript() && !x.IsSearchConfig);
 }
コード例 #6
0
 public bool CanHandle(ImportBaseElement x)
 {
     return(x.IsSearchConfig == true);
 }
コード例 #7
0
        public IComponentImport GetHandlerForElement(ImportBaseElement x)
        {
            var handler = container.GetAllInstances <IComponentImport>().Where(el => el.CanHandle(x)).FirstOrDefault();

            return(handler);
        }