コード例 #1
0
        public ErrorInfoControl(DatabaseCon con, error_code error)
        {
            InitializeComponent();

            this.labelID.Content              = $"{error.error_code_id}";
            this.labelCode.Content            = $"{error.error_code1}";
            this.labelMneumonic.Content       = error.error_code_mneumonic;
            this.labelNarrative.Content       = error.narrative;
            this.labelDefaultSeverity.Content = error.severity.description;

            var apps = con.getFromBitmask <application>(error.application_ids);

            this.labelApplications.Content = string.Join(",", apps.Select(a => a.description));

            var devices = con.getFromBitmask <device_type>(error.device_ids);

            this.labelDevices.Content = string.Join(",", devices.Select(d => d.description));
        }
コード例 #2
0
ファイル: DownloadService.cs プロジェクト: lwd-temp/Popcorn
        /// <summary>
        /// Download a torrent
        /// </summary>
        /// <returns><see cref="Task"/></returns>
        public async Task Download(T media, TorrentType torrentType, MediaType mediaType, string torrentPath,
                                   int uploadLimit, int downloadLimit, IProgress <double> downloadProgress,
                                   IProgress <BandwidthRate> bandwidthRate, IProgress <int> nbSeeds, IProgress <int> nbPeers, Action buffered,
                                   Action cancelled,
                                   CancellationTokenSource cts)
        {
            Logger.Info(
                $"Start downloading : {torrentPath}");
            await Task.Run(async() =>
            {
                using (var session = new session())
                {
                    downloadProgress.Report(0d);
                    bandwidthRate.Report(new BandwidthRate
                    {
                        DownloadRate = 0d,
                        UploadRate   = 0d
                    });
                    nbSeeds.Report(0);
                    nbPeers.Report(0);
                    string savePath = string.Empty;
                    switch (mediaType)
                    {
                    case MediaType.Movie:
                        savePath = _cacheService.MovieDownloads;
                        break;

                    case MediaType.Show:
                        savePath = _cacheService.ShowDownloads;
                        break;

                    case MediaType.Unkown:
                        savePath = _cacheService.DropFilesDownloads;
                        break;
                    }

                    if (torrentType == TorrentType.File)
                    {
                        using (var addParams = new add_torrent_params
                        {
                            save_path = savePath,
                            ti = new torrent_info(torrentPath)
                        })
                            using (var handle = session.add_torrent(addParams))
                            {
                                await HandleDownload(media, mediaType, uploadLimit, downloadLimit, downloadProgress,
                                                     bandwidthRate, nbSeeds, nbPeers, handle, session, buffered, cancelled, cts);
                            }
                    }
                    else
                    {
                        var magnet = new magnet_uri();
                        using (var error = new error_code())
                        {
                            var addParams = new add_torrent_params
                            {
                                save_path = savePath,
                            };
                            magnet.parse_magnet_uri(torrentPath, addParams, error);
                            using (var handle = session.add_torrent(addParams))
                            {
                                await HandleDownload(media, mediaType, uploadLimit, downloadLimit, downloadProgress,
                                                     bandwidthRate, nbSeeds, nbPeers, handle, session, buffered, cancelled, cts);
                            }
                        }
                    }
                }
            });
        }