Ejemplo n.º 1
0
        protected void cmdInstall_Click(object sender, EventArgs e)
        {
            string InstallPath = Globals.ApplicationMapPath + "\\Install\\Module\\";

            foreach (ListItem moduleItem in lstModules.Items)
            {
                if (moduleItem.Selected)
                {
                    string strFile      = InstallPath + moduleItem.Value;
                    string strExtension = Path.GetExtension(strFile);

                    if (strExtension.ToLower() == ".zip" | strExtension.ToLower() == ".resources")
                    {
                        phPaLogs.Visible = true;
                        PaInstaller objPaInstaller = new PaInstaller(strFile, Globals.ApplicationMapPath);
                        objPaInstaller.InstallerInfo.Log.StartJob(Localization.GetString("Installing", LocalResourceFile) + moduleItem.Text);
                        if (objPaInstaller.Install())
                        {
                            // delete package
                            DeleteFile(strFile);
                        }
                        else
                        {
                            // save error log
                            phPaLogs.Controls.Add(objPaInstaller.InstallerInfo.Log.GetLogsTable());
                        }
                    }
                }
            }

            if (phPaLogs.Controls.Count > 0)
            {
                // display error log
                cmdRefresh.Visible = true;
            }
            else
            {
                // refresh installed module list
                Response.Redirect(Request.RawUrl);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The cmdAdd_Click runs when the Add Button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///   [cnurse] 16/9/2004  Updated for localization, Help and 508
        /// </history>
        protected void cmdAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string strFileName;
                string strExtension;
                string strMessage = "";

                HttpPostedFile postedFile = cmdBrowse.PostedFile;

                //Get localized Strings
                string strInvalid = Localization.GetString("InvalidExt", this.LocalResourceFile);

                strFileName  = Path.GetFileName(postedFile.FileName);
                strExtension = Path.GetExtension(strFileName);

                if (!String.IsNullOrEmpty(postedFile.FileName))
                {
                    switch (FileType)
                    {
                    case UploadType.File:     // content files

                        strMessage += FileSystemUtils.UploadFile(RootFolder + ddlFolders.SelectedItem.Value.Replace("/", "\\"), postedFile, chkUnzip.Checked);
                        break;

                    case UploadType.Skin:     // skin package

                        if (strExtension.ToLower() == ".zip")
                        {
                            //SkinController objSkins = new SkinController();
                            Label objLbl = new Label();
                            objLbl.CssClass = "Normal";
                            objLbl.Text     = SkinController.UploadSkin(RootFolder, SkinInfo.RootSkin, Path.GetFileNameWithoutExtension(postedFile.FileName), postedFile.InputStream);
                            phPaLogs.Controls.Add(objLbl);
                        }
                        else
                        {
                            strMessage += strInvalid + " " + FileTypeName + " " + strFileName;
                        }
                        break;

                    case UploadType.Container:     // container package

                        if (strExtension.ToLower() == ".zip")
                        {
                            //SkinController objSkins = new SkinController();
                            Label objLbl = new Label();
                            objLbl.CssClass = "Normal";
                            objLbl.Text     = SkinController.UploadSkin(RootFolder, SkinInfo.RootContainer, Path.GetFileNameWithoutExtension(postedFile.FileName), postedFile.InputStream);
                            phPaLogs.Controls.Add(objLbl);
                        }
                        else
                        {
                            strMessage += strInvalid + " " + FileTypeName + " " + strFileName;
                        }
                        break;

                    case UploadType.Module:     // custom module

                        if (strExtension.ToLower() == ".zip")
                        {
                            phPaLogs.Visible = true;
                            PaInstaller pa = new PaInstaller(postedFile.InputStream, Request.MapPath("."));
                            pa.Install();
                            phPaLogs.Controls.Add(pa.InstallerInfo.Log.GetLogsTable());
                        }
                        else
                        {
                            strMessage += strInvalid + " " + FileTypeName + " " + strFileName;
                        }
                        break;

                    case UploadType.LanguagePack:

                        if (strExtension.ToLower() == ".zip")
                        {
                            LocaleFilePackReader objLangPack = new LocaleFilePackReader();
                            phPaLogs.Controls.Add(objLangPack.Install(postedFile.InputStream).GetLogsTable());
                        }
                        else
                        {
                            strMessage += strInvalid + " " + FileTypeName + " " + strFileName;
                        }
                        break;
                    }
                }

                if (phPaLogs.Controls.Count > 0)
                {
                    tblLogs.Visible = true;
                }
                else if (strMessage == "")
                {
                    Response.Redirect(ReturnURL(), true);
                }
                else
                {
                    lblMessage.Text = strMessage;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }