private void OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
        {
            PropertyDescriptor dropboxSessionProperty = faultContext.DataContext.GetProperties()[DropboxSessionPropertyName];
            IDropboxSession    dropboxSession         = dropboxSessionProperty?.GetValue(faultContext.DataContext) as IDropboxSession;

            dropboxSession?.Dispose();
        }
        protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken)
        {
            IDropboxSession dropboxSession = new DropboxSession(AuthToken.Get(context));

            return((nativeActivityContext) =>
            {
                if (Body != null)
                {
                    _dropboxSession = dropboxSession;
                    nativeActivityContext.ScheduleAction(Body, dropboxSession, OnCompleted, OnFaulted);
                }
            });
        }
Exemple #3
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            PropertyDescriptor dropboxSessionFactory = context.DataContext.GetProperties()[WithDropboxSession.DropboxSessionPropertyName];
            IDropboxSession    dropboxSession        = dropboxSessionFactory?.GetValue(context.DataContext) as IDropboxSession;

            if (dropboxSession == null)
            {
                throw new InvalidOperationException(Resources.DropboxSessionNotFoundException);
            }

            await dropboxSession.CreateFolderAsync(FolderPath.Get(context), cancellationToken);

            return((asyncCodeActivityContext) => { });
        }
Exemple #4
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            PropertyDescriptor dropboxSessionProperty = context.DataContext.GetProperties()[WithDropboxSession.DropboxSessionPropertyName];
            IDropboxSession    dropboxSession         = dropboxSessionProperty?.GetValue(context.DataContext) as IDropboxSession;

            if (dropboxSession == null)
            {
                throw new InvalidOperationException(Resources.DropboxSessionNotFoundException);
            }

            IEnumerable <DropboxFileMetadata> files = await dropboxSession.ListFolderContentAsync(FolderPath.Get(context), Recursive, cancellationToken);

            return((asyncCodeActivityContext) =>
            {
                Files.Set(asyncCodeActivityContext, files);
            });
        }
Exemple #5
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            PropertyDescriptor dropboxSessionFactory = context.DataContext.GetProperties()[WithDropboxSession.DropboxSessionPropertyName];
            IDropboxSession    dropboxSession        = dropboxSessionFactory?.GetValue(context.DataContext) as IDropboxSession;

            if (dropboxSession == null)
            {
                throw new InvalidOperationException(Resources.DropboxSessionNotFoundException);
            }

            var fileContent = FileContent.Get(context);

            if (string.IsNullOrEmpty(fileContent))
            {
                await dropboxSession.CreateEmptyFileAsync(FilePath.Get(context), cancellationToken);
            }
            else
            {
                await dropboxSession.CreateFileWithContentAsync(FilePath.Get(context), fileContent, cancellationToken);
            }

            return((asyncCodeActivityContext) => { });
        }