Compare commits
2 Commits
223e74c490
...
83264731f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 83264731f3 | |||
| 0f3047a2b6 |
@@ -1,8 +1,11 @@
|
|||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
using salesbook.Shared.Core.Dto;
|
||||||
using salesbook.Shared.Core.Entity;
|
using salesbook.Shared.Core.Entity;
|
||||||
|
using salesbook.Shared.Core.Helpers;
|
||||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||||
using salesbook.Shared.Core.Messages.Notification.NewPush;
|
using salesbook.Shared.Core.Messages.Notification.NewPush;
|
||||||
using Shiny.Push;
|
using Shiny.Push;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace salesbook.Maui.Core.System.Notification.Push;
|
namespace salesbook.Maui.Core.System.Notification.Push;
|
||||||
|
|
||||||
@@ -20,10 +23,25 @@ public class PushNotificationDelegate(
|
|||||||
public Task OnReceived(PushNotification notification)
|
public Task OnReceived(PushNotification notification)
|
||||||
{
|
{
|
||||||
if (notification.Notification is null) return Task.CompletedTask;
|
if (notification.Notification is null) return Task.CompletedTask;
|
||||||
|
var data = notification.Data;
|
||||||
|
|
||||||
|
NotificationDataDTO? notificationDataDto = null;
|
||||||
|
|
||||||
|
if (!data.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
var json = JsonSerializer.Serialize(data);
|
||||||
|
notificationDataDto = JsonSerializer.Deserialize<NotificationDataDTO>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notificationDataDto?.NotificationId == null) return Task.CompletedTask;
|
||||||
|
var notificationId = long.Parse(notificationDataDto.NotificationId);
|
||||||
|
|
||||||
var pushNotification = new WtbNotification
|
var pushNotification = new WtbNotification
|
||||||
{
|
{
|
||||||
|
Id = notificationId,
|
||||||
Title = notification.Notification.Title,
|
Title = notification.Notification.Title,
|
||||||
Body = notification.Notification.Message
|
Body = notification.Notification.Message,
|
||||||
|
NotificationData = notificationDataDto
|
||||||
};
|
};
|
||||||
|
|
||||||
messenger.Send(new NewPushNotificationMessage(pushNotification));
|
messenger.Send(new NewPushNotificationMessage(pushNotification));
|
||||||
|
|||||||
@@ -77,11 +77,11 @@
|
|||||||
[JSInvokable]
|
[JSInvokable]
|
||||||
public async Task Delete(string id)
|
public async Task Delete(string id)
|
||||||
{
|
{
|
||||||
Loading = true;
|
|
||||||
_ = InvokeAsync(StateHasChanged);
|
|
||||||
|
|
||||||
if (!long.TryParse(id, out var notificationId)) return;
|
if (!long.TryParse(id, out var notificationId)) return;
|
||||||
|
|
||||||
|
Loading = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
var removed = false;
|
var removed = false;
|
||||||
|
|
||||||
if (Notification.ReceivedNotifications.RemoveAll(x => x.Id == notificationId) > 0)
|
if (Notification.ReceivedNotifications.RemoveAll(x => x.Id == notificationId) > 0)
|
||||||
@@ -91,16 +91,18 @@
|
|||||||
else if (Notification.NotificationsRead.RemoveAll(x => x.Id == notificationId) > 0)
|
else if (Notification.NotificationsRead.RemoveAll(x => x.Id == notificationId) > 0)
|
||||||
removed = true;
|
removed = true;
|
||||||
|
|
||||||
if (!removed) return;
|
if (!removed)
|
||||||
|
{
|
||||||
|
Loading = false;
|
||||||
|
StateHasChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await IntegryNotificationRestClient.Delete(notificationId);
|
||||||
|
|
||||||
NotificationService.OrderNotificationList();
|
NotificationService.OrderNotificationList();
|
||||||
Loading = false;
|
Loading = false;
|
||||||
_ = InvokeAsync(StateHasChanged);
|
StateHasChanged();
|
||||||
|
|
||||||
_ = Task.Run(() =>
|
|
||||||
{
|
|
||||||
_ = IntegryNotificationRestClient.Delete(notificationId);
|
|
||||||
});
|
|
||||||
|
|
||||||
Messenger.Send(new NotificationsLoadedMessage());
|
Messenger.Send(new NotificationsLoadedMessage());
|
||||||
}
|
}
|
||||||
@@ -109,7 +111,7 @@
|
|||||||
public async Task MarkAsRead(string id)
|
public async Task MarkAsRead(string id)
|
||||||
{
|
{
|
||||||
Loading = true;
|
Loading = true;
|
||||||
_ = InvokeAsync(StateHasChanged);
|
StateHasChanged();
|
||||||
|
|
||||||
var notificationId = long.Parse(id);
|
var notificationId = long.Parse(id);
|
||||||
|
|
||||||
|
|||||||
@@ -47,11 +47,11 @@
|
|||||||
Notification.StartDate < DateTime.Today && Notification.Body != null && Notification.Body.Contains("Oggi")
|
Notification.StartDate < DateTime.Today && Notification.Body != null && Notification.Body.Contains("Oggi")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body.Replace("Oggi", $"{Notification.StartDate:d}")</MudText>
|
<div class="subtitle">@Notification.Body.Replace("Oggi", $"{Notification.StartDate:d}")</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body</MudText>
|
<div class="subtitle">@Notification.Body</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -105,4 +105,6 @@
|
|||||||
.notification-body ::deep > .subtitle {
|
.notification-body ::deep > .subtitle {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--mud-palette-drawer-text);
|
color: var(--mud-palette-drawer-text);
|
||||||
|
line-height: inherit;
|
||||||
|
margin-top: .5rem;
|
||||||
}
|
}
|
||||||
@@ -40,19 +40,18 @@
|
|||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span class="disable-full-width">Commessa</span>
|
<span class="disable-full-width">Commessa</span>
|
||||||
|
|
||||||
@if (Commesse.IsNullOrEmpty())
|
<MudAutocomplete
|
||||||
{
|
Disabled="ActivityModel.Cliente.IsNullOrEmpty()"
|
||||||
<span class="warning-text">Nessuna commessa presente</span>
|
T="JtbComt?"
|
||||||
}
|
@bind-Value="SelectedComessa"
|
||||||
else
|
@bind-Value:after="OnCommessaSelectedAfter"
|
||||||
{
|
SearchFunc="SearchCommesseAsync"
|
||||||
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || Commesse.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.CodJcom" @bind-Value:after="OnCommessaChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
ToStringFunc="@(c => c == null ? string.Empty : $"{c.CodJcom} - {c.Descrizione}")"
|
||||||
@foreach (var com in Commesse)
|
Clearable="true"
|
||||||
{
|
ShowProgressIndicator="true"
|
||||||
<MudSelectItemExtended Class="custom-item-select" Value="@com.CodJcom">@($"{com.CodJcom} - {com.Descrizione}")</MudSelectItemExtended>
|
DebounceInterval="300"
|
||||||
}
|
MaxItems="50"
|
||||||
</MudSelectExtended>
|
Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"/>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,13 +90,19 @@
|
|||||||
<div class="input-card">
|
<div class="input-card">
|
||||||
<div class="form-container">
|
<div class="form-container">
|
||||||
<span class="disable-full-width">Assegnata a</span>
|
<span class="disable-full-width">Assegnata a</span>
|
||||||
|
<MudAutocomplete
|
||||||
<MudSelectExtended FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.UserName" @bind-Value:after="OnUserChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
Disabled="Users.IsNullOrEmpty()"
|
||||||
@foreach (var user in Users)
|
T="StbUser"
|
||||||
{
|
@bind-Value="SelectedUser"
|
||||||
<MudSelectItemExtended Class="custom-item-select" Value="@user.UserName">@user.FullName</MudSelectItemExtended>
|
@bind-Value:after="OnUserSelectedAfter"
|
||||||
}
|
SearchFunc="SearchUtentiAsync"
|
||||||
</MudSelectExtended>
|
ToStringFunc="@(u => u == null ? string.Empty : u.FullName)"
|
||||||
|
Clearable="true"
|
||||||
|
ShowProgressIndicator="true"
|
||||||
|
DebounceInterval="300"
|
||||||
|
MaxItems="50"
|
||||||
|
Class="customIcon-select"
|
||||||
|
AdornmentIcon="@Icons.Material.Filled.Code"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -282,6 +287,15 @@
|
|||||||
private string? NamePosition { get; set; }
|
private string? NamePosition { get; set; }
|
||||||
private bool CanAddPosition { get; set; } = true;
|
private bool CanAddPosition { get; set; } = true;
|
||||||
|
|
||||||
|
// cache per commesse
|
||||||
|
private string? _lastLoadedCodAnag;
|
||||||
|
|
||||||
|
//Commessa
|
||||||
|
private JtbComt? SelectedComessa { get; set; }
|
||||||
|
|
||||||
|
//User
|
||||||
|
private StbUser? SelectedUser { get; set; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||||
@@ -291,24 +305,24 @@
|
|||||||
ActivityModel = ActivityCopied.Clone();
|
ActivityModel = ActivityCopied.Clone();
|
||||||
}
|
}
|
||||||
else if (!Id.IsNullOrEmpty())
|
else if (!Id.IsNullOrEmpty())
|
||||||
|
{
|
||||||
ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).Last();
|
ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).Last();
|
||||||
|
}
|
||||||
|
|
||||||
if (Id.IsNullOrEmpty()) Id = ActivityModel.ActivityId;
|
if (Id.IsNullOrEmpty()) Id = ActivityModel.ActivityId;
|
||||||
IsNew = Id.IsNullOrEmpty();
|
IsNew = Id.IsNullOrEmpty();
|
||||||
LabelSave = IsNew ? "Aggiungi" : null;
|
LabelSave = IsNew ? "Aggiungi" : null;
|
||||||
|
|
||||||
_ = LoadData();
|
|
||||||
await LoadCommesse();
|
|
||||||
|
|
||||||
if (IsNew)
|
if (IsNew)
|
||||||
{
|
{
|
||||||
ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour));
|
ActivityModel.EstimatedTime = DateTime.Today.AddHours(DateTime.Now.Hour);
|
||||||
ActivityModel.EstimatedEndtime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour) + TimeSpan.FromHours(1));
|
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime?.AddHours(1);
|
||||||
ActivityModel.UserName = UserSession.User.Username;
|
ActivityModel.UserName = UserSession.User.Username;
|
||||||
}
|
}
|
||||||
|
|
||||||
await LoadActivityType();
|
_ = LoadData();
|
||||||
|
|
||||||
|
await LoadActivityType();
|
||||||
OriginalModel = ActivityModel.Clone();
|
OriginalModel = ActivityModel.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,67 +334,59 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
await SavePosition();
|
await SavePosition();
|
||||||
|
|
||||||
var response = await IntegryApiService.SaveActivity(ActivityModel);
|
var response = await IntegryApiService.SaveActivity(ActivityModel);
|
||||||
|
|
||||||
if (response == null)
|
if (response == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var newActivity = response.Last();
|
var newActivity = response.Last();
|
||||||
|
|
||||||
await ManageData.InsertOrUpdate(newActivity);
|
await ManageData.InsertOrUpdate(newActivity);
|
||||||
|
|
||||||
await SaveAttached(newActivity.ActivityId!);
|
await SaveAttached(newActivity.ActivityId!);
|
||||||
|
|
||||||
SuccessAnimation = true;
|
SuccessAnimation = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
await Task.Delay(1250);
|
await Task.Delay(1250);
|
||||||
|
|
||||||
MudDialog.Close(newActivity);
|
MudDialog.Close(newActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SavePosition()
|
private async Task SavePosition()
|
||||||
{
|
{
|
||||||
if (AttachedList != null)
|
if (AttachedList is null) return;
|
||||||
{
|
|
||||||
foreach (var attached in AttachedList)
|
|
||||||
{
|
|
||||||
if (attached.Type != AttachedDTO.TypeAttached.Position) continue;
|
|
||||||
|
|
||||||
|
var positionTasks = AttachedList
|
||||||
|
.Where(a => a.Type == AttachedDTO.TypeAttached.Position)
|
||||||
|
.Select(async attached =>
|
||||||
|
{
|
||||||
var position = new PositionDTO
|
var position = new PositionDTO
|
||||||
{
|
{
|
||||||
Description = attached.Description,
|
Description = attached.Description,
|
||||||
Lat = attached.Lat,
|
Lat = attached.Lat,
|
||||||
Lng = attached.Lng
|
Lng = attached.Lng
|
||||||
};
|
};
|
||||||
|
|
||||||
ActivityModel.Position = await IntegryApiService.SavePosition(position);
|
ActivityModel.Position = await IntegryApiService.SavePosition(position);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
await Task.WhenAll(positionTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveAttached(string activityId)
|
private async Task SaveAttached(string activityId)
|
||||||
{
|
{
|
||||||
if (AttachedList != null)
|
if (AttachedList is null) return;
|
||||||
{
|
|
||||||
foreach (var attached in AttachedList)
|
var uploadTasks = AttachedList
|
||||||
{
|
.Where(a => a.FileContent is not null && a.Type != AttachedDTO.TypeAttached.Position)
|
||||||
if (attached.FileContent is not null && attached.Type != AttachedDTO.TypeAttached.Position)
|
.Select(a => IntegryApiService.UploadFile(activityId, a.FileBytes, a.Name));
|
||||||
{
|
|
||||||
await IntegryApiService.UploadFile(activityId, attached.FileBytes, attached.Name);
|
await Task.WhenAll(uploadTasks);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CheckPreSave()
|
private bool CheckPreSave()
|
||||||
{
|
{
|
||||||
Snackbar.Clear();
|
Snackbar.Clear();
|
||||||
|
|
||||||
if (!ActivityModel.ActivityTypeId.IsNullOrEmpty()) return true;
|
if (!ActivityModel.ActivityTypeId.IsNullOrEmpty()) return true;
|
||||||
Snackbar.Add("Tipo attività obbligatorio!", Severity.Error);
|
|
||||||
|
|
||||||
|
Snackbar.Add("Tipo attività obbligatorio!", Severity.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,11 +395,12 @@
|
|||||||
return Task.Run(async () =>
|
return Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (!IsNew && Id != null)
|
if (!IsNew && Id != null)
|
||||||
{
|
|
||||||
ActivityFileList = await IntegryApiService.GetActivityFile(Id);
|
ActivityFileList = await IntegryApiService.GetActivityFile(Id);
|
||||||
}
|
|
||||||
|
|
||||||
Users = await ManageData.GetTable<StbUser>();
|
Users = await ManageData.GetTable<StbUser>();
|
||||||
|
if (!ActivityModel.UserName.IsNullOrEmpty())
|
||||||
|
SelectedUser = Users.FindLast(x => x.UserName.Equals(ActivityModel.UserName));
|
||||||
|
|
||||||
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
||||||
Clienti = await ManageData.GetClienti(new WhereCondContact { FlagStato = "A" });
|
Clienti = await ManageData.GetClienti(new WhereCondContact { FlagStato = "A" });
|
||||||
Pros = await ManageData.GetProspect();
|
Pros = await ManageData.GetProspect();
|
||||||
@@ -404,76 +411,137 @@
|
|||||||
|
|
||||||
private async Task LoadActivityType()
|
private async Task LoadActivityType()
|
||||||
{
|
{
|
||||||
if (ActivityModel.UserName is null) ActivityType = [];
|
if (ActivityModel.UserName is null)
|
||||||
|
|
||||||
ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x =>
|
|
||||||
x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task LoadCommesse() =>
|
|
||||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(ActivityModel.CodAnag));
|
|
||||||
|
|
||||||
private async Task<IEnumerable<string>?> SearchCliente(string value, CancellationToken token)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(value))
|
ActivityType = [];
|
||||||
return null;
|
return;
|
||||||
|
|
||||||
var listToReturn = new List<string>();
|
|
||||||
|
|
||||||
listToReturn.AddRange(
|
|
||||||
Clienti.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => $"{x.CodAnag} - {x.RagSoc}")
|
|
||||||
);
|
|
||||||
|
|
||||||
listToReturn.AddRange(
|
|
||||||
Pros.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => $"{x.CodPpro} - {x.RagSoc}")
|
|
||||||
);
|
|
||||||
|
|
||||||
return listToReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnClienteChanged()
|
ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x => x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadCommesse()
|
||||||
|
{
|
||||||
|
if (_lastLoadedCodAnag == ActivityModel.CodAnag) return;
|
||||||
|
|
||||||
|
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag == ActivityModel.CodAnag);
|
||||||
|
Commesse = Commesse.OrderByDescending(x => x.CodJcom).ToList();
|
||||||
|
_lastLoadedCodAnag = ActivityModel.CodAnag;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<JtbComt>> SearchCommesseAsync(string value, CancellationToken token)
|
||||||
|
{
|
||||||
|
await LoadCommesse();
|
||||||
|
if (Commesse.IsNullOrEmpty()) return [];
|
||||||
|
|
||||||
|
IEnumerable<JtbComt> list;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
list = Commesse.OrderByDescending(x => x.CodJcom).Take(10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list = Commesse
|
||||||
|
.Where(x => (x.CodJcom.Contains(value, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| x.Descrizione.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||||
|
&& (x.CodAnag == ActivityModel.CodAnag || ActivityModel.CodAnag == null))
|
||||||
|
.OrderByDescending(x => x.CodJcom)
|
||||||
|
.Take(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
return token.IsCancellationRequested ? [] : list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<IEnumerable<StbUser>> SearchUtentiAsync(string value, CancellationToken token)
|
||||||
|
{
|
||||||
|
IEnumerable<StbUser> list;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
list = Users.OrderBy(u => u.FullName).Take(50);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list = Users
|
||||||
|
.Where(x => x.UserName.Contains(value, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| x.FullName.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.OrderBy(u => u.FullName)
|
||||||
|
.Take(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult(token.IsCancellationRequested ? [] : list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<IEnumerable<string>?> SearchCliente(string value, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
return Task.FromResult<IEnumerable<string>?>(null);
|
||||||
|
|
||||||
|
var results = new List<string>();
|
||||||
|
|
||||||
|
results.AddRange(Clienti
|
||||||
|
.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Select(x => $"{x.CodAnag} - {x.RagSoc}"));
|
||||||
|
|
||||||
|
results.AddRange(Pros
|
||||||
|
.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Select(x => $"{x.CodPpro} - {x.RagSoc}"));
|
||||||
|
|
||||||
|
return Task.FromResult<IEnumerable<string>?>(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task OnClienteChanged()
|
||||||
{
|
{
|
||||||
ActivityModel.CodJcom = null;
|
ActivityModel.CodJcom = null;
|
||||||
|
if (string.IsNullOrWhiteSpace(ActivityModel.Cliente)) return Task.CompletedTask;
|
||||||
|
|
||||||
if (ActivityModel.Cliente.IsNullOrEmpty()) return;
|
var parts = ActivityModel.Cliente.Split('-', 2, StringSplitOptions.TrimEntries);
|
||||||
|
if (parts.Length == 2)
|
||||||
|
{
|
||||||
|
ActivityModel.CodAnag = parts[0];
|
||||||
|
ActivityModel.Cliente = parts[1];
|
||||||
|
}
|
||||||
|
|
||||||
var match = Regex.Match(ActivityModel.Cliente!, @"^\s*(\S+)\s*-\s*(.*)$");
|
OnAfterChangeValue();
|
||||||
if (!match.Success)
|
return Task.CompletedTask;
|
||||||
return;
|
}
|
||||||
|
|
||||||
ActivityModel.CodAnag = match.Groups[1].Value;
|
private async Task OnCommessaSelectedAfter()
|
||||||
ActivityModel.Cliente = match.Groups[2].Value;
|
{
|
||||||
|
var com = SelectedComessa;
|
||||||
|
if (com != null)
|
||||||
|
{
|
||||||
|
ActivityModel.CodJcom = com.CodJcom;
|
||||||
|
ActivityModel.Commessa = com.Descrizione;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ActivityModel.CodJcom = null;
|
||||||
|
ActivityModel.Commessa = null;
|
||||||
|
}
|
||||||
|
|
||||||
await LoadCommesse();
|
|
||||||
OnAfterChangeValue();
|
OnAfterChangeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnCommessaChanged()
|
private async Task OnUserSelectedAfter()
|
||||||
{
|
|
||||||
ActivityModel.Commessa = (await ManageData.GetTable<JtbComt>(x => x.CodJcom.Equals(ActivityModel.CodJcom))).Last().Descrizione;
|
|
||||||
OnAfterChangeValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnUserChanged()
|
|
||||||
{
|
{
|
||||||
|
ActivityModel.UserName = SelectedUser?.UserName;
|
||||||
await LoadActivityType();
|
await LoadActivityType();
|
||||||
OnAfterChangeValue();
|
OnAfterChangeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAfterChangeTimeBefore()
|
private void OnAfterChangeTimeBefore()
|
||||||
{
|
{
|
||||||
if (ActivityModel.EstimatedTime != null)
|
if (ActivityModel.EstimatedTime is not null)
|
||||||
{
|
{
|
||||||
if (ActivityModel.MinuteBefore != -1)
|
ActivityModel.NotificationDate = ActivityModel.MinuteBefore switch
|
||||||
{
|
{
|
||||||
ActivityModel.NotificationDate = ActivityModel.MinuteBefore == 0 ?
|
-1 => null,
|
||||||
ActivityModel.EstimatedTime : ActivityModel.EstimatedTime.Value.AddMinutes(ActivityModel.MinuteBefore * -1);
|
0 => ActivityModel.EstimatedTime,
|
||||||
}
|
_ => ActivityModel.EstimatedTime.Value.AddMinutes(ActivityModel.MinuteBefore * -1)
|
||||||
else
|
};
|
||||||
{
|
|
||||||
ActivityModel.NotificationDate = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnAfterChangeValue();
|
OnAfterChangeValue();
|
||||||
@@ -482,24 +550,21 @@
|
|||||||
private void OnAfterChangeValue()
|
private void OnAfterChangeValue()
|
||||||
{
|
{
|
||||||
if (!IsNew)
|
if (!IsNew)
|
||||||
{
|
|
||||||
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
||||||
}
|
|
||||||
|
|
||||||
if (ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime)
|
if (ActivityModel.EstimatedTime is not null &&
|
||||||
|
(ActivityModel.EstimatedEndtime is null || ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime))
|
||||||
{
|
{
|
||||||
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
|
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnAfterChangeEsito()
|
private Task OnAfterChangeEsito()
|
||||||
{
|
{
|
||||||
OnAfterChangeValue();
|
OnAfterChangeValue();
|
||||||
|
return Task.CompletedTask;
|
||||||
// var result = await ConfirmMemo.ShowAsync();
|
|
||||||
|
|
||||||
// if (result is true)
|
|
||||||
// OpenAddMemo = !OpenAddMemo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenSelectEsito()
|
private void OpenSelectEsito()
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ namespace salesbook.Shared.Core.Dto;
|
|||||||
|
|
||||||
public class NotificationDataDTO
|
public class NotificationDataDTO
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("notificationId")]
|
||||||
|
public string? NotificationId { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("activityId")]
|
[JsonPropertyName("activityId")]
|
||||||
public string? ActivityId { get; set; }
|
public string? ActivityId { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace salesbook.Shared.Core.Interface.IntegryApi;
|
|||||||
|
|
||||||
public interface IIntegryNotificationRestClient
|
public interface IIntegryNotificationRestClient
|
||||||
{
|
{
|
||||||
Task<List<WtbNotification>> Get();
|
Task<List<WtbNotification>?> Get();
|
||||||
Task<WtbNotification> MarkAsRead(long id);
|
Task<WtbNotification> MarkAsRead(long id);
|
||||||
Task Delete(long id);
|
Task Delete(long id);
|
||||||
Task DeleteAll();
|
Task DeleteAll();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class IntegryNotificationRestClient(
|
|||||||
IUserSession userSession,
|
IUserSession userSession,
|
||||||
IIntegryApiRestClient integryApiRestClient) : IIntegryNotificationRestClient
|
IIntegryApiRestClient integryApiRestClient) : IIntegryNotificationRestClient
|
||||||
{
|
{
|
||||||
public Task<List<WtbNotification>> Get()
|
public Task<List<WtbNotification>?> Get()
|
||||||
{
|
{
|
||||||
var queryParams = new Dictionary<string, object>
|
var queryParams = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ public class IntegryNotificationRestClient(
|
|||||||
{ "forUser", userSession.User.Username }
|
{ "forUser", userSession.User.Username }
|
||||||
};
|
};
|
||||||
|
|
||||||
return integryApiRestClient.Get<List<WtbNotification>>("notification", queryParams)!;
|
return integryApiRestClient.Get<List<WtbNotification>>("notification", queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<WtbNotification> MarkAsRead(long id) =>
|
public Task<WtbNotification> MarkAsRead(long id) =>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public class NotificationService(
|
|||||||
public async Task LoadNotification()
|
public async Task LoadNotification()
|
||||||
{
|
{
|
||||||
var allNotifications = await integryNotificationRestClient.Get();
|
var allNotifications = await integryNotificationRestClient.Get();
|
||||||
|
if (allNotifications == null) return;
|
||||||
|
|
||||||
var allIds = allNotifications.Select(n => n.Id).ToHashSet();
|
var allIds = allNotifications.Select(n => n.Id).ToHashSet();
|
||||||
|
|
||||||
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
||||||
|
|||||||
@@ -145,13 +145,17 @@ function initRow(row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeRow(row) {
|
function removeRow(row) {
|
||||||
//collapseAndRemove(row);
|
const id = row.id;
|
||||||
dotnetHelper.invokeMethodAsync('Delete', row.id);
|
|
||||||
|
collapseAndRemove(row);
|
||||||
|
dotnetHelper.invokeMethodAsync('Delete', id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function markAsRead(row) {
|
function markAsRead(row) {
|
||||||
//collapseAndRemove(row);
|
const id = row.id;
|
||||||
dotnetHelper.invokeMethodAsync('MarkAsRead', row.id);
|
|
||||||
|
collapseAndRemove(row);
|
||||||
|
dotnetHelper.invokeMethodAsync('MarkAsRead', id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapseAndRemove(row) {
|
function collapseAndRemove(row) {
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ public class ManageDataService : IManageDataService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond)
|
public Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond)
|
public Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,11 @@ public class ManageDataService : IManageDataService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<List<ActivityDTO>> GetActivityTryLocalDb(WhereCondActivity whereCond)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false)
|
public Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user