private Task <IIngestManifestAsset> CreateAsync(IIngestManifest ingestManifest, IAsset asset, CancellationToken token, Action <IngestManifestAssetData> continueWith) { IngestManifestCollection.VerifyManifest(ingestManifest); IMediaDataServiceContext dataContext = MediaContext.MediaServicesClassFactory.CreateDataServiceContext(); var data = new IngestManifestAssetData { ParentIngestManifestId = ingestManifest.Id }; dataContext.AddObject(IngestManifestAssetCollection.EntitySet, data); dataContext.AttachTo(AssetCollection.AssetSet, asset); dataContext.SetLink(data, "Asset", asset); MediaRetryPolicy retryPolicy = this.MediaContext.MediaServicesClassFactory.GetSaveChangesRetryPolicy(); Task <IIngestManifestAsset> task = retryPolicy.ExecuteAsync <IMediaDataServiceResponse>(() => dataContext.SaveChangesAsync(data)) .ContinueWith <IIngestManifestAsset>(t => { t.ThrowIfFaulted(); token.ThrowIfCancellationRequested(); IngestManifestAssetData ingestManifestAsset = (IngestManifestAssetData)t.Result.AsyncState; continueWith(ingestManifestAsset); return(ingestManifestAsset); }, TaskContinuationOptions.ExecuteSynchronously); return(task); }
/// <summary> /// Initializes a new instance of the <see cref="IngestManifestFileCollection"/> class. /// </summary> /// <param name="cloudMediaContext">The <seealso cref="CloudMediaContext"/> instance.</param> /// <param name="parentIngestManifestAsset">The parent manifest asset.</param> internal IngestManifestFileCollection(CloudMediaContext cloudMediaContext, IIngestManifestAsset parentIngestManifestAsset) { this._cloudMediaContext = cloudMediaContext; this._dataContext = this._cloudMediaContext.DataContextFactory.CreateDataServiceContext(); this._query = new Lazy <IQueryable <IIngestManifestFile> >(() => this._dataContext.CreateQuery <IngestManifestFileData>(EntitySet)); if (parentIngestManifestAsset != null) { this._parentIngestManifestAsset = (IngestManifestAssetData)parentIngestManifestAsset; } }
/// <summary> /// Initializes a new instance of the <see cref="IngestManifestFileCollection"/> class. /// </summary> /// <param name="mediaContext"></param> /// <param name="parentIngestManifestAsset">The parent manifest asset.</param> internal IngestManifestFileCollection(MediaContextBase mediaContext, IIngestManifestAsset parentIngestManifestAsset) : base(mediaContext) { MediaServicesClassFactory factory = this.MediaContext.MediaServicesClassFactory; this._query = new Lazy <IQueryable <IIngestManifestFile> >(() => factory.CreateDataServiceContext().CreateQuery <IIngestManifestFile, IngestManifestFileData>(EntitySet)); if (parentIngestManifestAsset != null) { this._parentIngestManifestAsset = (IngestManifestAssetData)parentIngestManifestAsset; } }