public void SaveHisto(long modId, string signalName, string value, DateTime dt) { try { lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { HistoriansTable signalRecord = new HistoriansTable(); if (signalRecord == null) { return; } signalRecord.configID = modId; signalRecord.dt_update = dt; signalRecord.signalName = signalName; signalRecord.value = value; localDbContext.Histo.Add(signalRecord); localDbContext.SaveChanges(); logger.Debug("insert histo " + value + " for mod" + modId); } } } catch (Exception ex) { logger.Error(ex, "", null); throw; } }
protected void DataProcessed(object sender, ProcessedDataEventArgs args) { //lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { localDbContext.ArchiveMailboxMsg(args.Mbx, args.Comment); } } }
public string GetHWParameters(string name) { //lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { var hw = localDbContext.Hardware.FirstOrDefault(x => x.name == name); return(hw.parameters); } } }
public void RaiseEvent(long exprId, string eventmsg) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { var nots = localDbContext.Notifiers.Where(m => m.exprID == exprId).Include(u => u.userId); foreach (NotifiersTable not in nots) { SendMail(not.user.Email, eventmsg.Substring(0, 15) + "...", eventmsg); } } }
public string GetValue(long modId, string signalName) { lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { ValuesTable signalRecord = localDbContext.Values.FirstOrDefault(m => m.configID == modId && m.signalName == signalName); if (signalRecord == null) { return(null); } return(signalRecord.value); } } }
protected MailboxTable DataSubmitted(object sender, SubmitDataEventArgs args) { //lock (_lockObject) { if (!writeCounter.ContainsKey(args.Category)) //ajoute au dictionnaire des compteurs d'écriture { writeCounter.Add(args.Category, 0); } writeCounter[args.Category]++; using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { return(localDbContext.AddToMailbox(DateTime.Now, args.Category, args.Direction, args.Message)); } } }
protected List <MailboxTable> DataRequested(object sender, RequestDataEventArgs args) { //lock (_lockObject) { if (!readCounter.ContainsKey(args.Category)) { readCounter.Add(args.Category, 0); } readCounter[args.Category]++; using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { return(localDbContext.PeekMailbox(args.Category, args.Direction)); } } }
public void SaveValue(long modId, string signalName, string value) { try { lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { bool bCreated = false; List <ValuesTable> signalRecords = localDbContext.Values.Where(m => m.configID == modId && m.signalName == signalName).ToList(); ValuesTable signalRecord; if (signalRecords.Count == 0) //ligne non trouvée { signalRecord = new ValuesTable(); signalRecord.configID = modId; signalRecord.signalName = signalName; bCreated = true; } else { signalRecord = signalRecords.FirstOrDefault(); } signalRecord.dt_update = DateTime.Now; if (signalRecord.value != value) { signalRecord.dt_changed = DateTime.Now; } signalRecord.value = value; if (bCreated) { localDbContext.Values.Add(signalRecord); } else { localDbContext.Values.Update(signalRecord); } localDbContext.SaveChanges(); logger.Debug("update value " + value + " for mod" + modId); } } } catch (Exception ex) { logger.Error(ex, "", null); throw; } }
public void SetHWStatus(string name, int status) { //lock (_lockObject) { using (DominoDbContext localDbContext = new DominoDbContext(config.GetConnectionString("DefaultConnection"))) { var hw = localDbContext.Hardware.FirstOrDefault(x => x.name == name); if (hw == null) { hw = new HardwareTable(); hw.name = name; hw.enabled = 1; } hw.status = status; localDbContext.SaveChanges(); } } }
// private readonly IRepository<Person> _personRepository; public PersonService(DominoDbContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }