本文整理汇总了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);
}
示例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;
}
示例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"
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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());
}
示例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
};
}
示例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
};
}
示例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
};
}
}
示例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);
}
}
}
示例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
};
}
示例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;
}
}
示例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;
}
}