Exemple #1
0
        public void SetConfig(string moduleName, SaveConfigRequest request)
        {
            try
            {
                var module        = GetModuleFromManager(moduleName);
                var serialization = CreateSerialization(module);
                var config        = GetConfig(module, true);
                EntryConvert.UpdateInstance(config, request.Config.Root, serialization);
                ConfigManager.SaveConfiguration(config, request.UpdateMode == ConfigUpdateMode.UpdateLiveAndSave);

                if (request.UpdateMode == ConfigUpdateMode.SaveAndReincarnate)
                {
                    // This has to be done parallel so we can also reincarnate the Maintenance itself
                    ParallelOperations.ExecuteParallel(() => ModuleManager.ReincarnateModule(module));
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(LogLevel.Warning, ex, "Failed to save config of {0}", moduleName);
#if USE_WCF
                var ctx = WebOperationContext.Current;
                // ReSharper disable once PossibleNullReferenceException
                ctx.OutgoingResponse.StatusCode = HttpStatusCode.InternalServerError;
#else
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
#endif
            }
        }
        public void SetConfig(string moduleName, SaveConfigRequest request)
        {
            try
            {
                var module        = GetModuleFromManager(moduleName);
                var serialization = CreateSerialization(module);
                var config        = GetConfig(module, true);
                EntryConvert.UpdateInstance(config, request.Config.Root, serialization);
                ConfigManager.SaveConfiguration(config, request.UpdateMode == ConfigUpdateMode.UpdateLiveAndSave);

                if (request.UpdateMode == ConfigUpdateMode.SaveAndReincarnate)
                {
                    // This has to be done parallel so we can also reincarnate the Maintenance itself
                    ParallelOperations.ExecuteParallel(() => ModuleManager.ReincarnateModule(module));
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(LogLevel.Warning, ex, "Failed to save config of {0}", moduleName);
                HttpHelper.SetStatusCode(HttpStatusCode.InternalServerError);
            }
        }