public static void init() { string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); try { Console.WriteLine("\nBegin config initialization..."); // Open the text file using a stream reader. using (StreamReader sr = new StreamReader(path + Path.DirectorySeparatorChar + "config.json")) { // Read the stream to a string, and write the string to the console. String line = sr.ReadToEnd(); CommonConfig commonConfig = JsonConvert.DeserializeObject <CommonConfig>(line); db = commonConfig.dbConfig; logs = commonConfig.logsConfig; webServer = commonConfig.webServer; Console.WriteLine("Config initialized successfully."); } } catch (Exception e) { Console.WriteLine("\nError on read \"config.json\", program can not by start:"); Console.WriteLine(e.Message); LoggerService.writeError(e.Message, e.StackTrace); // Console app System.Environment.Exit(1); } }
public IActionResult Logs(LogsConfig model) { dynamic json = ReadConfig(); json.Logs = JObject.FromObject(model); WriteConfig(json); configuration.Reload(); SystemController.logs.config = model; return(RedirectToAction("Index")); }
public void init() { UpdateTimeConfig updateTimeConfig = new UpdateTimeConfig(); ProgramTypeConfig programTypeConfig = new ProgramTypeConfig(); programTypeConfig.setNext(updateTimeConfig); ProgramPathConfig programPathConfig = new ProgramPathConfig(); programPathConfig.setNext(programTypeConfig); LogsConfig logsConfig = new LogsConfig(); logsConfig.setNext(programPathConfig); DateConfig dateConfig = new DateConfig(); dateConfig.setNext(logsConfig); DataBaseConfig dataBaseConfig = new DataBaseConfig(); dataBaseConfig.setNext(dateConfig); ConnectionConfig connectionConfig = new ConnectionConfig(new MsSqlServerController()); connectionConfig.setNext(dataBaseConfig); firstConfigReader = new AvevaConfig(); firstConfigReader.setNext(connectionConfig); }