コード例 #1
0
        private void saveTaskScheduleData(PillSchedule pillSchedule, JsonSerializer serializer)
        {
            PillScheduleStorageObject pillScheduleStorageObject = new PillScheduleStorageObject(pillSchedule);

            using (StreamWriter sw = new StreamWriter($@"{pillScheduleDataFolderPath}\{pillSchedule.ID.ToString()}_Schedule.dat"))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    serializer.Serialize(writer, pillScheduleStorageObject);
                }
        }
コード例 #2
0
        public List <PillSchedule> GetAllTaskSchedule()
        {
            List <PillSchedule> pillSchedules = new List <PillSchedule>();
            List <PillScheduleStorageObject> pillScheduleStorageObjects = new List <PillScheduleStorageObject>();

            JsonSerializer serializer = new JsonSerializer();

            string[] pillScheduleDataFilesPath = Directory.GetFiles(pillScheduleDataFolderPath, "*.dat");
            foreach (var filePaath in pillScheduleDataFilesPath)
            {
                using (StreamReader sr = new StreamReader(filePaath))
                    using (JsonReader reader = new JsonTextReader(sr))
                    {
                        PillScheduleStorageObject pillScheduleStorageObject = serializer.Deserialize <PillScheduleStorageObject>(reader);
                        pillScheduleStorageObjects.Add(pillScheduleStorageObject);
                    }
            }
            pillScheduleStorageObjects.ForEach(p => pillSchedules.Add(p.PillScheduleStorageObjectToPillSchedule()));

            return(pillSchedules);
        }