Ejemplo n.º 1
0
        public IDropboxResult ExecuteTask(IDropboxClientWrapper client)
        {
            try
            {
                var listFolderArg    = new ListFolderArg(_path, _recursive, _includeMediaInfo, _includeDeleted);
                var listFolderResult = client.ListFolderAsync(listFolderArg).Result;
                return(new DropboxListFolderSuccesResult(listFolderResult));
            }
            catch (Exception exception)
            {
                Dev2Logger.Error(exception.Message);
                var hasInnerExc = exception.InnerException != null;
                if (hasInnerExc)
                {
                    if (exception.InnerException.Message.Contains("not_found"))
                    {
                        return(new DropboxFailureResult(new DropboxFileNotFoundException()));
                    }

                    if (exception.InnerException.Message.Contains("malformed"))
                    {
                        return(new DropboxFailureResult(new DropboxFileMalformdedException()));
                    }
                    return(exception.InnerException.Message.Contains("not_file") ? new DropboxFailureResult(new DropboxPathNotFileFoundException()) : new DropboxFailureResult(exception.InnerException));
                }
                return(new DropboxFailureResult(exception));
            }
        }
Ejemplo n.º 2
0
        //All units used here has been unit tested seperately
        protected override List <string> PerformExecution(Dictionary <string, string> evaluatedValues)
        {
            var writeMode = GetWriteMode();

            DropboxSingleExecutor = new DropBoxUpload(writeMode, evaluatedValues["ToPath"], evaluatedValues["FromPath"]);
            _clientWrapper        = _clientWrapper ?? new DropboxClientWrapper(GetClient());
            var dropboxExecutionResult = DropboxSingleExecutor.ExecuteTask(_clientWrapper);
            var dropboxSuccessResult   = dropboxExecutionResult as DropboxUploadSuccessResult;

            if (dropboxSuccessResult != null)
            {
                FileMetadata = dropboxSuccessResult.GerFileMetadata();
                return(new List <string> {
                    GlobalConstants.DropBoxSuccess
                });
            }
            var dropboxFailureResult = dropboxExecutionResult as DropboxFailureResult;

            if (dropboxFailureResult != null)
            {
                Exception = dropboxFailureResult.GetException();
            }
            var executionError = Exception.InnerException?.Message ?? Exception.Message;

            throw new Exception(executionError);
        }
Ejemplo n.º 3
0
 public IDropboxResult ExecuteTask(IDropboxClientWrapper client)
 {
     try
     {
         FileMetadata deleteAsync = client.DeleteAsync(_dropboxPath).Result as FileMetadata;
         return(new DropboxDeleteSuccessResult(deleteAsync));
     }
     catch (Exception exception)
     {
         Dev2Logger.Error(exception.Message);
         return(exception.InnerException != null ? new DropboxFailureResult(exception.InnerException) : new DropboxFailureResult(exception));
     }
 }
Ejemplo n.º 4
0
        protected override List <string> PerformExecution(Dictionary <string, string> evaluatedValues)
        {
            string toPath;

            evaluatedValues.TryGetValue("ToPath", out toPath);

            IDropboxSingleExecutor <IDropboxResult> dropboxFileRead = new DropboxFileRead(IsRecursive, toPath, IncludeMediaInfo, IncludeDeleted);
            var dropboxSingleExecutor = GetDropboxSingleExecutor(dropboxFileRead);

            _dropboxClientWrapper = _dropboxClientWrapper ?? new DropboxClientWrapper(GetDropboxClient());
            var dropboxExecutionResult = dropboxSingleExecutor.ExecuteTask(_dropboxClientWrapper);
            var dropboxSuccessResult   = dropboxExecutionResult as DropboxListFolderSuccesResult;

            if (dropboxSuccessResult != null)
            {
                var listFolderResult = dropboxSuccessResult.GetListFolderResulResult();
                var metadatas        = listFolderResult.Entries;
                if (IncludeDeleted)
                {
                    Files.AddRange(listFolderResult.Entries.Where(metadata => metadata.IsDeleted).Select(metadata => metadata.PathLower).ToList());
                }
                if (IsFoldersSelected)
                {
                    Files.AddRange(metadatas.Where(metadata => metadata.IsFolder).Select(metadata => metadata.PathLower).ToList());
                }
                if (IsFilesSelected)
                {
                    Files.AddRange(metadatas.Where(metadata => metadata.IsFile).Select(metadata => metadata.PathLower).ToList());
                }
                if (IsFilesAndFoldersSelected)
                {
                    Files.AddRange(metadatas.Where(metadata => metadata.IsFolder).Select(metadata => metadata.PathLower).ToList());
                    Files.AddRange(metadatas.Where(metadata => metadata.IsFile).Select(metadata => metadata.PathLower).ToList());
                }

                return(new List <string> {
                    GlobalConstants.DropBoxSuccess
                });
            }
            var dropboxFailureResult = dropboxExecutionResult as DropboxFailureResult;

            if (dropboxFailureResult != null)
            {
                Exception = dropboxFailureResult.GetException();
            }
            var executionError = Exception.InnerException?.Message ?? Exception.Message;

            throw new Exception(executionError);
        }
        //All units used here has been unit tested seperately
        protected override List <string> PerformExecution(Dictionary <string, string> evaluatedValues)
        {
            string localToPath;

            evaluatedValues.TryGetValue("ToPath", out localToPath);
            string localFromPath;

            evaluatedValues.TryGetValue("FromPath", out localFromPath);
            IDropboxSingleExecutor <IDropboxResult> dropBoxDownLoad = new DropBoxDownLoad(localToPath);
            var dropboxSingleExecutor = GetDropboxSingleExecutor(dropBoxDownLoad);

            _dropboxClientWrapper = _dropboxClientWrapper ?? new DropboxClientWrapper(GetClient());
            var dropboxExecutionResult = dropboxSingleExecutor.ExecuteTask(_dropboxClientWrapper);
            var dropboxSuccessResult   = dropboxExecutionResult as DropboxDownloadSuccessResult;

            if (dropboxSuccessResult != null)
            {
                Response = dropboxSuccessResult.GetDownloadResponse();
                var bytes = Response.GetContentAsByteArrayAsync().Result;
                if (Response.Response.IsFile)
                {
                    LocalPathManager = new LocalPathManager(localFromPath);
                    var validFolder = LocalPathManager.GetFullFileName();
                    var fileExist   = LocalPathManager.FileExist();
                    if (fileExist && !OverwriteFile)
                    {
                        throw new Exception(ErrorResource.DropBoxDestinationFileAlreadyExist);
                    }
                    DropboxFile.WriteAllBytes(validFolder, bytes);
                }
                return(new List <string> {
                    GlobalConstants.DropBoxSuccess
                });
            }
            var dropboxFailureResult = dropboxExecutionResult as DropboxFailureResult;

            if (dropboxFailureResult != null)
            {
                Exception = dropboxFailureResult.GetException();
            }
            var executionError = Exception.InnerException?.Message ?? Exception.Message;

            if (executionError.Contains("not_file"))
            {
                executionError = ErrorResource.DropBoxFilePathMissing;
            }
            throw new Exception(executionError);
        }
