• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Sync.SyncTarget类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MediaBrowser.Model.Sync.SyncTarget的典型用法代码示例。如果您正苦于以下问题:C# SyncTarget类的具体用法?C# SyncTarget怎么用?C# SyncTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyncTarget类属于MediaBrowser.Model.Sync命名空间,在下文中一共展示了SyncTarget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Sync

        public async Task Sync(IServerSyncProvider provider,
            ISyncDataProvider dataProvider,
            SyncTarget target,
            IProgress<double> progress,
            CancellationToken cancellationToken)
        {
            var serverId = _appHost.SystemId;
            var serverName = _appHost.FriendlyName;

            await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
            progress.Report(3);

            var innerProgress = new ActionableProgress<double>();
            innerProgress.RegisterAction(pct =>
            {
                var totalProgress = pct * .97;
                totalProgress += 1;
                progress.Report(totalProgress);
            });
            await GetNewMedia(provider, dataProvider, target, serverId, serverName, innerProgress, cancellationToken);

            // Do the data sync twice so the server knows what was removed from the device
            await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
            
            progress.Report(100);
        }
开发者ID:RavenB,项目名称:Emby,代码行数:26,代码来源:MediaSync.cs


示例2: RequestFactory

        /// <summary>
        /// Default ctor.
        /// </summary>
        public RequestFactory(SyncTarget target, string accessToken)
        {
            var config = PluginConfiguration.Configuration;

            this.syncAccount = config.SyncAccounts.FirstOrDefault(x => x.Id == target.Id);
            this.accessToken = accessToken;
        }
开发者ID:heksesang,项目名称:Emby.Plugins,代码行数:10,代码来源:RequestFactory.cs


示例3: GetQualityOptions

 public IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target)
 {
     return new List<SyncQualityOption>
     {
         new SyncQualityOption
         {
             Name = "Original",
             Id = "original",
             Description = "Syncs original files as-is, regardless of whether the device is capable of playing them or not."
         },
         new SyncQualityOption
         {
             Name = "High",
             Id = "high",
             IsDefault = true
         },
         new SyncQualityOption
         {
             Name = "Medium",
             Id = "medium"
         },
         new SyncQualityOption
         {
             Name = "Low",
             Id = "low"
         }
     };
 }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:28,代码来源:AppSyncProvider.cs


示例4: GetDeviceProfile

        public DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality)
        {
            var caps = _deviceManager.GetCapabilities(target.Id);

            var deviceProfile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
            deviceProfile.MaxStaticBitrate = SyncHelper.AdjustBitrate(deviceProfile.MaxStaticBitrate, quality);

            return deviceProfile;
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:9,代码来源:AppSyncProvider.cs


示例5: OneDriveCredentials

        public OneDriveCredentials(IConfigurationRetriever configurationRetriever, ILiveAuthenticationApi liveAuthenticationApi, SyncTarget target)
        {
            _configurationRetriever = configurationRetriever;
            _liveAuthenticationApi = liveAuthenticationApi;
            _syncAccountId = target.Id;

            var syncAccount = configurationRetriever.GetSyncAccount(target.Id);
            _accessToken = syncAccount.AccessToken;
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:9,代码来源:OneDriveCredentials.cs


示例6: FindSyncJob

        public OneDriveSyncJob FindSyncJob(SyncTarget target, string localPath, string hash)
        {
            var syncJob = SyncJobs.FirstOrDefault(x => x.Target == target && x.LocalPath == localPath && x.Hash == hash);

            if (syncJob != null && syncJob.ExpirationDateTime < DateTime.Now)
            {
                RemoveSyncJob(syncJob);
                syncJob = null;
            }

            return syncJob;
        }
开发者ID:heksesang,项目名称:Emby.Plugins,代码行数:12,代码来源:PluginConfiguration.cs


示例7: SendFile

        public async Task<SyncedFileInfo> SendFile(Stream stream, string[] remotePath, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
        {
            var fullPath = GetFullPath(remotePath, target);

            _fileSystem.CreateDirectory(Path.GetDirectoryName(fullPath));

            _logger.Debug("Folder sync saving stream to {0}", fullPath);

            using (var fileStream = _fileSystem.GetFileStream(fullPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
            {
                await stream.CopyToAsync(fileStream).ConfigureAwait(false);
                return GetSyncedFileInfo(fullPath);
            }
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:14,代码来源:SyncProvider.cs


示例8: GetFullPath

        public string GetFullPath(IEnumerable<string> paths, SyncTarget target)
        {
            var account = GetSyncAccounts()
                .FirstOrDefault(i => string.Equals(i.Id, target.Id, StringComparison.OrdinalIgnoreCase));

            if (account == null)
            {
                throw new ArgumentException("Invalid SyncTarget supplied.");
            }

            var list = paths.ToList();
            list.Insert(0, account.Path);

            return Path.Combine(list.ToArray());
        }
开发者ID:jvanhie,项目名称:Emby.Plugins,代码行数:15,代码来源:SyncProvider.cs


示例9: GetSyncedFileInfo

        public async Task<SyncedFileInfo> GetSyncedFileInfo(string id, SyncTarget target, CancellationToken cancellationToken)
        {
            _logger.Debug("Getting synced file info for {0} from {1}", id, target.Name);

            var googleCredentials = GetGoogleCredentials(target);

            var url = await _googleDriveService.CreateDownloadUrl(id, googleCredentials, cancellationToken).ConfigureAwait(false);

            return new SyncedFileInfo
            {
                Path = url,
                Protocol = MediaProtocol.Http,
                Id = id
            };
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:15,代码来源:GoogleDriveServerSyncProvider.cs


示例10: SendFile

        public async Task<SyncedFileInfo> SendFile(Stream stream, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
        {
            var path = GetFullPath(pathParts, target);
            _logger.Debug("Sending file {0} to {1}", path, target.Name);

            var syncAccount = _configurationRetriever.GetSyncAccount(target.Id);

            await UploadFile(path, stream, syncAccount.AccessToken, cancellationToken);

            return new SyncedFileInfo
            {
                Id = path,
                Path = path,
                Protocol = MediaProtocol.Http
            };
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:16,代码来源:DropboxServerSyncProvider.cs


示例11: SendFile

        public async Task<SyncedFileInfo> SendFile(Stream stream, string[] remotePath, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
        {
            var fullPath = GetFullPath(remotePath, target);

            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            using (var fileStream = _fileSystem.GetFileStream(fullPath, FileMode.Create, FileAccess.Write, FileShare.Read, true))
            {
                await stream.CopyToAsync(fileStream).ConfigureAwait(false);
                return new SyncedFileInfo
                {
                    Path = fullPath,
                    Protocol = MediaProtocol.File,
                    Id = fullPath
                };
            }
        }
开发者ID:jvanhie,项目名称:Emby.Plugins,代码行数:16,代码来源:SyncProvider.cs


示例12: SyncData

        private async Task SyncData(IServerSyncProvider provider,
            ISyncDataProvider dataProvider,
            string serverId,
            SyncTarget target,
            CancellationToken cancellationToken)
        {
            var localItems = await dataProvider.GetLocalItems(target, serverId).ConfigureAwait(false);
            var remoteFiles = await provider.GetFiles(new FileQuery(), target, cancellationToken).ConfigureAwait(false);
            var remoteIds = remoteFiles.Items.Select(i => i.Id).ToList();

            var jobItemIds = new List<string>();

            foreach (var localItem in localItems)
            {
                // TODO: Remove this after a while
                if (string.IsNullOrWhiteSpace(localItem.FileId))
                {
                    jobItemIds.Add(localItem.SyncJobItemId);
                }
                else if (remoteIds.Contains(localItem.FileId, StringComparer.OrdinalIgnoreCase))
                {
                    jobItemIds.Add(localItem.SyncJobItemId);
                }
            }

            var result = await _syncManager.SyncData(new SyncDataRequest
            {
                TargetId = target.Id,
                SyncJobItemIds = jobItemIds

            }).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            foreach (var itemIdToRemove in result.ItemIdsToRemove)
            {
                try
                {
                    await RemoveItem(provider, dataProvider, serverId, itemIdToRemove, target, cancellationToken).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error deleting item from device. Id: {0}", ex, itemIdToRemove);
                }
            }
        }
开发者ID:redteamcpu,项目名称:Emby,代码行数:46,代码来源:MediaSync.cs


示例13: SendFile

        public async Task<SyncedFileInfo> SendFile(Stream stream, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
        {
            _logger.Debug("Sending file {0} to {1}", string.Join("/", pathParts), target.Name);

            var syncAccount = _configurationRetriever.GetSyncAccount(target.Id);

            var googleCredentials = GetGoogleCredentials(target);

            var file = await _googleDriveService.UploadFile(stream, pathParts, syncAccount.FolderId, googleCredentials, progress, cancellationToken);

            return new SyncedFileInfo
            {
                Path = file.Item2,
                Protocol = MediaProtocol.Http,
                Id = file.Item1
            };
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:17,代码来源:GoogleDriveServerSyncProvider.cs


示例14: GetSyncedFileInfo

        public async Task<SyncedFileInfo> GetSyncedFileInfo(string id, SyncTarget target, CancellationToken cancellationToken)
        {
            _logger.Debug("Getting synced file info for {0} from {1}", id, target.Name);

            try
            {
                return await TryGetSyncedFileInfo(id, target, cancellationToken);
            }
            catch (HttpException ex)
            {
                if (ex.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new FileNotFoundException("File not found", ex);
                }

                throw;
            }
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:18,代码来源:DropboxServerSyncProvider.cs


示例15: DeleteFile

        public async Task DeleteFile(string id, SyncTarget target, CancellationToken cancellationToken)
        {
            try
            {
                var oneDriveCredentials = CreateOneDriveCredentials(target);

                await _oneDriveApi.Delete(id, oneDriveCredentials, cancellationToken);
            }
            catch (HttpException ex)
            {
                if (ex.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new FileNotFoundException("File not found", ex);
                }

                throw;
            }
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:18,代码来源:OneDriveServerSyncProvider.cs


示例16: SendFile

        public async Task<SyncedFileInfo> SendFile(Stream stream, string[] pathParts, SyncTarget target, IProgress<double> progress, CancellationToken cancellationToken)
        {
            string path = GetFullPath(pathParts);
            _logger.Debug("Sending file {0} to {1}", path, target.Name);

            var oneDriveCredentials = CreateOneDriveCredentials(target);

            await CreateFolderHierarchy(pathParts, oneDriveCredentials, cancellationToken);

            var uploadSession = await _oneDriveApi.CreateUploadSession(path, oneDriveCredentials, cancellationToken);
            var id = await UploadFile(uploadSession.uploadUrl, stream, oneDriveCredentials, cancellationToken);

            return new SyncedFileInfo
            {
                Id = id,
                Path = path,
                Protocol = MediaProtocol.Http
            };
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:19,代码来源:OneDriveServerSyncProvider.cs


示例17: GetFiles

        public Task<QueryResult<FileSystemMetadata>> GetFiles(string id, SyncTarget target, CancellationToken cancellationToken)
        {
            var account = GetSyncAccounts()
                .FirstOrDefault(i => string.Equals(i.Id, target.Id, StringComparison.OrdinalIgnoreCase));

            if (account == null)
            {
                throw new ArgumentException("Invalid SyncTarget supplied.");
            }

            var result = new QueryResult<FileSystemMetadata>();

            var file = _fileSystem.GetFileSystemInfo(id);

            if (file.Exists)
            {
                result.TotalRecordCount = 1;
                result.Items = new[] { file }.ToArray();
            }

            return Task.FromResult(result);
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:22,代码来源:SyncProvider.cs


示例18: DeleteFile

        public Task DeleteFile(string id, SyncTarget target, CancellationToken cancellationToken)
        {
            return Task.Run(() =>
            {
                File.Delete(id);

                var account = GetSyncAccounts()
                    .FirstOrDefault(i => string.Equals(i.Id, target.Id, StringComparison.OrdinalIgnoreCase));

                if (account != null)
                {
                    try
                    {
                        DeleteEmptyFolders(account.Path);
                    }
                    catch
                    {
                    }
                }

            }, cancellationToken);
        }
开发者ID:jvanhie,项目名称:Emby.Plugins,代码行数:22,代码来源:SyncProvider.cs


示例19: AddMediaSource

        private void AddMediaSource(List<MediaSourceInfo> list,
            LocalItem item,
            MediaSourceInfo mediaSource,
            IServerSyncProvider provider,
            SyncTarget target)
        {
            SetStaticMediaSourceInfo(item, mediaSource);

            var requiresDynamicAccess = provider as IHasDynamicAccess;

            if (requiresDynamicAccess != null)
            {
                mediaSource.RequiresOpening = true;

                var keyList = new List<string>();
                keyList.Add(provider.GetType().FullName.GetMD5().ToString("N"));
                keyList.Add(target.Id.GetMD5().ToString("N"));
                keyList.Add(item.Id);
                mediaSource.OpenToken = string.Join(StreamIdDelimeterString, keyList.ToArray());
            }

            list.Add(mediaSource);
        }
开发者ID:ratanparai,项目名称:Emby,代码行数:23,代码来源:SyncedMediaSourceProvider.cs


示例20: GetQualityOptions

        private IEnumerable<SyncQualityOption> GetQualityOptions(ISyncProvider provider, SyncTarget target, User user)
        {
            var hasQuality = provider as IHasSyncQuality;
            if (hasQuality != null)
            {
                var options = hasQuality.GetQualityOptions(target);

                if (user != null && !user.Policy.EnableSyncTranscoding)
                {
                    options = options.Where(i => i.IsOriginalQuality);
                }

                return options;
            }

            // Default options for providers that don't override
            return new List<SyncQualityOption>
            {
                new SyncQualityOption
                {
                    Name = "High",
                    Id = "high",
                    IsDefault = true
                },
                new SyncQualityOption
                {
                    Name = "Medium",
                    Id = "medium"
                },
                new SyncQualityOption
                {
                    Name = "Low",
                    Id = "low"
                },
                new SyncQualityOption
                {
                    Name = "Custom",
                    Id = "custom"
                }
            };
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:41,代码来源:SyncManager.cs



注:本文中的MediaBrowser.Model.Sync.SyncTarget类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ViewModels.ItemListViewModel类代码示例发布时间:2022-05-26
下一篇:
C# Querying.ItemQuery类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap