Exemplo n.º 1
0
        private static void CreateAllScheduleData()
        {
            if (AllScheduleData.Count == 0)
            {
                string BR    = "\r\n";
                string SPACE = " ";

                string[] courses    = new string[] { "语文", "数学", "英语", "物理", "生物", "历史" };
                string[] colors     = new string[] { "#82af6f", "#d15b47", "#9585bf", "#fee188", "#d6487e", "#3a87ad" };
                string[] textColors = new string[] { "#fff", "#fff", "#fff", "rgb(153, 102, 51)", "#fff", "#fff" };
                string[] allNames   = new string[] { "孔苇", "冯添桂", "伍兆斌", "方艾健", "米希雨", "王瑶伶", "成萍娴", "余卓超" };
                string[] allStatuss = new string[] { "排定", "已上" };

                int[][] times = new int[][]
                {
                    new int[] { 6, 30, 7, 0 },
                    new int[] { 8, 0, 9, 0 },
                    new int[] { 11, 0, 12, 0 },
                    new int[] { 13, 0, 13, 30 },
                    new int[] { 16, 0, 16, 30 },
                    new int[] { 18, 0, 19, 0 }
                };

                Random rnd = new Random();
                for (DateTime dtStart = DateTime.Now.AddMonths(-2); dtStart < DateTime.Now.AddMonths(3); dtStart = dtStart.AddDays(1))
                {
                    int        count     = rnd.Next(times.Length);
                    List <int> indexList = GetRandomIndexList(count, times.Length, rnd);
                    for (int i = 0; i < indexList.Count; i++)
                    {
                        int[] time                  = times[indexList[i]];
                        int   courseIndex           = rnd.Next(courses.Length);
                        Schedules.Schedule schedule = new Schedules.Schedule()
                        {
                            id     = Guid.NewGuid(),
                            title  = "高三" + courses[courseIndex] + SPACE + allNames[rnd.Next(allNames.Length)],// + BR + allStatuss[rnd.Next(allStatuss.Length)],
                            allDay = false,
                            start  = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, time[0], time[1], 0),
                            end    = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, time[2], time[3], 0)
                        };
                        schedule.startText = schedule.start.ToString("HH:mm");
                        schedule.endText   = schedule.end.ToString("HH:mm");
                        schedule.duration  = (schedule.start - DateTime.Now).TotalDays;
                        if (schedule.start < DateTime.Now)
                        {
                            schedule.status = "已上";
                        }
                        else
                        {
                            schedule.status = "排定";
                        }

                        AllScheduleData.Add(schedule);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void CreateAllScheduleData1()
        {
            if (AllScheduleData.Count == 0)
            {
                string BR    = "\r\n";
                string SPACE = " ";

                string[] courses    = new string[] { "语文", "数学", "英语", "物理", "生物", "历史" };
                string[] colors     = new string[] { "#82af6f", "#d15b47", "#9585bf", "#fee188", "#d6487e", "#3a87ad" };
                string[] textColors = new string[] { "#fff", "#fff", "#fff", "rgb(153, 102, 51)", "#fff", "#fff" };
                string[] allNames   = new string[] { "孔苇", "冯添桂", "伍兆斌", "方艾健", "米希雨", "王瑶伶", "成萍娴", "余卓超" };
                string[] allStatuss = new string[] { "排定", "已上", "异常", "取消", "已删除" };

                int[][] times = new int[][]
                {
                    new int[] { 6, 7 },
                    new int[] { 8, 10 },
                    new int[] { 11, 12 },
                    new int[] { 13, 16 },
                    new int[] { 16, 18 },
                    new int[] { 18, 19 }
                };

                Random rnd = new Random();
                for (DateTime dtStart = DateTime.Now.AddMonths(-2); dtStart < DateTime.Now.AddMonths(3); dtStart = dtStart.AddDays(1))
                {
                    int        count     = rnd.Next(times.Length);
                    List <int> indexList = GetRandomIndexList(count, times.Length, rnd);
                    for (int i = 0; i < indexList.Count; i++)
                    {
                        int[] time                  = times[indexList[i]];
                        int   courseIndex           = rnd.Next(courses.Length);
                        Schedules.Schedule schedule = new Schedules.Schedule()
                        {
                            id     = Guid.NewGuid(),
                            title  = "高中三年级" + BR + courses[courseIndex] + SPACE + allNames[rnd.Next(allNames.Length)] + BR + allStatuss[rnd.Next(allStatuss.Length)],
                            allDay = false,
                            start  = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, time[0], 0, 0),
                            end    = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, time[1], 0, 0)
                        };
                        if (schedule.start < DateTime.Now)
                        {
                            schedule.color     = "#a0a0a0";
                            schedule.textColor = "#fff";
                        }
                        else
                        {
                            schedule.color     = colors[courseIndex];
                            schedule.textColor = textColors[courseIndex];
                        }

                        AllScheduleData.Add(schedule);
                    }
                }
            }
        }