Compare commits
29 Commits
353088a6b2
...
maser
| Author | SHA1 | Date | |
|---|---|---|---|
| 8059ad679e | |||
|
|
137579bbcc | ||
|
|
4aa696410c | ||
|
|
3be920c06a | ||
|
|
4aa4a0add5 | ||
|
|
650f2c58d3 | ||
|
|
8e367e89c4 | ||
|
|
193c2c41cd | ||
|
|
6ee87f8b02 | ||
|
|
8249c99132 | ||
|
|
b1834c3417 | ||
|
|
dc0cfd6010 | ||
|
|
18b3a7dfff | ||
|
|
d9784115ce | ||
|
|
d0ae6c4541 | ||
|
|
e8cffa5fa0 | ||
|
|
39e78821cf | ||
|
|
152b4f7cff | ||
|
|
987cecba4c | ||
|
|
dcaf510bd3 | ||
|
|
71f0919bce | ||
|
|
5062930d5b | ||
|
|
c233ab0ed7 | ||
|
|
0346af5b29 | ||
|
|
8eabf99616 | ||
|
|
8c1ae0e373 | ||
|
|
ccf76a72c1 | ||
|
|
bcf0db1d5a | ||
|
|
82ce7996d1 |
@@ -27,8 +27,8 @@ Global
|
||||
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D499FEC3-FDDD-45F0-BEA2-025B533BCD21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Debug|Any CPU.Build.0 = Release|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{67E6A3A1-F863-417E-9619-DC9B6A710512}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DE6A7FB2-87D6-471E-8019-DF6E196FA471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
||||
BIN
src/WindreamHub.Legacy.Client/Assets/icon.png
Normal file
BIN
src/WindreamHub.Legacy.Client/Assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
@@ -1,6 +1,7 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WindreamHub.Legacy.Client.Route;
|
||||
using WindreamHub.Legacy.Client.Routes;
|
||||
|
||||
namespace WindreamHub.Legacy.Client
|
||||
{
|
||||
@@ -15,7 +16,9 @@ namespace WindreamHub.Legacy.Client
|
||||
})
|
||||
.AddSingleton<WindreamClientService>()
|
||||
.AddSingleton<SubscriptionsRouteService>()
|
||||
.AddSingleton<SystemDetailsRouteService>();
|
||||
.AddSingleton<SystemDetailsRouteService>()
|
||||
.AddSingleton<AuthenticationRouteService>()
|
||||
.AddSingleton<DocumentsRouteService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Authentication
|
||||
{
|
||||
public class Base64Credential : ICredential
|
||||
{
|
||||
public Base64Credential(string authorizationHeader) => AuthorizationHeader = authorizationHeader;
|
||||
|
||||
public string AuthorizationHeader { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using WindreamHub.Legacy.Client.Models.Shared;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Authentication
|
||||
{
|
||||
public class ErrorDetails
|
||||
{
|
||||
public ErrorItem Item { get; set; }
|
||||
public string Message { get; set; }
|
||||
public int? ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Authentication
|
||||
{
|
||||
public interface ICredential
|
||||
{
|
||||
string AuthorizationHeader { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using WindreamHub.Legacy.Client.Models.Authentication;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models
|
||||
{
|
||||
public class UserCredential : ICredential
|
||||
{
|
||||
public readonly string Domain;
|
||||
|
||||
public readonly string Name;
|
||||
|
||||
public string AuthorizationHeader { get; }
|
||||
|
||||
public UserCredential(string domain, string name, string password)
|
||||
{
|
||||
Domain = domain;
|
||||
Name = name;
|
||||
AuthorizationHeader = ConvertToBase64(domain, name, password);
|
||||
}
|
||||
|
||||
private static string ConvertToBase64(string domain, string username, string password)
|
||||
{
|
||||
var credentials = $"{domain}\\{username}:{password}";
|
||||
var base64Credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(credentials));
|
||||
return base64Credentials;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Authentication
|
||||
{
|
||||
public class ValidationResponse
|
||||
{
|
||||
public int? UserID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string FullUserName { get; set; }
|
||||
public bool? IsValidUser { get; set; }
|
||||
public ErrorDetails Error { get; set; }
|
||||
public List<ErrorDetails> Errors { get; set; }
|
||||
public bool? HasErrors { get; set; }
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request
|
||||
{
|
||||
public class Attribute
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public object Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request.Delete
|
||||
{
|
||||
public class DeleteItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request.Delete
|
||||
{
|
||||
public class DocDeleteBody
|
||||
{
|
||||
public DeleteItem Item { get; set; }
|
||||
public int Flags { get; set; }
|
||||
public int ResponseDetails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request
|
||||
{
|
||||
public class DocBody
|
||||
{
|
||||
public Item Item { get; set; }
|
||||
public bool? CreateFolder { get; set; }
|
||||
public int? ResponseDetails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
public ObjectType ObjectType { get; set; }
|
||||
public List<Attribute> Attributes { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Request
|
||||
{
|
||||
public class ObjectType
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class Attribute
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public object Value { get; set; }
|
||||
public int? Type { get; set; }
|
||||
public int? UnderlyingType { get; set; }
|
||||
public string Column { get; set; }
|
||||
public bool? IsSystem { get; set; }
|
||||
public bool? IsSortable { get; set; }
|
||||
public VectorDetails VectorDetails { get; set; }
|
||||
public TypeSpecificDetails TypeSpecificDetails { get; set; }
|
||||
public int? MaxSize { get; set; }
|
||||
public bool? AlwaysModifiable { get; set; }
|
||||
public int? PreDigits { get; set; }
|
||||
public int? PostDigits { get; set; }
|
||||
public bool? IsFulltext { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response.Delete
|
||||
{
|
||||
public class DocDelErrorResponse
|
||||
{
|
||||
public ErrorDetail Error { get; set; }
|
||||
public List<Error> Errors { get; set; }
|
||||
public bool HasErrors { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response.Delete
|
||||
{
|
||||
public class ErrorDetail
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public int? ErrorCode { get; set; }
|
||||
public int? Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class DocResponse
|
||||
{
|
||||
public Item Item { get; set; }
|
||||
public IndexingDetails IndexingDetails { get; set; }
|
||||
public Error Error { get; set; }
|
||||
public List<Error> Errors { get; set; }
|
||||
public bool? HasErrors { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using WindreamHub.Legacy.Client.Models.Shared;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class Error
|
||||
{
|
||||
public ErrorItem Item { get; set; }
|
||||
public string Message { get; set; }
|
||||
public int? ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class IndexingDetails
|
||||
{
|
||||
public bool? IndexEventRequired { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
public List<Attribute> Attributes { get; set; }
|
||||
public ObjectType ObjectType { get; set; }
|
||||
public ParentWindreamObject ParentWindreamObject { get; set; }
|
||||
public int? Entity { get; set; }
|
||||
public string LocationComplete { get; set; }
|
||||
public int? Id { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class ObjectType
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class ParentWindreamObject
|
||||
{
|
||||
public string LocationComplete { get; set; }
|
||||
public int? Id { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class TypeSpecificDetails
|
||||
{
|
||||
public bool? OnceEditable { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Documents.Response
|
||||
{
|
||||
public class VectorDetails
|
||||
{
|
||||
public int? EntriesLimit { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Models
|
||||
{
|
||||
@@ -16,13 +19,92 @@ namespace WindreamHub.Legacy.Client.Models
|
||||
return new SimplifiedResponse<TData, TError>(ok: message.IsSuccessStatusCode, status: message.StatusCode, data: data, error: err);
|
||||
}
|
||||
|
||||
public static async Task Subscribe<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error)
|
||||
public static async Task FetchAsync<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
var res = await responseAsync;
|
||||
if (res.Ok)
|
||||
next(res.Data);
|
||||
else
|
||||
error?.Invoke(res.Error);
|
||||
}
|
||||
|
||||
public static void Fetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
var res = await responseAsync;
|
||||
if (res.Ok)
|
||||
next(res.Data);
|
||||
else
|
||||
error?.Invoke(res.Error);
|
||||
});
|
||||
}
|
||||
|
||||
public static void Fetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, int millisecondsDelay, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var res = await responseAsync;
|
||||
if (res.Ok)
|
||||
next(res.Data);
|
||||
else
|
||||
error(res.Error);
|
||||
error?.Invoke(res.Error);
|
||||
|
||||
await Task.Delay(millisecondsDelay, cancellationToken);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Func<Task> CreateFetchAsync<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return async () =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
var res = await responseAsync;
|
||||
if (res.Ok)
|
||||
next(res.Data);
|
||||
else
|
||||
error?.Invoke(res.Error);
|
||||
};
|
||||
}
|
||||
|
||||
public static Action CreateFetch<TData, TError>(this Task<SimplifiedResponse<TData, TError>> responseAsync, Action<TData> next, Action<TError> error = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return () => Task.Run(async () =>
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
var res = await responseAsync;
|
||||
if (res.Ok)
|
||||
next(res.Data);
|
||||
else
|
||||
error?.Invoke(res.Error);
|
||||
});
|
||||
}
|
||||
|
||||
public static string Serialize(this object model) => JsonConvert.SerializeObject(model);
|
||||
|
||||
public static T Deserialize<T>(this string json) => JsonConvert.DeserializeObject<T>(json);
|
||||
|
||||
public static dynamic Deserialize(this string json) => JsonConvert.DeserializeObject<dynamic>(json);
|
||||
|
||||
public static IEnumerable<dynamic> DeserializeList(this string json) => JsonConvert.DeserializeObject<IEnumerable<dynamic>>(json);
|
||||
|
||||
public static HttpContent ToContent(this string json, Encoding encoding = null, string mediaType = "application/json")
|
||||
=> new StringContent(json, encoding ?? Encoding.UTF8, mediaType);
|
||||
|
||||
public static HttpContent Stringify(this object model, Encoding encoding = null, string mediaType = "application/json")
|
||||
=> model.Serialize().ToContent(encoding ?? Encoding.UTF8, mediaType);
|
||||
}
|
||||
}
|
||||
10
src/WindreamHub.Legacy.Client/Models/Shared/ErrorItem.cs
Normal file
10
src/WindreamHub.Legacy.Client/Models/Shared/ErrorItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace WindreamHub.Legacy.Client.Models.Shared
|
||||
{
|
||||
public class ErrorItem
|
||||
{
|
||||
public int? Entity { get; set; }
|
||||
public int? Id { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace WindreamHub.Legacy.Client.Models
|
||||
namespace WindreamHub.Legacy.Client.Models.SystemDetails
|
||||
{
|
||||
public class SystemDetails
|
||||
{
|
||||
@@ -8,6 +8,6 @@
|
||||
|
||||
public string DefaultDomain { get; set; }
|
||||
|
||||
public int AuthenticationModes { get; set; }
|
||||
public int? AuthenticationModes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace WindreamHub.Legacy.Client.Models
|
||||
namespace WindreamHub.Legacy.Client.Models.SystemDetails
|
||||
{
|
||||
public class SystemDetailsResponse
|
||||
{
|
||||
@@ -8,6 +8,6 @@
|
||||
|
||||
public object Errors { get; set; }
|
||||
|
||||
public bool HasErrors { get; set; }
|
||||
public bool? HasErrors { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using WindreamHub.Legacy.Client.Models;
|
||||
using WindreamHub.Legacy.Client.Models.Authentication;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Routes
|
||||
{
|
||||
public class AuthenticationRouteService : BaseRouteService
|
||||
{
|
||||
public AuthenticationRouteService(HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) : base(client, cookieContainer, clientOptions)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<SimplifiedResponse<ValidationResponse, object>> IsValidUserAsync()
|
||||
{
|
||||
return await FetchAsync(route: "/IsValidUser", HttpMethod.Get).ThenAsync(res => res.Simplify<ValidationResponse, object>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
@@ -15,8 +14,8 @@ namespace WindreamHub.Legacy.Client.Routes
|
||||
|
||||
clientOptions.Value.Routes.TryGetValue(route_name, out string route);
|
||||
|
||||
if(route is null)
|
||||
throw new InvalidOperationException($"Route not found for the route name: {route_name}.");
|
||||
if (route is null)
|
||||
Uri += $"/{route_name.ToLower()}";
|
||||
|
||||
Uri += route;
|
||||
}
|
||||
|
||||
122
src/WindreamHub.Legacy.Client/Routes/DocumentsRouteService.cs
Normal file
122
src/WindreamHub.Legacy.Client/Routes/DocumentsRouteService.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using System.Threading.Tasks;
|
||||
using WindreamHub.Legacy.Client.Models;
|
||||
using WindreamHub.Legacy.Client.Models.Documents.Response;
|
||||
using WindreamHub.Legacy.Client.Models.Documents.Request;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using WindreamHub.Legacy.Client.Models.Documents;
|
||||
using System.Linq;
|
||||
using WindreamHub.Legacy.Client.Models.Documents.Response.Delete;
|
||||
using WindreamHub.Legacy.Client.Models.Documents.Request.Delete;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Routes
|
||||
{
|
||||
public class DocumentsRouteService : BaseRouteService
|
||||
{
|
||||
public DocumentsRouteService(HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) : base(client, cookieContainer, clientOptions)
|
||||
{
|
||||
}
|
||||
|
||||
//Create
|
||||
public async Task<SimplifiedResponse<TData, TError>> CreateAsync<TData, TError>(DocBody docCreateBody)
|
||||
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody.Stringify())
|
||||
.ThenAsync(res => res.Simplify<TData, TError>());
|
||||
|
||||
public Task<SimplifiedResponse<dynamic, dynamic>> CreateDynamicAsync(DocBody docCreateBody) => CreateAsync<dynamic, dynamic>(docCreateBody);
|
||||
|
||||
public Task<SimplifiedResponse<DocResponse, DocResponse>> CreateAsync(DocBody docCreateBody) => CreateAsync<DocResponse, DocResponse>(docCreateBody);
|
||||
|
||||
//Upload
|
||||
public async Task<SimplifiedResponse<TData, TError>> UploadAsync<TData, TError>(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))
|
||||
{
|
||||
var fileContent = new StreamContent(fileStream);
|
||||
var formData = new MultipartFormDataContent
|
||||
{
|
||||
{ fileContent, "file" },
|
||||
};
|
||||
|
||||
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||
|
||||
if (item_id != null)
|
||||
query["parameter.item.id"] = item_id.ToString();
|
||||
|
||||
if (item_location != null)
|
||||
query["parameter.item.location"] = item_location;
|
||||
|
||||
if (item_name != null)
|
||||
query["parameter.item.name"] = item_name;
|
||||
|
||||
if (flags != null && flags.Length > 0)
|
||||
query["parameter.flags"] = string.Join(",", flags.Select(flag => (int)flag));
|
||||
|
||||
if (stream_identity != null)
|
||||
query["parameter.stream.__identity"] = stream_identity.ToString();
|
||||
|
||||
return await FetchAsync(route: $"/Upload?{query}", method: HttpMethod.Post, body: fileContent).ThenAsync(res => res.Simplify<TData, TError>());
|
||||
}
|
||||
}
|
||||
|
||||
public Task<SimplifiedResponse<dynamic, dynamic>> UploadDynamicAsync(string path, long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||
=> UploadAsync<dynamic, dynamic>(path: path, item_id: item_id, item_location: item_location, item_name: item_name, stream_identity: stream_identity, flags: flags);
|
||||
|
||||
public Task<SimplifiedResponse<DocResponse, DocResponse>> UploadAsync(string path, long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||
=> UploadAsync<DocResponse, DocResponse>(path: path, item_id: item_id, item_location: item_location, item_name: item_name, stream_identity: stream_identity, flags: flags);
|
||||
|
||||
//Update
|
||||
public async Task<SimplifiedResponse<TData, TError>> UpdateAsync<TData, TError>(DocBody docUpdateBody)
|
||||
=> await FetchAsync(route: "/Update", method: HttpMethod.Post, body: docUpdateBody.Stringify())
|
||||
.ThenAsync(res => res.Simplify<TData, TError>());
|
||||
|
||||
public Task<SimplifiedResponse<dynamic, dynamic>> UpdateDynamicAsync(DocBody docUpdateBody)
|
||||
=> UpdateAsync<dynamic, dynamic>(docUpdateBody);
|
||||
|
||||
public Task<SimplifiedResponse<DocResponse, DocResponse>> UpdateAsync(DocBody docUpdateBody)
|
||||
=> UpdateAsync<DocResponse, DocResponse>(docUpdateBody);
|
||||
|
||||
//Download
|
||||
public async Task<SimplifiedResponse<TData, TError>> DownloadAsync<TData, TError>(long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||
{
|
||||
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||
|
||||
if (item_id != null)
|
||||
query["parameter.item.id"] = item_id.ToString();
|
||||
|
||||
if (item_location != null)
|
||||
query["parameter.item.location"] = item_location;
|
||||
|
||||
if (item_name != null)
|
||||
query["parameter.item.name"] = item_name;
|
||||
|
||||
if (flags != null && flags.Length > 0)
|
||||
query["parameter.flags"] = string.Join(",", flags.Select(flag => (int)flag));
|
||||
|
||||
if (stream_identity != null)
|
||||
query["parameter.stream.__identity"] = stream_identity.ToString();
|
||||
|
||||
return await FetchAsync(route: $"/Download?{query}", method: HttpMethod.Get).ThenAsync(res => res.Simplify<TData, TError>());
|
||||
}
|
||||
|
||||
public Task<SimplifiedResponse<dynamic, dynamic>> DownloadDynamicAsync(long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||
=> DownloadAsync<dynamic, dynamic>(item_id: item_id, item_location: item_location, item_name: item_name, stream_identity: stream_identity, flags: flags);
|
||||
|
||||
public Task<SimplifiedResponse<DocResponse, DocResponse>> DownloadAsync(long? item_id = null, string item_location = null, string item_name = null, object stream_identity = null, params Flag[] flags)
|
||||
=> DownloadAsync<DocResponse, DocResponse>(item_id: item_id, item_location: item_location, item_name: item_name, stream_identity: stream_identity, flags: flags);
|
||||
|
||||
//Delete
|
||||
public async Task<SimplifiedResponse<TData, TError>> DeleteAsync<TData, TError>(DocDeleteBody docDeleteBody)
|
||||
=> await FetchAsync(route: "/Delete", HttpMethod.Post, body: docDeleteBody.Stringify())
|
||||
.ThenAsync(res => res.Simplify<TData, TError>());
|
||||
|
||||
public async Task<SimplifiedResponse<dynamic, dynamic>> DeleteDynamicAsync(DocDeleteBody docDeleteBody)
|
||||
=> await DeleteAsync<dynamic, dynamic>(docDeleteBody: docDeleteBody);
|
||||
|
||||
public async Task<SimplifiedResponse<DocResponse, DocDelErrorResponse>> DeleteAsync(DocDeleteBody docDeleteBody)
|
||||
=> await DeleteAsync<DocResponse, DocDelErrorResponse>(docDeleteBody: docDeleteBody);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Routes
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using DigitalData.Core.Legacy.Client;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using WindreamHub.Legacy.Client.Routes;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using WindreamHub.Legacy.Client.Models;
|
||||
using WindreamHub.Legacy.Client.Models.SystemDetails;
|
||||
using WindreamHub.Legacy.Client.Routes;
|
||||
|
||||
namespace WindreamHub.Legacy.Client.Route
|
||||
@@ -15,7 +16,7 @@ namespace WindreamHub.Legacy.Client.Route
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<SimplifiedResponse<SystemDetailsResponse, object>> GetSystemDetails()
|
||||
public async Task<SimplifiedResponse<SystemDetailsResponse, object>> GetSystemDetailsAsync()
|
||||
=> await FetchAsync(route: "/GetSystemDetails")
|
||||
.ThenAsync(res => res.Simplify<SystemDetailsResponse, object>());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace WindreamHub.Legacy.Client
|
||||
public Dictionary<string, string> Routes = new Dictionary<string, string>()
|
||||
{
|
||||
{ "Subscriptions", "/subscriptions" },
|
||||
{ "SystemDetails", "/systemDetails" }
|
||||
{ "SystemDetails", "/systemDetails" },
|
||||
{ "Authentication", "/authentication" }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,51 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using WindreamHub.Legacy.Client.Models.Authentication;
|
||||
using WindreamHub.Legacy.Client.Models;
|
||||
using WindreamHub.Legacy.Client.Route;
|
||||
using WindreamHub.Legacy.Client.Routes;
|
||||
|
||||
namespace WindreamHub.Legacy.Client
|
||||
{
|
||||
public class WindreamClientService : HttpClientService<WindreamClientOptions>
|
||||
{
|
||||
public WindreamClientService(SubscriptionsRouteService subscriptions, SystemDetailsRouteService systemDetails,
|
||||
HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) :
|
||||
public WindreamClientService(SubscriptionsRouteService subscriptions, SystemDetailsRouteService systemDetails, AuthenticationRouteService authentication, DocumentsRouteService documents, HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) :
|
||||
base(client, cookieContainer, clientOptions)
|
||||
{
|
||||
Subscriptions = subscriptions;
|
||||
SystemDetails = systemDetails;
|
||||
Authentication = authentication;
|
||||
Documents = documents;
|
||||
}
|
||||
|
||||
public SubscriptionsRouteService Subscriptions { get; }
|
||||
|
||||
public SystemDetailsRouteService SystemDetails { get; }
|
||||
|
||||
public AuthenticationRouteService Authentication { get; }
|
||||
|
||||
public DocumentsRouteService Documents { get; }
|
||||
|
||||
public async Task<bool> AuthenticateAsync(ICredential credential)
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credential.AuthorizationHeader);
|
||||
var res = await Authentication.IsValidUserAsync();
|
||||
return res.Ok && (res.Data.IsValidUser ?? false);
|
||||
}
|
||||
|
||||
public async Task<bool> AuthenticateAsync(string domain, string name, string password)
|
||||
{
|
||||
var uCredential = new UserCredential(domain, name, password);
|
||||
return await AuthenticateAsync(uCredential);
|
||||
}
|
||||
|
||||
public async Task<bool> AuthenticateAsync(string authorizationHeader)
|
||||
{
|
||||
var uCredential = new Base64Credential(authorizationHeader);
|
||||
return await AuthenticateAsync(uCredential);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,12 +31,15 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DigitalData.Core.Client.Legacy">
|
||||
<HintPath>..\..\..\WebCoreModules\DigitalData.Core.Legacy.Client\bin\Debug\DigitalData.Core.Client.Legacy.dll</HintPath>
|
||||
<Reference Include="DigitalData.Core.Client.Legacy, Version=1.0.1.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\DigitalData.Core.Client.Legacy.1.0.1.2\lib\net462\DigitalData.Core.Client.Legacy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -46,6 +49,9 @@
|
||||
<Reference Include="Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
@@ -68,6 +74,7 @@
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -77,11 +84,37 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DIExtensions.cs" />
|
||||
<Compile Include="Models\Authentication\ErrorDetails.cs" />
|
||||
<Compile Include="Models\Documents\Flag.cs" />
|
||||
<Compile Include="Models\Documents\Request\Delete\DeleteItem.cs" />
|
||||
<Compile Include="Models\Documents\Request\Delete\DocDeleteBody.cs" />
|
||||
<Compile Include="Models\Documents\Response\Delete\DocDelErrorResponse.cs" />
|
||||
<Compile Include="Models\Documents\Response\Delete\ErrorDetail.cs" />
|
||||
<Compile Include="Models\Documents\Response\Error.cs" />
|
||||
<Compile Include="Models\Shared\ErrorItem.cs" />
|
||||
<Compile Include="Models\Authentication\ICredential.cs" />
|
||||
<Compile Include="Models\Authentication\ValidationResponse.cs" />
|
||||
<Compile Include="Models\Authentication\Base64Credential.cs" />
|
||||
<Compile Include="Models\Documents\Request\Attribute.cs" />
|
||||
<Compile Include="Models\Documents\Request\Item.cs" />
|
||||
<Compile Include="Models\Documents\Request\ObjectType.cs" />
|
||||
<Compile Include="Models\Documents\Request\DocBody.cs" />
|
||||
<Compile Include="Models\Documents\Response\Attribute.cs" />
|
||||
<Compile Include="Models\Documents\Response\DocResponse.cs" />
|
||||
<Compile Include="Models\Documents\Response\IndexingDetails.cs" />
|
||||
<Compile Include="Models\Documents\Response\Item.cs" />
|
||||
<Compile Include="Models\Documents\Response\ObjectType.cs" />
|
||||
<Compile Include="Models\Documents\Response\ParentWindreamObject.cs" />
|
||||
<Compile Include="Models\Documents\Response\TypeSpecificDetails.cs" />
|
||||
<Compile Include="Models\Documents\Response\VectorDetails.cs" />
|
||||
<Compile Include="Models\ModelExtensions.cs" />
|
||||
<Compile Include="Models\SimplifiedResponse.cs" />
|
||||
<Compile Include="Models\SystemDetails.cs" />
|
||||
<Compile Include="Models\SystemDetailsResponse.cs" />
|
||||
<Compile Include="Models\SystemDetails\SystemDetails.cs" />
|
||||
<Compile Include="Models\SystemDetails\SystemDetailsResponse.cs" />
|
||||
<Compile Include="Models\Authentication\UserCredential.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Routes\DocumentsRouteService.cs" />
|
||||
<Compile Include="Routes\AuthenticationRouteService.cs" />
|
||||
<Compile Include="Routes\BaseRouteService.cs" />
|
||||
<Compile Include="Routes\RouteExtensions.cs" />
|
||||
<Compile Include="Routes\SystemDetailsRouteService.cs" />
|
||||
@@ -93,5 +126,11 @@
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\icon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,9 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DigitalData.Core.Client.Legacy" version="1.0.1.2" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net462" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.1" targetFramework="net462" />
|
||||
<package id="Microsoft.Extensions.Options" version="8.0.2" targetFramework="net462" />
|
||||
<package id="Microsoft.Extensions.Primitives" version="8.0.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
|
||||
<package id="NuGet.CommandLine" version="6.11.0" targetFramework="net462" developmentDependency="true" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
|
||||
|
||||
Reference in New Issue
Block a user