Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
 public JsonLogService(string path, int daysToRecover = 30)
 {
     _path = path;
     _log  = FetchLog();
 }