public DataRecord(DataCollectorContext context, string value, DateTimeOffset timestamp) { DCContext = context; Value = value; Timestamp = timestamp; D = DataFactory.Create(context, value); }
public ActionResult Liste() { using (var ctx = new DataCollectorContext()) { var liste = ctx.Enquete.ToList(); return(View(liste)); } }
public Data AsData(DataCollectorContext context) { DictionaryData d = new DictionaryData(context); d.Data["Message"] = Message; d.Data["TimeGenerated"] = TimeGeneratedAsDateTimeOffset.ToString("o"); d.Data["Source"] = SourceName; d.Data["RecordNumber"] = RecordNumber.ToString(); d.Data["EventCode"] = EventCode.ToString(); return(d); }
public DataRecord(DataCollectorContext context, Data d) { DCContext = context; Value = JsonConvert.SerializeObject(d, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml }); Timestamp = d.CollectedAt; D = d; }
public static Data Create(DataCollectorContext context, string value) { DictionaryData d = new DictionaryData(context); var definition = new { Value = new Dictionary <string, string>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d.Data = data.Value; } return(d); }
public static Data Create(DataCollectorContext context, string value) { ListData <ApplicationInfo> d = new ListData <ApplicationInfo>(context); var definition = new { Value = new List <ApplicationInfo>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d.Data.AddRange(data.Value); } return(d); }
public GISFeatureBL(DataCollectorContext context, ClassesBL classesBL, FieldsBL fieldsBl, DomainBL domainBl, string gdbConnection) { _DbContext = context; _GdbConnection = gdbConnection; _ClassesBL = classesBL; _FieldsBl = fieldsBl; _DomainBL = domainBl; }
public static Data Create(DataCollectorContext context, string value) { ListStringData d = new ListStringData(context, ListStringData.Options.IgnoreCase | ListStringData.Options.KeepSorted | ListStringData.Options.NoDuplicates); var definition = new { Value = new List <string>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d.Data.AddRange(data.Value); } return(d); }
public static Data Create(DataCollectorContext context, string value) { GenericDictionaryData <Process> d = new GenericDictionaryData <Process>(context); ProcessInfoBuilder builder = new ProcessInfoBuilder(); builder.Build(value); if (builder.Processes != null) { d.Data = builder.Processes; } return(d); }
public ActionResult Create(DataCollectorApp.Models.Enquete mClass) { //if (ModelState.IsValid) //{ using (var ctx = new DataCollectorContext()) { mClass.enCibleEnqueteID = 1; ctx.Enquete.Add(mClass); ctx.SaveChanges(); } //} return(RedirectToAction("Liste")); }
public static Data Create(DataCollectorContext context, string value) { Data d = null; var definition = new { Value = new Dictionary <string, DiskUsage>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d = new GenericDictionaryData <DiskUsage>(context) { Data = data.Value } } ; return(d); } }
public static Data Create(DataCollectorContext context, string value) { Data d = null; var definition = new { Value = string.Empty }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d = new Data(context) { Value = data.Value } } ; return(d); } }
private static void SaveConfiguration(SystemConfiguration config, Database db) { int system_configuration_id = -1; string sql = "SELECT CollectorID FROM Collectors WHERE Name = 'System.Configuration' AND IsEnabled = 1;"; try { using (SQLiteConnection conn = db.Connection) { conn.Open(); using (SQLiteCommand command = new SQLiteCommand(sql, conn)) using (SQLiteDataReader reader = command.ExecuteReader()) { if (reader.Read()) { system_configuration_id = reader.GetInt32(0); } } } } catch (Exception ex) { ILog log = LogManager.GetLogger(typeof(SystemConfigurationStore)); log.Error("Initialize: " + sql); log.Error(ex); } if (system_configuration_id > 0) { DataCollectorContext dcc = new DataCollectorContext(new CollectorID(system_configuration_id, "System.Configuration"), ECollectorType.Configuration); Data d = new Data(dcc) { Value = JsonConvert.SerializeObject(config), }; DataStorage ds = new DataStorage(); ds.SaveData(new CollectedData(dcc, true, d), db); } else { ILog log = LogManager.GetLogger(typeof(SystemConfigurationStore)); log.Error("Error obtaining ID for System.Configuration collector"); } }
void LookLikeTheOldStructure() { // We used to just put a Dictionary<string, string> in there, but for better OO principles I changed it to an // object. Unfortunately, I broke it when I did that so it stored an array of the objects and it didn't deserialize // properly any more. Let's make sure when a Data object with the new object is used that it matches the old format. string old_format = "{\"Value\":{\"Memory Capacity\":\"17098178560\",\"Free Memory\":\"15014670336\",\"Memory Used\":\"2083508224\"}}"; DataCollectorContext context = new DataCollectorContext(new CollectorID(-1, "Memory"), ECollectorType.Memory); MemoryUsage usage = new MemoryUsage() { CapacityNum = 17098178560, FreeNum = 15014670336 }; Data d = new GenericData <MemoryUsage>(context, usage); string new_format = JsonConvert.SerializeObject(d, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml }); Assert.Equal(old_format, new_format); }
public DateTimeCollector(WMIContext wmi_context, DataCollectorContext dc_context) : base(wmi_context, dc_context) { }
public UpdateLogBL(DataCollectorContext context) { _DbContext = context; }
/// <summary> /// Used to store a chunk of collected Data. Determines which Collector collected /// the data based on d.Name, then inserts it into the Data table, and updates /// the MostRecentDataPerCollector table. It then sends the Data off to each /// of the interpreters so they can interpret the new data however they wish. /// </summary> /// <param name="data">A collection of Data objects to store in the DB</param> /// <param name="db">The database to store the data in</param> /// <returns></returns> public bool SaveData(CollectedData data, Database db) { if (data == null) { return(false); } bool success = false; ILog log = LogManager.GetLogger(typeof(DataStorage)); //ApplicationEventLog elog = new ApplicationEventLog(); try { //string msg = $"SaveData -- data is collected: {data.DataIsCollected}, with {data.D.Count} items"; //log.Debug(msg); //elog.LogInformation(msg); // Record the last time a collection attempt was made for this collector, regardless of whether // it was successfully collected. If it wasn't collected, we'll bail out shortly. if (data.Context.ID.ID >= 0) { using (SQLiteConnection conn = db.Connection) { conn.Open(); Updater updater = new Updater("Collectors", $"CollectorID = {data.Context.ID.ID}", conn); if (data.DataIsCollected) { updater.Set("LastCollectedAt", DateTimeOffset.Now); } updater.Set("SuccessfullyCollected", data.DataIsCollected); updater.Execute(); } } if (data.DataIsCollected == false) { return(true); } Stopwatch watch = Stopwatch.StartNew(); List <DataRecord> to_insert = new List <DataRecord>(); foreach (Data d in data.D) { try { DataCollectorContext dc_context = d.Context; if (dc_context.ID.ID >= 0) { DataRecord dr = new DataRecord(dc_context, d); to_insert.Add(dr); } else { log.Error($"Unknown Data ({d.ID}, {d.Name})"); } } catch (Exception e) { log.Error("SaveData[A]: "); log.Error(e); } } success = Insert(to_insert, db); log.Debug($"Total insertion took {watch.ElapsedMilliseconds} ms"); } catch (Exception e) { log.Error("SaveData[B]: "); log.Error(e); } return(success); }
public SettingBL(DataCollectorContext context, Cryptor cryptor, string gdbConnection) { _DbContext = context; _GdbConnection = gdbConnection; _Cryptor = cryptor; }
public ClassesBL(DataCollectorContext context, string gdbConnection) { _DbContext = context; _GdbConnection = gdbConnection; }
public SummedData(WMIContext wmi_context, DataCollectorContext dc_context) : base(wmi_context, dc_context) { }
public UserLocationBL(DataCollectorContext context) { _DbContext = context; }
public UniqueStyleBL(DataCollectorContext context, ClassesBL classesBl) { _DbContext = context; _ClassesBl = classesBl; }
public MultiPropertyWMIDataCollector(WMIContext wmi_context, DataCollectorContext dc_context) : base(wmi_context, dc_context) { }
public FeaturePicBL(DataCollectorContext context, UpdateLogBL updateLogBL) { _DbContext = context; _UpdateLogBL = updateLogBL; }
public DomainBL(DataCollectorContext context) { _DbContext = context; }
public WMIDataCollector(WMIContext wmi_context, DataCollectorContext dc_context) : base(dc_context) { WmiContext = wmi_context; RetrieverOptions = new WMIRetrieverOptions(); }
public AverageData(WMIContext wmi_context, DataCollectorContext dc_context) : base(wmi_context, dc_context) { }
public FieldsBL(DataCollectorContext context, ClassesBL classesBl) { _DbContext = context; _ClassesBl = classesBl; }
public LoggService(DataCollectorContext context) { _Context = context; }
public ListWMIDataCollector(WMIContext wmi_context, DataCollectorContext dc_context, ListStringData.Options options) : base(wmi_context, dc_context) { m_options = options; }