public static void InitializeContextMenu(XmlDocumentEx appDocument)
        {
            using (new ProfileSection("Initialize context menu"))
            {
                ProfileSection.Argument("appDocument", appDocument);

                MainWindow window    = MainWindow.Instance;
                var        menuItems = appDocument.SelectElements("/app/mainWindow/contextMenu/*");

                foreach (var item in menuItems)
                {
                    using (new ProfileSection("Fill in context menu"))
                    {
                        ProfileSection.Argument("item", item);

                        if (item.Name == "item")
                        {
                            InitializeContextMenuItem(item, window.ContextMenu.Items, window, uri => Plugin.GetImage(uri, "App.xml"));
                        }
                        else if (item.Name == "separator")
                        {
                            window.ContextMenu.Items.Add(new Separator());
                        }
                        else if (item.Name == "plugins")
                        {
                            Log.Error(string.Format("Plugins no longer supported"));
                        }
                    }
                }
            }
        }
Example #2
0
        public static Database GetMainDatabase(Instance instance, SqlConnectionStringBuilder connectionString)
        {
            using (new ProfileSection("Get main database"))
            {
                ProfileSection.Argument("instance", instance);
                ProfileSection.Argument("connectionString", connectionString);

                var      sqlServerInstanceName   = connectionString.DataSource;
                Database mainDatabase            = null;
                string[] firstOrderDatabaseNames = new[]
                {
                    "core", "master", "web"
                };
                var localDBs =
                    instance.AttachedDatabases.Where(
                        d => d.ConnectionString.DataSource == sqlServerInstanceName).ToArray();
                Log.Debug($"localDbs.Length: {localDBs.Length}");

                foreach (string databaseName in firstOrderDatabaseNames)
                {
                    mainDatabase = localDBs.SingleOrDefault(d => d.Name == databaseName);
                    Log.Debug($"databaseName: {databaseName}");
                    Log.Debug($"mainDatabase!=null: {mainDatabase != null}");
                    if (mainDatabase != null)
                    {
                        return(ProfileSection.Result(mainDatabase));
                    }
                }

                mainDatabase = localDBs.FirstOrDefault();

                return(ProfileSection.Result(mainDatabase));
            }
        }
        private static void InitializeRibbonTab([NotNull] TabDefinition tab, MainWindow window, Func <string, ImageSource> getImage)
        {
            Assert.ArgumentNotNull(tab, nameof(tab));

            var name = tab.Name;

            Assert.IsNotNull(name, nameof(name));

            using (new ProfileSection("Initialize ribbon tab"))
            {
                ProfileSection.Argument("name", name);

                var tabName   = name + "Tab";
                var ribbonTab = window.FindName(tabName) as RibbonTabItem ?? CreateTab(window, name);
                Assert.IsNotNull(ribbonTab, "Cannot find RibbonTab with {0} name".FormatWith(tabName));

                foreach (var group in tab.Groups)
                {
                    Assert.IsNotNull(group, nameof(group));

                    // Get Ribbon Group to insert button to
                    name = group.Name;
                    var groupName   = tabName + name + "Group";
                    var ribbonGroup = GetRibbonGroup(name, tabName, groupName, ribbonTab, window);

                    Assert.IsNotNull(ribbonGroup, "Cannot find RibbonGroup with {0} name".FormatWith(groupName));

                    foreach (var button in group.Buttons)
                    {
                        InitializeRibbonButton(window, getImage, button, ribbonGroup);
                    }
                }
            }
        }
