IModuleSetupSave Method |
Namespace: AskiaPortalCmn.Setup
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; var myWebModuleGuid = Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5"); var 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/"; moduleSetup.Category = ModuleCategory.SurveysCreation; // 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"} } ); // Set URLs of the module moduleSetup.SetUrls(new Dictionary<ModuleUrlFor, string> { {ModuleUrlTo.ModulePage, ""}, {ModuleUrlTo.ModuleLogo, "img/logo.svg"}, {ModuleUrlTo.ModuleLogoHover, "img/logo-hover.svg"}, {ModuleUrlTo.AdminUserPage, "admin/User/"}, {ModuleUrlTo.AdminUserProfilePage, "admin/UserProfile/"}, {ModuleUrlTo.AdminSurveyPage, "admin/Survey/"}, {ModuleUrlTo.AdminSurveyUserPage, "admin/SurveyUser/"}, {ModuleUrlTo.AdminSurveyGroupage, "admin/SurveyGroup/"} }); // Save the module moduleSetup.Save(); } } }