public override void Read(BinaryReader reader) { int num1 = reader.ReadInt32(); this._filePath = reader.ReadString(); this.UploadState = (OutboundAttachmentUploadState)reader.ReadInt32(); if (this.UploadState == OutboundAttachmentUploadState.Uploading) { this.UploadState = OutboundAttachmentUploadState.Failed; } this._saveVideoResponse = reader.ReadGeneric <SaveVideoResponse>(); this._guid = new Guid(reader.ReadString()); int num2 = 2; if (num1 >= num2) { this._localThumbPath = reader.ReadString(); } int num3 = 3; if (num1 < num3) { return; } this._isPrivate = reader.ReadBoolean(); this._groupId = reader.ReadInt64(); }
public override async void Upload(Action completionCallback, Action <double> progressCallback = null) { if (this.UploadState == OutboundAttachmentUploadState.Uploading) { return; } if (this.UploadState == OutboundAttachmentUploadState.Completed) { completionCallback(); } else { this.UploadState = OutboundAttachmentUploadState.Uploading; if (this._sf == null) { try { OutboundUploadVideoAttachment uploadVideoAttachment = this; StorageFile storageFile = uploadVideoAttachment._sf; StorageFile fileFromPathAsync = await StorageFile.GetFileFromPathAsync(this._filePath); uploadVideoAttachment._sf = fileFromPathAsync; uploadVideoAttachment = (OutboundUploadVideoAttachment)null; } catch { this.UploadState = OutboundAttachmentUploadState.Failed; completionCallback(); return; } } Stream stream = ((IInputStream)await this._sf.OpenAsync((FileAccessMode)0)).AsStreamForRead(); this._c = new Cancellation(); VideoService.Instance.UploadVideo(stream, this._isPrivate, 0, this._groupId, "", "", (Action <BackendResult <SaveVideoResponse, ResultCode> >)(res => { if (res.ResultCode != ResultCode.Succeeded) { this.UploadState = OutboundAttachmentUploadState.Failed; if (this._retryFlag && !this._c.IsSet) { this._retryFlag = false; this.Upload(completionCallback, progressCallback); } else { completionCallback(); } } else { if (this.UploadState == OutboundAttachmentUploadState.Completed) { return; } this.UploadState = OutboundAttachmentUploadState.Completed; this._saveVideoResponse = res.ResultData; EventAggregator.Current.Publish((object)new VideoUploaded() { guid = this._guid, SaveVidResp = this._saveVideoResponse }); completionCallback(); } }), (Action <double>)(p => { this.UploadProgress = p; if (progressCallback == null) { return; } progressCallback(p); }), this._c, null, null); } }