Exemple #1
0
        public void InsertMP3Artists(MP3FileDataType mp3, ref OperationResult op)
        {
            if (this.DataStore == null)
            {
                op.AddError("DataStore not set!");
                return;
            }

            DataStore ds = this.DataStore;

            Dictionary <string, string> parms = new Dictionary <string, string>();

            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetFileInfo_File), mp3.FileName);
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetFileInfo_Path), mp3.FilePath);

            DataTable dt = ds.ExecuteSql(ds.Conn, SqlScriptEnum.GetFileInfo, parms, ref op);

            if (!op.Success)
            {
                return;
            }

            if (dt.Rows.Count < 1)
            {
                op.AddError(mp3.FileNamePath + " mp3 file info does not exists!");
                return;
            }

            parms = new Dictionary <string, string>();
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetMP3byFilePath_File), mp3.FileName);
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetMP3byFilePath_Path), mp3.FilePath);

            dt = ds.ExecuteSql(ds.Conn, SqlScriptEnum.GetMP3byFilePath, parms, ref op);
            if (!op.Success)
            {
                return;
            }

            if (dt.Rows.Count < 1)
            {
                op.AddError(mp3.FileNamePath + " mp3 info not exists!");
                return;
            }

            int?mid = BCHUtilities.GetInteger(dt.Rows[0]["Mp3Info_Id"].ToString());

            foreach (string artist in mp3.Artists)
            {
                parms = new Dictionary <string, string>();
                parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetArtist_File), mp3.FileName);
                parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetArtist_Path), mp3.FilePath);
                parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetArtist_Artist), artist.Trim());

                dt = ds.ExecuteSql(ds.Conn, SqlScriptEnum.GetArtist, parms, ref op);
                if (!op.Success)
                {
                    return;
                }

                if (dt.Rows.Count > 0)
                {
                    op.AddError(mp3.FileNamePath + ", Artist: " + artist + " mp3 already exists!");
                    break;
                }

                parms = new Dictionary <string, string>();
                parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertArtist_Mp3Info_Id), mid.ToString());
                parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertArtist_Artist), string.IsNullOrEmpty(artist.Trim()) ? null : artist.Trim());

                ds.ExecuteSql(ds.Conn, SqlScriptEnum.InsertArtist, parms, ref op);
                if (!op.Success)
                {
                    return;
                }
            }
        }
Exemple #2
0
        public void InsertMP3Info(MP3FileDataType mp3, ref OperationResult op)
        {
            if (this.DataStore == null)
            {
                op.AddError("DataStore not set!");
                return;
            }

            SetConnection(ref op);

            if (!op.Success)
            {
                return;
            }

            DataStore ds = this.DataStore;

            Dictionary <string, string> parms = new Dictionary <string, string>();

            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetFileInfo_File), mp3.FileName);
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetFileInfo_Path), mp3.FilePath);

            DataTable dt = ds.ExecuteSql(ds.Conn, SqlScriptEnum.GetFileInfo, parms, ref op);

            if (!op.Success)
            {
                return;
            }

            if (dt.Rows.Count < 1)
            {
                op.AddError(mp3.FileNamePath + " mp3 file info does not exists!");
                return;
            }

            int?fid = BCHUtilities.GetInteger(dt.Rows[0]["FileInfo_Id"].ToString());

            parms = new Dictionary <string, string>();
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetMP3byFilePath_File), mp3.FileName);
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.GetMP3byFilePath_Path), mp3.FilePath);

            dt = ds.ExecuteSql(ds.Conn, SqlScriptEnum.GetMP3byFilePath, parms, ref op);
            if (!op.Success)
            {
                return;
            }

            if (dt.Rows.Count > 0)
            {
                op.AddError(mp3.FileNamePath + " mp3 already exists!");
                return;
            }


            parms = new Dictionary <string, string>();
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Album), string.IsNullOrEmpty(mp3.Album) ? null : mp3.Album.Trim());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Comments), string.IsNullOrEmpty(mp3.Comments) ? null : mp3.Comments.Trim());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_FileInfo_Id), fid.ToString());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Genre), string.IsNullOrEmpty(mp3.Genre) ? null : mp3.Genre.Trim());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Song_Numeraton), string.IsNullOrEmpty(mp3.SongNumeration) ? null : mp3.SongNumeration.Trim());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Song_Tile), string.IsNullOrEmpty(mp3.SongTitle) ? null : mp3.SongTitle.Trim());
            parms.Add(ds.GetSqlScriptParam(SqlParamScriptEnum.InsertMP3_Track), mp3.Track == null ? null : mp3.Track.ToString());

            ds.ExecuteSql(ds.Conn, SqlScriptEnum.InsertMP3, parms, ref op);
            if (!op.Success)
            {
                return;
            }
        }