コード例 #1
0
        public void getCurrentTest()
        {
            ActivityTimeLine atl = new ActivityTimeLine();
            atl.Add(new Activity("TV", new DateTime(2011, 10, 15, 14, 30, 00), new TimeSpan(0, 20, 00), "Pivoruimte"));
            atl.Add(new Activity("Radio", new DateTime(2011, 10, 15, 14, 50, 00), new TimeSpan(0, 20, 00), "Beverruimte"));

            DateTime now = new DateTime(2011, 10, 15, 14, 40, 00);

            Activity expected = new Activity("TV", new DateTime(2011, 10, 15, 14, 30, 00), new TimeSpan(0, 20, 00), "Pivoruimte");
            Activity actual;
            actual = atl.getCurrent(now);
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        private void GetSchedule(Dictionary<string, ActivityTimeLine> schedule, DataTable table, string groupType)
        {
            #region get row for time
            int rowIndex = -1;
            //FOR ALL TIMES:
            for (int i = 0; i < table.Rows.Count; i++)
            {
                object start = table.Rows[i][STARTTIMEINDEX];
                object end = table.Rows[i][ENDTIMEINDEX];
                DateTime? iStartTime = start as DateTime?;
                DateTime? iEndTime = end as DateTime?;

                if (iStartTime != null && iEndTime != null)
                #region IF THE TIMES AREN'T NULL:
                {
                    rowIndex = i;
                    string activity = "Onbekend, vraag de leiding";
                    #region FOR EACH ACTIVITY (which happens to be in columns)
                    Dictionary<int, string> columnActivities = GetActivityMapping(iStartTime.Value, groupType);
                    foreach (int column in columnActivities.Keys)
                    {
                        //CHECK OUT WHICH GROUPS PARTICIPATE
                        List<int> groupsInCell = ParseCellContents(table.Rows[rowIndex][column]);

                        #region IF THE ACTIVITY IS FOR ALL:
                        if (groupsInCell == null)
                        {
                            activity = (string)GetFromRowSpan(table, rowIndex, column); //TODO: This doesnt work for cells which are overlapped by a cell with a rowspan > 1
                            var klein = from groupname in schedule.Keys
                                        where groupname.Contains(groupType)
                                        select groupname;
                            foreach (string groupname in klein)
                            {
                                schedule[groupname].Add(new Activity(activity, iStartTime.Value, iEndTime.Value, ""));
                            }
                            break;
                        }
                        #endregion
                        else
                        {
                            activity = columnActivities[column];
                            //string activity2 = SearchActivity(table, rowIndex, column);
                            //activity = LookupActivity(iStartTime.Value, groupType, column);
                            #region FOR EACH PARTICIPATING GROUP:
                            foreach (int group in groupsInCell)
                            {
                                string groupName = groupType + group.ToString();
                                Activity act = new Activity(activity, iStartTime.Value, iEndTime.Value, "");
                                schedule[groupName].Add(act);
                                //ADD THE ACTIVITY TO THEIR TIMELINE
                            }
                            #endregion
                        }
                    }
                    #endregion
                }
                #endregion
            }
            #endregion
        }