Exemplo n.º 1
0
        public static MediaEvent Info(int id)
        {
            //p_info_playlist_details
            MediaEvent m = null;

            try
            {
                using (MySqlConnection conn = new MySqlConnection(App.setting.connectString))
                {
                    conn.Open();
                    string query = "`p_info_playlist_details`";
                    using (MySqlCommand cmd = new MySqlCommand(query, conn))
                    {
                        cmd.Parameters.Add(new MySqlParameter("@_id", MySqlDbType.Int32)
                        {
                            Direction = System.Data.ParameterDirection.Input, Value = id
                        });
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        var tmp = cmd.ExecuteScalar();
                        if (Convert.ToInt32(tmp) > 0)
                        {
                            using (MySqlDataReader reader = cmd.ExecuteReader())
                            {
                                m = reader.toMediaEvent();
                            }
                        }
                    };
                    conn.Close();
                };
            }
            catch (Exception)
            {
            }
            return(m);
        }
Exemplo n.º 2
0
 public static int Insert(MediaEvent media)
 {
     //p_insert_playlist_details
     try
     {
         using (MySqlConnection conn = new MySqlConnection(App.setting.connectString))
         {
             conn.Open();
             string query = "`p_insert_playlist_details`";
             using (MySqlCommand cmd = new MySqlCommand(query, conn))
             {
                 cmd.Parameters.Add(new MySqlParameter("@_playlist_id", MySqlDbType.Int32)
                 {
                     Direction = System.Data.ParameterDirection.Input, Value = media.playlist_id
                 });
                 cmd.Parameters.Add(new MySqlParameter("@_media_id", MySqlDbType.Int32)
                 {
                     Direction = System.Data.ParameterDirection.Input, Value = media.media_id
                 });
                 cmd.Parameters.Add(new MySqlParameter("@_time_begin", MySqlDbType.Time)
                 {
                     Direction = System.Data.ParameterDirection.Input, Value = media.TimeBegin
                 });
                 cmd.Parameters.Add(new MySqlParameter("@_time_end", MySqlDbType.Time)
                 {
                     Direction = System.Data.ParameterDirection.Input, Value = media.TimeEnd
                 });
                 cmd.CommandType = System.Data.CommandType.StoredProcedure;
                 cmd.ExecuteScalar();
             };
             conn.Close();
         };
         return(1);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
 public static List<MediaEvent> toMediaEvents(this MySqlDataReader reader)
 {
     if (reader.HasRows)
     {
         List<MediaEvent> datas = new List<MediaEvent>();
         while (reader.Read())
         {
             if (!reader.IsDBNull(0))
             {
                 MediaEvent d = new MediaEvent();
                 d.ID = reader.GetInt32(Define.detail_id);
                 d.media_id = reader.GetInt32(Define.media_id);
                 d.playlist_id = reader.GetInt32(Define.playlist_id);
                 d.TimeBegin = reader.GetTimeSpan(Define.time_begin);
                 d.TimeEnd = reader.GetTimeSpan(Define.time_end);
                 d.Time = reader.GetDateTime(Define.detail_date);
                 datas.Add(d);
             }
         }
         return datas;
     }
     return null;
 }
        public static int Insert(MediaEvent media)
        {
            //p_insert_playlist_details
            try
            {
                using (MySqlConnection conn = new MySqlConnection(App.setting.connectString))
                {
                    conn.Open();
                    string query = "`p_insert_playlist_details`";
                    using (MySqlCommand cmd = new MySqlCommand(query, conn))
                    {
                        cmd.Parameters.Add(new MySqlParameter("@_playlist_id", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = media.playlist_id });
                        cmd.Parameters.Add(new MySqlParameter("@_media_id", MySqlDbType.Int32) { Direction = System.Data.ParameterDirection.Input, Value = media.media_id });
                        cmd.Parameters.Add(new MySqlParameter("@_time_begin", MySqlDbType.Time) { Direction = System.Data.ParameterDirection.Input, Value = media.TimeBegin });
                        cmd.Parameters.Add(new MySqlParameter("@_time_end", MySqlDbType.Time) { Direction = System.Data.ParameterDirection.Input, Value = media.TimeEnd });
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.ExecuteScalar();

                    };
                    conn.Close();
                };
                return 1;
            }
            catch (Exception)
            {
                return -1;
            }
        }