Example #4
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");
                }
            }
        }
        public Wizard(WizardPipeline wizardPipeline, ProcessorArgs args, [NotNull] Func <WizardArgs> createWizardArgs)
        {
            using (new ProfileSection("Create wizard instance", this))
            {
                ProfileSection.Argument("wizardPipeline", wizardPipeline);
                ProfileSection.Argument("args", args);

                WizardArgs = createWizardArgs();
                if (WizardArgs != null)
                {
                    WizardArgs.WizardWindow = this;
                }

                WizardPipeline = wizardPipeline;
                Args           = args;
                InitializeComponent();
                ProgressBar1Foreground = progressBar1.Foreground;
                if (!WinAppSettings.AppSysIsSingleThreaded.Value)
                {
                    CancelButton.IsCancel = false;
                    ResizeMode            = ResizeMode.CanMinimize;
                }
            }

            Initialize();
        }
        private static void InitializeRibbonGroup(string name, string tabName, XmlElement groupElement, RibbonTabItem ribbonTab, MainWindow window, Func <string, ImageSource> getImage)
        {
            using (new ProfileSection("Initialize ribbon group"))
            {
                ProfileSection.Argument("name", name);
                ProfileSection.Argument("tabName", tabName);
                ProfileSection.Argument("groupElement", groupElement);
                ProfileSection.Argument("ribbonTab", ribbonTab);
                ProfileSection.Argument("window", window);
                ProfileSection.Argument("getImage", getImage);

                // Get Ribbon Group to insert button to
                name = groupElement.GetNonEmptyAttribute("name");
                var groupName   = tabName + name + "Group";
                var ribbonGroup = GetRibbonGroup(name, tabName, groupName, ribbonTab, window);

                Assert.IsNotNull(ribbonGroup, "Cannot find RibbonGroup with {0} name".FormatWith(groupName));

                var buttons = SelectNonEmptyCollection(groupElement, "button");
                foreach (var button in buttons)
                {
                    InitializeRibbonButton(window, getImage, button, ribbonGroup);
                }
            }
        }
        private static void InitializeRibbonTab(XmlElement tabElement, MainWindow window, Func <string, ImageSource> getImage)
        {
            var name = tabElement.GetNonEmptyAttribute("name");

            if (string.IsNullOrEmpty(name))
            {
                Log.Error($"Ribbon tab doesn't have name: {tabElement.OuterXml}");
                return;
            }

            using (new ProfileSection("Initialize ribbon tab"))
            {
                ProfileSection.Argument("name", name);

                var tabName   = name + "Tab";
                var ribbonTab = window.FindName(tabName) as RibbonTabItem ?? CreateTab(window, name);
                Assert.IsNotNull(ribbonTab, "Cannot find RibbonTab with {0} name".FormatWith(tabName));

                var groups = SelectNonEmptyCollection(tabElement, "group");
                foreach (XmlElement groupElement in groups)
                {
                    InitializeRibbonGroup(name, tabName, groupElement, ribbonTab, window, getImage);
                }
            }
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            using (new ProfileSection("Refresh main window instances", this))
            {
                ProfileSection.Argument("mainWindow", mainWindow);
                ProfileSection.Argument("instance", instance);

                var refreshMode = this.GetMode(mainWindow);
                switch (refreshMode)
                {
                case RefreshMode.Instances:
                    MainWindowHelper.RefreshInstances();
                    return;

                case RefreshMode.Installer:
                    MainWindowHelper.RefreshInstaller();
                    return;

                case RefreshMode.Caches:
                    MainWindowHelper.RefreshCaches();
                    return;

                case RefreshMode.Everything:
                    MainWindowHelper.RefreshEverything();
                    return;
                }
            }
        }
Example #9
0
        private static void ProcessFile(string file)
        {
            Assert.IsNotNullOrEmpty(file, "file");

            using (new ProfileSection("Process file", typeof(ProductManager)))
            {
                ProfileSection.Argument("file", file);

                Product product;
                if (!Product.TryParse(file, out product))
                {
                    ProfileSection.Result("Skipped (not a product)");
                    return;
                }

                if (Products.Any(p => p.ToString().EqualsIgnoreCase(product.ToString())))
                {
                    ProfileSection.Result("Skipped (already exist)");
                    return;
                }

                Products.Add(product);
                ProfileSection.Result("Added");
            }
        }
        public virtual string FindCommonParent([NotNull] string path1, [NotNull] string path2)
        {
            Assert.ArgumentNotNull(path1, nameof(path1));
            Assert.ArgumentNotNull(path2, nameof(path2));
            var path = string.Empty;

            using (new ProfileSection("Find common parent", this))
            {
                ProfileSection.Argument("path1", path1);
                ProfileSection.Argument("path2", path2);

                string[] arr1   = path1.Replace('/', '\\').Split('\\');
                string[] arr2   = path2.Replace('/', '\\').Split('\\');
                var      minLen = Math.Min(arr1.Length, arr2.Length);
                for (int i = 0; i < minLen; ++i)
                {
                    var word1 = arr1[i];
                    var word2 = arr2[i];
                    if (!word1.EqualsIgnoreCase(word2))
                    {
                        break;
                    }

                    path += word1 + '\\';
                }

                path = path.TrimEnd('\\');
                ProfileSection.Result(path);
            }

            return(path);
        }
        public virtual int GetDistance(string directory1, string directory2)
        {
            Assert.ArgumentNotNullOrEmpty(directory1, nameof(directory1));
            Assert.ArgumentNotNullOrEmpty(directory2, nameof(directory2));

            using (new ProfileSection("Get distance", this))
            {
                ProfileSection.Argument("directory1", directory1);
                ProfileSection.Argument("directory2", directory2);

                directory1 = directory1.TrimEnd('\\');
                directory2 = directory2.TrimEnd('\\');

                var root1 = GetPathRoot(directory1);
                var root2 = GetPathRoot(directory2);
                Assert.IsTrue(HaveSameRoot(root1, root2), $"The '{directory1}' and '{directory2}' paths has different roots so unaplicable");

                var arr1   = directory1.Split('\\');
                var arr2   = directory2.Split('\\');
                var len    = Math.Min(arr1.Length, arr2.Length) - 1;
                var common = 0;
                for (int i = 0; i < len && arr1[i].EqualsIgnoreCase(arr2[i]); ++i)
                {
                    common++;
                }

                var distance = arr1.Length + arr2.Length - 2 * common - 2;

                return(ProfileSection.Result(distance));
            }
        }
Example #12
0
        private static bool InitializeProfileManager(Window mainWindow)
        {
            using (new ProfileSection("Initialize profile manager"))
            {
                ProfileSection.Argument("mainWindow", mainWindow);

                try
                {
                    ProfileManager.Initialize();
                    if (ProfileManager.IsValid)
                    {
                        return(ProfileSection.Result(true));
                    }

                    // if current profile is not valid then we will show the legacy profile if it exists, or at least use invalid one
                    WizardPipelineManager.Start("setup", mainWindow, null, false, null, ProfileManager.Profile ?? DetectProfile());
                    if (ProfileManager.IsValid)
                    {
                        return(ProfileSection.Result(true));
                    }
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Profile manager failed during initialization. " + AppLogsMessage, true, ex);
                }

                return(ProfileSection.Result(false));
            }
        }
        private static bool GetIsPackage(string packagePath, XmlDocument manifest)
        {
            if (string.IsNullOrEmpty(packagePath))
            {
                return(false);
            }

            const string cacheName = "IsPackage";
            string       path      = packagePath.ToLowerInvariant();

            using (new ProfileSection("Is it package or not"))
            {
                ProfileSection.Argument("packagePath", packagePath);
                ProfileSection.Argument("manifest", manifest);

                try
                {
                    // cache
                    var entry = CacheManager.GetEntry(cacheName, path);
                    if (entry != null)
                    {
                        var result = entry.EqualsIgnoreCase("true");

                        return(ProfileSection.Result(result));
                    }

                    if (
                        manifest.With(
                            x =>
                            x.SelectSingleElement(ManifestPrefix + "standalone") ?? x.SelectSingleElement(ManifestPrefix + "archive")) !=
                        null)
                    {
                        CacheManager.SetEntry(cacheName, path, "false");
                        return(ProfileSection.Result(false));
                    }

                    if (
                        manifest.With(
                            x =>
                            x.SelectSingleElement(ManifestPrefix + "package")) !=
                        null)
                    {
                        CacheManager.SetEntry(cacheName, path, "true");

                        return(ProfileSection.Result(true));
                    }

                    CacheManager.SetEntry(cacheName, path, "false");

                    return(ProfileSection.Result(false));
                }
                catch (Exception e)
                {
                    Log.Warn("Detecting if the '{0}' file is a Sitecore Package failed with exception.", path, e);
                    CacheManager.SetEntry(cacheName, path, "false");

                    return(ProfileSection.Result(false));
                }
            }
        }
