当前位置: 首页>>代码示例>>C#>>正文


C# Sync.SyncTarget类代码示例

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


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


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