コード例 #1
0
 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:
             CommonLibrary.Common.Lists.ListController listController = new CommonLibrary.Common.Lists.ListController();
             ListEntryInfo entry = listController.GetListEntryInfo("PackageWriter", package.PackageType);
             if (entry != null && !string.IsNullOrEmpty(entry.Text))
             {
                 writer = (PackageWriterBase)Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
             }
             break;
     }
     return writer;
 }
コード例 #2
0
 public static void ProcessLegacyModules()
 {
     foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
     {
         if (desktopModule.PackageID == Null.NullInteger)
         {
             string moduleFolder = Path.Combine(CommonLibrary.Common.Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName));
             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)
                 {
                     XPathDocument doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read));
                     rootNav = doc.CreateNavigator().SelectSingleNode("CommonLibrary");
                 }
                 PackageInfo 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))
                 {
                     package.IsSystemPackage = true;
                     desktopModule.IsAdmin = true;
                 }
                 else
                 {
                     desktopModule.IsAdmin = false;
                 }
                 package.PackageType = "Module";
                 ParsePackageName(package);
                 if (files.Length > 0)
                 {
                     ModulePackageWriter modulewriter = new ModulePackageWriter(desktopModule, rootNav, package);
                     package.Manifest = modulewriter.WriteManifest(true);
                 }
                 else
                 {
                     package.Manifest = "";
                 }
                 PackageController.SavePackage(package);
                 desktopModule.PackageID = package.PackageID;
                 DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
     }
 }
コード例 #3
0
        private void ReadManifest(Stream stream)
        {
            XPathDocument doc = new XPathDocument(stream);
            XPathNavigator rootNav = doc.CreateNavigator();
            XPathDocument legacyDoc = null;
            rootNav.MoveToFirstChild();
            string packageType = Null.NullString;
            string legacyManifest = Null.NullString;
            if (rootNav.Name == "CommonLibrary")
            {
                packageType = Util.ReadAttribute(rootNav, "type");
            }
            else if (rootNav.Name.ToLower() == "languagepack")
            {
                packageType = "LanguagePack";
            }
            else
            {
                InstallerInfo.Log.AddFailure(Util.PACKAGE_UnRecognizable);
            }
            switch (packageType.ToLower())
            {
                case "package":
                    InstallerInfo.IsLegacyMode = false;
                    ProcessPackages(rootNav);
                    break;
                case "module":
                    InstallerInfo.IsLegacyMode = true;
                    StringBuilder sb = new StringBuilder();
                    XmlWriter writer = XmlWriter.Create(sb, XmlUtils.GetXmlWriterSettings(ConformanceLevel.Fragment));
                    PackageWriterBase.WriteManifestStartElement(writer);
                    foreach (XPathNavigator folderNav in rootNav.Select("folders/folder"))
                    {
                        ModulePackageWriter modulewriter = new ModulePackageWriter(folderNav, InstallerInfo);
                        modulewriter.WriteManifest(writer, true);
                    }

                    PackageWriterBase.WriteManifestEndElement(writer);
                    writer.Close();
                    legacyDoc = new XPathDocument(new StringReader(sb.ToString()));
                    ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    break;
                case "languagepack":
                    InstallerInfo.IsLegacyMode = true;
                    LanguagePackWriter languageWriter = new LanguagePackWriter(rootNav, InstallerInfo);
                    LegacyError = languageWriter.LegacyError;
                    if (string.IsNullOrEmpty(LegacyError))
                    {
                        legacyManifest = languageWriter.WriteManifest(false);
                        legacyDoc = new XPathDocument(new StringReader(legacyManifest));
                        ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    }
                    break;
                case "skinobject":
                    InstallerInfo.IsLegacyMode = true;
                    SkinControlPackageWriter skinControlwriter = new SkinControlPackageWriter(rootNav, InstallerInfo);
                    legacyManifest = skinControlwriter.WriteManifest(false);
                    legacyDoc = new XPathDocument(new StringReader(legacyManifest));
                    ProcessPackages(legacyDoc.CreateNavigator().SelectSingleNode("CommonLibrary"));
                    break;
            }
        }