Exemple #1
0
        private static void ExecuteInitProcessors(Plugin plugin)
        {
            using (new ProfileSection("Execute <init> processors for plugins", typeof(PluginManager)))
            {
                ProfileSection.Argument("plugin", plugin);

                try
                {
                    var          xml   = plugin.PluginXmlDocument;
                    const string xpath = "/plugin/init/processor";

                    foreach (XmlElement processorNode in xml.SelectElements(xpath))
                    {
                        ExecuteInitProcessor(processorNode);
                    }

                    ProfileSection.Result("Done");
                }
                catch (Exception ex)
                {
                    HandleError(plugin, ex);

                    ProfileSection.Result("Failed");
                }
            }
        }
        private static IEnumerable <Site> GetOperableSites([NotNull] WebServerManager.WebServerContext context, [CanBeNull] string defaultRootFolder = null, bool?detectEverywhere = null)
        {
            Assert.IsNotNull(context, "Context cannot be null");

            using (new ProfileSection("Getting operable sites", typeof(InstanceManager)))
            {
                ProfileSection.Argument("context", context);
                ProfileSection.Argument("defaultRootFolder", defaultRootFolder);
                ProfileSection.Argument("detectEverywhere", detectEverywhere);

                if (defaultRootFolder != null)
                {
                    instancesFolder = defaultRootFolder.ToLower();
                }

                IEnumerable <Site> sites   = context.Sites;
                var detectEverywhereResult = detectEverywhere ?? Settings.CoreInstancesDetectEverywhere.Value;
                if (!detectEverywhereResult)
                {
                    if (string.IsNullOrEmpty(instancesFolder))
                    {
                        Log.Warn("Since the 'Detect.Instances.Everywhere' setting is disabled and the instances root isn't set in the Settings dialog, the 'C:\\inetpub\\wwwroot' will be used instead", typeof(InstanceManager));

                        instancesFolder = @"C:\inetpub\wwwroot";
                    }

                    instancesFolder = instancesFolder.ToLower();
                    sites           = sites.Where(s => WebServerManager.GetWebRootPath(s).ToLower().Contains(instancesFolder));
                }

                return(ProfileSection.Result(sites));
            }
        }
        private string ReplaceVariables(string name)
        {
            using (new ProfileSection("Replace variables", this))
            {
                ProfileSection.Argument("name", name);

                var abstractArgs = WizardArgs as object ?? Args;
                var result       = abstractArgs != null?Pipeline.ReplaceVariables(name, abstractArgs) : name;

                return(ProfileSection.Result(result));
            }
        }
Exemple #4
0
        private static void InitializeWizardPipeline(XmlElement element)
        {
            using (new ProfileSection("Initialize wizard pipeline"))
            {
                ProfileSection.Argument("element", element);

                var name1 = element.Name;
                try
                {
                    XmlElement argsElement = element.SelectSingleElement("args");
                    Type       args        = argsElement != null
            ? Type.GetType(argsElement.GetAttribute("type")).IsNotNull(
                        "Cannot find the {0} type".FormatWith(argsElement.GetAttribute("type")))
            : null;

                    XmlElement finish       = element.SelectSingleElement("finish");
                    var        title        = element.GetAttribute("title");
                    var        stepsElement = element.SelectSingleElement("steps").IsNotNull(
                        "Can't find the steps element in the WizardPipelines.config file");
                    var afterLastStepText = stepsElement.GetAttribute("afterLastStep");
                    var afterLastStep     = !string.IsNullOrWhiteSpace(afterLastStepText)
            ? (IAfterLastWizardPipelineStep)Activator.CreateInstance(Type.GetType(afterLastStepText))
            : null;

                    var steps =
                        stepsElement.ChildNodes.OfType <XmlElement>().
                        Select(
                            step =>
                            new StepInfo(step.GetAttribute("name"), Type.GetType(step.GetAttribute("type")),
                                         step.GetAttribute("param"))).ToArray();
                    var            cancelButtonText = element.GetAttribute("cancelButton");
                    var            startButtonText  = element.GetAttribute("startButton");
                    var            finishText       = element.GetAttribute("finishText");
                    FinishAction[] finishActions    = finish != null?GetFinishActions(finish, args).ToArray() : null;

                    var            finishActionHives = GetFinishActionHives(finish, args);
                    WizardPipeline wizardPipeline    = new WizardPipeline(name1, title, steps, args, startButtonText,
                                                                          cancelButtonText, finishText, finishActions,
                                                                          finishActionHives, afterLastStep);
                    Definitions.Add(name1, wizardPipeline);

                    ProfileSection.Result("Done");
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("WizardPipelineManager failed to load the {0} pipeline".FormatWith(name1), true, ex);

                    ProfileSection.Result("Failed");
                }
            }
        }
Exemple #5
0
        protected virtual string GetRootFolderViaDatabases(ICollection <Database> databases)
        {
            string webRootPath = this.WebRootPath;

            using (new ProfileSection("Get root folder (using databases)", this))
            {
                ProfileSection.Argument("databases", databases);

                foreach (var database in databases)
                {
                    Log.Debug("Database: " + database);
                    string fileName = database.FileName;
                    if (string.IsNullOrEmpty(fileName))
                    {
                        Log.Warn(
                            "The {0} database seems to be detached since it doesn't have a FileName property filled in".FormatWith(
                                database.RealName), typeof(string));
                        continue;
                    }

                    Log.Debug(
                        "name: {0}, fileName: {1}".FormatWith(database.Name, fileName),
                        typeof(Instance));
                    var folder = Path.GetDirectoryName(fileName);
                    if (folder.ContainsIgnoreCase(webRootPath))
                    {
                        continue;
                    }

                    Assert.IsNotNullOrEmpty(folder, "folder1");
                    var common = FileSystem.FileSystem.Local.Directory.FindCommonParent(webRootPath, folder);
                    if (string.IsNullOrEmpty(common))
                    {
                        continue;
                    }

                    if (Math.Abs(FileSystem.FileSystem.Local.Directory.GetDistance(webRootPath, common)) <= 1)
                    {
                        return(ProfileSection.Result(common));
                    }
                }

                return(ProfileSection.Result((string)null));
            }
        }