GetFromId() 공개 정적인 메소드

public static GetFromId ( System.Guid pluginId ) : Provider
pluginId System.Guid
리턴 Provider
예제 #1
0
        /// <summary>
        /// Build an ErrorReporting object from the data in this exception ready to send to the server.
        /// </summary>
        /// <returns>An ErrorReporting object containing information about the provider exception.</returns>
        public ErrorReporting BuildReport()
        {
            Exception provExp = this.InnerException;

            provExp.Data.Add("Provider", Provider.GetFromId(this.ProviderId).ToString());

            ErrorReporting report = new ErrorReporting(Provider.GetFromId(this.ProviderId).Class, provExp);

            return(report);
        }
예제 #2
0
 public static Panel GetFindNewPanel(Guid pluginID, object view)
 {
     if (Provider.Exists(pluginID))
     {
         findNewPluginInst = Provider.GetFromId(pluginID).CreateInstance();
         findNewPluginInst.FindNewException  += FindNewPluginInst_FindNewException;
         findNewPluginInst.FindNewViewChange += FindNewPluginInst_FindNewViewChange;
         findNewPluginInst.FoundNew          += FindNewPluginInst_FoundNew;
         return(findNewPluginInst.GetFindNewPanel(view));
     }
     else
     {
         return(new Panel());
     }
 }
예제 #3
0
        private void DownloadProgThread()
        {
            if (this.Progress != null)
            {
                // Raise a progress event to give the user some feedback
                this.Progress(this.episodeInfo.Epid, 0, ProgressType.Downloading);
            }

            if (!Provider.Exists(this.pluginId))
            {
                this.DownloadError(ErrorType.LocalProblem, "The plugin provider required to download this episode is not currently available.  Please try updating the Radio Downloader providers or cancelling the download.");
                return;
            }

            lock (this.pluginInstanceLock)
            {
                this.pluginInstance           = Provider.GetFromId(this.pluginId).CreateInstance();
                this.pluginInstance.Progress += this.DownloadPluginInst_Progress;
            }

            string finalName, fileExtension;

            try
            {
                string saveLocation;

                try
                {
                    saveLocation = FileUtils.GetSaveFolder();
                }
                catch (DirectoryNotFoundException)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Your chosen location for saving downloaded programmes no longer exists.  Select a new one under Options -> Main Options.");
                    return;
                }

                const int FreeMb         = 250;
                ulong     availableSpace = OsUtils.PathAvailableSpace(saveLocation);

                if (availableSpace <= FreeMb * 1024 * 1024)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Your chosen location for saving downloaded programmes does not have enough free space.  Make sure that you have at least " + FreeMb.ToString(CultureInfo.CurrentCulture) + " MB free, or select a new location under Options -> Main Options.");
                    return;
                }

                try
                {
                    finalName = Model.Download.FindFreeSaveFileName(Settings.FileNameFormat, this.progInfo, this.episodeInfo, saveLocation);
                }
                catch (IOException ioExp)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Encountered an error generating the download file name.  " + ioExp.Message + "  You may need to select a new location for saving downloaded programmes under Options -> Main Options.");
                    return;
                }
                catch (UnauthorizedAccessException unAuthExp)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Encountered a permissions problem generating the download file name.  " + unAuthExp.Message + "  You may need to select a new location for saving downloaded programmes under Options -> Main Options.");
                    return;
                }

                fileExtension = this.pluginInstance.DownloadProgramme(this.progExtId, this.episodeExtId, this.providerProgInfo, this.providerEpisodeInfo, finalName);
            }
            catch (DownloadException downloadExp)
            {
                if (downloadExp.ErrorType == ErrorType.UnknownError)
                {
                    this.DownloadError(downloadExp);
                }
                else
                {
                    this.DownloadError(downloadExp.ErrorType, downloadExp.Message);
                }

                return;
            }
            catch (Exception unknownExp)
            {
                this.DownloadError(unknownExp);
                return;
            }

            if (this.cancelled)
            {
                this.cancelResponse = true;
            }

            finalName += "." + fileExtension;

            lock (Database.DbUpdateLock)
            {
                Model.Download.SetComplete(this.episodeInfo.Epid, finalName);
                Model.Programme.SetLatestDownload(this.progInfo.Progid, this.episodeInfo.Date);
            }

            // Remove single episode subscriptions
            if (Model.Subscription.IsSubscribed(this.progInfo.Progid))
            {
                if (this.progInfo.SingleEpisode)
                {
                    Model.Subscription.Remove(this.progInfo.Progid);
                }
            }

            if (!string.IsNullOrEmpty(Settings.RunAfterCommand))
            {
                try
                {
                    // Use VB Interaction.Shell as Process.Start doesn't give the option of a non-focused window
                    // The "comspec" environment variable gives the path to cmd.exe
                    Microsoft.VisualBasic.Interaction.Shell("\"" + Environment.GetEnvironmentVariable("comspec") + "\" /c " + Settings.RunAfterCommand.Replace("%file%", finalName), Microsoft.VisualBasic.AppWinStyle.NormalNoFocus);
                }
                catch
                {
                    // Just ignore the error, as it just means that something has gone wrong with the run after command.
                }
            }

            this.DownloadFinished();
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderException" /> class with a specified error message,
 /// a reference to the inner provider exception that is the cause of this exception, and the
 /// ID of the provider that is the cause of this exception.
 /// </summary>
 /// <param name="message">The message that describes the error.</param>
 /// <param name="innerException">The provider exception that is the cause of this exception.</param>
 /// <param name="pluginId">The ID of the provider that is the cause of this exception.</param>
 public ProviderException(string message, Exception innerException, Guid pluginId)
     : base(message, innerException)
 {
     this.ProviderId   = pluginId;
     this.ProviderName = Provider.GetFromId(pluginId).Name;
 }