public int GetLatestLineNumber(bool final) { if (Lines == null || Lines.Length <= 0) { return(0); } ProtocolText template = GetProtocolTemplate(final); if (template == null) { return(LatestLineNumber); } if (template.VoteLines.Any(oVoteLine => oVoteLine.Type == VoteLineType.Line)) { return(LatestLineNumber); } return(0); }
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 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()); } }