public bool ImportData(IEnumerable <Voter> voterData, IEnumerable <Precinct> precinctData) { bool result = false; try { if (Database == null) { Console.WriteLine("null database!"); Database = new VoterListDatabase(this, _dbPrefix); } result = Database.Import(voterData); result &= Database.Import(precinctData); if (!result) { Database.Dispose(); Database = new VoterListDatabase(this, _dbPrefix); } } catch (Exception e) { Console.WriteLine("Exception when loading data: " + e); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="Station"/> class. /// Can I have a new Station that is the manager? /// </summary> /// <param name="ui"> /// A reference to the UI. /// </param> /// <param name="voterDataEncryptionKey"> /// The AsymmetricKey used for encrypting the data at this election venue. /// </param> /// <param name="masterPassword"> /// The master password known only by the election secretary. /// </param> /// <param name="port"> /// The network port the station is communicating over. Defaults to 62000. /// </param> /// <param name="dbPrefix"> /// The prefix of the voter database prefix. Defaults to Voters. /// </param> /// <param name="logPrefix"> /// The prefix of the logging database prefix. Defaults to Log. /// </param> public Station(IDvlUi ui, AsymmetricKey voterDataEncryptionKey, string masterPassword, bool local = false, int port = 62000, string dbPrefix = "Voters", string logPrefix = "Log") : this(ui, local, port, dbPrefix) { Contract.Requires(ui != null); Contract.Requires(masterPassword != null); Contract.Requires(dbPrefix != null); Contract.Requires(logPrefix != null); Crypto = new Crypto(voterDataEncryptionKey); MasterPassword = Crypto.Hash(Bytes.From(masterPassword)); Logger = new Logger(this, logPrefix); Database = new VoterListDatabase(this, _dbPrefix); Manager = Address; Logger.Log("Manager initialized", Level.Info); }