Click or drag to resize

AskiaPortalCmnApiOnSetup Event

Event raise when the module must be registered or updated according to the current assembly version.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static event SetupHandler OnSetup

Value

Type: AskiaPortalCmn.SetupSetupHandler
Remarks
This event will be raised from the InitializeModule(Guid, Version, String, Boolean) method.
Register the event before the call of this method.
Remarks
We strongly recommend to have only one assembly responsible to register the module.
It's the main application or service of the module.
Remarks
The version number of the current assembly will be use as reference to update the module.
Examples

Register a module using his main web service (Global.asax).

using System;
using System.Web;
using System.Collections.Generic;
using AskiaPortalCmn;
using AskiaPortalCmn.Setup;
using AskiaPortalCmn.Common;

namespace MyWebModule
{
    public class Global : HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            AskiaPortalCmnApi.OnSetup += AskiaPortalCmnApi_OnSetup;
            Guid myWebModuleGuid = Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5");
            Version myWebModuleVersion = new Version("1.0.0.0");
            AskiaPortalCmnApi.InitializeModule(myWebModuleGuid, myWebModuleVersion);
        }

        private void AskiaPortalCmnApi_OnSetup(IModuleSetup moduleSetup, IModule currentModule)
        {
            if (currentModule != null)
            {
                // This is an update of the version:
                // currentModule.Version
                // to the current assembly version
            }
            else
            {
                // This is the first registration 
                // of the module
            }

            // Set meta information
            moduleSetup.Name = "MyWebModule";
            moduleSetup.Description = "Web module to do something...";
            moduleSetup.Authors = "Myself and Co.";
            moduleSetup.RootUrl = "MyWebModule/";

            // Set the default module configuration
            moduleSetup.SetDefaultConfig(new Dictionary<string, object>
                {
                    {"myStringKey", "default value"},
                    {"myBoolKey", false},
                    {"myIntKey", 50},
                    {"myDblKey", 50.2},
                    {"myGuidKey", Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5"}
                }
            );

            // Set the default module translations
            moduleSetup.SetDefaultTranslations("en-GB", new Dictionary<string, string>
                {
                    {"new", "New"},
                    {"open", "Open"}
                }
            );
            moduleSetup.SetDefaultTranslations("fr-FR", new Dictionary<string, string>
                {
                    {"new", "Nouveau"},
                    {"open", "Ouvrir"}
                }
            );

            // Save the module
            moduleSetup.Save();
        }
    }
}
See Also