/// <summary> /// save the config file to the path, after done the operations. /// </summary> /// <returns>true if not error occured in try block.</returns> private bool SaveLog(SyncLog log) { JSONConfigurationManager <SyncLog> logManager = new JSONConfigurationManager <SyncLog>(log); try { logManager.WriteConfig(_path); return(true); } catch (Exception ex) { ExceptionHandling.LogException(ex); return(false); } }
/// <summary> /// force read the file in the path, should return null if not found. /// </summary> /// <returns></returns> private SyncLog FetchLog() { SyncLog log; JSONConfigurationManager <SyncLog> logManager = new JSONConfigurationManager <SyncLog>(); try { log = logManager.ReadConfig(_path); if (log == null) { log = new SyncLog(); } return(log); } catch (Exception ex) { ExceptionHandling.LogException(ex); log = new SyncLog(); return(log); } }
public JsonLogService(string path, int daysToRecover = 30) { _path = path; _log = FetchLog(); }