예제 #1
0
        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>());
            }
        }
예제 #2
0
 public void Lock( )
 {
     AppDataFolder.AccessFolder();
     if (!File.Exists(lockFile))
     {
         s = new FileStream(lockFile, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
     }
 }
예제 #3
0
 public void Unlock( )
 {
     if (s != null)
     {
         s.Close();
     }
     AppDataFolder.AccessFolder();
     if (File.Exists(lockFile))
     {
         File.Delete(lockFile);
     }
 }
예제 #4
0
파일: Logger.cs 프로젝트: lamarch/WpfData
        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);
        }
예제 #5
0
        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.");
            }
        }
예제 #6
0
 public bool Check( )
 {
     AppDataFolder.AccessFolder();
     return(!File.Exists(lockFile));
 }