This repository has been archived by the owner on Dec 5, 2018. It is now read-only.
forked from relativitydev/Gravity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: normalize dto hydration recursion
- Loading branch information
Avi Levin
committed
Nov 16, 2017
1 parent
a8ce0d8
commit 7e28c7b
Showing
3 changed files
with
89 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using kCura.Relativity.Client; | ||
using kCura.Relativity.Client.DTOs; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Gravity.Base; | ||
using Gravity.Exceptions; | ||
using Gravity.Extensions; | ||
|
||
namespace Gravity.DAL.RSAPI | ||
{ | ||
public partial class RsapiDao | ||
{ | ||
public ResultSet<Document> QueryDocumentsByDocumentViewID(int documentViewId) | ||
{ | ||
ResultSet<Document> returnObject; | ||
|
||
Query<Document> query = new Query<Document>() | ||
{ | ||
Condition = new ViewCondition(documentViewId), | ||
Fields = FieldValue.SelectedFields | ||
}; | ||
|
||
using (IRSAPIClient proxy = CreateProxy()) | ||
{ | ||
try | ||
{ | ||
returnObject = invokeWithRetryService.InvokeWithRetry(() => proxy.Repositories.Document.Query(query)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new ProxyOperationFailedException("Failed in method: " + MethodBase.GetCurrentMethod(), ex); | ||
} | ||
} | ||
|
||
return returnObject; | ||
} | ||
|
||
public KeyValuePair<byte[], FileMetadata> DownloadDocumentNative(int documentId) | ||
{ | ||
Document doc = new Document(documentId); | ||
byte[] documentBytes; | ||
|
||
KeyValuePair<DownloadResponse, Stream> documentNativeResponse = new KeyValuePair<DownloadResponse, Stream>(); | ||
|
||
using (IRSAPIClient proxy = CreateProxy()) | ||
{ | ||
try | ||
{ | ||
documentNativeResponse = invokeWithRetryService.InvokeWithRetry(() => proxy.Repositories.Document.DownloadNative(doc)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new ProxyOperationFailedException("Failed in method: " + MethodInfo.GetCurrentMethod(), ex); | ||
} | ||
} | ||
|
||
using (MemoryStream ms = (MemoryStream)documentNativeResponse.Value) | ||
{ | ||
documentBytes = ms.ToArray(); | ||
} | ||
|
||
return new KeyValuePair<byte[], FileMetadata>(documentBytes, documentNativeResponse.Key.Metadata); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters