Пример #1
0
        static public Dictionary <string, string> GetAlbums(string spaceName)
        {
            Dictionary <string, string> albums = new Dictionary <string, string>();

            try
            {
                // Get the space rss document
                XmlDocumentEx rssXmlDocument = new XmlDocumentEx();
                rssXmlDocument.Load("http://" + spaceName + ".spaces.live.com/photos/feed.rss");
                rssXmlDocument.LoadNamespaces();

                // Get the album xml documents that are part of this list
                List <XmlDocumentEx> albumXmlDocuments = new List <XmlDocumentEx>();
                XmlNodeList          xmlNodes          = rssXmlDocument.SelectNodes("rss/channel/item");

                foreach (XmlNode xmlNode in xmlNodes)
                {
                    // See if this is an album
                    XmlNode type = xmlNode.SelectSingleNode("live:type", rssXmlDocument.NamespaceManager);
                    if (type.InnerText == "photoalbum")
                    {
                        string title = xmlNode.SelectSingleNode("title").InnerText;
                        title = title.Substring(title.IndexOf(": ") + 2);
                        string albumGuid = xmlNode.SelectSingleNode("guid").InnerText;

                        albums.Add(title, albumGuid);
                    }
                }
            }
            catch (Exception)
            {
            }

            return(albums);
        }
Пример #2
0
 private Plugin(string pluginFilePath)
 {
     this.PluginFilePath    = pluginFilePath;
     this.PluginFolder      = Path.GetDirectoryName(pluginFilePath);
     this.AssemblyFilePaths = FileSystem.FileSystem.Local.File.GetNeighbourFiles(pluginFilePath, "*.dll");
     this.PluginXmlDocument = XmlDocumentEx.LoadFile(pluginFilePath);
 }
Пример #3
0
        private static void WipeSqlServerCredentials(string webRootPath)
        {
            var pathToConnectionStringsConfig = webRootPath.PathCombine("App_Config").PathCombine("ConnectionStrings.config");

            var connectionStringsDocument = new XmlDocumentEx();

            connectionStringsDocument.Load(pathToConnectionStringsConfig);

            var connectionsStringsElement = new XmlElementEx(connectionStringsDocument.DocumentElement, connectionStringsDocument);

            var connectionStrings = new ConnectionStringCollection(connectionsStringsElement);

            connectionStrings.AddRange(connectionsStringsElement.Element.ChildNodes.OfType <XmlElement>().Select(element => new ConnectionString(element, connectionsStringsElement.Document)));

            foreach (var connectionString in connectionStrings)
            {
                if (!connectionString.IsSqlConnectionString)
                {
                    continue;
                }

                var builder = new SqlConnectionStringBuilder(connectionString.Value)
                {
                    DataSource = string.Empty,
                    UserID     = string.Empty,
                    Password   = string.Empty
                };
                connectionString.Value = builder.ToString();
            }

            connectionStrings.Save();
        }
        private void GetSettingsFromIISFiles(ImportArgs args)
        {
            using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("ImportSolution.Initialization"))
            {
                string        appPoolFilePath         = FileSystem.FileSystem.Local.Zip.ZipUnpackFile(args.PathToExportedInstance, args.temporaryPathToUnpack, ImportArgs.appPoolSettingsFileName);
                string        websiteSettingsFilePath = FileSystem.FileSystem.Local.Zip.ZipUnpackFile(args.PathToExportedInstance, args.temporaryPathToUnpack, ImportArgs.websiteSettingsFileName);
                XmlDocumentEx appPool = new XmlDocumentEx();
                appPool.Load(appPoolFilePath);

                XmlDocumentEx websiteSettings = new XmlDocumentEx();
                websiteSettings.Load(websiteSettingsFilePath);
                args.oldSiteName = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site", "name");
                if (args.siteName == string.Empty)
                {
                    args.siteName = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site", "name");
                }

                args.virtualDirectoryPath = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site/application/virtualDirectory", "path");

                if (args.virtualDirectoryPhysicalPath == string.Empty)
                {
                    args.virtualDirectoryPhysicalPath = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site/application/virtualDirectory", "physicalPath");
                }

                args.appPoolName = appPool.GetElementAttributeValue("/appcmd/APPPOOL", "APPPOOL.NAME"); // need to set appPoolName in both files
                if (args.appPoolName != args.siteName)
                {
                    args.appPoolName = args.siteName;
                }

                args.appPoolName = SetupWebsiteHelper.ChooseAppPoolName(args.appPoolName, context.ApplicationPools);
                args.siteID      = long.Parse(websiteSettings.GetElementAttributeValue("/appcmd/SITE", "SITE.ID"));
            }
        }
        public virtual XmlDocumentEx XmlMerge(string filePath, string xmlString)
        {
            XmlDocumentEx doc1 = XmlDocumentEx.LoadFile(filePath);
            XmlDocument   doc2 = XmlDocumentEx.LoadXml(xmlString);

            return(doc1.Merge(doc2));
        }
        public void Constructor_InvalidSolrVersion_Throws()
        {
            XmlDocumentEx solr4Definition =
                XmlDocumentEx.LoadXml(@"<response><lst name=""lucene""><str name=""solr-spec-version"">3.0.0</str></lst></response>");

            new SolrInformation(solr4Definition);
        }
        public static void AreEqual(XmlDocumentEx actual, XmlDocumentEx expected, string footerMessage = null)
        {
            var afp = actual.FilePath;
              if (string.IsNullOrEmpty(afp) || !File.Exists(afp))
              {
            afp = Path.GetTempFileName() + ".xml";
            actual.Save(afp);
              }

              var efp = expected.FilePath;
              if (string.IsNullOrEmpty(efp) || !File.Exists(efp))
              {
            efp = Path.GetTempFileName() + ".xml";
            expected.Save(efp);
              }

              AreEqual(XmlDocumentEx.Normalize(actual.OuterXml), XmlDocumentEx.Normalize(expected.OuterXml), @"Xml files are different
            Path (Actual): {0}
            Path (Expect): {1}

            Compare CMD:
            WinMergeU ""{0}"" ""{1}""

            {2}".FormatWith(afp, efp, footerMessage));
        }
Пример #8
0
        private static bool InitializePipelines()
        {
            using (new ProfileSection("Re-initializing pipelines"))
            {
                try
                {
                    var wizardPipelinesConfig = XmlDocumentEx.LoadFile(WizardPipelineManager.WizardpipelinesConfigFilePath);
                    var pipelinesNode         = wizardPipelinesConfig.SelectSingleNode("/configuration/pipelines") as XmlElement;
                    Assert.IsNotNull(pipelinesNode, "pipelinesNode2");

                    var pipelinesConfig = XmlDocumentEx.LoadFile(PipelineManager.PipelinesConfigFilePath);
                    pipelinesConfig.Merge(XmlDocumentEx.LoadXml("<configuration>" + pipelinesNode.OuterXml + "</configuration>"));

                    var resultPipelinesNode = pipelinesConfig.SelectSingleNode("configuration/pipelines") as XmlElement;
                    Assert.IsNotNull(resultPipelinesNode, "Can't find pipelines configuration node");

                    PipelineManager.Initialize(resultPipelinesNode);

                    return(true);
                }
                catch (Exception ex)
                {
                    WindowHelper.HandleError("Error during initializing pipelines", true, ex);

                    return(false);
                }
            }
        }
Пример #9
0
        public static XmlElement Initialize(string pipelinesConfigFilePath = null)
        {
            var        document      = XmlDocumentEx.LoadFile(pipelinesConfigFilePath.EmptyToNull() ?? PipelinesConfigFilePath);
            XmlElement pipelinesNode = GetPipelines(document);

            return(Initialize(pipelinesNode));
        }
        public void Constructor_SolrPathMissing_Throws()
        {
            XmlDocumentEx missingPath =
                XmlDocumentEx.LoadXml(@"<response><lst name=""lucene""><str name=""solr-spec-version"">4.0.0</str></lst></response>");

            new SolrInformation(missingPath);
        }
 private XMLHelper()
 {
     XmlDocument objDoc = new XmlDocument();
     string path = System.Environment.CurrentDirectory + @"\XMLFileList.xml";
     objDoc.Load(path);
     XmlNodeList xmlFiles = objDoc.DocumentElement.SelectSingleNode("Files").ChildNodes;
     if (xmlFiles != null && xmlFiles.Count > 0)
     {
         foreach (XmlNode voiceItem in xmlFiles)
         {
             if (voiceItem.NodeType != XmlNodeType.Element)
                 continue;
             XmlAttribute keyAttr = voiceItem.Attributes["key"];
             XmlAttribute pathAttr = voiceItem.Attributes["path"];
             if (null != keyAttr && !string.IsNullOrEmpty(keyAttr.Value)
                 && null != pathAttr && !string.IsNullOrEmpty(pathAttr.Value))
             {
                 string pathN = System.Environment.CurrentDirectory + (pathAttr.Value.StartsWith(@"\") ? pathAttr.Value : @"\" + pathAttr.Value);
                 XmlDocument XmldocN = new XmlDocument();
                 XmldocN.Load(pathN);
                 XmlDocumentEx xmlDocEx = new XmlDocumentEx();
                 xmlDocEx.XmlDoc = XmldocN;
                 XMLFiles.Add(keyAttr.Value, xmlDocEx);
             }
         }
     }
 }
        private static void UpdateSettings([NotNull] string nugetFolderPath)
        {
            Assert.ArgumentNotNull(nugetFolderPath, "nugetFolderPath");

            var nugetConfigPath = Environment.ExpandEnvironmentVariables(@"%appdata%\NuGet\nuget.config");
            var bakFilePath     = nugetConfigPath + ".bak";

            if (!File.Exists(bakFilePath))
            {
                File.Copy(nugetConfigPath, bakFilePath);
            }

            var nugetConfig = XmlDocumentEx.LoadFile(nugetConfigPath);

            Assert.IsNotNull(nugetConfig, "nugetConfig");

            var config = nugetConfig.SelectSingleNode("/configuration") ?? nugetConfig.DocumentElement.AddElement("configuration");

            Assert.IsNotNull(config, "config");

            var keyName        = "Sitecore NuGet";
            var packageSources = nugetConfig.SelectSingleElement("/configuration/packageSources") ?? config.AddElement("packageSources");

            Assert.IsNotNull(packageSources, "packageSources");

            var addElements = packageSources.ChildNodes.OfType <XmlElement>();
            var add         = addElements.FirstOrDefault(x => x.GetAttribute("key").Equals(keyName, StringComparison.OrdinalIgnoreCase)) ?? packageSources.AddElement("add");

            Assert.IsNotNull(add, "add");

            add.SetAttribute("key", keyName);
            add.SetAttribute("value", nugetFolderPath);
            nugetConfig.Save();
        }
        private void SetElementValueTest(string str, string path, string value, string expected)
        {
            var xml = XmlDocumentEx.LoadXml(str);

            xml.SetElementValue(path, value);
            Assert.AreEqual(Environment.NewLine + expected + Environment.NewLine, Environment.NewLine + xml.OuterXml + Environment.NewLine);
        }
        public void Constructor_InvalidSolrNode_Throws()
        {
            XmlDocumentEx definitionWithInvalidVersion =
                XmlDocumentEx.LoadXml(@"<response><lst name=""lucene""><str name=""solr-spec-version"">invalidSolrVersion</str></lst></response>");

            new SolrInformation(definitionWithInvalidVersion);
        }
    private void GetSettingsFromIISFiles(ImportArgs args)
    {
      using (WebServerManager.WebServerContext context = WebServerManager.CreateContext("ImportSolution.Initialization"))
      {
        string appPoolFilePath = FileSystem.FileSystem.Local.Zip.ZipUnpackFile(args.PathToExportedInstance, args.temporaryPathToUnpack, ImportArgs.appPoolSettingsFileName);
        string websiteSettingsFilePath = FileSystem.FileSystem.Local.Zip.ZipUnpackFile(args.PathToExportedInstance, args.temporaryPathToUnpack, ImportArgs.websiteSettingsFileName);
        XmlDocumentEx appPool = new XmlDocumentEx();
        appPool.Load(appPoolFilePath);

        XmlDocumentEx websiteSettings = new XmlDocumentEx();
        websiteSettings.Load(websiteSettingsFilePath);
        args.oldSiteName = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site", "name");
        if (args.siteName == string.Empty)
        {
          args.siteName = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site", "name");
        }

        args.virtualDirectoryPath = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site/application/virtualDirectory", "path");

        if (args.virtualDirectoryPhysicalPath == string.Empty)
        {
          args.virtualDirectoryPhysicalPath = websiteSettings.GetElementAttributeValue("/appcmd/SITE/site/application/virtualDirectory", "physicalPath");
        }

        args.appPoolName = appPool.GetElementAttributeValue("/appcmd/APPPOOL", "APPPOOL.NAME"); // need to set appPoolName in both files
        if (args.appPoolName != args.siteName)
        {
          args.appPoolName = args.siteName;
        }

        args.appPoolName = SetupWebsiteHelper.ChooseAppPoolName(args.appPoolName, context.ApplicationPools);
        args.siteID = long.Parse(websiteSettings.GetElementAttributeValue("/appcmd/SITE", "SITE.ID"));
      }
    }
Пример #16
0
        protected override void DoExecute(CommandResult <string[]> result)
        {
            Assert.ArgumentNotNull(result, "result");

            var name = this.Name;

            Assert.ArgumentNotNullOrEmpty(name, "name");

            var profile          = Profile.Read();
            var connectionString = profile.GetValidConnectionString();

            InstanceManager.Initialize();
            var instance = InstanceManager.Instances.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            Ensure.IsNotNull(instance, "instance is not found");

            PipelineManager.Initialize(XmlDocumentEx.LoadXml(PipelinesConfig.Contents).DocumentElement);

            var deleteArgs = new DeleteArgs(instance, connectionString);
            var controller = new AggregatePipelineController();

            PipelineManager.StartPipeline("delete", deleteArgs, controller, false);

            result.Success = !string.IsNullOrEmpty(controller.Message);
            result.Message = controller.Message;
            result.Data    = controller.GetMessages().ToArray();
        }
Пример #17
0
        private static XmlElementEx GetConnectionStringsElement(XmlDocumentEx webConfig)
        {
            var        webRootPath       = Path.GetDirectoryName(webConfig.FilePath);
            XmlElement configurationNode = webConfig.SelectSingleNode(WebConfig.ConfigurationXPath) as XmlElement;

            Assert.IsNotNull(configurationNode,
                             "The {0} element is missing in the {1} file".FormatWith("/configuration", webConfig.FilePath));
            XmlElement webConfigConnectionStrings = configurationNode.SelectSingleNode("connectionStrings") as XmlElement;

            Assert.IsNotNull(webConfigConnectionStrings,
                             "The web.config file doesn't contain the /configuration/connectionStrings node");
            XmlAttribute configSourceAttribute = webConfigConnectionStrings.Attributes[WebConfig.ConfigSourceAttributeName];

            if (configSourceAttribute != null)
            {
                string configSourceValue = configSourceAttribute.Value;
                if (!string.IsNullOrEmpty(configSourceValue) && !string.IsNullOrEmpty(webRootPath))
                {
                    string filePath = Path.Combine(webRootPath, configSourceValue);
                    if (FileSystem.FileSystem.Local.File.Exists(filePath))
                    {
                        XmlDocumentEx connectionStringsConfig = XmlDocumentEx.LoadFile(filePath);
                        XmlElement    connectionStrings       = connectionStringsConfig.SelectSingleNode("/connectionStrings") as XmlElement;
                        if (connectionStrings != null)
                        {
                            return(new XmlElementEx(connectionStrings, connectionStringsConfig));
                        }
                    }
                }
            }

            return(new XmlElementEx(webConfigConnectionStrings, webConfig));
        }
        public static void AreEqual(XmlDocumentEx actual, XmlDocumentEx expected, string footerMessage = null)
        {
            var afp = actual.FilePath;

            if (string.IsNullOrEmpty(afp) || !File.Exists(afp))
            {
                afp = Path.GetTempFileName() + ".xml";
                actual.Save(afp);
            }

            var efp = expected.FilePath;

            if (string.IsNullOrEmpty(efp) || !File.Exists(efp))
            {
                efp = Path.GetTempFileName() + ".xml";
                expected.Save(efp);
            }

            AreEqual(XmlDocumentEx.Normalize(actual.OuterXml), XmlDocumentEx.Normalize(expected.OuterXml), @"Xml files are different
Path (Actual): {0}
Path (Expect): {1}

Compare CMD: 
WinMergeU ""{0}"" ""{1}""

{2}".FormatWith(afp, efp, footerMessage));
        }
Пример #19
0
        public static void Install([NotNull] IFolder root, string version, string role)
        {
            var webConfigFile = root.GetChildFile("web.config");

            var webConfig    = new XmlDocumentEx(webConfigFile.FullName);
            var configReader = webConfig.SelectSingleElement("/configuration/configSections/section[@name='sitecore']");

            Assert.IsNotNull(configReader);

            if (configReader.GetAttribute("type") == "Sitecore.Configuration.ConfigReader, Sitecore.Kernel")
            {
                InstallAssemblyTo(root.GetChildFolder("bin"));
                InstallIncludeFiles(version, root);

                webConfigFile.ReplaceLine("<section name=\"sitecore\" .+/>", "<section name=\"sitecore\" type=\"Sitecore.Configuration.Roles.RoleConfigReader, Sitecore.Configuration.Roles\" />");
                webConfigFile.ReplaceLine("</appSettings>", $"  <add key=\"role:define\" value=\"{role}\" />\r\n  </appSettings>");
            }
            else
            {
                // modified image with config roles pre-installed so only specify role
                var roleDefine = webConfig.SelectSingleElement("/configuration/appSettings/add[@key='role:define']");
                if (roleDefine != null)
                {
                    roleDefine.SetAttribute("value", role);
                    webConfig.Save();
                }
                else
                {
                    webConfigFile.ReplaceLine("</appSettings>", $"  <add key=\"role:define\" value=\"{role}\" />\r\n  </appSettings>");
                }
            }
        }
        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"));
                        }
                    }
                }
            }
        }
Пример #21
0
        public void RealTest()
        {
            string path     = Path.GetFullPath(@"..\..\..\..\Code\Core Level 4\Pipelines\Pipelines.config");
            var    actual   = XmlDocumentEx.LoadXml(PipelineManager.Initialize(path).OuterXml);
            var    expected = XmlDocumentEx.LoadXml(ExpectedPipelinesXml);

            TestHelper.AreEqual(actual, expected);
        }
Пример #22
0
        private static XmlElement GetWizardPipelinesElement()
        {
            var        document      = XmlDocumentEx.LoadFile(WizardpipelinesConfigFilePath);
            XmlElement pipelinesNode = document.SelectSingleNode("configuration/wizardPipelines") as XmlElement;

            Assert.IsNotNull(pipelinesNode, "Can't find wizardPipelines configuration node in the WizardPipelines.config file");
            return(pipelinesNode);
        }
Пример #23
0
        private XmlElementEx GetConnectionStringsElement()
        {
            XmlDocumentEx webConfig = this.instance.GetWebConfig();

            Assert.IsNotNull(webConfig, "webConfig");

            return(GetConnectionStringsElement(webConfig));
        }
    public XmlElementEx([NotNull] XmlElement element, [NotNull] XmlDocumentEx document)
    {
      Assert.ArgumentNotNull(element, "element");
      Assert.ArgumentNotNull(document, "document");

      this.Document = document;
      this.Element = element;
    }
        private void MergeTest(string str1, string str2, string expected)
        {
            this.iteration++;
            XmlDocumentEx doc1   = XmlDocumentEx.LoadXml(str1);
            XmlDocumentEx doc2   = XmlDocumentEx.LoadXml(str2);
            var           actual = doc1.Merge(doc2);

            Assert.AreEqual(this.iteration + Environment.NewLine + expected + Environment.NewLine, this.iteration + Environment.NewLine + actual.OuterXml + Environment.NewLine);
        }
        private static string GetProductFullName([NotNull] string assemblyPath)
        {
            Assert.ArgumentNotNull(assemblyPath, nameof(assemblyPath));

            var websiteFolderPath = Path.GetDirectoryName(Path.GetDirectoryName(assemblyPath));

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

            var sitecoreVersionFilePath = Path.Combine(websiteFolderPath, "sitecore\\shell\\sitecore.version.xml");

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

            if (FileSystem.FileSystem.Local.File.Exists(sitecoreVersionFilePath))
            {
                try
                {
                    var xml   = new XmlDocumentEx(sitecoreVersionFilePath);
                    var major = xml.SelectSingleNode("information/version/major");
                    Assert.IsNotNull(major, nameof(major));

                    var minor = xml.SelectSingleNode("information/version/minor");
                    Assert.IsNotNull(minor, nameof(minor));

                    var build    = xml.SelectSingleNode("information/version/build");
                    var revision = xml.SelectSingleNode("information/version/revision");
                    return("Sitecore CMS {0}.{1}.{2} rev. {3}"
                           .FormatWith(major.InnerText, minor.InnerText, build == null ? string.Empty : build.InnerText, revision == null ? string.Empty : revision.InnerText)
                           .Replace(". rev", " rev")
                           .Trim(" .".ToCharArray()));
                }
                catch (Exception ex)
                {
                    Log.Warn(ex, $"An error occurred during reading {assemblyPath} file");
                }
            }

            FileInfo kernel = new FileInfo(assemblyPath);

            Assert.IsTrue(kernel.Exists, "It's not a Sitecore product");

            FileVersionInfo info = FileVersionInfo.GetVersionInfo(assemblyPath);

            if (info.ProductVersion == "5.3.0.0")
            {
                if (kernel.LastWriteTime.Year == 2006)
                {
                    return("Sitecore CMS 5.3.0 rev. 06802");
                }

                if (kernel.LastWriteTime.Year == 2007)
                {
                    return("Sitecore CMS 5.3.0 rev. 070215");
                }
            }

            return(info.ProductName + ' ' + info.ProductVersion);
        }
        private string NormalizeXml(XmlDocumentEx xml)
        {
            string outerXml  = xml.OuterXml;
            string formatted = XmlDocumentEx.Normalize(outerXml);
            Regex  r         = new Regex(@"^<\?.*\?>");
            string corrected = r.Replace(formatted, @"<?xml version=""1.0"" encoding=""UTF-8"" ?>"); //Solr requires UTF-8.

            return(corrected);
        }
