示例#1
0
        /// <summary>
        /// Fetch data from the db based on the current filter.
        /// </summary>
        public void FetchData()
        {
            pDAO = new PollingStationDAO(DigitalVoterList.GetDefaultInstance());
            mDAO = new MunicipalityDAO(DigitalVoterList.GetDefaultInstance());
            vDAO = new VoterDAO(DigitalVoterList.GetDefaultInstance());

            VoterFilter f = this.Filter;

            if (f.CPRNO != 0)
            {
                this.Voters = vDAO.Read(v => v.PrimaryKey == f.CPRNO);
                VoterDO voter = this.Voters.First();
                this.PollingStations = pDAO.Read(ps => ps.PrimaryKey == voter.PollingStationId);
                PollingStationDO pollingStation = this.PollingStations.First();
                this.Municipalities = mDAO.Read(m => m.PrimaryKey == pollingStation.MunicipalityId);
            }
            else if (f.PollingStation != null)
            {
                this.PollingStations = pDAO.Read(ps => ps.PrimaryKey == f.PollingStation.PrimaryKey);
                this.Voters = vDAO.Read(v => v.PollingStationId == f.PollingStation.PrimaryKey);
                this.Municipalities = mDAO.Read(m => m.PrimaryKey == f.PollingStation.MunicipalityId);
            }
            else if (f.Municipality != null)
            {
                this.Municipalities = mDAO.Read(m => m.PrimaryKey == f.Municipality.PrimaryKey);
                this.PollingStations = pDAO.Read(p => p.MunicipalityId == f.Municipality.PrimaryKey);

                this.Voters = Enumerable.Empty<VoterDO>();
                foreach (var ps in this.PollingStations)
                {
                    PollingStationDO ps1 = ps;
                    this.Voters = this.Voters.Concat(vDAO.Read(v => v.PollingStationId == ps1.PrimaryKey));
                }
            }
        }
示例#2
0
        public void Setup()
        {
            var connection = new MySqlConnection(
                "server=localhost;" + "port=3306;" + "uid=groupCJN;" + "password=abc123;" + "Sql Server Mode=true;"
                + "database=groupcjn;");

            var creator = new DBCreator(connection);

            var generator = new Generator(DigitalVoterList.GetDefaultInstance());

            generator.Generate(10, 100, 5000);
        }
示例#3
0
        public void Setup()
        {
            this.daos = new List <PessimisticVoterDAO>();

            var connection = new MySqlConnection(
                "server=localhost;" + "port=3306;" + "uid=groupCJN;" + "password=abc123;" + "Sql Server Mode=true;"
                + "database=groupcjn;");

            var creator = new DBCreator(connection);

            var generator = new Generator(DigitalVoterList.GetDefaultInstance());

            generator.Generate(1, 1, 3);

            VoterDAO voterDAO = new VoterDAO();

            this.voters = voterDAO.Read(v => true);
        }
示例#4
0
        /// <summary> Initializes a new instance of the <see cref="VoterSelection"/> class with proper values for the default selection. </summary>
        public VoterSelection()
        {
            pDAO = new PollingStationDAO(DigitalVoterList.GetDefaultInstance());
            mDAO = new MunicipalityDAO(DigitalVoterList.GetDefaultInstance());
            vDAO = new VoterDAO(DigitalVoterList.GetDefaultInstance());

            // Call database to get initial values (no selection, ie. entire DB)
            try
            {
                Municipalities  = mDAO.Read(o => true);
                PollingStations = pDAO.Read(o => true);
                voterCount      = vDAO.Read(o => true).Count();
                currentFilter   = null;
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(
                    string.Format("The system was not able to connect to the server. The system said: {0}", e.Message));
                Environment.Exit(-1);
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractDataAccessObject{T}"/> class,
 /// connects to the default instance.
 /// </summary>
 protected AbstractDataAccessObject()
 {
     this.db = DigitalVoterList.GetDefaultInstance();
 }