Ejemplo n.º 1
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
                {
                    if (!btnUseInstaller.Visible)
                    {
                        ModuleInstall.InstallGroup(Server.MapPath(Path.ApplicationRoot + "/" + InstallerFileName.Text),
                                                   lblGUID.Text == string.Empty);
                    }
                    else
                    {
                        ModuleInstall.Install(FriendlyName.Text, DesktopSrc.Text, MobileSrc.Text,
                                              lblGUID.Text == string.Empty);
                    }

                    ModulesDB modules = new ModulesDB();

                    // 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>";
                    if (!btnUseInstaller.Visible)
                    {
                        lblErrorDetail.Text += " Installer: " +
                                               Server.MapPath(Path.ApplicationRoot + "/" + InstallerFileName.Text);
                    }
                    else
                    {
                        lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text +
                                               "' - Mobile: '" + MobileSrc.Text + "'";
                    }
                    lblErrorDetail.Visible = true;

                    ErrorHandler.Publish(LogLevel.Error, lblErrorDetail.Text, ex);
                }
            }
        }
        /// <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);
                }
            }
        }
        /// <summary>
        /// OnUpdate installs or refresh module definiton on db
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUpdate(EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (!btnUseInstaller.Visible)
                    {
                        Rainbow.Helpers.ModuleInstall.InstallGroup(Server.MapPath(Rainbow.Settings.Path.ApplicationRoot + "/" + InstallerFileName.Text), lblGUID.Text == string.Empty);
                    }
                    else
                    {
                        Rainbow.Helpers.ModuleInstall.Install(FriendlyName.Text, DesktopSrc.Text, MobileSrc.Text, lblGUID.Text == string.Empty);
                    }

                    ModulesDB modules = new ModulesDB();

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

                    // Redirect back to the portal admin page
                    RedirectBackToReferringPage();
                }
                catch (Exception ex)
                {
                    lblErrorDetail.Text = Esperantus.Localize.GetString("MODULE_DEFINITIONS_INSTALLING", "An error occurred installing.", this) + "<br>";
                    if (!btnUseInstaller.Visible)
                    {
                        lblErrorDetail.Text += " Installer: " + Server.MapPath(Rainbow.Settings.Path.ApplicationRoot + "/" + InstallerFileName.Text);
                    }
                    else
                    {
                        lblErrorDetail.Text += " Module: '" + FriendlyName.Text + "' - Source: '" + DesktopSrc.Text + "' - Mobile: '" + MobileSrc.Text + "'";
                    }
                    lblErrorDetail.Visible = true;

                    Rainbow.Configuration.ErrorHandler.HandleException(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
        private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName, string portalPath)
        {
            int newPortalID;

            PortalsDB portals = new PortalsDB();
            TabsDB    tabs    = new TabsDB();
            ModulesDB modules = new ModulesDB();
            UsersDB   users   = new UsersDB();

            // create an Array to stores modules ID and GUID for finding them later
            ArrayList      templateModules = new ArrayList();
            moduleTemplate module;
            // create an Array to stores tabs ID for finding them later
            ArrayList   templateTabs = new ArrayList();
            tabTemplate tab;

            // Create a new portal
            newPortalID = portals.AddPortal(portalAlias, portalName, portalPath);

            // Open the connection to the PortalTemplates Database
            SqlConnection myConnection    = GetConnection();
            SqlConnection my2ndConnection = GetConnection();
            SqlConnection my3rdConnection = GetConnection();

            myConnection.Open();
            my2ndConnection.Open();
            my3rdConnection.Open();

            // get module definitions and save them in the new portal
            SqlDataReader myReader = GetTemplateModuleDefinitions(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                module.id     = (int)myReader["ModuleDefID"];
                module.GuidID = GetGeneralModuleDefinitionByName(myReader["FriendlyName"].ToString(), my2ndConnection);
                try
                {
                    // save module definitions in the new portal
                    modules.UpdateModuleDefinitions(module.GuidID, newPortalID, true);
                    // Save the modules into a list for finding them later
                    templateModules.Add(module);
                }
                catch
                {
                    // tried to add a Module thas doesn´t exists in this implementation of the portal
                }
            }

            myReader.Close();

            if (!PortalSettings.UseSingleUserBase)
            {
                int roleID;
                int userID;
                int adminRoleID = 0;

                // get roles and save them in the new portal
                myReader = GetPortalRoles(templateID, myConnection);

                // Always call Read before accessing data.
                while (myReader.Read())
                {
                    roleID = users.AddRole(newPortalID, myReader["RoleName"].ToString());
                    if (myReader["RoleName"].ToString() == "Admins")
                    {
                        adminRoleID = roleID;
                    }
                }

                myReader.Close();

                // Create the "admin" User for the new portal
                string AdminEmail = "*****@*****.**";
                userID = users.AddUser("admin", AdminEmail, "admin", newPortalID);

                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the "admin" user
                users.AddUserRole(adminRoleID, userID);
            }

            // Get all the Tabs in the Template Portal, store IDs in a list for finding them later
            // and create the Tabs in the new Portal
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Save the tabs into a list for finding them later
                tab.oldID = (int)myReader["TabID"];
                tab.newID = tabs.AddTab(newPortalID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString()));
                templateTabs.Add(tab);
            }
            myReader.Close();

            // now I have to get them again to set up the ParentID for each Tab
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Find the news TabID and ParentTabID
                System.Collections.IEnumerator myEnumerator = templateTabs.GetEnumerator();
                int newTabID       = -1;
                int newParentTabID = -1;

                while (myEnumerator.MoveNext() && (newTabID == -1 || newParentTabID == -1))
                {
                    tab = (tabTemplate)myEnumerator.Current;
                    if (tab.oldID == (int)myReader["TabID"])
                    {
                        newTabID = tab.newID;
                    }
                    if (tab.oldID == Int32.Parse("0" + myReader["ParentTabID"]))
                    {
                        newParentTabID = tab.newID;
                    }
                }

                if (newParentTabID == -1)
                {
                    newParentTabID = 0;
                }

                // Update the Tab in the new portal
                tabs.UpdateTab(newPortalID, newTabID, newParentTabID, myReader["TabName"].ToString(),
                               Int32.Parse(myReader["TabOrder"].ToString()), myReader["AuthorizedRoles"].ToString(),
                               myReader["MobileTabName"].ToString(), (bool)myReader["ShowMobile"]);

                // Finally use GetPortalSettings to access each Tab and its Modules in the Template Portal
                // and create them in the new Portal
                SqlDataReader result;

                try
                {
                    result = GetTabModules(Int32.Parse(myReader["TabID"].ToString()), my2ndConnection);

                    object myValue;

                    while (result.Read())
                    {
                        ModuleSettings m = new ModuleSettings();
                        m.ModuleID    = (int)result["ModuleID"];
                        m.ModuleDefID = (int)result["ModuleDefID"];
                        m.TabID       = newTabID;
                        m.PaneName    = (string)result["PaneName"];
                        m.ModuleTitle = (string)result["ModuleTitle"];

                        myValue = result["AuthorizedEditRoles"];
                        m.AuthorizedEditRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedViewRoles"];
                        m.AuthorizedViewRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedAddRoles"];
                        m.AuthorizedAddRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteRoles"];
                        m.AuthorizedDeleteRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPropertiesRoles"];
                        m.AuthorizedPropertiesRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedMoveModuleRoles"];
                        m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteModuleRoles"];
                        m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPublishingRoles"];
                        m.AuthorizedPublishingRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue           = result["SupportWorkflow"];
                        m.SupportWorkflow = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        myValue = result["AuthorizedApproveRoles"];
                        m.AuthorizedApproveRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue          = result["WorkflowState"];
                        m.WorkflowStatus = !Convert.IsDBNull(myValue) ? (WorkflowState)(0 + (byte)myValue) : WorkflowState.Original;

                        try { myValue = result["SupportCollapsable"]; }
                        catch { myValue = DBNull.Value; }
                        m.SupportCollapsable = DBNull.Value != myValue ? (bool)myValue : false;

                        try { myValue = result["ShowEveryWhere"]; }
                        catch { myValue = DBNull.Value; }
                        m.ShowEveryWhere = DBNull.Value != myValue ? (bool)myValue : false;

                        m.CacheTime   = int.Parse(result["CacheTime"].ToString());
                        m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString());

                        myValue      = result["ShowMobile"];
                        m.ShowMobile = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        // Find the new ModuleDefID assigned to the module in the new portal
                        myEnumerator = templateModules.GetEnumerator();
                        int newModuleDefID = 0;

                        while (myEnumerator.MoveNext() && newModuleDefID == 0)
                        {
                            module = (moduleTemplate)myEnumerator.Current;
                            if (module.id == m.ModuleDefID)
                            {
                                newModuleDefID = modules.GetModuleDefinitionByGuid(newPortalID, module.GuidID);
                            }
                        }

                        if (newModuleDefID > 0)
                        {
                            // add the module to the new tab
                            int newModuleID = modules.AddModule(newTabID, m.ModuleOrder, m.PaneName, m.ModuleTitle,
                                                                newModuleDefID, m.CacheTime, m.AuthorizedEditRoles, m.AuthorizedViewRoles,
                                                                m.AuthorizedAddRoles, m.AuthorizedDeleteRoles, m.AuthorizedPropertiesRoles,
                                                                m.AuthorizedMoveModuleRoles, m.AuthorizedDeleteModuleRoles,
                                                                m.ShowMobile, m.AuthorizedPublishingRoles, m.SupportWorkflow,
                                                                m.ShowEveryWhere, m.SupportCollapsable);
                            // At the end, get all ModuleSettings and save them in the new module
                            SqlDataReader dr = GetModuleSettings(m.ModuleID, my3rdConnection);

                            while (dr.Read())
                            {
                                ModuleSettings.UpdateModuleSetting(newModuleID, dr["SettingName"].ToString(), dr["SettingValue"].ToString());
                            }
                            dr.Close();
                        }
                    }

                    result.Close();
                }
                catch
                {
                    // Error? ignore Tab ...
                }
            }
            myReader.Close();

            // Set the CustomSettings of the New Portal based in the Template Portal
            myReader = GetPortalCustomSettings(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                PortalSettings.UpdatePortalSetting(newPortalID, myReader["SettingName"].ToString(), myReader["SettingValue"].ToString());
            }

            myReader.Close();

            // close the conections
            myConnection.Close();
            myConnection.Dispose();
            my2ndConnection.Close();
            my2ndConnection.Dispose();
            my3rdConnection.Close();
            my3rdConnection.Dispose();

            // Create paths
            portals.CreatePortalPath(portalPath);

            return(newPortalID);
        }
        public JsonResult Clone(int id, int parentId)
        {
            try
            {
                var      generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2");
                object[] queryargs        = { generalModuleDef, PortalSettings.PortalID };

                int moduleDefinition;

                try
                {
                    moduleDefinition =
                        new rb_ModuleDefinitions().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }
                catch (Exception e)
                {
                    // Shortcut module doesn't exist in current Portal

                    var modules = new ModulesDB();

                    modules.UpdateModuleDefinitions(
                        generalModuleDef,
                        PortalSettings.PortalID,
                        true);

                    moduleDefinition =
                        new rb_ModuleSettings().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }

                var db = new PagesDB();

                PortalPages = db.GetPagesFlat(PortalSettings.PortalID);
                var t = new PageItem
                {
                    Name  = General.GetString("TAB_NAME", "New Page Name"),
                    ID    = -1,
                    Order = 990000
                };

                PortalPages.Add(t);

                var tabs = new PagesDB();
                t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order);

                db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID);

                OrderPages();
                //JsonResult treeData = GetTreeData();

                // Coping Modules



                var pagesModules = new rb_Modules().All(where : "TabID = @0", args: id);

                foreach (var module in pagesModules)
                {
                    var m = new ModuleItem();
                    m.Title       = module.ModuleTitle;
                    m.ModuleDefID = moduleDefinition;
                    m.Order       = module.ModuleOrder;

                    // save to database
                    var mod = new ModulesDB();

                    m.ID = mod.AddModule(
                        t.ID,
                        m.Order,
                        module.PaneName,
                        module.ModuleTitle,
                        m.ModuleDefID,
                        0,
                        module.AuthorizedEditRoles,
                        module.AuthorizedViewRoles,
                        module.AuthorizedAddRoles,
                        module.AuthorizedDeleteRoles,
                        module.AuthorizedPropertiesRoles,
                        module.AuthorizedMoveModuleRoles,
                        module.AuthorizedDeleteModuleRoles,
                        false,
                        PortalSecurity.GetDeleteModulePermissions(module.ModuleID),
                        false,
                        false,
                        false);

                    var settings = new rb_ModuleSettings();
                    settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID });
                }



                return(Json(new { pageId = t.ID }));
            }
            catch (Exception e)
            {
                ErrorHandler.Publish(LogLevel.Error, e);
                Response.StatusCode = 500;
                return(Json(""));
            }
        }
