|
@@ -148,54 +148,19 @@ namespace InABox.Clients
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region Abstract Methods
|
|
|
+
|
|
|
public abstract CoreTable Query(IFilter? filter = null, IColumns? columns = null, ISortOrder? sortOrder = null, CoreRange? range = null);
|
|
|
public abstract void Save(Entity entity, string auditNote);
|
|
|
public abstract void Save(IEnumerable<Entity> entity, string auditNote);
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
private static IClient CheckClient()
|
|
|
{
|
|
|
return ClientFactory.CreateClient<User>();
|
|
|
}
|
|
|
|
|
|
- public static Task<Dictionary<string, CoreTable>> QueryMultipleAsync(Dictionary<string, IQueryDef> queries)
|
|
|
- {
|
|
|
- return Task.Run(() =>
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- using var timer = new Profiler(false);
|
|
|
- var result = CheckClient().QueryMultiple(queries);
|
|
|
- timer.Log(result.Sum(x => x.Value.Rows.Count));
|
|
|
- return result;
|
|
|
- }
|
|
|
- catch (RequestException e)
|
|
|
- {
|
|
|
- ClientFactory.RaiseRequestError(e);
|
|
|
- throw;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- public static Dictionary<string, CoreTable> QueryMultiple(Dictionary<string, IQueryDef> queries)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- using var timer = new Profiler(false);
|
|
|
- var result = CheckClient().QueryMultiple(queries);
|
|
|
- timer.Log(result.Sum(x => x.Value.Rows.Count));
|
|
|
- return result;
|
|
|
- }
|
|
|
- catch (RequestException e)
|
|
|
- {
|
|
|
- ClientFactory.RaiseRequestError(e);
|
|
|
- throw;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private static IClient<TEntity> CheckClient<TEntity>() where TEntity : Entity, IRemotable, new()
|
|
|
- {
|
|
|
- return ClientFactory.CreateClient<TEntity>();
|
|
|
- }
|
|
|
-
|
|
|
public static void EnsureColumns<TEntity>(TEntity entity, Columns<TEntity> columns)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -230,6 +195,8 @@ namespace InABox.Clients
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #region Query
|
|
|
+
|
|
|
public static CoreTable Query<TEntity>(Filter<TEntity>? filter = null, Columns<TEntity>? columns = null, SortOrder<TEntity>? orderby = null, CoreRange? range = null)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -254,6 +221,10 @@ namespace InABox.Clients
|
|
|
new Client<TEntity>().Query(filter, columns, orderby, null, callback);
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Save
|
|
|
+
|
|
|
public static void Save<TEntity>(TEntity entity, string auditNote)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -265,6 +236,17 @@ namespace InABox.Clients
|
|
|
new Client<TEntity>().Save(entities, auditNote);
|
|
|
}
|
|
|
|
|
|
+ public static Task SaveAsync<TEntity>(TEntity entity, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, new()
|
|
|
+ {
|
|
|
+ return Task.Run(() => new Client<TEntity>().Save(entity, auditNote));
|
|
|
+ }
|
|
|
+ public static Task SaveAsync<TEntity>(IEnumerable<TEntity> entities, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, new()
|
|
|
+ {
|
|
|
+ return Task.Run(() => new Client<TEntity>().Save(entities, auditNote));
|
|
|
+ }
|
|
|
+
|
|
|
public static void Save<TEntity>(TEntity entity, string auditNote, Action<TEntity, Exception?> callback)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -276,6 +258,10 @@ namespace InABox.Clients
|
|
|
new Client<TEntity>().Save(entities, auditNote, callback);
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Delete
|
|
|
+
|
|
|
public static void Delete<TEntity>(TEntity entity, string auditNote)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -288,6 +274,17 @@ namespace InABox.Clients
|
|
|
new Client<TEntity>().Delete(entity, auditNote, callback);
|
|
|
}
|
|
|
|
|
|
+ public static Task DeleteAsync<TEntity>(TEntity entity, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, new()
|
|
|
+ {
|
|
|
+ return Task.Run(() => new Client<TEntity>().Delete(entity, auditNote));
|
|
|
+ }
|
|
|
+ public static Task DeleteAsync<TEntity>(IEnumerable<TEntity> entities, string auditNote)
|
|
|
+ where TEntity : Entity, IRemotable, new()
|
|
|
+ {
|
|
|
+ return Task.Run(() => new Client<TEntity>().Delete(entities, auditNote));
|
|
|
+ }
|
|
|
+
|
|
|
public static void Delete<TEntity>(IEnumerable<TEntity> entities, string auditNote)
|
|
|
where TEntity : Entity, IRemotable, new()
|
|
|
{
|
|
@@ -300,6 +297,10 @@ namespace InABox.Clients
|
|
|
new Client<TEntity>().Delete(entities, auditNote, callback);
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Query Multiple
|
|
|
+
|
|
|
public static void QueryMultiple(
|
|
|
Action<Dictionary<string, CoreTable>?, Exception?> callback,
|
|
|
Dictionary<string, IQueryDef> queries)
|
|
@@ -357,6 +358,44 @@ namespace InABox.Clients
|
|
|
return new QueryMultipleResults(await QueryMultipleAsync(queries.ToDictionary(x => x.Key, x => x as IQueryDef)));
|
|
|
}
|
|
|
|
|
|
+ public static Dictionary<string, CoreTable> QueryMultiple(Dictionary<string, IQueryDef> queries)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using var timer = new Profiler(false);
|
|
|
+ var result = CheckClient().QueryMultiple(queries);
|
|
|
+ timer.Log(result.Sum(x => x.Value.Rows.Count));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ catch (RequestException e)
|
|
|
+ {
|
|
|
+ ClientFactory.RaiseRequestError(e);
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Task<Dictionary<string, CoreTable>> QueryMultipleAsync(Dictionary<string, IQueryDef> queries)
|
|
|
+ {
|
|
|
+ return Task.Run(() =>
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using var timer = new Profiler(false);
|
|
|
+ var result = CheckClient().QueryMultiple(queries);
|
|
|
+ timer.Log(result.Sum(x => x.Value.Rows.Count));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ catch (RequestException e)
|
|
|
+ {
|
|
|
+ ClientFactory.RaiseRequestError(e);
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
public static IValidationData Validate(Guid session)
|
|
|
{
|
|
|
try
|