feat: Flag-Enum für Dokumentoperationen eingeführt
- Ein `Flag`-Enum erstellt, um dokumentbezogene Operationen zu repräsentieren (z.B. `CreateObject`, `CheckIn` usw.). - Die Verwendung von Integer-Flags in `DocumentsRouteService` durch das neue Enum ersetzt, um die Lesbarkeit und Wartbarkeit des Codes zu verbessern. - Die `Upload`-Methode aktualisiert, um Flags als Array von `Flag`-Enum-Werten zu verarbeiten.
This commit is contained in:
parent
d9784115ce
commit
18b3a7dfff
13
src/WindreamHub.Legacy.Client/Models/Documents/Flag.cs
Normal file
13
src/WindreamHub.Legacy.Client/Models/Documents/Flag.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace WindreamHub.Legacy.Client.Models.Documents
|
||||||
|
{
|
||||||
|
public enum Flag
|
||||||
|
{
|
||||||
|
CreateObject = 1,
|
||||||
|
CheckIn = 2,
|
||||||
|
CreateNewVersion = 4,
|
||||||
|
UseDefaultLocation = 8,
|
||||||
|
ReturnIndexingDetails = 16,
|
||||||
|
ForceOverwrite = 32,
|
||||||
|
CreateTree = 64
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,9 @@ using WindreamHub.Legacy.Client.Models.Documents.Response;
|
|||||||
using WindreamHub.Legacy.Client.Models.Documents.Create.Request;
|
using WindreamHub.Legacy.Client.Models.Documents.Create.Request;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using WindreamHub.Legacy.Client.Models.Documents;
|
||||||
|
using System.Linq;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace WindreamHub.Legacy.Client.Routes
|
namespace WindreamHub.Legacy.Client.Routes
|
||||||
{
|
{
|
||||||
@ -17,22 +20,22 @@ namespace WindreamHub.Legacy.Client.Routes
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SimplifiedResponse<DocResponse, object>> Create(HttpContent docCreateBody)
|
public async Task<SimplifiedResponse<DocResponse, DocResponse>> Create(HttpContent docCreateBody)
|
||||||
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody)
|
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody)
|
||||||
.ThenAsync(res => res.Simplify<DocResponse, object>());
|
.ThenAsync(res => res.Simplify<DocResponse, DocResponse>());
|
||||||
|
|
||||||
public async Task<SimplifiedResponse<DocResponse, object>> Create(DocCreateBody docCreateBody)
|
public async Task<SimplifiedResponse<DocResponse, DocResponse>> Create(DocCreateBody docCreateBody)
|
||||||
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody.Stringify())
|
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody.Stringify())
|
||||||
.ThenAsync(res => res.Simplify<DocResponse, object>());
|
.ThenAsync(res => res.Simplify<DocResponse, DocResponse>());
|
||||||
|
|
||||||
public async Task<SimplifiedResponse<DocResponse, object>> Upload(string path, long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params int[] flags)
|
public async Task<SimplifiedResponse<DocResponse, DocResponse>> Upload(string path, long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||||
{
|
{
|
||||||
using (var fileStream = File.OpenRead(path))
|
using (var fileStream = File.OpenRead(path))
|
||||||
{
|
{
|
||||||
var fileContent = new StreamContent(fileStream);
|
var fileContent = new StreamContent(fileStream);
|
||||||
var formData = new MultipartFormDataContent
|
var formData = new MultipartFormDataContent
|
||||||
{
|
{
|
||||||
{ fileContent, "file", "filename.pdf" }
|
{ fileContent, "file" },
|
||||||
};
|
};
|
||||||
|
|
||||||
var query = HttpUtility.ParseQueryString(string.Empty);
|
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||||
@ -47,13 +50,14 @@ namespace WindreamHub.Legacy.Client.Routes
|
|||||||
query["parameter.item.name"] = item_name;
|
query["parameter.item.name"] = item_name;
|
||||||
|
|
||||||
if (flags != null && flags.Length > 0)
|
if (flags != null && flags.Length > 0)
|
||||||
query["parameter.flags"] = string.Join(",", flags);
|
query["parameter.flags"] = string.Join(",", flags.Select(flag => (int)flag));
|
||||||
|
|
||||||
if (stream_identity != null)
|
if (stream_identity != null)
|
||||||
query["parameter.stream.__identity"] = stream_identity.ToString();
|
query["parameter.stream.__identity"] = stream_identity.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return await FetchAsync(route: "/Upload", method: HttpMethod.Post, body: fileContent)
|
return await FetchAsync(route: $"/Upload?{query}", method: HttpMethod.Post, body: fileContent).ThenAsync(res => res.Simplify<DocResponse, DocResponse>());
|
||||||
.ThenAsync(res => res.Simplify<DocResponse, object>());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DIExtensions.cs" />
|
<Compile Include="DIExtensions.cs" />
|
||||||
<Compile Include="Models\Authentication\ErrorDetails.cs" />
|
<Compile Include="Models\Authentication\ErrorDetails.cs" />
|
||||||
|
<Compile Include="Models\Documents\Flag.cs" />
|
||||||
<Compile Include="Models\Documents\Response\Error.cs" />
|
<Compile Include="Models\Documents\Response\Error.cs" />
|
||||||
<Compile Include="Models\Shared\ErrorItem.cs" />
|
<Compile Include="Models\Shared\ErrorItem.cs" />
|
||||||
<Compile Include="Models\Authentication\ICredential.cs" />
|
<Compile Include="Models\Authentication\ICredential.cs" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user