Beispiel #1
0
    public void ParseRows()
    {
        for (int i = 0; i < 3; i++)
        {
            Row dateRow          = Rows[1 + (i * 8)]; // First row is empty, then adds a week each iteration.
            Row scheduleHoursRow = Rows[2 + (i * 8)];
            Row activityRow      = Rows[3 + (i * 8)];
            Row locationRow      = Rows[4 + (i * 8)];
            Row scheduleTimesRow = Rows[5 + (i * 8)];
            Row commentsRow      = Rows[6 + (i * 8)];

            int dayIndex = 1; // 0 is column names
            while (true)
            {
                var    workDay    = new WorkDay();
                String dateString = dateRow.cells[dayIndex].value;

                // Get the day of the week
                workDay.Day = workDay.enumDay(dateString);
                if (workDay.Day == WorkDay.DayEnum.INVALID)
                {
                    break;
                }

                // split the string "Tue 6/23"
                // and use the second part ['Tue', '6/23']
                String datePart = dateString.Split(' ')[1];
                workDay.Date = DateTime.Parse(datePart);

                workDay.Hours    = float.Parse(scheduleHoursRow.cells[dayIndex].value.Replace(":", "."));
                workDay.Activity = activityRow.cells[dayIndex].value;
                workDay.Comments = commentsRow.cells[dayIndex].value;
                workDay.Location = workDay.ConvertLocation(locationRow.cells[dayIndex].value);


                String   timeSpanPart = scheduleTimesRow.cells[dayIndex].value;
                String[] times        = timeSpanPart.Split('-'); // split '2:00 AM-8:00 PM' on the '-'

                workDay.StartTime = times[0];
                workDay.EndTime   = times.Length == 1 ? times[0] : times[1];

                if (workDay.Hours > 0)
                {
                    workDay.StartDateTime = DateTime.Parse(workDay.Date.ToShortDateString() + " " + workDay.StartTime);
                    workDay.EndDateTime   = DateTime.Parse(workDay.Date.ToShortDateString() + " " + workDay.EndTime);
                }
                Schedule.Add(workDay);
                dayIndex++;
            }
        }
    }
Beispiel #2
0
    public void ParseRows()
    {
        for (int i = 0; i < 3; i++)
        {
            Row dateRow = Rows[1 + (i * 8)]; // First row is empty, then adds a week each iteration.
            Row scheduleHoursRow = Rows[2 + (i * 8)];
            Row activityRow = Rows[3 + (i * 8)];
            Row locationRow = Rows[4 + (i * 8)];
            Row scheduleTimesRow = Rows[5 + (i * 8)];
            Row commentsRow = Rows[6 + (i * 8)];

            int dayIndex = 1; // 0 is column names
            while (true)
            {
                var workDay = new WorkDay();
                String dateString = dateRow.cells[dayIndex].value;

                // Get the day of the week
                workDay.Day = workDay.enumDay(dateString);
                if (workDay.Day == WorkDay.DayEnum.INVALID)
                {
                    break;
                }

                // split the string "Tue 6/23"
                // and use the second part ['Tue', '6/23']
                String datePart = dateString.Split(' ')[1];
                workDay.Date = DateTime.Parse(datePart);

                workDay.Hours = float.Parse(scheduleHoursRow.cells[dayIndex].value.Replace(":", "."));
                workDay.Activity = activityRow.cells[dayIndex].value;
                workDay.Comments = commentsRow.cells[dayIndex].value;
                workDay.Location = workDay.ConvertLocation(locationRow.cells[dayIndex].value);


                String timeSpanPart = scheduleTimesRow.cells[dayIndex].value;
                String[] times = timeSpanPart.Split('-'); // split '2:00 AM-8:00 PM' on the '-'

                workDay.StartTime = times[0];
                workDay.EndTime = times.Length == 1 ? times[0] : times[1];

                if (workDay.Hours > 0)
                {
                    workDay.StartDateTime = DateTime.Parse(workDay.Date.ToShortDateString() + " " + workDay.StartTime);
                    workDay.EndDateTime = DateTime.Parse(workDay.Date.ToShortDateString() + " " + workDay.EndTime);
                }
                Schedule.Add(workDay);
                dayIndex++;
            }
        }
    }