260320_01_EHN: 분석 도중 쓸데없는 코드들 제거
This commit is contained in:
@@ -329,22 +329,20 @@ namespace Keps.WinForms.Forms
|
|||||||
if (targetRow != null)
|
if (targetRow != null)
|
||||||
{
|
{
|
||||||
int total = targetRow.PollingPlaceCount;
|
int total = targetRow.PollingPlaceCount;
|
||||||
int sample = Math.Max(0, targetRow.SampleCount);
|
int sample = targetRow.SampleCount;
|
||||||
if (sample > 0)
|
|
||||||
{
|
int interval = total / sample;
|
||||||
int interval = total / sample;
|
int start = interval / 2;
|
||||||
int start = interval / 2;
|
int endPoint = start + (interval * (sample - 1));
|
||||||
int endPoint = start + (interval * (sample - 1));
|
int x1 = total - endPoint;
|
||||||
int x1 = total - endPoint;
|
int x2 = start - 1;
|
||||||
int x2 = start - 1;
|
start = (int)Math.Round((x1 + x2) / 2m, 0, MidpointRounding.AwayFromZero);
|
||||||
start = (int)Math.Round((x1 + x2) / 2m, 0, MidpointRounding.AwayFromZero);
|
maxRange = total - (interval * (sample - 1)) - start;
|
||||||
maxRange = total - (interval * (sample - 1)) - start;
|
|
||||||
|
|
||||||
if (interval == 0)
|
if (interval == 0)
|
||||||
{
|
{
|
||||||
maxRange = 0;
|
maxRange = 0;
|
||||||
offsetEnabled = false;
|
offsetEnabled = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,35 +82,21 @@ namespace Keps.WinForms.Services
|
|||||||
using (SqlConnection connection = _connectionFactory.Open())
|
using (SqlConnection connection = _connectionFactory.Open())
|
||||||
using (SqlCommand command = new SqlCommand(LegacySqlCatalog.RealCandidateNames, connection))
|
using (SqlCommand command = new SqlCommand(LegacySqlCatalog.RealCandidateNames, connection))
|
||||||
{
|
{
|
||||||
int electionNo;
|
command.Parameters.AddWithValue("@electionName", electionName);
|
||||||
if (int.TryParse(electionName, out electionNo))
|
|
||||||
|
using (SqlDataReader reader = command.ExecuteReader())
|
||||||
{
|
{
|
||||||
command.Parameters.AddWithValue("@electionName", electionNo);
|
while (reader.Read())
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@electionName", electionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (SqlDataReader reader = command.ExecuteReader())
|
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
string candNo = Convert.ToString(reader["cand_no"]);
|
||||||
|
string candName = Convert.ToString(reader["cand_name"]);
|
||||||
|
result.Add(new CandidateOption
|
||||||
{
|
{
|
||||||
string candNo = Convert.ToString(reader["cand_no"]);
|
Key = "cand_ratio_" + candNo,
|
||||||
string candName = Convert.ToString(reader["cand_name"]);
|
DisplayName = candName + "(" + candNo + ")"
|
||||||
result.Add(new CandidateOption
|
});
|
||||||
{
|
|
||||||
Key = "cand_ratio_" + candNo,
|
|
||||||
DisplayName = candName + "(" + candNo + ")"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Add(new CandidateOption { Key = "투표인수", DisplayName = "투표인수" });
|
result.Add(new CandidateOption { Key = "투표인수", DisplayName = "투표인수" });
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ namespace Keps.WinForms.Services
|
|||||||
string sortKey,
|
string sortKey,
|
||||||
string sortDisplayName,
|
string sortDisplayName,
|
||||||
bool descending,
|
bool descending,
|
||||||
List<ClusterSummaryRow> allocationRows,
|
List<ClusterSummaryRow> workingRows,
|
||||||
int signedOffset,
|
int signedOffset,
|
||||||
string offsetDescription,
|
string offsetDescription,
|
||||||
bool isAutoAllocation)
|
bool isAutoAllocation)
|
||||||
@@ -190,23 +190,23 @@ namespace Keps.WinForms.Services
|
|||||||
List<ExtractionRow> populationRows = new List<ExtractionRow>();
|
List<ExtractionRow> populationRows = new List<ExtractionRow>();
|
||||||
List<PollingPlaceRecord> extractedSourceRows = new List<PollingPlaceRecord>();
|
List<PollingPlaceRecord> extractedSourceRows = new List<PollingPlaceRecord>();
|
||||||
|
|
||||||
foreach (ClusterSummaryRow allocation in allocationRows.OrderBy(x => x.ClusterNo))
|
foreach (ClusterSummaryRow workingRow in workingRows.OrderBy(x => x.ClusterNo))
|
||||||
{
|
{
|
||||||
List<PollingPlaceRecord> clusterRows = allRows.Where(x => x.ClusterValue == allocation.ClusterNo).ToList();
|
List<PollingPlaceRecord> clusterRows = allRows.Where(x => x.ClusterValue == workingRow.ClusterNo).ToList();
|
||||||
clusterRows = descending
|
clusterRows = descending
|
||||||
? clusterRows.OrderByDescending(x => x.GetSortValue(sortKey)).ThenBy(x => x.EupMyeonDong).ThenBy(x => GetPollingPlaceSortValue(x.PollingPlaceNo)).ThenBy(x => x.PollingPlaceNo).ToList()
|
? clusterRows.OrderByDescending(x => x.GetSortValue(sortKey)).ThenBy(x => x.EupMyeonDong).ThenBy(x => GetPollingPlaceSortValue(x.PollingPlaceNo)).ThenBy(x => x.PollingPlaceNo).ToList()
|
||||||
: clusterRows.OrderBy(x => x.GetSortValue(sortKey)).ThenBy(x => x.EupMyeonDong).ThenBy(x => GetPollingPlaceSortValue(x.PollingPlaceNo)).ThenBy(x => x.PollingPlaceNo).ToList();
|
: clusterRows.OrderBy(x => x.GetSortValue(sortKey)).ThenBy(x => x.EupMyeonDong).ThenBy(x => GetPollingPlaceSortValue(x.PollingPlaceNo)).ThenBy(x => x.PollingPlaceNo).ToList();
|
||||||
|
|
||||||
int interval;
|
int interval;
|
||||||
int startPosition;
|
int startPosition;
|
||||||
List<int> extractIds = SelectLegacyExtractIds(clusterRows.Count, allocation.SampleCount, signedOffset, out interval, out startPosition);
|
List<int> extractIds = SelectLegacyExtractIds(clusterRows.Count, workingRow.SampleCount, signedOffset, out interval, out startPosition);
|
||||||
HashSet<int> selectedPositions = new HashSet<int>(extractIds);
|
HashSet<int> selectedPositions = new HashSet<int>(extractIds);
|
||||||
|
|
||||||
for (int i = 0; i < clusterRows.Count; i++)
|
for (int i = 0; i < clusterRows.Count; i++)
|
||||||
{
|
{
|
||||||
int originalOrder = i + 1;
|
int originalOrder = i + 1;
|
||||||
PollingPlaceRecord row = clusterRows[i];
|
PollingPlaceRecord row = clusterRows[i];
|
||||||
populationRows.Add(CreateExtractionRow(row, allocation.ClusterNo, originalOrder, originalOrder, interval, startPosition, offsetDescription, row.GetSortValue(sortKey), selectedPositions.Contains(originalOrder), selectedPositions.Contains(originalOrder)));
|
populationRows.Add(CreateExtractionRow(row, workingRow.ClusterNo, originalOrder, originalOrder, interval, startPosition, offsetDescription, row.GetSortValue(sortKey), selectedPositions.Contains(originalOrder), selectedPositions.Contains(originalOrder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < extractIds.Count; i++)
|
for (int i = 0; i < extractIds.Count; i++)
|
||||||
@@ -219,7 +219,7 @@ namespace Keps.WinForms.Services
|
|||||||
|
|
||||||
PollingPlaceRecord row = clusterRows[extractId - 1];
|
PollingPlaceRecord row = clusterRows[extractId - 1];
|
||||||
extractedSourceRows.Add(row);
|
extractedSourceRows.Add(row);
|
||||||
extractedRows.Add(CreateExtractionRow(row, allocation.ClusterNo, i + 1, extractId, interval, startPosition, offsetDescription, row.GetSortValue(sortKey), true, true));
|
extractedRows.Add(CreateExtractionRow(row, workingRow.ClusterNo, i + 1, extractId, interval, startPosition, offsetDescription, row.GetSortValue(sortKey), true, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,9 +235,9 @@ namespace Keps.WinForms.Services
|
|||||||
ExtractedRows = extractedRows.OrderBy(x => x.ClusterNo).ThenBy(x => x.ClusterOrder).ToList(),
|
ExtractedRows = extractedRows.OrderBy(x => x.ClusterNo).ThenBy(x => x.ClusterOrder).ToList(),
|
||||||
PopulationRows = populationRows.OrderBy(x => x.ClusterNo).ThenBy(x => x.OriginalOrder).ToList(),
|
PopulationRows = populationRows.OrderBy(x => x.ClusterNo).ThenBy(x => x.OriginalOrder).ToList(),
|
||||||
AdjustmentRows = BuildAdjustmentRows(extractedRows),
|
AdjustmentRows = BuildAdjustmentRows(extractedRows),
|
||||||
VerificationRows = BuildVerificationRows(allRows, extractedSourceRows, allocationRows, candidateMeta),
|
VerificationRows = BuildVerificationRows(allRows, extractedSourceRows, workingRows, candidateMeta),
|
||||||
ClusterMax = clusterMax,
|
ClusterMax = clusterMax,
|
||||||
TotalSampleCount = allocationRows.Sum(x => x.SampleCount),
|
TotalSampleCount = workingRows.Sum(x => x.SampleCount),
|
||||||
IsAutoAllocation = isAutoAllocation,
|
IsAutoAllocation = isAutoAllocation,
|
||||||
SortDisplayName = sortDisplayName,
|
SortDisplayName = sortDisplayName,
|
||||||
SortDescending = descending,
|
SortDescending = descending,
|
||||||
@@ -308,15 +308,7 @@ namespace Keps.WinForms.Services
|
|||||||
using (SqlConnection connection = _connectionFactory.Open())
|
using (SqlConnection connection = _connectionFactory.Open())
|
||||||
using (SqlCommand command = new SqlCommand(LegacySqlCatalog.RealCandidateNames, connection))
|
using (SqlCommand command = new SqlCommand(LegacySqlCatalog.RealCandidateNames, connection))
|
||||||
{
|
{
|
||||||
int electionNo;
|
command.Parameters.AddWithValue("@electionName", electionName);
|
||||||
if (int.TryParse(electionName, out electionNo))
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@electionName", electionNo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@electionName", electionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user