Example #14
0
        public static void AddMongoDatabases([NotNull] XmlElement connectionStringsNode, [NotNull] List <MongoDbDatabase> databases)
        {
            Assert.ArgumentNotNull(connectionStringsNode, "connectionStringsNode");
            Assert.ArgumentNotNull(databases, "databases");

            using (new ProfileSection("Add mongo databases to web.config", typeof(WebConfig)))
            {
                ProfileSection.Argument("connectionStringsNode", connectionStringsNode);
                ProfileSection.Argument("databases", databases);

                XmlNodeList nodes = connectionStringsNode.SelectNodes("add");
                if (nodes != null && nodes.Count > 0)
                {
                    var elements = nodes.OfType <XmlElement>().ToArray();
                    Log.Debug("WebConfig:AddMongoDatabases(...)#elements.Length: " + elements.Length);
                    foreach (XmlElement node in elements)
                    {
                        string value = node.GetAttribute("connectionString");
                        Log.Debug("WebConfig:AddMongoDatabases(...)#value: " + value);

                        if (SqlServerManager.Instance.IsSqlConnectionString(value))
                        {
                            continue;
                        }

                        var name = node.GetAttribute("name");
                        Log.Debug("WebConfig:AddMongoDatabases(...)#name: " + name);

                        databases.Add(new MongoDbDatabase(name, value));
                    }
                }
            }
        }
Example #15
0
        public static string GetScVariable([NotNull] XmlDocument webConfig, [NotNull] string variableName)
        {
            Assert.ArgumentNotNull(webConfig, "webConfig");
            Assert.ArgumentNotNull(variableName, "variableName");

            using (new ProfileSection("Get Sitecore variable", typeof(WebConfig)))
            {
                ProfileSection.Argument("webConfig", webConfig);
                ProfileSection.Argument("variableName", variableName);

                try
                {
                    XmlElement dataFolderNode = GetScVariableElement(webConfig, variableName);
                    if (dataFolderNode != null)
                    {
                        XmlAttribute valueAttr = dataFolderNode.Attributes["value"];
                        if (valueAttr != null)
                        {
                            var result = valueAttr.Value;

                            return(ProfileSection.Result(result));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn("Cannot get sc variable {0}".FormatWith(variableName), typeof(WebConfig), ex);
                }

                return(ProfileSection.Result <string>(null));
            }
        }
        private void InitializeStep(int?i = null)
        {
            using (new ProfileSection("Initializing step", this))
            {
                ProfileSection.Argument("i", i);

                var n = i ?? PageNumber;

                using (new ProfileSection("Set header", this))
                {
                    StepInfo[] stepInfos = WizardPipeline._StepInfos;
                    if (stepInfos.Length > n)
                    {
                        var title = stepInfos[n].Title;
                        HeaderDetails.Text = ReplaceVariables(title);
                    }
                }

                InitializeIWizardStep(n);

                // regular step
                if (PageNumber < StepsCount - 1)
                {
                    NextButton.Content = "Next";
                    return;
                }

                // the last step before Progress Step
                if (PageNumber == StepsCount - 1)
                {
                    NextButton.Content = WizardPipeline.StartButtonText;
                    return;
                }

                // the Progress Step
                if (PageNumber == StepsCount)
                {
                    string pipelineName = WizardPipeline.Name;
                    if (!string.IsNullOrWhiteSpace(_ProcessorArgs.PipelineName))
                    {
                        pipelineName = _ProcessorArgs.PipelineName;
                    }

                    if (!PipelineManager.Definitions.ContainsKey(WizardPipeline.Name))
                    {
                        Finish("Done.", true);

                        return;
                    }

                    PipelineManager.StartPipeline(pipelineName, _ProcessorArgs, this);
                    backButton.Visibility = Visibility.Hidden;
                    CancelButton.Content  = "Cancel";
                    NextButton.IsEnabled  = false;
                    NextButton.Content    = "Retry";
                    NextButton.Click     -= MoveNextClick;
                    NextButton.Click     += RetryClick;
                }
            }
        }
Example #17
0
        private static void Refresh([NotNull] string localRepository)
        {
            Assert.ArgumentNotNull(localRepository, "localRepository");

            using (new ProfileSection("Refresh product manager", typeof(ProductManager)))
            {
                ProfileSection.Argument("localRepository", localRepository);

                if (!string.IsNullOrEmpty(localRepository))
                {
                    Assert.IsNotNull(localRepository.EmptyToNull(), "The Local Repository folder isn't specified in the Settings dialog");
                    try
                    {
                        FileSystem.FileSystem.Local.Directory.AssertExists(localRepository, "The Local Repository folder ('{0}') doesn't exist".FormatWith(localRepository));
                    }
                    catch (Exception ex)
                    {
                        throw new ConfigurationErrorsException(ex.Message, ex);
                    }

                    if (FileSystem.FileSystem.Local.Directory.Exists(localRepository))
                    {
                        var zipFiles = GetProductFiles(localRepository);

                        Refresh(zipFiles);
                    }
                }
            }
        }
        private static List <string> GetFileNamePatterns(IEnumerable <string> fileNamesRaw)
        {
            using (new ProfileSection("Get manifest lookup folders"))
            {
                ProfileSection.Argument("fileNamesRaw", fileNamesRaw);

                var fileNamePatterns = new List <string>();
                foreach (string filename in fileNamesRaw)
                {
                    if (string.IsNullOrEmpty(filename) || fileNamePatterns.Contains(filename))
                    {
                        continue;
                    }

                    fileNamePatterns.Add(filename);

                    // if it is CMS
                    if (filename.StartsWith("sitecore 6") || filename.StartsWith("sitecore 7"))
                    {
                        continue;
                    }

                    var cut = filename.TrimStart("sitecore ").Trim();
                    if (!string.IsNullOrEmpty(cut) && !fileNamePatterns.Contains(cut))
                    {
                        fileNamePatterns.Add(cut);
                    }
                }

                return(fileNamePatterns);
            }
        }
        private static void Execute([NotNull] PipelineStartInfo info)
        {
            using (new ProfileSection("Execute pipeline processors"))
            {
                ProfileSection.Argument("info", info);

                try
                {
                    if (info.PipelineController != null)
                    {
                        info.PipelineController.Maximum = ProcessorManager.GetProcessorsCount(info.ProcessorArgs, info._Steps);
                    }

                    bool result = ExecuteSteps(info.ProcessorArgs, info._Steps, info.PipelineController);

                    if (info.PipelineController != null)
                    {
                        info.PipelineController.Finish("Done.", result);
                    }

                    if (result)
                    {
                        info.ProcessorArgs.FireOnCompleted();
                        info.ProcessorArgs.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn(ex, "An error occurred during executing a pipeline");
                    info.ProcessorArgs.Dispose();
                }
            }
        }
        private bool TryCopyFromExternalRepository(string fileName, string destFileName)
        {
            var externalRepositories = WindowsSettings.AppDownloaderExternalRepository.Value;

            if (!string.IsNullOrEmpty(externalRepositories))
            {
                try
                {
                    foreach (var repository in externalRepositories.Split('|').Reverse())
                    {
                        var files = FileSystem.FileSystem.Local.Directory.GetFiles(repository, fileName, SearchOption.AllDirectories);
                        var externalRepositoryFilePath = files.FirstOrDefault();
                        if (!string.IsNullOrEmpty(externalRepositoryFilePath) && FileSystem.FileSystem.Local.File.Exists(externalRepositoryFilePath))
                        {
                            using (new ProfileSection("Copying file from remote repository", this))
                            {
                                ProfileSection.Argument("fileName", fileName);
                                ProfileSection.Argument("externalRepositoryFilePath", externalRepositoryFilePath);

                                WindowHelper.CopyFileUi(externalRepositoryFilePath, destFileName, Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException);
                            }

                            Log.Info($"Copying the {fileName} file has completed");
                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn(ex, $"Unable to copy the {fileName} file from external repository");
                }
            }

            return(false);
        }
        public static string ReplaceVariables([NotNull] string message, [NotNull] object args)
        {
            Assert.ArgumentNotNull(message, nameof(message));
            Assert.ArgumentNotNull(args, nameof(args));

            using (new ProfileSection("Replace pipeline variables in message"))
            {
                ProfileSection.Argument("message", message);
                ProfileSection.Argument("args", args);

                Type type = args.GetType();
                foreach (var propertyName in message.Extract('{', '}', false))
                {
                    var propertyInfo = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);
                    Assert.IsNotNull(propertyInfo, $"Cannot find {propertyName} property in {type.FullName}");

                    var propertyValue = propertyInfo.GetValue(args, new object[0]) as string;
                    if (propertyValue != null)
                    {
                        message = message.Replace('{' + propertyName + '}', propertyValue);
                    }
                }

                return(ProfileSection.Result(message));
            }
        }
        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));
            }
        }
 public object Convert([CanBeNull] object value, [CanBeNull] Type targetType, [CanBeNull] object parameter, [CanBeNull] CultureInfo culture)
 {
     using (new ProfileSection("Checking if button is visible", this))
     {
         ProfileSection.Argument("this.button", Button.GetType().FullName);
         return(Button.IsVisible(MainWindow.Instance, value as Instance) ? Visibility.Visible : Visibility.Collapsed);
     }
 }
 public object Convert([CanBeNull] object value, [CanBeNull] Type targetType, [CanBeNull] object parameter, [CanBeNull] CultureInfo culture)
 {
     using (new ProfileSection("Checking if button is enabled", this))
     {
         ProfileSection.Argument("this.button", this.button.GetType().FullName);
         return(this.button.IsEnabled(MainWindow.Instance, value as Instance));
     }
 }
        public virtual XmlDocument GetShowconfig(bool normalize = false)
        {
            using (new ProfileSection("Get showconfig.xml config", this))
            {
                ProfileSection.Argument("normalize", normalize);

                return(this.RuntimeSettingsAccessor.GetShowconfig(normalize));
            }
        }
        public virtual XmlDocument GetWebResultConfig(bool normalize = false)
        {
            using (new ProfileSection("Get web.config.result.xml config", this))
            {
                ProfileSection.Argument("normalize", normalize);

                return(this.RuntimeSettingsAccessor.GetWebConfigResult(normalize));
            }
        }
        public static void Initialize([CanBeNull] string defaultRootFolder = null)
        {
            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("Initialize instance manager"))
            {
                ProfileSection.Argument("defaultRootFolder", defaultRootFolder);

                IEnumerable <Site> sites = GetOperableSites(context, defaultRootFolder);
                PartiallyCachedInstances = GetPartiallyCachedInstances(sites);
                Instances = GetInstances();
            }
        }
        private static IEnumerable <Instance> GetPartiallyCachedInstances(IEnumerable <Site> sites)
        {
            using (new ProfileSection("Getting partially cached Sitecore instances"))
            {
                ProfileSection.Argument("sites", sites);

                var array = sites.Select(GetPartiallyCachedInstance).Where(IsSitecore).ToArray();

                return(ProfileSection.Result(array));
            }
        }
        public static Instance GetInstance(long id)
        {
            using (new ProfileSection("Get instance by id"))
            {
                ProfileSection.Argument("id", id);

                var instance = new Instance((int)id);

                return(ProfileSection.Result(instance));
            }
        }
Example #30
0
        private static string[] GetProductFiles(string localRepository)
        {
            using (new ProfileSection("Get product files", typeof(ProductManager)))
            {
                ProfileSection.Argument("localRepository", localRepository);

                var zipFiles = FileSystem.FileSystem.Local.Directory.GetFiles(localRepository, "*.zip", SearchOption.AllDirectories);

                return(ProfileSection.Result(zipFiles));
            }
        }