public int GetAboveCandidateVotesCount(Election election) { if (!election.NoneAboveExists) return 0; var key = new VoteKey { ElectionNum = election.ElectionId, CandidateId = election.NoneAboveCandidate.Id }; return VotesCount(key); }
public NextActivityKey MoveNextElection( WorkflowExecutionContext context, ActivityParameterDictionary parameters) { if (++CurrentElectionIndex < _electionManager.SourceData.Elections.Length) { _currentElection = _electionManager.SourceData.Elections[CurrentElectionIndex]; _currentBlankId = _electionManager.SourceData.GetBlankIdByElectionNumber(_currentElection.ElectionId); return BpcNextActivityKeys.Yes; } else return BpcNextActivityKeys.No; }
protected override void Initialize(WorkflowExecutionContext context) { base.Initialize(context); if (!context.Restoring) { CurrentElectionIndex = -1; } else if (0 <= CurrentElectionIndex && CurrentElectionIndex < _electionManager.SourceData.Elections.Length) { _currentElection = _electionManager.SourceData.Elections[CurrentElectionIndex]; _currentBlankId = _electionManager.SourceData.GetBlankIdByElectionNumber(_currentElection.ElectionId); } }
public void BindAutoLinesAndChecksCountMethods(Election oElection) { if (_protocolLinesAssembly == null) { _protocolLinesAssembly = CompileAutoLinesAndChecksAssembly(); } foreach (Line oLine in oElection.Protocol.Lines) { oLine.BindMethod(_protocolLinesAssembly); } foreach (CheckExpression oCheck in oElection.Protocol.Checks) { oCheck.BindMethod(_protocolLinesAssembly); } }
public int GetElectionIndex(Election election) { if (election == null) { return(-1); } for (var i = 0; i < Elections.Length; ++i) { if (string.CompareOrdinal(Elections[i].ElectionId, election.ElectionId) == 0) { return(i); } } return(-1); }
public void SetElection(Election election) { _electionLink = election; }
private List<BasePlainElement> CreateProtocolBodyTable( ProtocolText protocolTemplate, Election election, bool final, bool printResults) { int lineNumber = election.Protocol.GetLatestLineNumber(final); string disabled = election.Protocol.DisabledString; bool showDisabled = !string.IsNullOrEmpty(disabled); bool delimiter = false; var table = new List<BasePlainElement>(); foreach (var voteLine in protocolTemplate.VoteLines) { var mask = new VoteKey { ElectionNum = election.ElectionId }; switch (voteLine.Type) { case VoteLineType.Vote: foreach (Candidate currentCand in election.Candidates) { if ((currentCand.Id == voteLine.ID) && (!currentCand.Disabled || showDisabled)) { lineNumber++; mask.CandidateId = currentCand.Id; int votesCount = _votingResultManager.VotingResults.VotesCount(mask); table.Add(new LineClause( new[] { lineNumber.ToString(), currentCand.GetInitials(!currentCand.NoneAbove), currentCand.Disabled ? disabled : (printResults ? votesCount.ToString() : "0"), currentCand.Disabled ? "" : (printResults ? "(" + CustomRusNumber.Str(votesCount, true).Trim() + ")" : CustomRusNumber.Str(0, true).Trim()) }, voteLine.FontSize, voteLine.Bold, voteLine.Italic, delimiter)); delimiter = false; break; } } break; case VoteLineType.Line: if (string.CompareOrdinal(voteLine.ID, VoteTextLine.TOTAL_RECEIVED_VOTETEXTLINE_ID) == 0) { var value = _votingResultManager.VotingResults.VotesCount( new VoteKey( BlankType.AllButBad, null, null, null, null, _electionManager.SourceData.GetBlankIdByElectionNumber(election.ElectionId))); var text = string.IsNullOrEmpty(voteLine.Text) ? VoteTextLine.TOTAL_RECEIVED_VOTETEXTLINE_DEFAULT_TEXT : voteLine.Text; table.Add(new LineClause( new[] { "", text, printResults ? value.ToString() : "0", printResults ? "(" + CustomRusNumber.Str(value, true).Trim() + ")" : CustomRusNumber.Str(0, true).Trim() }, voteLine.FontSize, voteLine.Bold, voteLine.Italic, delimiter)); } else { foreach (Line currentLine in election.Protocol.Lines) { if (currentLine.Id == voteLine.ID) { int value = final && currentLine.Value.HasValue ? currentLine.Value.Value : 0; table.Add(new LineClause( new[] { currentLine.Num + currentLine.AdditionalNum, currentLine.Name, printResults ? value.ToString() : "0", printResults ? "(" + CustomRusNumber.Str(value, true).Trim() + ")" : CustomRusNumber.Str(0, true).Trim() }, voteLine.FontSize, voteLine.Bold, voteLine.Italic, delimiter)); break; } } } delimiter = false; break; case VoteLineType.Delimiter: delimiter = true; break; } } return table; }
private void ApplyStandartTemplatesToLine(Election election, StringBuilder text) { text.Replace(MACRO_ELECTION_NAME, election.Name); if (PlatformDetector.IsUnix) { text.Replace(MACRO_VOTING_DATE, ReportTemplateParser.DataConvert( _electionManager.SourceData.ElectionDate.ToString(ELECTION_DATE_FORMAT, new System.Globalization.CultureInfo("ru-RU")))); text.Replace(MACRO_CURRENT_DATE, ReportTemplateParser.DataConvert( DateTime.Now.ToString(CURRENT_DATETIME_FORMAT, new System.Globalization.CultureInfo("ru-RU")))); } else { text.Replace(MACRO_VOTING_DATE, _electionManager.SourceData.ElectionDate.ToString(ELECTION_DATE_FORMAT)); text.Replace(MACRO_CURRENT_DATE, DateTime.Now.ToString(CURRENT_DATETIME_FORMAT)); } text.Replace(MACRO_UIK, _electionManager.SourceData.Uik.ToString()); var exp = new UikMemberNamesRegex(); foreach (Match match in exp.Matches(text.ToString())) { var altValue = match.Value.Split(':')[1].Trim('}'); string name = null; if (match.Value.Contains(CommitteeMemberType.ChairmanAssistant.ToString())) { name = _electionManager.SourceData.GetCommitteeMemberInitialByType(CommitteeMemberType.ChairmanAssistant); } else if (match.Value.Contains(CommitteeMemberType.Chairman.ToString())) { name = _electionManager.SourceData.GetCommitteeMemberInitialByType(CommitteeMemberType.Chairman); } else if (match.Value.Contains(CommitteeMemberType.Secretary.ToString())) { name = _electionManager.SourceData.GetCommitteeMemberInitialByType(CommitteeMemberType.Secretary); } text.Replace(match.Value, string.IsNullOrEmpty(name) ? altValue : name); } }
private void ApplyStandartTemplates( ProtocolText protocolTemplate, Election election, Dictionary<PageSection, List<BasePlainElement>> headers) { foreach (ProtocolTextLine textLine in protocolTemplate.ProtocolLines) { var text = new StringBuilder(textLine.Text); ApplyStandartTemplatesToLine(election, text); if (textLine.Text != null && textLine.Text.IndexOf(MACRO_PROTOCOL_NAME) != -1) { var lines = election.Protocol.Name.Split('\n'); if (lines.Length > 1) { foreach (var line in lines) AddLineToList(headers[textLine.Section], textLine, line); continue; } text.Replace(MACRO_PROTOCOL_NAME, election.Protocol.Name); } AddLineToList(headers[textLine.Section], textLine, text.ToString()); } }
public int GetElectionIndex(Election election) { if (election == null) return -1; for (var i = 0; i < Elections.Length; ++i) if (string.CompareOrdinal(Elections[i].ElectionId, election.ElectionId) == 0) return i; return -1; }
public void BindAutoLinesAndChecksCountMethods(Election oElection) { if (_protocolLinesAssembly == null) _protocolLinesAssembly = CompileAutoLinesAndChecksAssembly(); foreach (Line oLine in oElection.Protocol.Lines) oLine.BindMethod(_protocolLinesAssembly); foreach (CheckExpression oCheck in oElection.Protocol.Checks) oCheck.BindMethod(_protocolLinesAssembly); }