Beispiel #1
0
        private String determineNewShowName(ShowList showList, DownloadShow downloadShow)
        {
            String baseFileName = DriveInfo.CheckFileName(downloadShow.DataFileName.ToString());
            String fileExt      = FileUtil.DetermineFileExtFromURL(downloadShow.ShowURL.ToString());

            if (fileExt == null)
            {
                fileExt = "";
            }

            if (baseFileName.Length + fileExt.Length > DataFileNameMaxLen)
            {
                baseFileName = baseFileName.Substring(0, DataFileNameMaxLen - fileExt.Length);
            }

            int    count        = 2;
            String testFileName = baseFileName + fileExt;

            while (true)
            {
                if (!showList.ContainsByDataFileName(testFileName))
                {
                    return(testFileName);
                }

                String postfix = String.Format(" ({0})", count++);

                if (baseFileName.Length + postfix.Length + fileExt.Length > DataFileNameMaxLen)
                {
                    baseFileName = baseFileName.Substring(0, DataFileNameMaxLen - postfix.Length - fileExt.Length);
                }
                testFileName = baseFileName + postfix + fileExt;
            }
        }
Beispiel #2
0
        //Create Show from DownloadShow
        private void AddDownloadShowToList(ShowList showList, DownloadShow downloadShow)
        {
            Show show = Show.NewInstance(downloadShow.RentedShowID);

            show.ShowURL        = downloadShow.ShowURL;
            show.DataFileName   = new TString(determineNewShowName(showList, downloadShow));
            show.DownloadStatus = DownloadStatus.NotStarted;

            showList.Add(show);
        }