|
@@ -5,6 +5,7 @@ using System.ComponentModel;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Linq.Expressions;
|
|
|
|
+using System.Reflection;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using InABox.Clients;
|
|
using InABox.Clients;
|
|
@@ -58,6 +59,17 @@ namespace InABox.Mobile
|
|
|
|
|
|
protected CoreRepository(IModelHost host, Func<Filter<TEntity>> baseFilter)
|
|
protected CoreRepository(IModelHost host, Func<Filter<TEntity>> baseFilter)
|
|
{
|
|
{
|
|
|
|
+ _items = new CoreObservableCollection<TItem>();
|
|
|
|
+ BindingBase.EnableCollectionSynchronization(_items, null,
|
|
|
|
+ (collection, context, method, access) =>
|
|
|
|
+ {
|
|
|
|
+ lock (collection)
|
|
|
|
+ {
|
|
|
|
+ method?.Invoke();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
Reset();
|
|
Reset();
|
|
Host = host;
|
|
Host = host;
|
|
BaseFilter = baseFilter;
|
|
BaseFilter = baseFilter;
|
|
@@ -208,8 +220,8 @@ namespace InABox.Mobile
|
|
private IList<TItem> _allitems;
|
|
private IList<TItem> _allitems;
|
|
|
|
|
|
private CoreTable _table = new CoreTable();
|
|
private CoreTable _table = new CoreTable();
|
|
-
|
|
|
|
- private readonly CoreObservableCollection<TItem> _items = new CoreObservableCollection<TItem>();
|
|
|
|
|
|
+
|
|
|
|
+ private readonly CoreObservableCollection<TItem> _items;
|
|
public IList<TItem> Items => _items;
|
|
public IList<TItem> Items => _items;
|
|
IEnumerable ICoreRepository.Items => Items;
|
|
IEnumerable ICoreRepository.Items => Items;
|
|
|
|
|
|
@@ -296,7 +308,11 @@ namespace InABox.Mobile
|
|
_items.ReplaceRange(items);
|
|
_items.ReplaceRange(items);
|
|
OnPropertyChanged(nameof(Items));
|
|
OnPropertyChanged(nameof(Items));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ void ICoreRepository.Search(Func<object,bool> method)
|
|
|
|
+ => Search((o) => method(o as TItem));
|
|
|
|
+
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
protected virtual Expression<Func<TEntity, object>> ImageColumn => null;
|
|
protected virtual Expression<Func<TEntity, object>> ImageColumn => null;
|
|
@@ -323,6 +339,7 @@ namespace InABox.Mobile
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
protected virtual void BeforeLoad(MultiQuery query)
|
|
protected virtual void BeforeLoad(MultiQuery query)
|
|
@@ -337,10 +354,25 @@ namespace InABox.Mobile
|
|
|
|
|
|
protected void DoLoad()
|
|
protected void DoLoad()
|
|
{
|
|
{
|
|
- DoBeforeLoad();
|
|
|
|
- _query.Query();
|
|
|
|
- DoAfterLoad();
|
|
|
|
- LastUpdated = DateTime.Now;
|
|
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ DoBeforeLoad();
|
|
|
|
+ BeforeLoad(_query);
|
|
|
|
+ Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ _query.Query();
|
|
|
|
+ DoAfterLoad();
|
|
|
|
+ }).Wait();
|
|
|
|
+ Search();
|
|
|
|
+ AfterLoad(_query);
|
|
|
|
+ LastUpdated = DateTime.Now;
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ MobileLogging.Log(e,"CoreRepository");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
protected void DoAfterLoad()
|
|
protected void DoAfterLoad()
|
|
@@ -354,7 +386,7 @@ namespace InABox.Mobile
|
|
_query.Get<Document>().IntoDictionary<Document, Guid, byte[]>(Images, x => x.ID,
|
|
_query.Get<Document>().IntoDictionary<Document, Guid, byte[]>(Images, x => x.ID,
|
|
r => r.Get<Document, byte[]>(x => x.Data));
|
|
r => r.Get<Document, byte[]>(x => x.Data));
|
|
}
|
|
}
|
|
- AfterLoad(_query);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#endregion
|