Exemplo n.º 1
0
    protected void lvModules_ItemCommand(object source, ListViewCommandEventArgs e)
    {
        if (e.CommandName == "InstallLastVersion")
        {
            var moduleVersion          = ((HiddenField)e.Item.FindControl("hfLastVersion")).Value;
            var moduleIdOnRemoteServer = ((HiddenField)e.Item.FindControl("hfId")).Value;

            var message = ModulesService.GetModuleArchiveFromRemoteServer(moduleIdOnRemoteServer);

            if (message.IsNullOrEmpty())
            {
                //ModulesService.InstallModule(Convert.ToString(e.CommandArgument));
                HttpRuntime.UnloadAppDomain();

                Context.ApplicationInstance.CompleteRequest();
                Response.Redirect(
                    UrlService.GetAdminAbsoluteLink("modulesmanager.aspx?installModule=" + e.CommandArgument + "&version=" +
                                                    moduleVersion), false);
            }
            else
            {
                //вывести message
            }
        }
        if (e.CommandName == "Install")
        {
            ModulesService.InstallModule(Convert.ToString(e.CommandArgument));
        }
        if (e.CommandName == "Uninstall")
        {
            ModulesService.UninstallModule(Convert.ToString(e.CommandArgument));
            HttpRuntime.UnloadAppDomain();
            Response.Redirect(Request.Url.AbsoluteUri);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// Load all the assemblies & run all the migrations
        /// </summary>
        /// <param name="services">The ServiceCollection "this"</param>
        /// <returns>The modified IServiceCollection</returns>
        public static IServiceCollection LoadAllServicesFromExternalAssembiles(this IServiceCollection services, IConfigurationRoot _config)
        {
            // Service migraotr used for the main system migrating
            var serviceProviderMigrateg = CreateserviceMigrator(typeof(Migration1270720191).Assembly, _config);

            // We create a scope for the migrator service
            using (var scope = serviceProviderMigrateg.CreateScope())
            {
                (scope as IServiceProvider).GetRequiredService <IMigrationRunner>().MigrateUp();
            }
            // Call the loading method from the ModulesService
            ModulesService.LoadAssembliesInDirrectory();
            List <AssemblyEntity> ass = RuntimeAssemblies.AssemblyEntities.Values.ToList();

            // For each assemblies, we load the migrations
            foreach (AssemblyEntity assembly in ass)
            {
                var assm = assembly.Assembly;
                try
                {
                    var serviceProviderMigrate = CreateserviceMigrator(assm, _config);
                    using var scope = serviceProviderMigrate.CreateScope();
                    (scope as IServiceProvider).GetRequiredService <IMigrationRunner>().MigrateUp();
                }
                catch (Exception e) { Console.WriteLine(e); }
                foreach (TypeInfo typeInfo in assm.DefinedTypes.Where(x => !x.IsInterface && !x.IsEnum && x.IsClass && x.IsPublic && x.Name.Contains("Service")))
                {
                    services.AddSingleton(assm.GetTypes().FirstOrDefault(x => x.Name == typeInfo.Name));
                }
            }
            return(services);
        }
Exemplo n.º 3
0
        protected void LoadData()
        {
            var modulesBox = ModulesService.GetModules();

            paging.TotalPages           = (int)Math.Ceiling((double)modulesBox.Items.Count / ItemsPerPage);
            lvModulesManager.DataSource = modulesBox.Items.Skip((paging.CurrentPage - 1) * ItemsPerPage).Take(ItemsPerPage);
            lvModulesManager.DataBind();
        }
Exemplo n.º 4
0
 protected void LoadData()
 {
     var modulesBox = ModulesService.GetModules();
     //if (modulesBox.Message.IsNullOrEmpty())
     {
         lvModules.DataSource = modulesBox.Items.OrderBy(t => t.Name);
         lvModules.DataBind();
     }
 }
Exemplo n.º 5
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        Page.Title = string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_ModuleManager_Header);

        if (!string.IsNullOrEmpty(Request["installModule"]))
        {
            ModulesService.InstallModule(Convert.ToString(Request["installModule"].ToLower()), Request["version"]);
        }

        LoadData();
    }
Exemplo n.º 6
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_ModuleManager_Header));
            lTrialMode.Visible = TrialService.IsTrialEnabled;

            if (!string.IsNullOrEmpty(Request["installModule"]))
            {
                ModulesService.InstallModule(SQLDataHelper.GetString(Request["installModule"].ToLower()), Request["version"]);
                Response.Redirect(UrlService.GetAdminAbsoluteLink("modulesmanager.aspx"));
            }

            LoadData();
        }
Exemplo n.º 7
0
        public ModulesServiceTest()
        {
            var workContextMock = new Mock <IWorkContext>();

            workContextMock.SetupGet(m => m.ApiKey).Returns("key");
            _cacheMock     = new Mock <ICacheManager>();
            _webClientMock = new Mock <IWebClient>();
            var optionsMock = new Mock <IOptions <ModulesServiceOptions> >();

            optionsMock.SetupGet(m => m.Value).Returns(_serviceOptions);

            var modules = new ModulesListDto
            {
                Modules = new List <ModuleDto>
                {
                    new ModuleDto
                    {
                        Name     = "Active 1",
                        IsActive = true
                    },
                    new ModuleDto
                    {
                        Name     = "Active 2",
                        IsActive = true
                    },
                    new ModuleDto
                    {
                        Name     = "Inactive",
                        IsActive = false
                    }
                }
            };

            _cacheMock.Setup(x => x.IsSet(ModulesCacheKey)).Returns(true);
            _cacheMock.Setup(x => x.Get <ModulesListDto>(ModulesCacheKey)).Returns(modules);

            _modulesService = new ModulesService(optionsMock.Object, workContextMock.Object, _cacheMock.Object, _webClientMock.Object);
        }
Exemplo n.º 8
0
 public RolesController(RolesService rolesService, ModulesService modulesService)
 {
     _rolesService = rolesService;
     moduleService = modulesService;
 }
Exemplo n.º 9
0
 public ModulesServiceManager(ConnectionHelper connectionHelper)
 {
     modulesService = new ModulesService(connectionHelper);
 }
Exemplo n.º 10
0
 public ModulesController(ModulesService modulesService)
 {
     this.modulesService = modulesService;
 }
Exemplo n.º 11
0
 public ModuleController(ModulesService modulesService)
 {
     _modulesService = modulesService;
 }