Add SignalRDataSource, SignalRDataSourceAsync
This commit is contained in:
parent
1a15ab4128
commit
4f97dcec4c
|
|
@ -4,6 +4,8 @@ namespace TIAM.Services;
|
|||
|
||||
public class SignalRTags : AcSignalRTags
|
||||
{
|
||||
public const int None = 0;
|
||||
|
||||
public const int GetTransfer = 3;
|
||||
public const int GetTransfers = 4;
|
||||
public const int GetTransfersByContextId = 5;
|
||||
|
|
|
|||
|
|
@ -194,10 +194,10 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
|||
|
||||
protected virtual async Task PostDataToServerAsync(TDataItem dataItem, int messageTag, DataChangeMode dataChangeMode)
|
||||
{
|
||||
var eventArgs = new GridDataItemChangingEventArgs<TDataItem>(this, dataItem, dataChangeMode);
|
||||
await OnDataItemChanging.InvokeAsync(eventArgs);
|
||||
var changingEventArgs = new GridDataItemChangingEventArgs<TDataItem>(this, dataItem, dataChangeMode);
|
||||
await OnDataItemChanging.InvokeAsync(changingEventArgs);
|
||||
|
||||
if (eventArgs.IsCanceled)
|
||||
if (changingEventArgs.IsCanceled)
|
||||
{
|
||||
Logger.Debug($"{_gridLogName} OnDataItemChanging canceled");
|
||||
return;
|
||||
|
|
@ -211,17 +211,19 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
|||
|
||||
_dataSource.UpdateCollection(dataItem, dataChangeMode == DataChangeMode.Remove); //egyből látszódik a változás a grid-ben, nem csak a callback lefutásakor! felhasználóbarátabb... - J.
|
||||
|
||||
SignalRClient.PostDataAsync(messageTag, dataItem, async repsonse =>
|
||||
SignalRClient.PostDataAsync(messageTag, dataItem, async response =>
|
||||
{
|
||||
if (repsonse.Status != SignalResponseStatus.Success || repsonse.ResponseData == null)
|
||||
if (response.Status != SignalResponseStatus.Success || response.ResponseData == null)
|
||||
{
|
||||
RefreshDataSourceAsync().Forget();
|
||||
return;
|
||||
}
|
||||
|
||||
_dataSource.UpdateCollection(repsonse.ResponseData, dataChangeMode == DataChangeMode.Remove);
|
||||
_dataSource.UpdateCollection(response.ResponseData, dataChangeMode == DataChangeMode.Remove);
|
||||
|
||||
var changedEventArgs = new GridDataItemChangedEventArgs<TDataItem>(this, response.ResponseData, dataChangeMode);
|
||||
await OnDataItemChanged.InvokeAsync(changedEventArgs);
|
||||
|
||||
await OnDataItemChanged.InvokeAsync(eventArgs);
|
||||
InvokeAsync(StateHasChanged).Forget();
|
||||
}).Forget();
|
||||
|
||||
|
|
|
|||
|
|
@ -94,13 +94,16 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
public virtual Task GetByIdAsync<TResponseData>(int messageTag, Guid id, Action<ISignalResponseMessage<TResponseData?>> responseCallback)
|
||||
=> SendMessageToServerAsync(messageTag, new SignalPostJsonDataMessage<IdMessage>(new IdMessage(id)), responseCallback);
|
||||
|
||||
public virtual Task<TResponse?> GetAllAsync<TResponse>(int messageTag) where TResponse : class
|
||||
=> SendMessageToServerAsync<TResponse>(messageTag);
|
||||
public virtual Task<TResponseData?> GetAllAsync<TResponseData>(int messageTag) where TResponseData : class
|
||||
=> SendMessageToServerAsync<TResponseData>(messageTag);
|
||||
public virtual Task GetAllAsync<TResponseData>(int messageTag, Action<ISignalResponseMessage<TResponseData?>> responseCallback)
|
||||
=> SendMessageToServerAsync(messageTag, null, responseCallback);
|
||||
public virtual Task GetAllAsync<TResponseData>(int messageTag, Guid? contextId, Action<ISignalResponseMessage<TResponseData?>> responseCallback)
|
||||
=> SendMessageToServerAsync(messageTag, (contextId.IsNullOrEmpty() ? null : new SignalPostJsonDataMessage<IdMessage>(new IdMessage(contextId.Value))), responseCallback);
|
||||
|
||||
public virtual Task<TResponseData?> GetAllAsync<TResponseData>(int messageTag, Guid? contextId) where TResponseData : class
|
||||
=> SendMessageToServerAsync<TResponseData>(messageTag, contextId.IsNullOrEmpty() ? null : new SignalPostJsonDataMessage<IdMessage>(new IdMessage(contextId.Value)), AcDomain.NextUniqueInt32);
|
||||
|
||||
public virtual Task<TPostData?> PostDataAsync<TPostData>(int messageTag, TPostData postData) where TPostData : class
|
||||
=> SendMessageToServerAsync<TPostData>(messageTag, new SignalPostJsonDataMessage<TPostData>(postData), AcDomain.NextUniqueInt32);
|
||||
public virtual Task PostDataAsync<TPostData>(int messageTag, TPostData postData, Action<ISignalResponseMessage<TPostData?>> responseCallback) where TPostData : class
|
||||
|
|
|
|||
|
|
@ -0,0 +1,380 @@
|
|||
using System.Collections;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using AyCode.Core.Enums;
|
||||
using AyCode.Core.Extensions;
|
||||
using AyCode.Core.Interfaces;
|
||||
using AyCode.Services.SignalRs;
|
||||
using TIAM.Services;
|
||||
using TIAMWebApp.Shared.Application.Services;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Utility
|
||||
{
|
||||
public class ChangeTracking<T>(DataChangeMode dataChangeMode, T newItem, T originalItem = default(T))where T: class, IId<Guid>
|
||||
{
|
||||
public DataChangeMode DataChangeMode { get; init; } = dataChangeMode;
|
||||
public T NewItem { get; init; } = newItem;
|
||||
public T OriginalItem { get; init; } = originalItem;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public class SignalRDataSource<T> : IList<T>, IList, IReadOnlyList<T> where T: class, IId<Guid>
|
||||
{
|
||||
protected readonly List<T> InnerList = [];
|
||||
private readonly object _syncRoot = new();
|
||||
|
||||
protected Guid? ContextId;
|
||||
protected AcSignalRClientBase SignalRClient;
|
||||
protected readonly SignalRCrudTags SignalRCrudTags;
|
||||
|
||||
public SignalRDataSource(AcSignalRClientBase signalRClient, SignalRCrudTags signalRCrudTags, Guid? contextId = null, bool autoLoadDataSource = true)
|
||||
{
|
||||
ContextId = contextId;
|
||||
|
||||
SignalRCrudTags = signalRCrudTags;
|
||||
SignalRClient = signalRClient;
|
||||
|
||||
if (autoLoadDataSource) LoadDataSource();
|
||||
}
|
||||
|
||||
public bool IsSynchronized => true;
|
||||
public object SyncRoot => _syncRoot;
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
/// <summary>
|
||||
/// GetAllMessageTag
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <exception cref="NullReferenceException"></exception>
|
||||
public void LoadDataSource()
|
||||
{
|
||||
if (SignalRCrudTags.GetAllMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.GetAllMessageTag == SignalRTags.None;");
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
var resultList = SignalRClient.GetAllAsync<List<T>>(SignalRCrudTags.GetAllMessageTag, ContextId).GetAwaiter().GetResult() ?? throw new NullReferenceException();
|
||||
|
||||
Clear();
|
||||
InnerList.AddRange(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set: UpdateMessageTag
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public T this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((uint)index >= (uint)Count) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
return InnerList[index];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
Update(index, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_syncRoot) return InnerList.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddMessageTag
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public void Add(T item)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (Contains(item))
|
||||
throw new ArgumentException($@"It already contains this Id! Id: {item.Id}", nameof(item));
|
||||
|
||||
UnsafeAdd(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddMessageTag or UpdateMessageTag
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public T AddOrUpdate(T item)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
var index = IndexOf(item);
|
||||
|
||||
return index > -1 ? Update(index, item) : UnsafeAdd(item);
|
||||
}
|
||||
}
|
||||
|
||||
//public void AddRange(IEnumerable<T> collection)
|
||||
//{
|
||||
// lock (_syncRoot)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
private T UnsafeAdd(T item)
|
||||
{
|
||||
if (SignalRCrudTags.AddMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.AddMessageTag == SignalRTags.None;");
|
||||
|
||||
var result = SignalRClient.PostDataAsync(SignalRCrudTags.AddMessageTag, item).GetAwaiter().GetResult() ?? throw new NullReferenceException();
|
||||
InnerList.Add(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddMessageTag
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <exception cref="NullReferenceException"></exception>
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
if (SignalRCrudTags.AddMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.AddMessageTag == SignalRTags.None;");
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (Contains(item))
|
||||
throw new ArgumentException($@"It already contains this Id! Id: {item.Id}", nameof(item));
|
||||
|
||||
var result = SignalRClient.PostDataAsync(SignalRCrudTags.AddMessageTag, item).GetAwaiter().GetResult() ?? throw new NullReferenceException();
|
||||
InnerList.Insert(index, result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UpdateMessageTag
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public T Update(T item) => Update(IndexOf(item), item);
|
||||
|
||||
/// <summary>
|
||||
/// UpdateMessageTag
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="item"></param>
|
||||
/// /// <exception cref="ArgumentException"></exception>
|
||||
/// /// <exception cref="NullReferenceException"></exception>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public T Update(int index, T item)
|
||||
{
|
||||
if (SignalRCrudTags.UpdateMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.UpdateMessageTag == SignalRTags.None;");
|
||||
|
||||
if (default(T) != null && item == null) throw new NullReferenceException(nameof(item));
|
||||
if (item.Id.IsNullOrEmpty()) throw new ArgumentNullException(nameof(item), "Update->item.Id.IsNullOrEmpty()");
|
||||
if ((uint)index >= (uint)Count) throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (InnerList[index].Id != item.Id)
|
||||
throw new ArgumentException($@"_list[index].Id != item.Id! Id: {item.Id}", nameof(item));
|
||||
|
||||
var result = SignalRClient.PostDataAsync(SignalRCrudTags.UpdateMessageTag, item).GetAwaiter().GetResult() ?? throw new NullReferenceException();
|
||||
|
||||
InnerList[index] = result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RemoveMessageTag
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(T item)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
var index = IndexOf(item);
|
||||
|
||||
if (index < 0) return false;
|
||||
|
||||
RemoveAt(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RemoveMessageTag
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// /// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="NullReferenceException"></exception>
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (SignalRCrudTags.RemoveMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.RemoveMessageTag == SignalRTags.None;");
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
var item = InnerList[index];
|
||||
if (item.Id.IsNullOrEmpty()) throw new ArgumentNullException(nameof(item), $@"RemoveAt->item.Id.IsNullOrEmpty(); index: {index}");
|
||||
|
||||
var result = SignalRClient.PostDataAsync(SignalRCrudTags.RemoveMessageTag, item).GetAwaiter().GetResult() ?? throw new NullReferenceException();
|
||||
|
||||
InnerList.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
lock (_syncRoot) InnerList.Clear();
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
return InnerList.FindIndex(x => x.Id == item.Id);
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
lock (_syncRoot)
|
||||
return IndexOf(item) > -1;
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array) => CopyTo(array, 0);
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
lock (_syncRoot) InnerList.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int BinarySearch(int index, int count, T item, IComparer<T>? comparer)
|
||||
{
|
||||
if (index < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
if (Count - index < count)
|
||||
throw new ArgumentException("Invalid length");
|
||||
|
||||
lock (_syncRoot)
|
||||
return InnerList.BinarySearch(index, count, item, comparer);
|
||||
}
|
||||
|
||||
public int BinarySearch(T item) => BinarySearch(0, Count, item, null);
|
||||
public int BinarySearch(T item, IComparer<T>? comparer) => BinarySearch(0, Count, item, comparer);
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
lock (_syncRoot)
|
||||
return InnerList.ToList().GetEnumerator();
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<T> AsReadOnly() => new(this);
|
||||
private static bool IsCompatibleObject(object? value) => (value is T) || (value == null && default(T) == null);
|
||||
|
||||
|
||||
#region IList, ICollection
|
||||
bool IList.IsReadOnly => false;
|
||||
|
||||
object? IList.this[int index]
|
||||
{
|
||||
get => this[index];
|
||||
set
|
||||
{
|
||||
if (default(T) != null && value == null) throw new NullReferenceException(nameof(value));
|
||||
|
||||
try
|
||||
{
|
||||
this[index] = (T)value!;
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new InvalidCastException(nameof(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int IList.Add(object? item)
|
||||
{
|
||||
if (default(T) != null && item == null) throw new NullReferenceException(nameof(item));
|
||||
|
||||
try
|
||||
{
|
||||
Add((T)item!);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new InvalidCastException(nameof(item));
|
||||
}
|
||||
|
||||
return Count - 1;
|
||||
}
|
||||
|
||||
void IList.Clear() => Clear();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
bool IList.Contains(object? item) => IsCompatibleObject(item) && Contains((T)item!);
|
||||
int IList.IndexOf(object? item) => (IsCompatibleObject(item)) ? IndexOf((T)item!) : -1;
|
||||
|
||||
void IList.Insert(int index, object? item)
|
||||
{
|
||||
if (default(T) != null && item == null) throw new NullReferenceException(nameof(item));
|
||||
|
||||
try
|
||||
{
|
||||
Insert(index, (T)item!);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
throw new InvalidCastException(nameof(item));
|
||||
}
|
||||
}
|
||||
|
||||
void IList.Remove(object? item)
|
||||
{
|
||||
if (IsCompatibleObject(item)) Remove((T)item!);
|
||||
}
|
||||
|
||||
void ICollection<T>.Clear() => Clear();
|
||||
|
||||
void ICollection.CopyTo(Array array, int arrayIndex)
|
||||
{
|
||||
if ((array != null) && (array.Rank != 1))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//TODO: _list.ToArray() - ez nem az igazi... - J.
|
||||
Array.Copy(InnerList.ToArray(), 0, array!, arrayIndex, InnerList.Count);
|
||||
}
|
||||
catch (ArrayTypeMismatchException)
|
||||
{
|
||||
throw new ArrayTypeMismatchException();
|
||||
}
|
||||
}
|
||||
|
||||
int ICollection.Count => Count;
|
||||
int ICollection<T>.Count => Count;
|
||||
bool ICollection<T>.IsReadOnly => false;
|
||||
void IList<T>.RemoveAt(int index) => RemoveAt(index);
|
||||
int IReadOnlyCollection<T>.Count => Count;
|
||||
#endregion IList, ICollection
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
using System.Diagnostics;
|
||||
using AyCode.Core.Enums;
|
||||
using AyCode.Core.Helpers;
|
||||
using AyCode.Core.Interfaces;
|
||||
using AyCode.Services.SignalRs;
|
||||
using TIAM.Services;
|
||||
using TIAMWebApp.Shared.Application.Services;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Utility;
|
||||
|
||||
[Serializable]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public class SignalRDataSourceAsync<T> : SignalRDataSource<T> where T : class, IId<Guid>
|
||||
{
|
||||
public Action<ItemChangedEventArgs<T>>? OnItemChanged;
|
||||
public Action<SignalRDataSourceAsync<T>>? OnDataSourceLoaded;
|
||||
|
||||
public SignalRDataSourceAsync(AcSignalRClientBase signalRClient, SignalRCrudTags signalRCrudTags, Guid? contextId = null, Action<SignalRDataSourceAsync<T>>? onDataSourceLoaded = null, bool autoLoadDataSource = false)
|
||||
: base(signalRClient, signalRCrudTags, contextId, false)
|
||||
{
|
||||
OnDataSourceLoaded = onDataSourceLoaded;
|
||||
|
||||
if (autoLoadDataSource) LoadDataSourceAsync();
|
||||
}
|
||||
|
||||
public void LoadDataSourceAsync()
|
||||
{
|
||||
if (SignalRCrudTags.GetAllMessageTag == SignalRTags.None) throw new ArgumentException($"_signalRCrudTags.GetAllMessageTag == SignalRTags.None;");
|
||||
|
||||
Monitor.Exit(SyncRoot); //Exception test - J.
|
||||
|
||||
Monitor.Enter(SyncRoot);
|
||||
try
|
||||
{
|
||||
SignalRClient.GetAllAsync<List<T>>(SignalRCrudTags.GetAllMessageTag, ContextId, response =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (response.Status == SignalResponseStatus.Error) throw new Exception($"LoadDataSourceAsync; response.Status == SignalResponseStatus.Error");
|
||||
if (response.ResponseData == null) throw new NullReferenceException($"response.ResponseData == null");
|
||||
|
||||
Clear();
|
||||
InnerList.AddRange(response.ResponseData);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(SyncRoot);
|
||||
}
|
||||
|
||||
OnDataSourceLoaded?.Invoke(this);
|
||||
}).Forget();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Monitor.Exit(SyncRoot);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//public T Add(T item, int messageTag) => PostDataToServerAsync(item, messageTag, DataChangeMode.Add).GetAwaiter().GetResult();
|
||||
//public Task AddAsync(T item, int messageTag) => PostDataToServerAsync(item, messageTag, DataChangeMode.Add);
|
||||
|
||||
|
||||
//public Task UpdateAsync(T item, int messageTag) => PostDataToServerAsync(item, messageTag, DataChangeMode.Update);
|
||||
|
||||
//public Task RemoveAsync(T item, int messageTag) => PostDataToServerAsync(item, messageTag, DataChangeMode.Remove);
|
||||
|
||||
//public Task RemoveAsync(Guid id, int messageTag)
|
||||
//{
|
||||
// var item = _list.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
// return item == null ? Task.CompletedTask : RemoveAsync(item, messageTag);
|
||||
//}
|
||||
|
||||
//protected virtual Task PostDataToServerAsync(T item, int messageTag, DataChangeMode dataChangeMode)
|
||||
//{
|
||||
// if (messageTag == 0) return Task.CompletedTask;
|
||||
|
||||
// logger.Info($"{_listLogName} PostDataToServerAsync called; transferId " + item.Id);
|
||||
|
||||
// if (item.Id.IsNullOrEmpty()) item.Id = Guid.NewGuid();
|
||||
|
||||
// _list.UpdateCollection(item, dataChangeMode == DataChangeMode.Remove); //egyből látszódik a változás a grid-ben, nem csak a callback lefutásakor! felhasználóbarátabb... - J.
|
||||
|
||||
// await _signalRClient.PostDataAsync(messageTag, item, async repsonse =>
|
||||
// {
|
||||
// if (repsonse.Status != SignalResponseStatus.Success || repsonse.ResponseData == null)
|
||||
// {
|
||||
// RefreshDataSourceAsync().Forget();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// _list.UpdateCollection(repsonse.ResponseData, dataChangeMode == DataChangeMode.Remove);
|
||||
|
||||
// var eventArgs = new ItemChangedEventArgs<T>(repsonse.ResponseData, dataChangeMode);
|
||||
// OnItemChanged.Invoke(eventArgs);
|
||||
// });
|
||||
|
||||
// //transfer = await devAdminSignalClient.PostDataAsync(SignalRTags.UpdateTransferAsync, transfer);
|
||||
|
||||
// return Task.CompletedTask;
|
||||
//}
|
||||
|
||||
public class ItemChangedEventArgs<T> where T : IId<Guid>
|
||||
{
|
||||
internal ItemChangedEventArgs(T item, DataChangeMode dataChangeMode)
|
||||
{
|
||||
Item = item;
|
||||
DataChangeMode = dataChangeMode;
|
||||
}
|
||||
|
||||
public T Item { get; }
|
||||
public DataChangeMode DataChangeMode { get; }
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue