示例#1
0
        public ActionResult Configure(string configName, FormCollection model)
        {
            var config = ModuleConfiguration.GetModuleConfiguration(Globals.ModuleId, configName);
            var o      = model.Parse(ControllerContext, config.Type);

            config.SetConfiguration(o);
            return(PartialView(config.View, o));
        }
示例#2
0
        public ActionResult Configure(string configName)
        {
            var config  = ModuleConfiguration.GetModuleConfiguration(Globals.ModuleId, configName);
            var jObject = config.Parse <JObject>();

            ViewData.TemplateInfo = new TemplateInfo
            {
                HtmlFieldPrefix = config.Type.Name,
            };
            return(PartialView(config.View, jObject.ToObject(config.Type)));
        }
        public override T GetConfiguration()
        {
            var moduleConfiguration = ModuleConfiguration.GetModuleConfiguration(_moduleId, ConfigName, typeof(T));

            try
            {
                return(moduleConfiguration.Parse <T>());
            }
            catch
            {
                return(GetTObject());
            }
        }
        public override bool SetConfiguration(T config)
        {
            try
            {
                var moduleConfiguration = ModuleConfiguration.GetModuleConfiguration(_moduleId, ConfigName, typeof(T));
                moduleConfiguration.SetConfiguration(config);
                moduleConfiguration.Save();

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogException(e);
                return(false);
            }
        }
示例#5
0
        public LogManager(string application, Type type = null)
        {
            try
            {
                Application = application;
                Type        = type;

                var consoleOutputTemplate =
                    $"[{application}" + " {Timestamp:HH:mm:ss.ff} {Level:u3}] {Message:lj}{NewLine}{Exception}";
                var arCommonSettings    = ModuleConfiguration.GetModuleConfiguration(Globals.ModuleId, "ArCommonSettings").Parse <ArCommonSettings>();
                var loggerConfiguration = new LoggerConfiguration()
                                          .WriteTo.Console(outputTemplate: consoleOutputTemplate)
                                          .MinimumLevel.Is(arCommonSettings.MinimumLogLevel);

                if (type != null)
                {
                    var assemblyName = Type.Assembly.GetName().Name;
                    LogLocation =
                        Path.Combine(
                            _logBaseLocation
                            .Replace("{0}", assemblyName)
                            .Replace("{1}", Type.Namespace?.Replace(assemblyName, "").Trim('.'))
                            .Replace("{2}", application));
                }
                else
                {
                    LogLocation =
                        Path.Combine(
                            _logBaseLocation
                            .Replace("{0}", "Unknown")
                            .Replace("{1}", application)
                            .Replace("{2}", application));
                }

                loggerConfiguration.WriteTo.File(LogLocation, rollingInterval: RollingInterval.Day, shared: true);
                InternalLogger = loggerConfiguration.CreateLogger();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }