Skip to content

Commit

Permalink
feat: Event-us 대응 추가 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimYunSup authored Sep 9, 2024
1 parent f8e2827 commit 9686bd7
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/DotNetDevLottery/Models/EventInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public class EventInfo
public string? ticketCellString { get; init; }
public string? checkedCellString { get; init; }
public string? checkedString { get; init; }
public string? beforeStartTicketString { get; init; }
public bool isOldExcel { get; init; } = false;
public bool isEnumTicketCell { get; init; } = true;
}
14 changes: 9 additions & 5 deletions src/DotNetDevLottery/Pages/Main.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
else
{
<span>
<span class="file-dropzone__filename">
@targetFile.Name
</span>
}
Expand All @@ -48,13 +48,17 @@
<div class="form-row">
@foreach (var groupName in groupNames.Select((value, index) => new { value, index }).ToArray())
{
<ui-checkbox onclick="@(() =>OnClickCheckbox(groupName.index))">
<ui-checkbox
checked="@filterGroup[groupName.index]"
@onchange="@(() =>OnChangeCheckbox(groupName.index))">
@groupName.value
</ui-checkbox>
}
</div>
<div class="form-row">
<ui-checkbox @onclick="OnClickFilterCheckInCheckbox">
<ui-checkbox
checked="@filterCheckedIn"
@onchange="OnChangeFilterCheckInCheckbox">
체크인 한 사람만 포함
</ui-checkbox>
</div>
Expand Down Expand Up @@ -116,11 +120,11 @@
await elementUtils.InvokeVoidAsync("clickElement", inputFileElement?.Element);
}

private void OnClickCheckbox(int index)
private void OnChangeCheckbox(int index)
{
filterGroup[index] = !(filterGroup[index]);
}
private void OnClickFilterCheckInCheckbox()
private void OnChangeFilterCheckInCheckbox()
{
filterCheckedIn = !filterCheckedIn;
}
Expand Down
10 changes: 9 additions & 1 deletion src/DotNetDevLottery/Pages/Main.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@
padding-top: 3rem;
padding-bottom: 3rem;
margin: 0 auto 2rem;

& .file-dropzone__input {
display: none;
}

& .file-dropzone__filename {
display: block;
width: 100%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}

.form-row {
Expand Down
65 changes: 54 additions & 11 deletions src/DotNetDevLottery/Services/Implementations/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ public class EventService : IEventService
isOldExcel = true,
},
new()
{
name = "EVENTUS",
firstRowCellString = "순서",
nameCellString = "이름",
phoneCellString = "전화번호",
emailCellString = "이메일",
beforeStartTicketString = "오프라인 전체 출석",
checkedCellString = "출석",
checkedString = "O",
isOldExcel = false,
isEnumTicketCell = false,
},
new()
{
name = "FESTA",
firstRowCellString = "이름",
Expand Down Expand Up @@ -102,7 +115,9 @@ public async Task LoadUserInfoListAsync(int eventInfoIndex, IBrowserFile file, C
int emailIndex = 0;
int ticketIndex = 0;
int isCheckedIndex = 0;
int beforeStartTicketIndex = 0;
bool isUserInfoStarted = false;
IRow? firstRow = null;
ISheet sheet;

if (eventInfo.isOldExcel)
Expand All @@ -115,10 +130,10 @@ public async Task LoadUserInfoListAsync(int eventInfoIndex, IBrowserFile file, C
var xsswb = new XSSFWorkbook(ms);
sheet = xsswb.GetSheetAt(0);
}

for (var index = sheet.FirstRowNum; index < sheet.LastRowNum; index++)
for (var index = sheet.FirstRowNum; index <= sheet.LastRowNum; index++)
{
var currentRow = sheet.GetRow(index);

if (currentRow == null)
{
if (isUserInfoStarted)
Expand All @@ -131,11 +146,12 @@ public async Task LoadUserInfoListAsync(int eventInfoIndex, IBrowserFile file, C

if (firstCellString == eventInfo.firstRowCellString)
{
firstRow = currentRow;
isUserInfoStarted = true;

for (var cellIndex = currentRow.FirstCellNum; cellIndex < currentRow.LastCellNum; cellIndex++)
for (var cellIndex = firstRow.FirstCellNum; cellIndex < firstRow.LastCellNum; cellIndex++)
{
var currentCellString = currentRow.GetCell(cellIndex).ToString();
var currentCellString = firstRow.GetCell(cellIndex).ToString();

if (currentCellString == eventInfo.nameCellString)
nameIndex = cellIndex;
Expand All @@ -147,25 +163,52 @@ public async Task LoadUserInfoListAsync(int eventInfoIndex, IBrowserFile file, C
ticketIndex = cellIndex;
else if (currentCellString == eventInfo.checkedCellString)
isCheckedIndex = cellIndex;
else if (currentCellString == eventInfo.beforeStartTicketString)
beforeStartTicketIndex = cellIndex;
}
continue;
}

if (isUserInfoStarted == false)
continue;

var checkedString = (eventInfo.checkedString ?? string.Empty);
// onoffmix가 출석확인시간으로 엑셀에 저장하는 이슈로 checkedString이 없는 경우 해당 열이 empty인지만 체크
bool isChecked = (eventInfo.checkedString == string.Empty)
? (currentRow.GetCell(isCheckedIndex)?.ToString() ?? string.Empty).Contains(checkedString)
: (currentRow.GetCell(isCheckedIndex)?.ToString() ?? string.Empty) == string.Empty;

var ticketType = string.Empty;
var isChecked = false;
if (eventInfo.isEnumTicketCell)
{
var checkedString = (eventInfo.checkedString ?? string.Empty);
// onoffmix가 출석확인시간으로 엑셀에 저장하는 이슈로 checkedString이 없는 경우 해당 열이 empty인지만 체크
isChecked = (eventInfo.checkedString == string.Empty)
? (currentRow.GetCell(isCheckedIndex)?.ToString() ?? string.Empty).Contains(checkedString)
: (currentRow.GetCell(isCheckedIndex)?.ToString() ?? string.Empty) == string.Empty;

ticketType = currentRow.GetCell(ticketIndex)?.ToString() ?? string.Empty;
}
else
{
if (firstRow == null)
{
continue;
}
for (var cellIndex = beforeStartTicketIndex + 1; cellIndex < firstRow.LastCellNum; cellIndex += 3)
{
if (currentRow.GetCell(cellIndex).ToString() != "O") continue;

ticketType = firstRow.GetCell(cellIndex).ToString();
if (firstRow.GetCell(cellIndex + 2).ToString() == eventInfo.checkedCellString)
{
isChecked = (currentRow.GetCell(cellIndex + 2).ToString() == eventInfo.checkedString);
}
break;
}
}

UserInfos.Add(new()
{
personName = MaskName(currentRow.GetCell(nameIndex).ToString() ?? string.Empty),
email = MaskEmail(currentRow.GetCell(emailIndex).ToString() ?? string.Empty),
phone = MaskPhone(currentRow.GetCell(phoneIndex).ToString() ?? string.Empty),
ticketType = currentRow.GetCell(ticketIndex)?.ToString() ?? string.Empty,
ticketType = ticketType,
isChecked = isChecked
});
}
Expand Down

0 comments on commit 9686bd7

Please sign in to comment.