Ejemplo n.º 7
0
        /// <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
                {
                    // Removed MVC Action and Portable Area installation code
                    //if (this.chbMVCAction.Visible || this.chbPortableAreas.Visible)
                    {
                        // Es un módulo clásico
                        if (!this.btnUseInstaller.Visible)
                        {
                            ModuleInstall.InstallGroup(
                                this.Server.MapPath(Path.ApplicationRoot + "/" + this.InstallerFileName.Text),
                                this.lblGUID.Text == string.Empty, true);
                        }
                        else
                        {
                            ModuleInstall.Install(
                                this.FriendlyName.Text,
                                this.DesktopSrc.Text,
                                this.MobileSrc.Text,
                                this.lblGUID.Text == string.Empty);
                        }

                        // Update the module definition
                    }

                    // Removed MVC Action and Portable Area installation code
                    //else
                    //{
                    //    // Es una acción MVC
                    //    var path = this.ddlAction.SelectedValue;

                    //    path = path.Substring(path.IndexOf("Areas"));
                    //    path = path.Replace("\\", "/");
                    //    path = path.Replace(".aspx", string.Empty);
                    //    path = path.Replace(".ascx", string.Empty);

                    //    var name = this.FriendlyNameMVC.Text;

                    //    this.defId = ModelServices.AddMVCActionModule(name, path);
                    //}

                    var modules = new ModulesDB();

                    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 += ex.Message + "<br />";
                    if (!this.btnUseInstaller.Visible)
                    {
                        this.lblErrorDetail.Text += string.Format(
                            " Installer: {0}",
                            this.Server.MapPath(
                                string.Format("{0}/{1}", Path.ApplicationRoot, this.InstallerFileName.Text)));
                    }
                    else
                    {
                        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.º 8
0
        public int CreatePortal(int solutionId, string portalAlias, string portalName, string portalPath)
        {
            var tabs    = new PagesDB();
            var modules = new ModulesDB();

            // Create a new portal
            var portalId = this.AddPortal(portalAlias, portalName, portalPath);

            // get module definitions
            foreach (var solutionModuleDefinition in modules.GetSolutionModuleDefinitions(solutionId))
            {
                modules.UpdateModuleDefinitions(solutionModuleDefinition.GeneralModuleDefinitionId, portalId, true);
            }

            if (!Config.UseSingleUserBase)
            {
                const string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                var user = new UsersDB();

                // Create the "Admins" role for the new portal
                var roleId = user.AddRole(portalAlias, "Admins");
                var userId = user.AddUser(StringsAdmin, AdminEmail, StringsAdmin, portalAlias);

                // Create the "Admins" profile for the new portal
                var profile = ProfileBase.Create(AdminEmail);
                profile.SetPropertyValue("Email", AdminEmail);
                profile.SetPropertyValue("Name", "admin");
                try {
                    profile.Save();
                } catch  {
                }

                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                user.AddUserRole(roleId, userId, portalAlias);
            }

            // Create a new Page "home"
            var homePageId = tabs.AddPage(portalId, "Home", 1);

            // Create a new Page "admin"
            var localizedString = General.GetString("ADMIN_TAB_NAME");
            var adminPageId     = tabs.AddPage(portalId, localizedString, StrAdmins, 9999);

            // Add Modules for portal use
            // Html Document
            modules.UpdateModuleDefinitions(new Guid(StrGuidhtmlDocument), portalId, true);

            // Add Modules for portal administration
            // Site Settings (Admin)
            localizedString = General.GetString("MODULE_SITE_SETTINGS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidSiteSettings), portalId, true);
            modules.AddModule(
                adminPageId,
                1,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidSiteSettings)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Pages (Admin)
            localizedString = General.GetString("MODULE_TABS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidPages), portalId, true);
            modules.AddModule(
                adminPageId,
                2,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidPages)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Roles (Admin)
            localizedString = General.GetString("MODULE_SECURITY_ROLES");
            modules.UpdateModuleDefinitions(new Guid(StrGuidSecurityRoles), portalId, true);
            modules.AddModule(
                adminPageId,
                3,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidSecurityRoles)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Manage Users (Admin)
            localizedString = General.GetString("MODULE_MANAGE_USERS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidManageUsers), portalId, true);
            modules.AddModule(
                adminPageId,
                4,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidManageUsers)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Module Definitions (Admin)
            localizedString = General.GetString("MODULE_MODULES");
            modules.UpdateModuleDefinitions(new Guid(StrGuidModules), portalId, true);
            modules.AddModule(
                adminPageId,
                1,
                StringsRightPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidModules)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // End Change [email protected]
            // Change by [email protected]
            // Add Signin Module and put it on the hometab
            // Signin
            localizedString = General.GetString("MODULE_LOGIN", "Login");
            modules.UpdateModuleDefinitions(new Guid(StrGuidLogin), portalId, true);
            modules.AddModule(
                homePageId,
                -1,
                StrLeftPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidLogin)),
                0,
                StrAdmins,
                "Unauthenticated Users;Admins;",
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Add language switcher to available modules
            // Language Switcher
            modules.UpdateModuleDefinitions(new Guid(StrGuidLanguageSwitcher), portalId, true);

            // End of change by [email protected]
            // Create paths
            this.CreatePortalPath(portalPath);
            return(portalId);
        }
Ejemplo n.º 9
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.º 10
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);
                }
            }
        }
