Exemple #1
0
 public void Add(HistoryDbModel model)
 {
     lock (_lockObj)
     {
         using (var context = new ScadaDbContext())
         {
             context.History.Add(model);
             context.SaveChanges();
         }
     }
 }
Exemple #2
0
        public static HistoryDbModel ToHistoryDbModel(this DiscretePoint point)
        {
            var model = new HistoryDbModel();

            model.ClassType       = point.ClassType;
            model.Index           = point.Index;
            model.MeasurementType = Enum.GetName(typeof(MeasurementType), point.MeasurementType);
            model.Mrid            = point.Mrid;
            model.RegisterType    = point.RegisterType;
            model.TimeStamp       = point.TimeStamp;
            model.Value           = point.Value;
            return(model);
        }
Exemple #3
0
        public async System.Threading.Tasks.Task SaveAsync(string content, string id, string userId, CheckPointType checkPointType)
        {
            var history = await _historyService.GetHistoryAsync(id);

            var jsonDiffPatch = new JsonDiffPatch();
            var left          = JToken.Parse("{}");

            if (history == null)
            {
                history = new HistoryDbModel()
                {
                    CheckPoints = new List <CheckPoint>(),
                    ElementId   = id,
                };
            }
            else
            {
                foreach (var checkpoint in history.CheckPoints)
                {
                    var patch = JToken.Parse(checkpoint.Patch);
                    left = jsonDiffPatch.Patch(left, patch);
                }
            }

            var checkPoint = new CheckPoint()
            {
                Id             = Guid.NewGuid().ToString(),
                UserId         = userId,
                CheckPointType = checkPointType,
                Hash           = Hash(content)
            };

            var lastRight = JToken.Parse(content);

            checkPoint.Patch = jsonDiffPatch.Diff(left, lastRight).ToString();
            await _historyService.AddAsync(id, checkPoint);
        }
 public void Add(HistoryDbModel model)
 {
     historyRepository.Add(model);
 }
 public void Add(HistoryDbModel model)
 {
     _context.History.Add(model);
     _context.SaveChanges();
 }
 public async Task Add(HistoryDbModel model)
 {
     ServiceEventSource.Current.ServiceMessage(_context, "HistoryService - Add");
     await Task.Factory.StartNew(() => _repo.Add(model));
 }
 public void Add(HistoryDbModel model)
 {
     proxy.Add(model);
 }
Exemple #8
0
 public async Task Add(HistoryDbModel model)
 {
     var client = BuildClient();
     await client.InvokeWithRetryAsync(x => x.Channel.Add(model));
 }