Пример #28
0
 public void Initialize()
 {
     using (new ProfileSection("Initializing main window", this))
     {
         var appDocument = XmlDocumentEx.LoadFile("App.xml");
         MainWindowHelper.InitializeRibbon(appDocument);
         MainWindowHelper.InitializeContextMenu(appDocument);
     }
 }
        public void Constructor_PathInSolrHome_SetsProperty()
        {
            string        anonymousPath  = "anonymousPath" + Guid.NewGuid();
            XmlDocumentEx solrDefinition = XmlDocumentEx.LoadXml($@"<response><lst name=""lucene""><str name=""solr-spec-version"">5.0.0</str></lst><str name=""solr_home"">{anonymousPath}</str></response>");

            var info = new SolrInformation(solrDefinition);

            Assert.AreEqual(info.SolrBasePath, anonymousPath);
        }
        private SolrInformation GetSolrInformation(string url)
        {
            string solrInfoUrl      = $"{url}/admin/info/system";
            Stream response         = RequestAndGetResponseStream(solrInfoUrl);
            string responseAsString = GetStringFromStream(response);
            var    doc = XmlDocumentEx.LoadXml(responseAsString);

            return(new SolrInformation(doc));
        }
Пример #31
0
        public static XmlElement Initialize(string pipelinesConfigFilePath)
        {
            Assert.ArgumentNotNull(pipelinesConfigFilePath, "pipelinesConfigFilePath");

            var        document      = XmlDocumentEx.LoadFile(pipelinesConfigFilePath);
            XmlElement pipelinesNode = GetPipelines(document);

            return(Initialize(pipelinesNode));
        }
