示例#1
0
        private void CreateM3uFromResults(DataTable dt, string m3uFileName, ref OperationResult op)
        {
            try
            {
                if (dt == null || dt.Rows.Count < 1)
                {
                    return;
                }

                List <string> songs = new List <string>();

                foreach (DataRow row in dt.Rows)
                {
                    songs.Add(Path.Combine((string)row["Path"], (string)row["File_Name"]));

                    BCHFileIO.WriteFullFile(m3uFileName, songs, ref op);

                    if (!op.Success)
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
                return;
            }
        }
示例#2
0
        public static void CreatePdbTable(DataTable dt, string fileName, ref OperationResult op)
        {
            string pdbTable = AddColumnRow(dt, ref op);

            if (op.Success)
            {
                pdbTable += AddDataRows(dt, ref op);
            }
            if (op.Success)
            {
                List <string> list = new List <string>();
                list.Add(pdbTable);
                BCHFileIO.WriteFullFile(fileName, list, ref op);
            }
        }
        private void CreateDbFiles(ref OperationResult op)
        {
            if (!MP3DBExists())
            {
                op.AddError("You must choose an Access 2000 to 2003 version database (mdb) file!");
                return;
            }

            try
            {
                MP3DBManager mdbmgr = new MP3DBManager();
                mdbmgr.SetDataStore(ddtbMp3DbFile.ItemText, ref op);
                if (!op.Success)
                {
                    return;
                }

                string dirName = dddtbTargetDir.ItemText;

                string        delimiter = rbtnTab.Checked ? "\t" : ",";
                List <string> tables    = new List <string> {
                    "tbFileInfo", "tbMp3Info", "tbArtist"
                };
                foreach (var table in tables)
                {
                    string sql = $"select  * from {table}";

                    List <string> data = GetTableData(sql, table, delimiter, ref op);
                    if (!op.Success)
                    {
                        return;
                    }

                    string fName = Path.Combine(dirName, $"{table}.txt");
                    BCHFileIO.WriteFullFile(fName, data, ref op);
                    if (!op.Success)
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
                rtbMessages.Text = op.GetAllErrorsAndExceptions("\n");
                return;
            }
        }
示例#4
0
        private void btnCrtMu3FrmPlyLst_Click(object sender, EventArgs e)
        {
            tbMessages.Text = "";

            OperationResult op = new OperationResult();

            try
            {
                if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1 ||
                    this.iTunesPlayLists == null || this.iTunesPlayLists.ITunesPlayLists.Count < 1)
                {
                    GetiTunesLibXml();
                }

                foreach (var pl in this.iTunesPlayLists.ITunesPlayLists)
                {
                    List <string> songs = GetPlayListSongPathsList(pl);

                    string path  = this.dddtbOutputPath.ItemText;
                    string fName = Path.Combine(path, pl.Name + ".m3u");

                    if (!string.IsNullOrWhiteSpace(dddMusicDirPath.ItemText))
                    {
                        songs = FormatSongsMusicDir(tbLibraryMusicPath.Text, songs, dddMusicDirPath.ItemText);
                    }

                    BCHFileIO.WriteFullFile(fName, songs, ref op);

                    if (!op.Success)
                    {
                        tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                tbMessages.Text = ex.Message;
                return;
            }

            tbMessages.Text = "Finished";
        }
示例#5
0
        public void CreateM3U(ref OperationResult op)
        {
            if (!IsSet)
            {
                op.AddError("M3U object not set.  You must call the \"SetM3U(string fileNameAndPath, " +
                            "ref OperationResult op)\" successfully before you can create an M3U file");
                return;
            }

            if (this.M3USongList.Count < 1)
            {
                op.AddError("There are no songs in the M3U list.  You must call the \"SetM3USongs(List<string> list, bool" +
                            "addOrReplace, ref OperationResult op)\" successfully before you can create an M3U file");
                return;
            }

            List <string> mList = new List <string>();

            //mList.Add("#EXTM3U - Created by Barry Hill's M3U Editor");
            //mList.Add("#EXTINF - ");

            mList.AddRange(this.M3USongList);

            string fname = this.M3UFileNameAndPath;

            if (!fname.EndsWith(".m3u", StringComparison.CurrentCultureIgnoreCase))
            {
                fname = fname + ".m3u";
            }

            BCHFileIO.WriteFullFile(fname, mList, ref op);

            if (!op.Success)
            {
                return;
            }

            op.AddInformation("M3U file created successfully.");
        }
示例#6
0
        public static void CreateCsvTable(DataTable dt, string fileName, ref OperationResult op, string colDelim, string rowDelim)
        {
            try
            {
                string pdbTable = AddColumnRow(dt, ref op, colDelim);

                if (op.Success)
                {
                    pdbTable += AddDataRows(dt, ref op, rowDelim);
                }
                if (op.Success)
                {
                    List <string> list = new List <string>();
                    list.Add(pdbTable);
                    BCHFileIO.WriteFullFile(fileName, list, ref op);
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
                return;
            }
        }
示例#7
0
        private void btnExportSongList_Click(object sender, EventArgs e)
        {
            if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1)
            {
                GetiTunesLibXml();
            }

            List <string> list = GetSongsList(this.iTuneSongs);

            OperationResult op = new OperationResult();

            string path  = this.dddtbOutputPath.ItemText;
            string fName = Path.Combine(path, "iTunesSongs.txt");

            BCHFileIO.WriteFullFile(fName, list, ref op);

            if (!op.Success)
            {
                tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl();
                return;
            }

            tbMessages.Text = "Finished";
        }
示例#8
0
        private void btnExportPlayLists_Click(object sender, EventArgs e)
        {
            tbMessages.Text = "";

            OperationResult op = new OperationResult();

            if (this.iTuneSongs == null || iTuneSongs.iTunesSongList.Count < 1 ||
                this.iTunesPlayLists == null || this.iTunesPlayLists.ITunesPlayLists.Count < 1)
            {
                GetiTunesLibXml();
            }

            List <Tuple <string, List <string> > > pls = GetPlayListSongsTuple();

            foreach (var kv in pls)
            {
                string path  = this.dddtbOutputPath.ItemText;
                string fName = Path.Combine(path, kv.Item1 + ".txt");

                BCHFileIO.WriteFullFile(fName, kv.Item2, ref op);

                if (!op.Success)
                {
                    tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl();
                    return;
                }
            }

            if (!op.Success)
            {
                tbMessages.Text = op.GetAllErrorsAndExceptionsWthNl();
                return;
            }

            tbMessages.Text = "Finished";
        }