Ejemplo n.º 6
0
 public IDropboxResult ExecuteTask(IDropboxClientWrapper client)
 {
     try
     {
         using (var stream = new MemoryStream(File.ReadAllBytes(_fromPath)))
         {
             FileMetadata uploadAsync = client.UploadAsync(_dropboxPath, _writeMode, true, null, false, stream).Result;
             return(new DropboxUploadSuccessResult(uploadAsync));
         }
     }
     catch (Exception exception)
     {
         Dev2Logger.Error(exception.Message);
         return(exception.InnerException != null ? new DropboxFailureResult(exception.InnerException) : new DropboxFailureResult(exception));
     }
 }
Ejemplo n.º 7
0
        protected override List <string> PerformExecution(Dictionary <string, string> evaluatedValues)
        {
            DropboxSingleExecutor = new DropboxDelete(evaluatedValues["DeletePath"]);
            _dropboxClientWrapper = _dropboxClientWrapper ?? new DropboxClientWrapper(GetClient());
            var dropboxExecutionResult = DropboxSingleExecutor.ExecuteTask(_dropboxClientWrapper);

            if (dropboxExecutionResult is DropboxDeleteSuccessResult dropboxSuccessResult)
            {
                dropboxSuccessResult.GerFileMetadata();
                return(new List <string> {
                    GlobalConstants.DropBoxSuccess
                });
            }
            if (dropboxExecutionResult is DropboxFailureResult dropboxFailureResult)
            {
                Exception = dropboxFailureResult.GetException();
            }
            var executionError = Exception.InnerException?.Message ?? Exception.Message;

            throw new Exception(executionError);
        }
Ejemplo n.º 8
0
        public IDropboxResult ExecuteTask(IDropboxClientWrapper client)
        {
            try
            {
                var downloadArg = new DownloadArg(_path);
                IDownloadResponse <FileMetadata> uploadAsync = client.DownloadAsync(downloadArg).Result;
                return(new DropboxDownloadSuccessResult(uploadAsync));
            }
            catch (Exception exception)
            {
                Dev2Logger.Error(exception.Message);

                var hasInnerExc = exception.InnerException != null;
                if (hasInnerExc)
                {
                    if (exception.InnerException.Message.Contains("not_found"))
                    {
                        return(new DropboxFailureResult(new DropboxFileNotFoundException()));
                    }
                    return(exception.InnerException.Message.Contains("not_file") ? new DropboxFailureResult(new DropboxPathNotFileFoundException()) : new DropboxFailureResult(exception.InnerException));
                }
                return(new DropboxFailureResult(exception));
            }
        }
 protected DsfDropBoxDeleteActivity(IDropboxClientWrapper dropboxClientWrapper)
     : this()
 {
     _dropboxClientWrapper = dropboxClientWrapper;
 }
Ejemplo n.º 10
0
 public DsfDropBoxUploadActivityMock(IDropboxSingleExecutor <IDropboxResult> singleExecutor, IDropboxClientWrapper dropboxClientWrapper)
     : base(dropboxClientWrapper)
 {
     _dropboxClientWrapper = dropboxClientWrapper;
     DropboxSingleExecutor = singleExecutor;
 }
Ejemplo n.º 11
0
 public DsfDropBoxUploadActivity(IDropboxClientWrapper clientWrapper)
     : this()
 {
     _clientWrapper = clientWrapper;
 }
Ejemplo n.º 12
0
 public DsfDropBoxDownloadActivityMockForFiles(IDropboxClientWrapper clientWrapper)
     : base(clientWrapper)
 {
     _clientWrapper = clientWrapper;
 }
Ejemplo n.º 13
0
 protected DsfDropboxFileListActivity(IDropboxClientWrapper dropboxClientWrapper)
     : this()
 {
     _dropboxClientWrapper = dropboxClientWrapper;
 }
 public DsfDropboxFileListActivityMock(IDropboxClientWrapper clientWrapper)
     : base(clientWrapper)
 {
     _clientWrapper = clientWrapper;
 }