示例#1
0
        public bool DoDownloadsFg(bool showProgress, bool showMsgBox, ICollection <SeriesSpecifier> shows)
        {
            if (TVSettings.Instance.OfflineMode)
            {
                return(true); // don't do internet in offline mode!
            }

            Logger.Info("Doing downloads in the foreground...");

            StartBgDownloadThread(true, shows, showMsgBox);

            const int DELAY_STEP = 100;
            int       count      = 1000 / DELAY_STEP; // one second

            while ((count-- > 0) && (!DownloadDone))
            {
                Thread.Sleep(DELAY_STEP);
            }

            if (!DownloadDone && showProgress) // downloading still going on, so time to show the dialog if we're not in /hide mode
            {
                DownloadProgress dp = new DownloadProgress(this);
                dp.ShowDialog();
                dp.Update();
            }

            WaitForBgDownloadDone();

            //TheTVDB.Instance.SaveCache();

            if (!downloadOk)
            {
                Logger.Warn(TheTVDB.Instance.LastError);
                if (showErrorMsgBox)
                {
                    CannotConnectForm ccform   = new CannotConnectForm("Error while downloading", TheTVDB.Instance.LastError);
                    DialogResult      ccresult = ccform.ShowDialog();
                    if (ccresult == DialogResult.Abort)
                    {
                        TVSettings.Instance.OfflineMode = true;
                    }
                }

                TheTVDB.Instance.LastError = "";
            }

            return(downloadOk);
        }
示例#2
0
        public bool DoDownloadsFG(bool showProgress, bool showErrorMsgBox, ICollection <int> shows)
        {
            if (TVSettings.Instance.OfflineMode)
            {
                return(true); // don't do internet in offline mode!
            }
            logger.Info("Doing downloads in the foreground...");

            this.StartBGDownloadThread(true, shows);

            const int delayStep = 100;
            int       count     = 1000 / delayStep; // one second

            while ((count-- > 0) && (!this.DownloadDone))
            {
                System.Threading.Thread.Sleep(delayStep);
            }

            if (!this.DownloadDone && showProgress) // downloading still going on, so time to show the dialog if we're not in /hide mode
            {
                DownloadProgress dp = new DownloadProgress(this);
                dp.ShowDialog();
                dp.Update();
            }

            this.WaitForBGDownloadDone();

            TheTVDB.Instance.SaveCache();

            if (!this.DownloadOK)
            {
                logger.Warn(TheTVDB.Instance.LastError);
                if (showErrorMsgBox)
                {
                    MessageBox.Show(TheTVDB.Instance.LastError, "Error while downloading", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                TheTVDB.Instance.LastError = "";
            }

            return(this.DownloadOK);
        }
示例#3
0
文件: TVDoc.cs 项目: mudboy/tvrename
        public bool DoDownloadsFG()
        {
            if (this.Settings.OfflineMode)
                return true; // don't do internet in offline mode!

            this.StartBGDownloadThread(true);

            const int delayStep = 100;
            int count = 1000 / delayStep; // one second
            while ((count-- > 0) && (!this.DownloadDone))
                System.Threading.Thread.Sleep(delayStep);

            if (!this.DownloadDone && !this.Args.Hide) // downloading still going on, so time to show the dialog if we're not in /hide mode
            {
                DownloadProgress dp = new DownloadProgress(this);
                dp.ShowDialog();
                dp.Update();
            }

            this.WaitForBGDownloadDone();

            this.GetTVDB(false, "").SaveCache();

            this.GenDict();

            if (!this.DownloadOK)
            {
                if (!this.Args.Unattended)
                    MessageBox.Show(this.mTVDB.LastError, "Error while downloading", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.mTVDB.LastError = "";
            }

            return this.DownloadOK;
        }