Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Modules

BaseModule

Every Module inherits from BaseModule. So the properties of BaseModule are described below:

 public abstract class BaseModule
    {

        /// <summary>
        /// Gets the title of the module a.e: "EasyWeb"
        /// </summary>
        /// <value>
        /// The title.
        /// </value>
        public abstract string Title { get; }

        /// <summary>
        /// Gets the name of the module a.e: "ECIT.WebFrame.Modules.EasyWeb"
        /// </summary>
        /// <value>
        /// The name.
        /// </value>
        public abstract string Name { get; }

        /// <summary>
        /// Gets the required role for accessing this module.
        /// </summary>
        /// <value>
        /// The required role.
        /// </value>
        public abstract Role RequiredRole { get; }

        /// <summary>
        /// Gets the version of the module
        /// </summary>
        /// <value>
        /// The version.
        /// </value>
        public abstract Version Version { get; }


        /// <summary>
        /// Gets the module navigation
        /// </summary>
        /// <value>
        /// The admin navigation.
        /// </value>
        public abstract ModuleNavigation Navigation { get; }


        /// <summary>
        /// Gets the robots information.
        /// </summary>
        /// <value>
        /// The robots information.
        /// </value>
        public virtual RobotsInformation RobotsInformation
        {
            get { return null; }
        }

        /// <summary>
        /// Gets the wildcard routes.
        /// </summary>
        /// <value>
        /// The wildcard routes.
        /// </value>
        public virtual List<MvcRoute> WildcardRoutes
        {
            get { return null; }
        }

        /// <summary>
        /// Gets the FTP interface for the Module
        /// </summary>
        /// <value>
        /// The FTP interface.
        /// </value>
        public virtual IFtp FtpInterface
        {
            get { return null; }
        }

        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public abstract void Init();

        /// <summary>
        /// Users the cleanup.
        /// </summary>
        /// <param name="user">The user.</param>
        public abstract void UserCleanup(User user);

        /// <summary>
        /// Gets or sets the application identifier.
        /// </summary>
        /// <value>
        /// The application identifier.
        /// </value>
        public int ApplicationId { get; set; }
    }

Init()

Init is used to execute code before the modules get loaded. As example for creating user roles:

public override void Init()
{
    RoleManager.InitRole(EasyWebDefaultRoles.EASYWEB_USER, "EasyWeb User Role");
}

FtpInterface

FtpInterface provides a simple way to add FTP Support for the Module. What you are going to do with the FTP Protocoll and the transfered data is completly by the logic of the module :=)

For an easy implementation just override the abstract property with the following code:

public override IFtp FtpInterface
{
	get { return new FtpInterface(); }
}

Create a class that interhits from the IFtp Interface as showed bellow and fill out the methods:

…. -> Further information coming soon!

public class FtpInterface : IFtp
    {
        /// <summary>
        /// Deletes the specified pathname.
        /// </summary>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string Delete(string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Renames the specified rename from.
        /// </summary>
        /// <param name="renameFrom">The rename from.</param>
        /// <param name="renameTo">The rename to.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string Rename(string renameFrom, string renameTo)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Creates the dir.
        /// </summary>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string CreateDir(string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Removes the dir.
        /// </summary>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string RemoveDir(string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Changes the working directory.
        /// </summary>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string ChangeWorkingDirectory(string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Lists the operation.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string ListOperation(NetworkStream dataStream, string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Retrieves the operation.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string RetrieveOperation(NetworkStream dataStream, string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Stores the operation.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string StoreOperation(NetworkStream dataStream, string pathname)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Appends the operation.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="pathname">The pathname.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public string AppendOperation(NetworkStream dataStream, string pathname)
        {
            throw new NotImplementedException();
        }
    }

…. -> Further information coming soon!

Wildcardroutes

Wildcardroutes provides a simple way to add wildcardroutes to the routing of your Module

The Wildcardroutes is built as a abstract property in the BaseModule so it can be overriden in the individual Module.

public override List<MvcRoute> WildcardRoutes
{
    get
    {
        var retVal = new List<MvcRoute>
        {
            new MvcRoute
            {
                Name = "EasyWeb_404",
                Url = "{lang}/error/404",
                Defaults = new {controller = "Web", action = "Error404", lang = ""},
                Namespaces = new[] {"ECIT.WebFrame.Modules.EasyWeb.Controllers.Frontend"},
                Constraints = new {customConstraint = new TenantHasModuleConstraint(this.Title)}
            }
        };
        return retVal;
    }
}

Navigation provides a simple way to create a navigation for your Module

The Navigation is built as a abstract property in the BaseModule so it can be overriden in the individual Module.

Use the following code in your Module implementation, to allow the lowest user level:

public override ModuleNavigation Navigation
{
    get
    {
        var retVal = new ModuleNavigation()
        {
            Icon = "fa-globe",
            Name = "EasyWeb",
            NavigationPoints = new List<ModuleNavigationPoint>
            {
                new ModuleNavigationPoint
                {
                    Name = "Dashboard",
                    Url = "/Admin/" + this.Title + "/Dashboard",
                    RequiredRole = null,
                    Icon = "fa-dashboard"
                }
            }
        };
    }
}

RequiredRole

RequiredRole provides a simple way to permissioning your Module

The RequiredRole is built as a abstract property in the BaseModule so it can be overriden in the individual Module.

Use the following code in your Module implementation, to allow the lowest user level:

public override Role RequiredRole
{
    get
    {
        return RoleManager.GetRole(EasyWebDefaultRoles.EASYWEB_USER);
    }
}

RobotsInformation

RobotsInformation provides a simple way to provide Instance wide Robots.txt Information.

The RobotsInforamtion is built as a abstract property in the BaseModule so it can be overriden in the individual Module

public class RobotsInformation
{
	public List<string> DisallowUrls { get; set; }
	public string SitemapUrl { get; set; }
}

Use the following code in your Module implemetation, to add your nessecary infos into robots.txt:

public override RobotsInformation RobotsInformation
{
    get
    {
        var disallowUrls =  GeneralSettingsManager.CreateInstance(this.ApplicationId).GetGeneralSettings().IsUnderConstructionMode ? new List<string>{"/"} : PageContentManager.CreateInstance(this.ApplicationId).GetPageContentsRaw().Where(m => m.AllowPageIndexing == false).ToList().Select(pageContent => PageContentManager.CreateInstance(this.ApplicationId).GetPageContentUrl(pageContent)).ToList();
        return new RobotsInformation
        {
            DisallowUrls = disallowUrls,
            SitemapUrl = GeneralSettingsManager.CreateInstance(this.ApplicationId).GetGeneralSettings().WebsiteUrl + "/sitemap.xml"
        };
    }
}