public static void LoadData( ) { logger.Log(Logger.LogType.Event, Logger.LogLevel.Info, "static:DataLayer.LoadData()", "Call"); if (!isInit) { logger.LogException("isInit", new ValueUnavailableException("false")); throw new InvalidOperationException("Init method not called !"); } AppDataFolder.AccessFolder(); try { dailyMeasures.Load(); } catch (Exception ex) { logger.LogException("static,await:dailyMeasures.Load()", ex); MessageBox.Show("Une erreur est survenue lors du chargement des données, contactez le dev."); } if (dailyMeasures.Get() == null) { dailyMeasures.Set(new List <NetworkMeasure>()); } }
public void Lock( ) { AppDataFolder.AccessFolder(); if (!File.Exists(lockFile)) { s = new FileStream(lockFile, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); } }
public void Unlock( ) { if (s != null) { s.Close(); } AppDataFolder.AccessFolder(); if (File.Exists(lockFile)) { File.Delete(lockFile); } }
public void Log(LogType t, LogLevel l, string name, object message = null, [CallerMemberName] string caller = "Unknown", [CallerLineNumber] int line = -1) { AppDataFolder.AccessFolder(); string finalMessage = "None"; finalMessage = message?.ToString(); string final = $"{DateTime.Now.ToString()}\t{l} / {t} [{caller} at {line}], {name.ToUpperInvariant()} : {finalMessage}\n\n"; File.AppendAllText(filePath, final); }
public static void SaveData( ) { logger.Log(Logger.LogType.Event, Logger.LogLevel.Info, "static:DataLayer.SaveData()", "Call"); if (!isInit) { logger.LogException("isInit", new ValueUnavailableException("false")); throw new InvalidOperationException("Init method not called !"); } AppDataFolder.AccessFolder(); try { dailyMeasures.Save(); } catch (Exception ex) { logger.LogException("static,await:dailyMeasures.Save()", ex); MessageBox.Show("Une erreur est survenue lors de la sauvegarde des données, contactez le dev."); } }
public bool Check( ) { AppDataFolder.AccessFolder(); return(!File.Exists(lockFile)); }