示例#1
0
        public List <ScheduleItem> GetScheduleItems()
        {
            List <ScheduleItem> scheduleItems = new List <ScheduleItem>();
            string       sql          = "SELECT * FROM RecordingSchedules";
            SQLiteResult sqliteResult = SQLite.Select(DatabasePath, sql);

            if (sqliteResult.success)
            {
                while (sqliteResult.reader.Read())
                {
                    Dictionary <string, bool> days = new Dictionary <string, bool>();
                    ScheduleItem scheduleItem      = new ScheduleItem();
                    scheduleItem.ID = Convert.ToInt32(sqliteResult.reader["ID"].ToString());
                    scheduleItem.ChannelToRecord = sqliteResult.reader["Channel"].ToString();
                    scheduleItem.StartTime       = DateTime.Parse(sqliteResult.reader["StartTime"].ToString(), new System.Globalization.CultureInfo("en-US"));
                    scheduleItem.EndTime         = DateTime.Parse(sqliteResult.reader["EndTime"].ToString(), new System.Globalization.CultureInfo("en-US"));
                    days["Monday"]            = sqliteResult.reader["Monday"].ToString() == "0" ? false : true;
                    days["Tuesday"]           = sqliteResult.reader["Tuesday"].ToString() == "0" ? false : true;
                    days["Wednesday"]         = sqliteResult.reader["Wednesday"].ToString() == "0" ? false : true;
                    days["Thursday"]          = sqliteResult.reader["Thursday"].ToString() == "0" ? false : true;
                    days["Friday"]            = sqliteResult.reader["Friday"].ToString() == "0" ? false : true;
                    days["Saturday"]          = sqliteResult.reader["Saturday"].ToString() == "0" ? false : true;
                    days["Sunday"]            = sqliteResult.reader["Sunday"].ToString() == "0" ? false : true;
                    scheduleItem.DaysToRecord = days;
                    scheduleItem.Repeat       = sqliteResult.reader["Repeat"].ToString() == "0" ? false : true;
                    scheduleItems.Add(scheduleItem);
                }
                SQLite.CloseConnection(sqliteResult);
            }
            else
            {
                throw new Exception(String.Format("Error in GetScheduleItem. {0}", sqliteResult.message));
            }

            return(scheduleItems);
        }