Ejemplo n.º 1
0
        // Methods
        #region Public Methods

        /// <summary>
        /// Adds the MVC action module.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="actionPath">The action path.</param>
        /// <returns></returns>
        public static Guid AddMVCActionModule(string name, string actionPath)
        {
            var sdb             = new ModulesDB();
            var generalModDefId = Guid.NewGuid();

            sdb.AddGeneralModuleDefinitions(
                generalModDefId, name, actionPath, string.Empty, string.Empty, string.Empty, false, false);
            return(generalModDefId);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the portable area.
        /// </summary>
        /// <param name="areaName">Name of the area.</param>
        /// <param name="assemblyFullName">Full name of the assembly.</param>
        /// <param name="controllerName">The module.</param>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="sdb">The SDB.</param>
        /// <param name="actionName">The actionName.</param>
        /// <returns></returns>
        private static Guid AddPortableArea(string areaName, string assemblyFullName, string controllerName, string friendlyName, ModulesDB sdb, string actionName)
        {
            var mId    = Guid.NewGuid();
            var action = string.Format("Areas/{0}/Views/{1}/{2}", areaName, controllerName, actionName);

            sdb.AddGeneralModuleDefinitions(
                mId, friendlyName, action, string.Empty, assemblyFullName, areaName, false, false);

            return(mId);
        }
        /// <summary>
        /// OnUpdate installs or refresh module definition on db
        /// </summary>
        /// <param name="e">
        /// The <see cref="T:System.EventArgs"/> instance containing the event data.
        /// </param>
        protected override void OnUpdate(EventArgs e)
        {
            if (this.Page.IsValid)
            {
                try
                {
                    var modules = new ModulesDB();
                    modules.AddGeneralModuleDefinitions(
                        new Guid(this.ModuleGuid.Text),
                        this.FriendlyName.Text,
                        this.DesktopSrc.Text,
                        this.MobileSrc.Text,
                        "Appleseed.Modules.OneFileModule.dll",
                        "Appleseed.Content.Web.ModulesOneFileModule",
                        false,
                        false);

                    // Update the module definition
                    for (var i = 0; i < this.PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(
                            this.defId,
                            Convert.ToInt32(this.PortalsName.Items[i].Value),
                            this.PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    this.RedirectBackToReferringPage();
                }
                catch (ThreadAbortException)
                {
                    // normal with redirect
                }
                catch (Exception ex)
                {
                    this.lblErrorDetail.Text =
                        string.Format("{0}<br />", General.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this));
                    this.lblErrorDetail.Text   += string.Format("{0}<br />", ex.Message);
                    this.lblErrorDetail.Text   += string.Format(" Module: '{0}' - Source: '{1}' - Mobile: '{2}'", this.FriendlyName.Text, this.DesktopSrc.Text, this.MobileSrc.Text);
                    this.lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, this.lblErrorDetail.Text, ex);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// OnUpdate installs or refresh module definiton on db
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnUpdate(EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    ModulesDB modules = new ModulesDB();
                    modules.AddGeneralModuleDefinitions(new Guid(ModuleGuid.Text), FriendlyName.Text, DesktopSrc.Text,
                                                        MobileSrc.Text,
                                                        "Rainbow.Modules.OneFileModule.dll",
                                                        "Rainbow.Content.Web.ModulesOneFileModule", false, false);

                    // Update the module definition
                    for (int i = 0; i < PortalsName.Items.Count; i++)
                    {
                        modules.UpdateModuleDefinitions(defID, Convert.ToInt32(PortalsName.Items[i].Value),
                                                        PortalsName.Items[i].Selected);
                    }

                    // Redirect back to the portal admin page
                    RedirectBackToReferringPage();
                }
                catch (ThreadAbortException)
                {
                    //normal with redirect
                }
                catch (Exception ex)
                {
                    lblErrorDetail.Text =
                        General.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this) +
                        "<br>";
                    lblErrorDetail.Text += ex.Message + "<br>";
                    lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text +
                                           "' - Mobile: '" + MobileSrc.Text + "'";
                    lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, lblErrorDetail.Text, ex);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Installs module
        /// </summary>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="desktopSource">The desktop source.</param>
        /// <param name="mobileSource">The mobile source.</param>
        /// <param name="install">if set to <c>true</c> [install].</param>
        public static void Install(string friendlyName, string desktopSource, string mobileSource, bool install)
        {
            ErrorHandler.Publish(LogLevel.Info,
                                 "Installing DesktopModule '" + friendlyName + "' from '" + desktopSource + "'");
            if (mobileSource != null && mobileSource.Length > 0)
            {
                ErrorHandler.Publish(LogLevel.Info,
                                     "Installing MobileModule '" + friendlyName + "' from '" + mobileSource + "'");
            }

            string controlFullPath = Path.ApplicationRoot + "/" + desktopSource;

            // Instantiate the module
            Page page = new Page();
            //http://sourceforge.net/tracker/index.php?func=detail&aid=738670&group_id=66837&atid=515929
            //Rainbow.Framework.Web.UI.Page page = new Rainbow.Framework.Web.UI.Page();

            Control myControl = page.LoadControl(controlFullPath);

            if (!(myControl is PortalModuleControl))
            {
                throw new Exception("Module '" + myControl.GetType().FullName + "' is not a PortalModule Control");
            }

            PortalModuleControl portalModule = (PortalModuleControl)myControl;

            // Check mobile module
            if (mobileSource != null && mobileSource.Length != 0 && mobileSource.ToLower().EndsWith(".ascx"))
            {
                //TODO: Check mobile module
                //TODO: MobilePortalModuleControl mobileModule = (MobilePortalModuleControl) page.LoadControl(Rainbow.Framework.Settings.Path.ApplicationRoot + "/" + mobileSource);
                if (!File.Exists(HttpContext.Current.Server.MapPath(Path.ApplicationRoot + "/" + mobileSource)))
                {
                    throw new FileNotFoundException("Mobile Control not found");
                }
            }

            // Get Module ID
            Guid defID = portalModule.GuidID;

            //Get Assembly name
            string assemblyName = portalModule.GetType().BaseType.Assembly.CodeBase;

            assemblyName = assemblyName.Substring(assemblyName.LastIndexOf('/') + 1); //Get name only

            // Get Module Class name
            string className = portalModule.GetType().BaseType.FullName;

            // Now we add the definition to module list
            ModulesDB modules = new ModulesDB();

            if (install)
            {
                //Install as new module

                //Call Install
                try
                {
                    ErrorHandler.Publish(LogLevel.Debug, "Installing '" + friendlyName + "' as new module.");
                    portalModule.Install(null);
                }
                catch (Exception ex)
                {
                    //Error occurred
                    portalModule.Rollback(null);
                    //Rethrow exception
                    throw new Exception("Exception occurred installing '" + portalModule.GuidID.ToString() + "'!", ex);
                }

                try
                {
                    // Add a new module definition to the database
                    modules.AddGeneralModuleDefinitions(defID, friendlyName, desktopSource, mobileSource, assemblyName,
                                                        className, portalModule.AdminModule, portalModule.Searchable);
                }
                catch (Exception ex)
                {
                    //Rethrow exception
                    throw new Exception(
                              "AddGeneralModuleDefinitions Exception '" + portalModule.GuidID.ToString() + "'!", ex);
                }

                // All is fine: we can call Commit
                portalModule.Commit(null);
            }
            else
            {
                // Update the general module definition
                try
                {
                    ErrorHandler.Publish(LogLevel.Debug, "Updating '" + friendlyName + "' as new module.");
                    modules.UpdateGeneralModuleDefinitions(defID, friendlyName, desktopSource, mobileSource,
                                                           assemblyName, className, portalModule.AdminModule,
                                                           portalModule.Searchable);
                }
                catch (Exception ex)
                {
                    //Rethrow exception
                    throw new Exception(
                              "UpdateGeneralModuleDefinitions Exception '" + portalModule.GuidID.ToString() + "'!", ex);
                }
            }

            // Update the module definition - install for portal 0
            modules.UpdateModuleDefinitions(defID, 0, true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Installs module
        /// </summary>
        /// <param name="friendlyName">
        /// Name of the friendly.
        /// </param>
        /// <param name="desktopSource">
        /// The desktop source.
        /// </param>
        /// <param name="mobileSource">
        /// The mobile source.
        /// </param>
        /// <param name="install">
        /// if set to <c>true</c> [install].
        /// </param>
        public static void Install(string friendlyName, string desktopSource, string mobileSource, bool install)
        {
            ErrorHandler.Publish(
                LogLevel.Info, string.Format("Installing DesktopModule '{0}' from '{1}'", friendlyName, desktopSource));
            if (!string.IsNullOrEmpty(mobileSource))
            {
                ErrorHandler.Publish(
                    LogLevel.Info, string.Format("Installing MobileModule '{0}' from '{1}'", friendlyName, mobileSource));
            }

            var controlFullPath = Path.ApplicationRoot + "/" + desktopSource;

            // if ascx User Control based Module-> Instantiate the module
            if (controlFullPath.ToLowerInvariant().Trim().EndsWith(".ascx"))
            {
                var page = new Page();

                var control = page.LoadControl(controlFullPath);
                if (!(control is PortalModuleControl))
                {
                    throw new Exception(string.Format("Module '{0}' is not a PortalModule Control", control.GetType().FullName));
                }

                var portalModule = (PortalModuleControl)control;

                // Check mobile module
                if (!string.IsNullOrEmpty(mobileSource) && mobileSource.ToLower().EndsWith(".ascx"))
                {
                    // TODO: Check mobile module
                    // TODO: MobilePortalModuleControl mobileModule = (MobilePortalModuleControl) page.LoadControl(Appleseed.Framework.Settings.Path.ApplicationRoot + "/" + mobileSource);
                    if (!File.Exists(HttpContext.Current.Server.MapPath(Path.ApplicationRoot + "/" + mobileSource)))
                    {
                        throw new FileNotFoundException("Mobile Control not found");
                    }
                }

                // Get Module ID
                var defId = portalModule.GuidID;

                var baseType = portalModule.GetType().BaseType;

                // Get Assembly name
                if (baseType != null)
                {
                    var assemblyName = baseType.Assembly.CodeBase;
                    assemblyName = assemblyName.Substring(assemblyName.LastIndexOf('/') + 1); // Get name only

                    // Get Module Class name
                    var className = baseType.FullName;

                    // Now we add the definition to module list
                    var modules = new ModulesDB();

                    if (install)
                    {
                        // Install as new module

                        // Call Install
                        try
                        {
                            ErrorHandler.Publish(LogLevel.Debug, string.Format("Installing '{0}' as new module.", friendlyName));
                            portalModule.Install(null);
                        }
                        catch (Exception ex)
                        {
                            // Error occurred
                            portalModule.Rollback(null);

                            // Re-throw exception
                            throw new Exception(string.Format("Exception occurred installing '{0}'!", portalModule.GuidID), ex);
                        }

                        try
                        {
                            // Add a new module definition to the database
                            modules.AddGeneralModuleDefinitions(
                                defId,
                                friendlyName,
                                desktopSource,
                                mobileSource,
                                assemblyName,
                                className,
                                portalModule.AdminModule,
                                portalModule.Searchable);
                        }
                        catch (Exception ex)
                        {
                            // Re-throw exception
                            throw new Exception(string.Format("AddGeneralModuleDefinitions Exception '{0}'!", portalModule.GuidID), ex);
                        }

                        // All is fine: we can call Commit
                        portalModule.Commit(null);
                    }
                    else
                    {
                        // Update the general module definition
                        try
                        {
                            ErrorHandler.Publish(LogLevel.Debug, string.Format("Updating '{0}' as new module.", friendlyName));
                            modules.UpdateGeneralModuleDefinitions(
                                defId,
                                friendlyName,
                                desktopSource,
                                mobileSource,
                                assemblyName,
                                className,
                                portalModule.AdminModule,
                                portalModule.Searchable);
                        }
                        catch (Exception ex)
                        {
                            // Re-throw exception
                            throw new Exception(
                                      string.Format("UpdateGeneralModuleDefinitions Exception '{0}'!", portalModule.GuidID), ex);
                        }
                    }

                    // Update the module definition - install for portal 0
                    modules.UpdateModuleDefinitions(defId, 0, true);
                }
            }
        }