private void GetHallsFromSpreadSheet(int row, ExcelWorksheet sheet, int EventId) { Hall h = new Hall(); h.Capacity = Convert.ToInt32(sheet.Cells[COLUMN_CAPACITE + Convert.ToString(row)].Value); h.Name = (string)sheet.Cells[COLUMN_NAME + Convert.ToString(row)].Value; h.EventId = EventId; try { h.HallType = Convertors.GetHallSectionType((string)sheet.Cells[TYPE_HALL + Convert.ToString(row)].Value); } catch (Exception) { h.HallType = HallSectionTypeEnum.NONE; } h.Persist(); }
public void LoadUsers(ExcelWorksheet worksheet, int EventId) { int maxEmpty = 0; int currentRow = 2; while (maxEmpty < MAX_EMPTY_CELLS) { EventAttendee attendee = new EventAttendee(); string name = (string)worksheet.Cells[COLUMN_FIRSTNAME + Convert.ToString(currentRow)].Value; if (!string.IsNullOrEmpty(name)) { User u = GetUserFromSpreadSheet(currentRow, worksheet); attendee.EventId = EventId; attendee.UserId = u.Id; try { attendee.TableType = Convertors.GetRegimeType((string)worksheet.Cells[COLUMN_TABLE_TYPE + Convert.ToString(currentRow)].Value); } catch { log.Info("Regime import for table failed, setting regime to none"); attendee.TableType = RegimeEnum.NONE; } try { attendee.SectionType = Convertors.GetHallSectionType((string)worksheet.Cells[COLUMN_HALL_TYPE + Convert.ToString(currentRow)].Value); } catch { attendee.SectionType = HallSectionTypeEnum.NONE; } try { attendee.DormCategory = Convertors.GetDormirtoryCategory((string)worksheet.Cells[COLUMN_DORM_TYPE + Convert.ToString(currentRow)].Value); } catch { attendee.SectionType = HallSectionTypeEnum.NONE; } attendee.Remarks = (string)worksheet.Cells[COLUMN_REMARKS + Convert.ToString(currentRow)].Value; try { attendee.AmountPaid = Convert.ToInt32(worksheet.Cells[COLUMN_AMOUNTPAID + Convert.ToString(currentRow)].Value); } catch (Exception) { attendee.AmountPaid = 0; } attendee.InvitedBy = User.GetUserIdByName((string)worksheet.Cells[COLUMN_INVITED_BY + Convert.ToString(currentRow)].Value); try { attendee.SharingCategory = Convertors.GetSharingGroupCategory((string)worksheet.Cells[COLUMN_SHARING_CATEGORY + Convert.ToString(currentRow)].Value); } catch { attendee.SharingCategory = SharingGroupCategoryEnum.ADULTE; } attendee.Persist(); maxEmpty = 0; } else { maxEmpty++; } currentRow++; } }