public void Insert(FileInfo fileInfo, AudioFileInfo audioFileInfo) { Database database = (new DbFactory()).CreateDatabase(); string spName = ((new Resources()).CreateInsertSPList())[TableList.Track].ToString(); ExecuteStoredProcWithParam executeStoredProcWithParam = new ExecuteStoredProcWithParam(database, spName); executeStoredProcWithParam.AddInParameter(database, InsertValueByTableName(fileInfo.DirectoryName, TableList.Path), @"PathID"); executeStoredProcWithParam.AddInParameter(database, InsertValueByTableName(audioFileInfo.Artist, TableList.Artist), @"ArtistID"); executeStoredProcWithParam.AddInParameter(database, InsertValueByTableName(audioFileInfo.Album, TableList.Album), @"AlbumID"); executeStoredProcWithParam.AddInParameter(database, InsertValueByTableName(audioFileInfo.Genre, TableList.Genre), @"GenreID"); executeStoredProcWithParam.AddInParameter(database, InsertValueByTableName(audioFileInfo.Bitrate, TableList.Bitrate), @"BitrateID"); executeStoredProcWithParam.AddInParameter(database, audioFileInfo.Title, @"TrackTitle"); executeStoredProcWithParam.AddInParameter(database, fileInfo.Name, @"FileName"); executeStoredProcWithParam.AddInParameter(database, fileInfo.Length, @"FileSize"); string newName = string.Empty; if (string.IsNullOrEmpty(audioFileInfo.Artist) && string.IsNullOrEmpty(audioFileInfo.Title)) { newName = fileInfo.Name; } else { newName = audioFileInfo.Artist + "_" + audioFileInfo.Title; } executeStoredProcWithParam.AddInParameter(database, newName, @"NewFileName"); executeStoredProcWithParam.AddOutParameter(database, @"return_value"); executeStoredProcWithParam.ExecuteSpSetResultValue(database, @"return_value"); }
private int InsertValueByTableName(string value, TableList tableName) { Database database = (new DbFactory()).CreateDatabase(); string spName = ((new Resources()).CreateInsertSPList())[tableName].ToString(); ExecuteStoredProcWithParam executeStoredProcWithParam = new ExecuteStoredProcWithParam(database, spName); executeStoredProcWithParam.AddInParameter(database, value, @"ValueToInsert"); executeStoredProcWithParam.AddOutParameter(database, @"return_value"); return executeStoredProcWithParam.ExecuteSpSetResultValue(database, @"return_value"); }
public void ClearDataBase() { Database database = (new DbFactory()).CreateDatabase(); ExecuteStoredProcWithParam executeStoredProcWithParam = new ExecuteStoredProcWithParam( database, (new Resources().CreateSelectSPList())[TableList.ClearDataBase].ToString()); executeStoredProcWithParam.AddOutParameter(database, @"return_value"); executeStoredProcWithParam.ExecuteSpSetResultValue(database, @"return_value"); }