Пример #1
0
        public static XPathNavigator ConvertLegacyNavigator(XPathNavigator rootNav, InstallerInfo info)
        {
            XPathNavigator nav = null;

            var packageType = Null.NullString;
            if (rootNav.Name == "dotnetnuke")
            {
                packageType = Util.ReadAttribute(rootNav, "type");
            }
            else if (rootNav.Name.ToLower() == "languagepack")
            {
                packageType = "LanguagePack";
            }

            XPathDocument legacyDoc;
            string legacyManifest;
            switch (packageType.ToLower())
            {
                case "module":
                    var sb = new StringBuilder();
                    var writer = XmlWriter.Create(sb, XmlUtils.GetXmlWriterSettings(ConformanceLevel.Fragment));

                    //Write manifest start element
                    PackageWriterBase.WriteManifestStartElement(writer);

                    //Legacy Module - Process each folder
                    foreach (XPathNavigator folderNav in rootNav.Select("folders/folder"))
                    {
                        var modulewriter = new ModulePackageWriter(folderNav, info);
                        modulewriter.WriteManifest(writer, true);
                    }

                    //Write manifest end element
                    PackageWriterBase.WriteManifestEndElement(writer);

                    //Close XmlWriter
                    writer.Close();

                    //Load manifest into XPathDocument for processing
                    legacyDoc = new XPathDocument(new StringReader(sb.ToString()));

                    //Parse the package nodes
                    nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    break;
                case "languagepack":
                    //Legacy Language Pack
                    var languageWriter = new LanguagePackWriter(rootNav, info);
                    info.LegacyError = languageWriter.LegacyError;
                    if (string.IsNullOrEmpty(info.LegacyError))
                    {
                        legacyManifest = languageWriter.WriteManifest(false);
                        legacyDoc = new XPathDocument(new StringReader(legacyManifest));

                        //Parse the package nodes
                        nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    }
                    break;
                case "skinobject":
                    //Legacy Skin Object
                    var skinControlwriter = new SkinControlPackageWriter(rootNav, info);
                    legacyManifest = skinControlwriter.WriteManifest(false);
                    legacyDoc = new XPathDocument(new StringReader(legacyManifest));

                    //Parse the package nodes
                    nav = legacyDoc.CreateNavigator().SelectSingleNode("dotnetnuke");
                    break;
            }

            return nav;
        }
Пример #2
0
        public static void ProcessLegacySkinControls()
        {
            foreach (SkinControlInfo skinControl in SkinControlController.GetSkinControls().Values)
            {
                if (skinControl.PackageID == Null.NullInteger)
                {
                    try
                    {
						//SkinControl is not affiliated with a Package
                        var package = new PackageInfo(new InstallerInfo());
                        package.Name = skinControl.ControlKey;

                        package.FriendlyName = skinControl.ControlKey;
                        package.Description = Null.NullString;
                        package.Version = new Version(1, 0, 0);
                        package.PackageType = "SkinObject";

                        //See if the SkinControl is using a "Namespace" for its name
                        ParsePackageName(package);

                        var skinControlWriter = new SkinControlPackageWriter(skinControl, package);
                        package.Manifest = skinControlWriter.WriteManifest(true);

                        //Save Package
                        PackageController.Instance.SaveExtensionPackage(package);

                        //Update SkinControl with new PackageID
                        skinControl.PackageID = package.PackageID;

                        //Save SkinControl
                        SkinControlController.SaveSkinControl(skinControl);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);

                    }
                }
            }
        }