Beispiel #1
0
 public void Dispose()
 {
     if (_dispose)
     {
         _db?.Dispose();
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         db?.Dispose();
     }
 }
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                _StoreContext?.Dispose();
            }

            _disposed = true;
        }
Beispiel #4
0
        public void Dispose()
        {
            _context.Database.EnsureDeleted();

            _context.Dispose();
        }
Beispiel #5
0
 protected override void Dispose(bool disposing)
 {
     db.Dispose();
     base.Dispose(disposing);
 }
 public void Dispose()
 {
     StoreDataInitializer.ClearData(new StoreContext());
     _db.Dispose();
 }
 public void Dispose()
 {
     _orderRepository.Dispose();
     _db.Dispose();
 }
 public void Dispose()
 {
     _container?.Dispose();
     GC.SuppressFinalize(this);
 }
Beispiel #9
0
 public void Dispose()
 {
     _db.Dispose();
     _connection.Dispose();
 }
Beispiel #10
0
 public void Dispose()
 {
     StoreDataInitializer.ClearData(_db);
     _db.Dispose();
 }
 public void Dispose()
 {
     CleanDatabase();
     _storeContext.Dispose();
 }
Beispiel #12
0
 public virtual void Dispose()
 {
     Db.Dispose();
 }
 public override void Dispose()
 {
     _db.Dispose();
 }
Beispiel #14
0
 public virtual void Dispose()
 {
     Context.Dispose();
 }
Beispiel #15
0
 public void Dispose()
 {
     db.Dispose();
 }
 public void Dispose()
 {
     CleanDatabase();
     _db.Dispose();
 }
Beispiel #17
0
 protected override void Dispose(bool disposing)
 {
     _context.Dispose();
 }
 public void Dispose()
 {
     _storeContext?.Dispose();
 }
Beispiel #19
0
 public void Dispose()
 {
     StoreContext.Dispose();
 }
Beispiel #20
0
 public void Dispose()
 {
     _context?.Dispose();
 }
Beispiel #21
0
        /// <summary>
        /// Loads and restores main storage
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public Store Load(string target)
        {
            var context = new StoreContext(target);

            var store  = new Store();
            var scales = new Dictionary <int, Scale>();

            foreach (var scaleCfg in context.Scales)
            {
                scales.Add(
                    scaleCfg.Id,
                    new Scale {
                    Name        = scaleCfg.Name,
                    Description = scaleCfg.Description,
                    Units       = scaleCfg.Units,
                    DevMax      = scaleCfg.DevMax,
                    DevMin      = scaleCfg.DevMin,
                    Max         = scaleCfg.Max,
                    Min         = scaleCfg.Min,
                }
                    );
            }


            foreach (var cfg in context.Connections)
            {
                var connectionSource = connectionSerializers[cfg.ClassName].Unpack(cfg);
                store.ConnectionsSources.Add(cfg.Name, connectionSource);
            }

            var storedDeviceToTemplates = context.DeviceToTemplates
                                          .Include(e => e.Device)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Tags)
                                          .ThenInclude((TagCfg e) => e.TagsToTagsGroups)
                                          .ThenInclude((TagsToTagsGroups e) => e.TagsGroupCfg)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Alarms)
                                          .ThenInclude((AlarmCfg e) => e.Category)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Archives)
                                          .ToList();

            var facilityConfigs = context.Facilities.Include(e => e.Devices).ToList();

            foreach (var facilityCfg in facilityConfigs)
            {
                var facility = new Facility
                {
                    AccessName  = facilityCfg.AccessName,
                    Name        = facilityCfg.Name,
                    Description = facilityCfg.Description,
                    Id          = facilityCfg.Id,
                };


                foreach (var deviceCfg in facilityCfg.Devices)
                {
                    var protocolSerializer = protorolSerializers[deviceCfg.ClassName];
                    var device             = protocolSerializer.UnpackDevice(deviceCfg, store);

                    // Обработка шаблона (переделать этот код когда в EF Core будет реализован релейшн many2many)
                    foreach (var deviceToTemplate in storedDeviceToTemplates.Where(e => e.DeviceId == deviceCfg.Id))
                    {
                        var template = deviceToTemplate.Template;
                        // Распакуем тэги
                        foreach (var tagCfg in template.Tags)
                        {
                            var tag = protocolSerializer.UnpackTag(tagCfg);
                            tag.TemplateId = template.Id;
                            if (scales.ContainsKey(tagCfg.ScaleId))
                            {
                                tag.Scale = scales[tagCfg.ScaleId];
                            }

                            // добавим/восстановим/создадим группы тэгов

                            foreach (var tttg in tagCfg.TagsToTagsGroups)
                            {
                                var       tagGroupCfg = tttg.TagsGroupCfg;
                                TagsGroup tagGroup;
                                if (device.Groups.ContainsKey(tagGroupCfg.Name))
                                {
                                    tagGroup = device.Groups[tagGroupCfg.Name];
                                }
                                else
                                {
                                    tagGroup = new TagsGroup
                                    {
                                        Name        = tagGroupCfg.Name,
                                        Description = tagGroupCfg.Description,
                                        Min         = tagGroupCfg.Min,
                                    };
                                    device.Groups.AddByName(tagGroup);
                                }
                                tag.Groups.AddByName(tagGroup);
                            }

                            // добавим тэг в сервис архива
                            if (tagCfg.ArchiveCfg != default)
                            {
                                var tagLogConfig = new TagLogger.TagLogConfig(tag)
                                {
                                    Hyst         = tagCfg.ArchiveCfg.Hyst,
                                    PeriodMaxSec = tagCfg.ArchiveCfg.PeriodMaxSec,
                                    PeriodMinSec = tagCfg.ArchiveCfg.PeriodMinSec,
                                    TagLogInfo   = new TagLogger.Entities.TagLogInfo
                                    {
                                        DeviceName         = deviceCfg.Name,
                                        FacilityAccessName = facilityCfg.AccessName,
                                        TagName            = tagCfg.Name,
                                    }
                                };

                                store.TagLogService.Configs.Add(tagLogConfig);
                            }

                            device.Tags.AddByName(tag);
                        }

                        // Распакуем алармы
                        foreach (var alarmCfg in template.Alarms)
                        {
                            var alarmInfo = new AlarmLogger.Entities.AlarmInfo
                            {
                                Category           = alarmCfg.Category,
                                Name               = alarmCfg.Name,
                                Condition          = alarmCfg.Condition,
                                Description        = alarmCfg.Description,
                                DeviceName         = device.Name,
                                FacilityAccessName = facility.AccessName,
                                TemplateTxt        = alarmCfg.TemplateTxt,
                            };
                            var alarmConfig = AlarmLogger.AlarmConfig.From(alarmCfg, device.Tags.Values, alarmInfo);
                            store.AlarmService.Configs.Add(alarmConfig);
                        }
                    }

                    facility.Devices.AddByName(device);
                }

                store.Facilities.Add(facility.AccessName, facility);
            }
            context.Dispose();
            context = null;
            return(store);
        } // Load();