Esempio n. 1
0
        private void GetRefectoryFromSpreadSheet(int row, ExcelWorksheet sheet, int EventId)
        {
            Refectory h = new Refectory();

            h.Name    = (string)sheet.Cells[REFECTORY_NAME + Convert.ToString(row)].Value;
            h.EventId = EventId;
            h.Persist();
            Table t = new Table();

            t.Name        = (string)sheet.Cells[TABLE_NAME + Convert.ToString(row)].Value;
            t.RefectoryId = h.Id;
            try
            {
                t.Capacity = Convert.ToInt32(sheet.Cells[TABLE_CAPACITY + Convert.ToString(row)].Value);
            }
            catch (Exception)
            {
                t.Capacity = 0;
            }

            try
            {
                t.RegimeType = Convertors.GetRegimeType((string)sheet.Cells[TYPE_TABLE + Convert.ToString(row)].Value.ToString().ToLowerInvariant());
            }
            catch (Exception)
            {
                t.RegimeType = RegimeEnum.NONE;
            }
            t.Persist();
        }
Esempio n. 2
0
        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++;
            }
        }