private OnlineDownloadManager add(IDownloadInfo info, DownloadStatus status, bool isPrior, bool isLocalDownload, string errorInfo = null)
        {
            OnlineDownloadManager down = isLocalDownload? GetDownloadManager(info) : GetDownloadManagerIgnorePath(info);

            if (down == null)
            {
                down = new OnlineDownloadManager(info, status, isLocalDownload, errorInfo);
                add(down);
                down.SetPriority(isPrior);
                _needWriting = true;
            }
            else
            {
                if (isPrior)
                {
                    down.SetPriority(isPrior);
                }
                if (!down.IsLocalDownload && isLocalDownload)
                {
                    down.DownloadToLocal(info.DownloadPath);
                }
            }
            Logger.Default.Trace($"添加下载任务:Guid: {down.GuidCode} 名称:{info.VideoName}, VideoId:{info.VideoId}, Stream:{info.StreamId}," +
                                 $" Path:{info.DownloadPath}. Begin:{info.BeginTime}, End:{info.EndTime}, " +
                                 $"SourceIp:{info.SourceIp}, SourcePort:{info.SourcePort},本地:{isLocalDownload}");
            return(down);
        }
 private void delete(OnlineDownloadManager down)
 {
     lock (_downloads)
     {
         down.ExpandChanged -= onExpandChanged;
         _downloads.Remove(down);
     }
 }
 private void updateDownloadStatus(OnlineDownloadManager down)
 {
     if (down.DownloadStatus == DownloadStatus.Deleted)
     {
         delete(down);
     }
     _needDowning = _needWriting = true;
 }
 private void onPart(OnlineDownloadManager down, string obj)
 {
     byte[] buffer = DownloadInfoPartConverter.Encode(down, obj);
     if (buffer != null)
     {
         onDownloadInfoPartChanged(buffer);
     }
 }
        private void onDownloadChanged(OnlineDownloadManager down)
        {
            var handle = DownloadAdded;

            if (handle != null)
            {
                handle(DownloadInfoExpandPacket.Encode(down));
            }
        }
 private void add(OnlineDownloadManager down)
 {
     lock (_downloads)
     {
         down.ExpandChanged += onExpandChanged;
         _downloads.Add(down);
         onDownloadChanged(down);
     }
 }
Beispiel #7
0
 private void onDownloadExpandChanged(OnlineDownloadManager download, string obj)
 {
     if (download == _download)
     {
         if (obj == nameof(download.IsLocalDownload) || obj == nameof(download.DownloadInfo))
         {
             sendDownloadPath(download);
         }
     }
 }
        private void onDownloadExpand(OnlineDownloadManager down, string obj)
        {
            switch (obj)
            {
            case nameof(down.DownloadStatus):
                updateDownloadStatus(down);
                break;

            case nameof(down.IsLocalDownload):
                _needWriting = true;
                break;

            case nameof(down.IsPrior):
                _needDowning = true;
                break;
            }
        }
 private void onExpandChanged(OnlineDownloadManager down, string obj)
 {
     onDownloadExpand(down, obj);
     onPart(down, obj);
 }