Esempio n. 1
0
        public static void SaveConfigToFile(ConfigContainer config, string filename)
        {
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            File.AppendAllText(filename, $"{base_.CONFIG_SAVE_TITLE_STRING}\n");

            foreach (ConfigGroup i in config.Items)
            {
                File.AppendAllText(filename, $"\n[{i.GroupName}]\n");

                foreach (string j in i.GroupItems.Keys)
                {
                    File.AppendAllText(filename, $"{j}={i.FindItem(j)}\n");
                }
            }
        }
Esempio n. 2
0
        public static void LoadSchedules()
        {
            ConfigContainer config = ConfigLoader.LoadConfigFromFile(base_.SCHEDULES_FILE_LOCATION);

            base_.SCHEDULES_CONFIGCONTANER = config;

            foreach (ConfigGroup i in config.Items)
            {
                Schedule sc = new Schedule();

                //아이템 추가
                List <string> AllItems = new List <string>()
                {
                    "active", "tvon", "tvoff", "clock", "food", "bus", "firstbelltime", "reboot"
                };
                List <string> reachableItems = new List <string>();

                foreach (string j in AllItems)
                {
                    if (i.FindItem(j) != null)
                    {
                        reachableItems.Add(j);
                    }
                }


                foreach (string j in reachableItems)
                {
                    switch (j)
                    {
                    case "active":
                        sc.Enable
                            = i.FindItem("active") == "true";     //사실 이부분이 좀 걸리긴 하는데 뭐 괜찮겠지.
                        break;

                    case "tvon":
                        sc.ScreenOnTime = Schedule.ParseStringToTime(i.FindItem("tvon")); break;

                    case "tvoff":
                        sc.ScreenOffTime = Schedule.ParseStringToTime(i.FindItem("tvoff")); break;

                    case "clock":
                        sc.ClockScreenOnTime  = Schedule.ParseStringToTime(i.FindItem("clock").Split('-')[0]);
                        sc.ClockScreenOffTime = Schedule.ParseStringToTime(i.FindItem("clock").Split('-')[1]);
                        break;

                    case "food":
                        sc.FoodScreenOnTime  = Schedule.ParseStringToTime(i.FindItem("food").Split('-')[0]);
                        sc.FoodScreenOffTime = Schedule.ParseStringToTime(i.FindItem("food").Split('-')[1]);
                        break;

                    case "bus":
                        sc.BusScreenOnTime  = Schedule.ParseStringToTime(i.FindItem("bus").Split('-')[0]);
                        sc.BusScreenOffTime = Schedule.ParseStringToTime(i.FindItem("bus").Split('-')[1]);
                        break;

                    case "firstbelltime":
                        sc.BellRingTime = Schedule.ParseStringToTime(i.FindItem("firstbelltime")); break;

                    case "reboot":
                        sc.RebootTime = Schedule.ParseStringToTime(i.FindItem("reboot")); break;
                    }
                }

                //분류 & 추가

                if (i.GroupName.Contains("custom"))
                {
                    sc.Date = i.GroupName.Replace("custom_", "");
                    base_.SPECIAL_SCHEDULES.Add(sc);
                }
                else
                {
                    sc.DayOfWeek = i.GroupName;
                    base_.DEFAULT_SCHEDULES.Add(sc);
                }
            }
        }