Beispiel #1
0
        public void AddOrUpdateRange(List <DomDbModel> list)
        {
            lock (_lockObject)
            {
                using (var context = new ScadaDbContext())
                {
                    foreach (var model in list)
                    {
                        DomDbModel m = context.Dom.FirstOrDefault(d => !String.IsNullOrEmpty(d.Mrid) && d.Mrid == model.Mrid);

                        if (m == null)
                        {
                            context.Dom.Add(model);
                        }
                        else
                        {
                            m.ManipulationConut++;
                            m.TimeStamp            = DateTime.Now.ToString();
                            context.Entry(m).State = System.Data.Entity.EntityState.Modified;
                        }
                    }
                    context.SaveChanges();
                }
            }
        }
Beispiel #2
0
        public void AddOrUpdate(DomDbModel model)
        {
            DomDbModel m = _context.Dom.FirstOrDefault(d => d.Mrid == model.Mrid);

            if (m == null)
            {
                _context.Dom.Add(model);
            }
            else
            {
                m.ManipulationConut++;
                m.TimeStamp             = DateTime.Now.ToString();
                _context.Entry(m).State = System.Data.Entity.EntityState.Modified;
            }

            _context.SaveChanges();
        }
Beispiel #3
0
        public void UpdateSingle(DomDbModel model)
        {
            lock (_lockObject)
            {
                using (var context = new ScadaDbContext())
                {
                    DomDbModel m = context.Dom.FirstOrDefault(d => !String.IsNullOrEmpty(d.Mrid) && d.Mrid == model.Mrid);

                    if (m != null)
                    {
                        m.ManipulationConut++;
                        m.TimeStamp            = DateTime.Now.ToString();
                        context.Entry(m).State = System.Data.Entity.EntityState.Modified;
                    }


                    context.SaveChanges();
                }
            }
        }