/// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetWriter method instantiates the relevant PackageWriter Installer.
        /// </summary>
        /// <param name="package">The associated PackageInfo instance.</param>
        /// <returns></returns>
        /// -----------------------------------------------------------------------------
        public static PackageWriterBase GetWriter(PackageInfo package)
        {
            PackageWriterBase writer = null;

            switch (package.PackageType)
            {
            case "Auth_System":
                writer = new AuthenticationPackageWriter(package);
                break;

            case "Module":
                writer = new ModulePackageWriter(package);
                break;

            case "Container":
                writer = new ContainerPackageWriter(package);
                break;

            case "Skin":
                writer = new SkinPackageWriter(package);
                break;

            case "CoreLanguagePack":
            case "ExtensionLanguagePack":
                writer = new LanguagePackWriter(package);
                break;

            case "SkinObject":
                writer = new SkinControlPackageWriter(package);
                break;

            case "Provider":
                writer = new ProviderPackageWriter(package);
                break;

            case "Library":
                writer = new LibraryPackageWriter(package);
                break;

            case "Widget":
                writer = new WidgetPackageWriter(package);
                break;

            default:
                // PackageType is defined in the List
                var           listController = new ListController();
                ListEntryInfo entry          = listController.GetListEntryInfo("PackageWriter", package.PackageType);

                if (entry != null && !string.IsNullOrEmpty(entry.Text))
                {
                    // The class for the Installer is specified in the Text property
                    writer = (PackageWriterBase)Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
                }

                break;
            }

            return(writer);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetWriter method instantiates the relevant PackageWriter Installer
        /// </summary>
        /// <param name="package">The associated PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/31/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static PackageWriterBase GetWriter(PackageInfo package)
        {
            PackageWriterBase writer = null;
            switch (package.PackageType)
            {
                case "Auth_System":
                    writer = new AuthenticationPackageWriter(package);
                    break;
                case "Module":
                    writer = new ModulePackageWriter(package);
                    break;
                case "Container":
                    writer = new ContainerPackageWriter(package);
                    break;
                case "Skin":
                    writer = new SkinPackageWriter(package);
                    break;
                case "CoreLanguagePack":
                case "ExtensionLanguagePack":
                    writer = new LanguagePackWriter(package);
                    break;
                case "SkinObject":
                    writer = new SkinControlPackageWriter(package);
                    break;
                case "Provider":
                    writer = new ProviderPackageWriter(package);
                    break;
                case "Library":
                    writer = new LibraryPackageWriter(package);
                    break;
                case "Widget":
                    writer = new WidgetPackageWriter(package);
                    break;
                default:
                    //PackageType is defined in the List
                    var listController = new ListController();
                    ListEntryInfo entry = listController.GetListEntryInfo("PackageWriter", package.PackageType);

                    if (entry != null && !string.IsNullOrEmpty(entry.Text))
                    {
						//The class for the Installer is specified in the Text property
                        writer = (PackageWriterBase) Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
                    }
                    break;
            }
            return writer;
        }
Esempio n. 3
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;
        }
        public static void ProcessLegacyModule(DesktopModuleInfo desktopModule)
        {
            //Get the Module folder
            string moduleFolder = Path.Combine(Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName));

            //Find legacy manifest
            XPathNavigator rootNav = null;
            try
            {
                string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                string[] files = Directory.GetFiles(moduleFolder, "*.dnn.config");
                if (files.Length > 0)
                {
                    //Create an XPathDocument from the Xml
                    var doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read));
                    rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                }

                //Module is not affiliated with a Package
                var package = new PackageInfo(new InstallerInfo());
                package.Name = desktopModule.ModuleName;

                package.FriendlyName = desktopModule.FriendlyName;
                package.Description = desktopModule.Description;
                package.Version = new Version(1, 0, 0);
                if (!string.IsNullOrEmpty(desktopModule.Version))
                {
                    package.Version = new Version(desktopModule.Version);
                }
                if (hostModules.Contains(desktopModule.ModuleName))
                {
                    //Host Module so make this a system package
                    package.IsSystemPackage = true;
                    desktopModule.IsAdmin = true;
                }
                else
                {
                    desktopModule.IsAdmin = false;
                }
                package.PackageType = "Module";

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

                if (files.Length > 0)
                {
                    var modulewriter = new ModulePackageWriter(desktopModule, rootNav, package);
                    package.Manifest = modulewriter.WriteManifest(true);
                }
                else
                {
                    package.Manifest = ""; //module has no manifest
                }

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

                //Update Desktop Module with new PackageID
                desktopModule.PackageID = package.PackageID;

                //Save DesktopModule
                DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

            }            
        }