internal bool OpenDatabase() { try { SupervisorData tmpDB; if (File.Exists(DatabaseName)) { Log.WriteEntry(TraceEventType.Verbose, "Database existente"); tmpDB = DeSerializarDeDisco(DatabaseName); } else { Log.WriteEntry(TraceEventType.Verbose, "Database creada"); tmpDB = new SupervisorData(); SerializarADisco(tmpDB, DatabaseName); } _dbRoot = tmpDB; return(true); } catch (Exception ex) { Log.WriteEntry(ClassName, "OpenDatabase", TraceEventType.Error, ex.Message); return(false); } }
// Emplea funcionalidad del componente AppUtils private void SerializarADisco(SupervisorData obj, string file) { if (obj == null) { Log.WriteEntry(ClassName, "SerializarADisco", TraceEventType.Warning, "Objeto a serializar es Null"); return; } try { Serializer.Serialize <SupervisorData>(obj, file); } catch (Exception ex) { Log.WriteEntry(ClassName, "SerializarADisco", TraceEventType.Error, ex.Message); throw; } }
// Constructor public SendSupervisorData(SupervisorData data) { Data = data; }