Exemplo n.º 1
0
 public bool Add(WfFileItem f)
 {
     try
     {
         long lastPlay = f.LastPlayDate == DateTime.MinValue ? 0 : f.LastPlayDate.ToFileTimeUtc();
         mCmd.CommandText = $"INSERT INTO t_playlist (path,date,size,mark,rating,lastPlay,playCount,trimming,aspect) "
                            + $"VALUES('{f.FullPath}','{f.Date.ToFileTimeUtc()}','{f.Size}','{f.Mark}','{(int)f.Rating}','{lastPlay}','{f.PlayCount}','0', '{(long)f.Aspect}')";
         return(1 == mCmd.ExecuteNonQuery());
     }
     catch (SQLiteException)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
            private bool ReadOne(SQLiteDataReader reader, out WfFileItem rec)
            {
                rec = null;
                if (!reader.Read())
                {
                    return(false);
                }
                var  path   = Convert.ToString(reader["path"]);
                bool exists = true;

                if (mUpdateExistsFlag)
                {
                    exists = File.Exists(path);
                }
                long     lastPlay     = Convert.ToInt64(reader["lastPlay"]);
                DateTime lastPlayDate = (lastPlay == 0) ? DateTime.MinValue : DateTime.FromFileTimeUtc(lastPlay);

                WfFileItem.Trim trim      = WfFileItem.Trim.NoTrim;
                var             rawTrimId = reader["trim_id"];
                long            trimId    = !(rawTrimId is DBNull) ? Convert.ToInt64(rawTrimId) : 0;

                //if (!(rawTrimId is DBNull)) {
                //    long trimId = Convert.ToInt64(rawTrimId);
                //    if (trimId > 0) {
                //        try {
                //            trim = new WfFileItem.Trim(trimId, Convert.ToString(reader["trim_name"]),
                //                Convert.ToInt64(reader["prologue"]),
                //                Convert.ToInt64(reader["epilogue"]),
                //                refPath: "");
                //        } catch (SQLiteException) {
                //            trim = WfFileItem.Trim.NoTrim;
                //        }
                //    }
                //}
                rec = new WfFileItem(
                    path,
                    Convert.ToInt64(reader["size"]),
                    DateTime.FromFileTimeUtc(Convert.ToInt64(reader["date"])),
                    Convert.ToString(reader["mark"]),
                    (Ratings)Convert.ToInt32(reader["rating"]),
                    exists,
                    lastPlayDate,
                    Convert.ToInt32(reader["playCount"]),
                    trimId,
                    (WfAspect)Convert.ToInt32(reader["aspect"]),
                    Convert.ToInt64(reader["trim_start"]),
                    Convert.ToInt64(reader["trim_end"])
                    );
                return(true);
            }
Exemplo n.º 3
0
 public void UpdatePlaylistItem(WfFileItem item, long flags)
 {
     if (flags == 0)
     {
         return;
     }
     using (var cmd = mDB.CreateCommand()) {
         var  sql  = new StringBuilder("UPDATE t_playlist SET ");
         bool prev = false;
         if (0 != (flags & (long)FieldFlag.MARK))
         {
             sql.Append($"mark='{item.Mark}' "); prev = true;
         }
         if (0 != (flags & (long)FieldFlag.RATING))
         {
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"rating='{(int)item.Rating}' "); prev = true;
         }
         if (0 != (flags & (long)FieldFlag.PLAY_COUNT))
         {
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"playCount='{item.PlayCount} '"); prev = true;
         }
         if (0 != (flags & (long)FieldFlag.LAST_PLAY))
         {
             long tm = item.LastPlayDate == DateTime.MinValue ? 0 : item.LastPlayDate.ToFileTimeUtc();
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"lastPlay='{tm}' "); prev = true;
         }
         //if (0 != (flags & (long)FieldFlag.TRIMMING))
         //{
         //    if (prev) sql.Append(", ");
         //    sql.Append($"trimming='{item.Trimming.Id}' "); prev = true;
         //}
         if (0 != (flags & (long)FieldFlag.ASPECT))
         {
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"aspect='{(long)item.Aspect}' "); prev = true;
         }
         if (0 != (flags & (long)FieldFlag.TRIM_START))
         {
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"trim_start='{item.TrimStart}' "); prev = true;
         }
         if (0 != (flags & (long)FieldFlag.TRIM_END))
         {
             if (prev)
             {
                 sql.Append(", ");
             }
             sql.Append($"trim_end='{item.TrimEnd}' "); prev = true;
         }
         sql.Append($" WHERE path='{item.FullPath}'");
         executeSql(sql.ToString());
     }
 }