/// <summary> /// Loads the election parameters /// </summary> /// <param name="strConnection">The STR connection.</param> /// <param name="machineAssignmentId">The machine assignment id.</param> /// <externalUnit/> /// <revision revisor="dev16" date="1/11/2009" version="1.0.0.0"> /// Member Created /// </revision> private void LoadElecParams( string strConnection, int machineAssignmentId) { BallotEntrySet elecParam = new BallotEntrySet(typeof(StpElecParam)); // pass in the machineAssignmentId to the proc if we got one if (machineAssignmentId != 0) { elecParam.Load(strConnection, machineAssignmentId); } else { elecParam.Load(strConnection); } for (int i = 0; i < elecParam.Count; i = i + 1) { ElectionParameter parameter = new ElectionParameter(); parameter.Name = elecParam.GetValueStr( i, StpElecParam.ParamName); parameter.Value = elecParam.GetValueStr( i, StpElecParam.ParamValue); this.electionParameters.Add(parameter); } }
/// <summary> /// Loads the machine options /// </summary> /// <param name="strConnection">The STR connection.</param> /// <externalUnit/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> private void LoadMachOptn(string strConnection) { BallotEntrySet machOptn = new BallotEntrySet(typeof(StpMachOptn)); machOptn.Load(strConnection); for (int i = 0; i < machOptn.Count; i = i + 1) { MachineOption option = new MachineOption(); option.Name = machOptn.GetValueStr(i, StpMachOptn.OptionName); option.Value = machOptn.GetValueStr(i, StpMachOptn.OptionValue); this.machineOptions.Add(option); } }
/// <summary> /// Initializes a new instance of the <see cref="PaperBallotRichTextTemplate"/> class. /// </summary> /// <param name="parameters">The pdf layout parameters.</param> /// <externalUnit/> /// <revision revisor="dev11" date="4/11/2009" version="1.0.11.0201"> /// Member Created /// </revision> public PaperBallotRichTextTemplate(BallotEntrySet parameters) { try { int idx = parameters.FindIndex( StpParam.PDFLayoutParamId, Convert.ToInt32(PdfParam.DataFolder)); string txmlFullPath = Path.Combine( parameters.GetValueStr(idx, StpParam.ParamValue), FileName); // load the xml (TXML) from the file as plain text since this // is what AquaPDF's engine uses StreamReader reader = new StreamReader(txmlFullPath); this.txml = reader.ReadToEnd(); reader.Close(); // parse the file simply to verify it is well-formed XML. No // TXML-specific tests are done here on the XML // X mlDocument xmlDocument = new XmlDocument(); // x mlDocument.LoadXml(txml); // no exception thrown means that the XML is valid and loaded this.isValidXml = true; } catch { // drop any loaded text this.txml = null; // set the flag to false this.isValidXml = false; } }
/// <summary> /// Initializes a new instance of the <see cref="PaperBallotElectionInfo"/> class. /// </summary> /// <externalUnit/> /// <revision revisor="dev11" date="4/2/2009" version="1.0.9.1701"> /// Member Created /// </revision> public PaperBallotElectionInfo(string strConnection) { BallotEntrySet entrySet = new BallotEntrySet(typeof(StpElecParam)); entrySet.Load(strConnection, DefaultMachineId); int idx = entrySet.FindIndex( StpElecParam.ParamName, ParamElectionName); if (idx >= 0) { this.electionName = entrySet.GetValueStr( idx, StpElecParam.ParamValue); } else { // no election name found, use empty string this.electionName = string.Empty; } idx = entrySet.FindIndex(StpElecParam.ParamName, ParamElectionDate); try { this.electionDate = entrySet.GetValueDate( idx, StpElecParam.ParamValue); } catch { // do nothing and let election date be null } }
/// <summary> /// Loads from db. /// </summary> /// <param name="contests">The contests.</param> /// <param name="index">The index.</param> /// <param name="defFont">The def font.</param> /// <param name="defSize">Size of the def.</param> /// <returns> /// An <see cref="OfficeText" /> from the database. /// </returns> /// <externalUnit cref="BallotEntrySet"/> /// <externalUnit cref="OfficeText"/> /// <externalUnit cref="StpCont"/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> public static OfficeText LoadFromDb( BallotEntrySet contests, int index, string defFont, double defSize) { string text = contests.GetValueStr(index, StpCont.DisplayText); return(new OfficeText(text, defFont, defSize)); }
/// <summary> /// Loads a candidate from the DB using supplied entry sets /// </summary> /// <param name="ballots">The ballots.</param> /// <param name="candidates">The candidates.</param> /// <param name="id">The candidate id.</param> /// <param name="ballotId">The ballot id.</param> /// <returns> /// A <see cref="Candidate" /> from the database. /// </returns> /// <externalUnit cref="BallotEntrySet"/> /// <externalUnit cref="BreakType"/> /// <externalUnit cref="Candidate"/> /// <externalUnit cref="StpBallot"/> /// <externalUnit cref="StpCand"/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> /// <revision revisor="dev11" date="04/14/2009" version="1.0.11.0401"> /// added ballot style id /// </revision> public static Candidate LoadFromDb( BallotEntrySet ballots, BallotEntrySet candidates, int id, int ballotId) { int idxBal = ballots.FindIndex( StpBallot.BallotStyleId, ballotId, StpBallot.CandidateId, id), idxCnd = candidates.FindIndex(StpCand.CandidateId, id), maskCnd = ballots.GetValueInt(idxBal, StpBallot.CandDispFormat), intBreak = (int)BreakType.Column; string name = candidates.GetValueStr( idxCnd, StpCand.CandidateDisplayName); Candidate cand = new Candidate( id, name, (maskCnd & VotedFlag) == VotedFlag, (maskCnd & intBreak) == intBreak); cand.Type = (CandidateType)Enum.ToObject( typeof(CandidateType), candidates.GetValueInt( idxCnd, StpCand.CandidateType)); return(cand); }
/// <summary> /// Loads the machine parameters /// </summary> /// <param name="strConnection">The STR connection.</param> /// <externalUnit/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> private void LoadMachParams(string strConnection) { BallotEntrySet machParm = new BallotEntrySet(typeof(StpMachParm)); machParm.Load(strConnection); for (int i = 0; i < machParm.Count; i = i + 1) { ParameterFile file = new ParameterFile(); file.Name = machParm.GetValueStr(i, StpMachParm.ParamName); this.machineParams.ParameterFiles.Add(file); } }
/// <summary> /// Loads the contest list. /// </summary> /// <param name="contList">Contest List</param> /// <param name="candList">Candidate List</param> /// <externalUnit cref="BallotEntrySet"/> /// <externalUnit cref="contests"/> /// <externalUnit cref="DomainObjects.Contest"/> /// <externalUnit cref="GetContest"/> /// <externalUnit cref="StpCandList"/> /// <externalUnit cref="StpContList"/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> /// <revision revisor="dev11" date="04/14/2009" version="1.0.11.0401"> /// each candidate is added now only once. This assumes obviously /// that each contest appearance has the exact same candidates /// </revision> private void LoadContList( BallotEntrySet contList, BallotEntrySet candList) { // B allotEntrySet candList = new BallotEntrySet(typeof (StpCandList)), // contList = new BallotEntrySet(typeof (StpContList)); Dictionary <int, DomainObjects.Contest> contMap = new Dictionary <int, DomainObjects.Contest>(); List <int> candidateIds = new List <int>(); DomainObjects.Contest cont; int contId, candId; // for every candidate, find the corresponding contest for (int i = 0; i < candList.Count; i = i + 1) { contId = candList.GetValueInt(i, StpCandList.ContestId); if (contMap.ContainsKey(contId) == false) { // this contest has not been created yet, so create an // instance for it, add it to the map for easy access and // to the contest collection cont = this.GetContest(contList, contId); contMap.Add(contId, cont); this.contests.Add(cont); } else { // get the contest from the map cont = contMap[contId]; } candId = candList.GetValueInt(i, StpCandList.CandidateId); if (candidateIds.Contains(candId) == false) { DomainObjects.Candidate cand = new DomainObjects.Candidate(); cand.Id = candId; cand.Name = candList.GetValueStr( i, StpCandList.CandidateDisplayName); cand.BallotStatusId = candList.GetValueInt( i, StpCandList.BallotStatusId); cand.CandidateType = candList.GetValueInt( i, StpCandList.CandidateType); cand.PartyId = candList.GetValueInt(i, StpCandList.PartyId); cont.Candidates.Add(cand); candidateIds.Add(candId); } } }
/// <summary> /// Creates a new instance of Contest from the entry set of contests /// using a supplied contest id. /// </summary> /// <param name="contList">The contest entry set.</param> /// <param name="contId">The contest id.</param> /// <returns>The Contest</returns> /// <externalUnit cref="BallotEntrySet"/> /// <externalUnit cref="DomainObjects.Contest"/> /// <externalUnit cref="StpContList"/> /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0"> /// Member Created /// </revision> /// <revision revisor="dev01" date="11/16/2009" version="1.1.3.4"> /// Changed party assigment /// </revision> private DomainObjects.Contest GetContest( BallotEntrySet contList, int contId) { int idx = contList.FindIndex(StpContList.ContestId, contId); DomainObjects.Contest contest = new DomainObjects.Contest(); contest.Id = contId; contest.Name = contList.GetValueStr(idx, StpContList.ContestName); contest.VoteFor = contList.GetValueInt(idx, StpContList.VoteFor); contest.BallotStatusId = contList.GetValueInt( idx, StpContList.BallotStatusId); contest.ContestType = contList.GetValueInt( idx, StpContList.ContestType); contest.ListOrder = contList.GetValueInt(idx, StpContList.ListOrder); contest.Party = new Party( contList.GetValueInt(idx, StpContList.PartyId), string.Empty, string.Empty, 0, false); return(contest); }