Ejemplo n.º 11
0
        public int CreatePortal(int solutionID, string portalAlias, string portalName, string portalPath)
        {
            int       portalID;
            PagesDB   tabs    = new PagesDB();
            ModulesDB modules = new ModulesDB();

            // Create a new portal
            portalID = AddPortal(portalAlias, portalName, portalPath);
            // get module definitions
            SqlDataReader myReader;

            myReader = modules.GetSolutionModuleDefinitions(solutionID);

            // Always call Read before accessing data.
            try
            {
                while (myReader.Read())
                {
                    modules.UpdateModuleDefinitions(new Guid(myReader["GeneralModDefID"].ToString()), portalID, true);
                }
            }

            finally
            {
                myReader.Close(); //by Manu, fixed bug 807858
            }

            if (!Config.UseSingleUserBase)
            {
                string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                UsersDB User = new UsersDB();
                // Create the "Admins" role for the new portal
                Guid roleID = User.AddRole("Admins");
                Guid userID = User.AddUser(stradmin, AdminEmail, stradmin);
                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                User.AddUserRole(roleID, userID);
            }
            // Create a new Page "home"
            int homePageID = tabs.AddPage(portalID, "Home", 1);
            // Create a new Page "admin"
            string localizedString = General.GetString("ADMIN_TAB_NAME");
            int    adminPageID     = tabs.AddPage(portalID, localizedString, strAdmins, 9999);

            // Add Modules for portal use
            // Html Document
            modules.UpdateModuleDefinitions(new Guid(strGUIDHTMLDocument), portalID, true);
            // Add Modules for portal administration
            // Site Settings (Admin)
            localizedString = General.GetString("MODULE_SITE_SETTINGS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDSiteSettings), portalID, true);
            modules.AddModule(adminPageID, 1, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDSiteSettings)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Pages (Admin)
            localizedString = General.GetString("MODULE_TABS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDPages), portalID, true);
            modules.AddModule(adminPageID, 2, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDPages)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Roles (Admin)
            localizedString = General.GetString("MODULE_SECURITY_ROLES");
            modules.UpdateModuleDefinitions(new Guid(strGUIDSecurityRoles), portalID, true);
            modules.AddModule(adminPageID, 3, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDSecurityRoles)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Manage Users (Admin)
            localizedString = General.GetString("MODULE_MANAGE_USERS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDManageUsers), portalID, true);
            modules.AddModule(adminPageID, 4, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDManageUsers)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Module Definitions (Admin)
            localizedString = General.GetString("MODULE_MODULES");
            modules.UpdateModuleDefinitions(new Guid(strGUIDModules), portalID, true);
            modules.AddModule(adminPageID, 1, strRightPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDModules)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // End Change [email protected]
            // Change by [email protected]
            // Add Signin Module and put it on the hometab
            // Signin
            localizedString = General.GetString("MODULE_LOGIN", "Login");
            modules.UpdateModuleDefinitions(new Guid(strGUIDLogin), portalID, true);
            modules.AddModule(homePageID, -1, strLeftPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDLogin)), 0, strAdmins,
                              "Unauthenticated Users;Admins;", strAdmins, strAdmins, strAdmins, strAdmins, strAdmins,
                              false, string.Empty, false, false, false);
            // Add language switcher to available modules
            // Language Switcher
            modules.UpdateModuleDefinitions(new Guid(strGUIDLanguageSwitcher), portalID, true);
            // End of change by [email protected]
            // Create paths
            CreatePortalPath(portalPath);
            return(portalID);
        }