//[ExpectedException(typeof(RawConnException), "Aucune Erreur reçue", AllowDerivedTypes = true)] public void TestAdd() { SecuredConnector sc = new SecuredConnector(); Assert.IsNotNull(sc); SysInfo info = new SysInfo(); info.Environment = Environment.OSVersion.VersionString; var data = RedX.Diagnostics.Client.SystemDiagnostics.SystemInfo(); info.PercentageCPU = data[0]; info.PercentageRAM = data[1]; info.Date = DateTime.Now; Assert.IsFalse(sc.Add(info)); }
private void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { try{ ThreadPool.QueueUserWorkItem( delegate { var data = SystemDiagnostics.SystemInfo(); lastData.PercentageCPU = data[0]; lastData.PercentageRAM = data[1]; lastData.Date = DateTime.Now; try { sc.Add(lastData); } catch (RawConnException e) { if (e.Gravity <= ExceptionGravity.MEDIUM) { wLog.WriteIntoFile("Une erreur pouvant entrainer l'instabilité du système à été détectée, arrêt de l'ajout."); return; } else { wLog.WriteIntoFile("Une erreur sans incidence à été reportée."); } } wLog.WriteIntoFile("--------- Dernière donnée sauvegardée "); wLog.WriteIntoFile("OS: " + lastData.Environment + " at " + lastData.Date.ToString() + " : CPU at " + lastData.PercentageCPU + "%, RAM at " + lastData.PercentageRAM + "%. "); } ); } catch (Exception e) { wLog.WriteIntoFile("Exception Caught:"); wLog.WriteIntoFile(e.Message + ":" + e.StackTrace); this.Stop(); } }