public bool SavePackageSettings(PackageSettingsDto packageSettings, out string errorMessage)
        {
            errorMessage = string.Empty;

            try
            {
                var isHostUser = UserController.Instance.GetCurrentUserInfo().IsSuperUser;

                if (isHostUser)
                {
                    string value;
                    var    skin = SkinController.GetSkinByPackageID(packageSettings.PackageId);

                    if (packageSettings.EditorActions.TryGetValue("themePackageName", out value) &&
                        !string.IsNullOrEmpty(value))
                    {
                        skin.SkinName = value;
                        SkinController.UpdateSkinPackage(skin);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                errorMessage = ex.Message;
                return(false);
            }
        }
Exemple #2
0
 public override void UpdatePackage()
 {
     if (skinForm.IsValid)
     {
         var skin = skinForm.DataSource as SkinPackageInfo;
         if (skin != null)
         {
             SkinController.UpdateSkinPackage(skin);
         }
     }
 }
 public override void Rollback()
 {
     if (TempSkinPackage == null)
     {
         DeleteSkinPackage();
     }
     else
     {
         SkinController.UpdateSkinPackage(TempSkinPackage);
     }
     base.Rollback();
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Rollback method undoes the installation of the component in the event
        /// that one of the other components fails
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void Rollback()
        {
            //If Temp Skin exists then we need to update the DataStore with this
            if (TempSkinPackage == null)
            {
                //No Temp Skin - Delete newly added Skin
                DeleteSkinPackage();
            }
            else
            {
                //Temp Skin - Rollback to Temp
                SkinController.UpdateSkinPackage(TempSkinPackage);
            }

            //Call base class to prcoess files
            base.Rollback();
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the skin component
        /// </summary>
        public override void Install()
        {
            bool bAdd = Null.NullBoolean;

            try
            {
                //Attempt to get the Skin Package
                TempSkinPackage = SkinController.GetSkinPackage(SkinPackage.PortalID, SkinPackage.SkinName, SkinType);
                if (TempSkinPackage == null)
                {
                    bAdd = true;
                    SkinPackage.PackageID = Package.PackageID;
                }
                else
                {
                    SkinPackage.SkinPackageID = TempSkinPackage.SkinPackageID;
                    if (TempSkinPackage.PackageID != Package.PackageID)
                    {
                        Completed = false;
                        Log.AddFailure(Util.SKIN_Installed);
                        return;
                    }
                    else
                    {
                        SkinPackage.PackageID = TempSkinPackage.PackageID;
                    }
                }
                SkinPackage.SkinType = SkinType;
                if (bAdd)
                {
                    //Add new skin package
                    SkinPackage.SkinPackageID = SkinController.AddSkinPackage(SkinPackage);
                }
                else
                {
                    //Update skin package
                    SkinController.UpdateSkinPackage(SkinPackage);
                }
                Log.AddInfo(string.Format(Util.SKIN_Registered, SkinPackage.SkinName));

                //install (copy the files) by calling the base class
                base.Install();

                //process the list of skin files
                if (SkinFiles.Count > 0)
                {
                    Log.StartJob(Util.SKIN_BeginProcessing);
                    string strMessage = Null.NullString;
                    var    NewSkin    = new SkinFileProcessor(RootPath, SkinRoot, SkinPackage.SkinName);
                    foreach (string skinFile in SkinFiles)
                    {
                        strMessage += NewSkin.ProcessFile(skinFile, SkinParser.Portable);
                        skinFile.Replace(Globals.HostMapPath + "\\", "[G]");
                        switch (Path.GetExtension(skinFile))
                        {
                        case ".htm":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile.Replace("htm", "ascx"));
                            break;

                        case ".html":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile.Replace("html", "ascx"));
                            break;

                        case ".ascx":
                            SkinController.AddSkin(SkinPackage.SkinPackageID, skinFile);
                            break;
                        }
                    }
                    Array arrMessage = strMessage.Split(new[] { "<br />" }, StringSplitOptions.None);
                    foreach (string strRow in arrMessage)
                    {
                        Log.AddInfo(HtmlUtils.StripTags(strRow, true));
                    }
                    Log.EndJob(Util.SKIN_EndProcessing);
                }
                Completed = true;
            }
            catch (Exception ex)
            {
                Log.AddFailure(ex);
            }
        }