/// -----------------------------------------------------------------------------
        /// <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);
        }
예제 #2
0
 public LanguagePackWriter(PackageInfo package) : base(package)
 {
     _LanguagePack = LanguagePackController.GetLanguagePackByPackage(package.PackageID);
     if (LanguagePack != null)
     {
         _Language = LocaleController.Instance.GetLocale(_LanguagePack.LanguageID);
         if (LanguagePack.PackageType == LanguagePackType.Core)
         {
             BasePath = Null.NullString;
         }
         else
         {
             //Get the BasePath of the Dependent Package
             PackageInfo       dependendentPackage    = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == LanguagePack.DependentPackageID);
             PackageWriterBase dependentPackageWriter = PackageWriterFactory.GetWriter(dependendentPackage);
             BasePath = dependentPackageWriter.BasePath;
         }
     }
     else
     {
         BasePath = Null.NullString;
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Page_Load runs when the page loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]   01/31/2008    Created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            chkUseManifest.CheckedChanged += chkUseManifest_CheckedChanged;
            cmdGetFiles.Click += cmdGetFiles_Click;
            wizPackage.ActiveStepChanged += wizPackage_ActiveStepChanged;
            wizPackage.CancelButtonClick += wizPackage_CancelButtonClick;
            wizPackage.FinishButtonClick += wizPackage_FinishButtonClick;
            wizPackage.NextButtonClick += wizPackage_NextButtonClick;

            try
            {
                CheckSecurity();

                ctlPackage.EditMode = PropertyEditorMode.View;

                switch (Package.PackageType)
                {
                    case "CoreLanguagePack":
                        Package.IconFile = "N\\A";
                        break;
                    default:
                        Package.IconFile = Util.ParsePackageIconFileName(Package);
                        break;
                }

                ctlPackage.DataSource = Package;
                ctlPackage.DataBind();

                _Writer = PackageWriterFactory.GetWriter(Package);

                if (Page.IsPostBack)
                {
                    _Writer.BasePath = txtBasePath.Text;
                }
                else
                {
                    txtBasePath.Text = _Writer.BasePath;

                    //Load Manifests
                    if (!string.IsNullOrEmpty(Package.Manifest))
                    {
                        cboManifests.Items.Add(new ListItem("Database version", ""));
                    }
                    string filePath = Server.MapPath(_Writer.BasePath);
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        if (Directory.Exists(filePath))
                        {
                            foreach (string file in Directory.GetFiles(filePath, "*.dnn"))
                            {
                                string fileName = file.Replace(filePath + "\\", "");
                                cboManifests.Items.Add(new ListItem(fileName, fileName));
                            }
                            foreach (string file in Directory.GetFiles(filePath, "*.dnn.resources"))
                            {
                                string fileName = file.Replace(filePath + "\\", "");
                                cboManifests.Items.Add(new ListItem(fileName, fileName));
                            }
                        }
                    }
                    if (cboManifests.Items.Count > 0)
                    {
                        trUseManifest.Visible = true;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }