Beispiel #1
0
        private static List <Schedules> ParseObjectToList(SchedulesResultList oSchedulesResultList)
        {
            List <Schedules> oSchedulesList = new List <Schedules>();

            foreach (Schedules oSchedules in oSchedulesResultList.ScheduleResult.Schedules)
            {
                // Execute and set the work time list for the person
                List <DateTime> lstWorkTime = new List <DateTime>();
                foreach (Projection oProjectionTmp in oSchedules.Projection)
                {
                    string sToday          = oSchedules.Date.ToString("yyyy-MM-dd");
                    string sProjectionDate = oProjectionTmp.Start.ToString("yyyy-MM-dd");
                    if (sToday == sProjectionDate && !sDescFilter.Contains(oProjectionTmp.Description))
                    {
                        int iCount = oProjectionTmp.minutes / 15;
                        for (int i = 0; i < iCount; i++)
                        {
                            DateTime dtCanMeetingTime = oProjectionTmp.Start.AddMinutes(i * 15);

                            // only add the date in the same day.
                            bool bAdd = dtCanMeetingTime.Date >= oSchedules.Date.Date.AddDays(1) ? false : true;
                            if (bAdd)
                            {
                                lstWorkTime.Add(dtCanMeetingTime);
                            }
                        }
                    }
                }
                oSchedules.lstWorkTime = lstWorkTime;

                oSchedulesList.Add(oSchedules);
            }

            return(oSchedulesList);
        }
Beispiel #2
0
        public static List <Schedules> InitData()
        {
            SchedulesResultList oSchedulesResultList = ConvertJsonToObject();
            List <Schedules>    oSchedulesList       = ParseObjectToList(oSchedulesResultList);

            return(oSchedulesList);
        }
Beispiel #3
0
        private static SchedulesResultList ConvertJsonToObject()
        {
            string sJsonStr = "";

            using (StreamReader sr = new StreamReader(File.Open(@"schedule.json", FileMode.Open)))
            {
                sJsonStr = sr.ReadToEnd();
            }
            SchedulesResultList oSchedulesResultList = JsonConvert.DeserializeObject <SchedulesResultList>(sJsonStr);

            return(oSchedulesResultList);
        }