public void Save() { try { _db.Open(ConnectionStringPrimary, ConnectionStringSecondary); EngineList.ForEach(e => { if (e.IsModified) { if (e.Id == 0) { _db.DbInsertEngine(e); } else { _db.DbUpdateEngine(e); } } }); DeletedEngines.ForEach(s => { if (s.Id > 0) { _db.DbDeleteEngine(s); } }); } finally { _db.Close(); } }
public Engines(string connectionStringPrimary, string connectionStringSecondary) { ConnectionStringPrimary = connectionStringPrimary; ConnectionStringSecondary = connectionStringSecondary; _db = DatabaseProviderLoader.LoadDatabaseProvider(); _db.Open(connectionStringPrimary, connectionStringSecondary); ArchiveDirectories = new ArchiveDirectories(_db); try { _db.Open(); EngineList = _db.DbLoadEngines <Engine>(); Servers = _db.DbLoadServers <CasparServer>(); Servers.ForEach(s => { s.Channels.ForEach(c => c.Owner = s); s.Recorders.ForEach(r => r.Owner = s); }); EngineList.ForEach(e => { e.IsNew = false; e.Servers = Servers; e.ArchiveDirectories = ArchiveDirectories; }); } finally { _db.Close(); } }
public void Save() { EngineList.ForEach(e => { if (e.IsModified) { if (e.Id == 0) { _db.InsertEngine(e); } else { _db.UpdateEngine(e); } } }); DeletedEngines.ForEach(s => { if (s.Id > 0) { _db.DeleteEngine(s); } }); }