Пример #32
0
        private void Arrange()
        {
            ArrangeGetSolrInfo();
            _sut.FileExists(TemplateCollectionPath).Returns(true);
            _sut.FileExists(SchemaPath).Returns(true);
            _sut.FileExists(ManagedSchemaPath).Returns(false);
            var xmlDocumentEx = XmlDocumentEx.LoadXml("<anonymous />");

            _sut.XmlMerge(Arg.Any <string>(), Arg.Any <string>()).Returns(xmlDocumentEx);
        }
        public void SelectSingleElementOrCreateTest()
        {
            var doc = XmlDocumentEx.LoadXml("<doc />");

            var result = doc.SelectSingleElementOrCreate("/doc/test");

            Assert.IsNotNull(result);
            Assert.AreEqual("test", result.Name);
            Assert.AreEqual(doc.DocumentElement, result.ParentNode);
        }
Пример #34
0
        public static XmlElement GetPipelines(XmlDocumentEx document)
        {
            Assert.ArgumentNotNull(document, "document");

            XmlElement pipelinesNode = document.SelectSingleNode("configuration/pipelines") as XmlElement;

            Assert.IsNotNull(pipelinesNode, "Can't find pipelines configuration node");

            return(pipelinesNode);
        }
 public new static XmlDocumentEx LoadXml(string xml)
 {
   try
   {
     XmlDocument doc = new XmlDocumentEx();
     doc.LoadXml(xml);
     return (XmlDocumentEx)doc;
   }
   catch (Exception ex)
   {
     Log.Warn(ex, "Cannot load xml: {0}. {1}\r\n{2}", xml, ex.Message, Environment.StackTrace);
     return null;
   }
 }
        public static XmlDocumentEx LoadFile([NotNull] string path)
        {
            Assert.ArgumentNotNull(path, "path");
              if (!FileSystem.FileSystem.Local.File.Exists(path))
              {
            throw new FileIsMissingException("The " + path + " doesn't exists");
              }

              var document = new XmlDocumentEx
              {
            FilePath = path
              };
              document.Load(path);
              return document;
        }
        public static XmlDocumentEx LoadFileSafe([NotNull] string path)
        {
            Assert.ArgumentNotNull(path, "path");

              if (!FileSystem.FileSystem.Local.File.Exists(path))
              {
            return null;
              }

              var document = new XmlDocumentEx
              {
            FilePath = path
              };

              document.Load(path);
              return document;
        }
        private static string GetProductFullName([NotNull] string assemblyPath)
        {
            Assert.ArgumentNotNull(assemblyPath, "assemblyPath");

              var websiteFolderPath = Path.GetDirectoryName(Path.GetDirectoryName(assemblyPath));
              Assert.IsNotNull(websiteFolderPath, "folder");

              var sitecoreVersionFilePath = Path.Combine(websiteFolderPath, "sitecore\\shell\\sitecore.version.xml");
              Assert.IsNotNull(sitecoreVersionFilePath, "sitecoreVersionFilePath");

              if (FileSystem.FileSystem.Local.File.Exists(sitecoreVersionFilePath))
              {
            try
            {
              var xml = new XmlDocumentEx(sitecoreVersionFilePath);
              var major = xml.SelectSingleNode("information/version/major");
              Assert.IsNotNull(major, "major");

              var minor = xml.SelectSingleNode("information/version/minor");
              Assert.IsNotNull(minor, "minor");

              var build = xml.SelectSingleNode("information/version/build");
              var revision = xml.SelectSingleNode("information/version/revision");
              return "Sitecore CMS {0}.{1}.{2} rev. {3}"
            .FormatWith(major.InnerText, minor.InnerText, build == null ? string.Empty : build.InnerText, revision == null ? string.Empty : revision.InnerText)
            .Replace(". rev", " rev")
            .Trim(" .".ToCharArray());
            }
            catch (Exception ex)
            {
              Log.Warn("An error occurred during reading {0} file".FormatWith(assemblyPath), typeof(ProductHelper));
            }
              }

              FileInfo kernel = new FileInfo(assemblyPath);
              Assert.IsTrue(kernel.Exists, "It's not a Sitecore product");

              FileVersionInfo info = FileVersionInfo.GetVersionInfo(assemblyPath);
              if (info.ProductVersion == "5.3.0.0")
              {
            if (kernel.LastWriteTime.Year == 2006)
            {
              return "Sitecore CMS 5.3.0 rev. 06802";
            }

            if (kernel.LastWriteTime.Year == 2007)
            {
              return "Sitecore CMS 5.3.0 rev. 070215";
            }
              }

              return info.ProductName + ' ' + info.ProductVersion;
        }