Merge branch 'develop' into feature/Firebase

# Conflicts:
#	salesbook.Shared/Components/Pages/Home.razor
This commit is contained in:
2025-09-08 12:22:24 +02:00
69 changed files with 2364 additions and 369 deletions

View File

@@ -1,7 +1,7 @@
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers.Enum;
namespace salesbook.Shared.Core.Dto;
namespace salesbook.Shared.Core.Dto.Activity;
public class ActivityDTO : StbActivity
{

View File

@@ -0,0 +1,24 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.Activity;
public class CRMRetrieveActivityRequestDTO
{
[JsonPropertyName("dateFilter")]
public string? DateFilter { get; set; }
[JsonPropertyName("activityId")]
public string? ActivityId { get; set; }
[JsonPropertyName("codAnag")]
public string? CodAnag { get; set; }
[JsonPropertyName("codJcom")]
public string? CodJcom { get; set; }
[JsonPropertyName("startDate")]
public DateTime? StarDate { get; set; }
[JsonPropertyName("endDate")]
public DateTime? EndDate { get; set; }
}

View File

@@ -1,7 +1,7 @@
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Helpers.Enum;
namespace salesbook.Shared.Core.Dto;
namespace salesbook.Shared.Core.Dto.Activity;
public class FilterActivityDTO
{

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.Activity;
public class WhereCondActivity
{
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
public string? ActivityId { get; set; }
}

View File

@@ -8,8 +8,12 @@ public class AttachedDTO
public string? MimeType { get; set; }
public long? DimensionBytes { get; set; }
public string? Path { get; set; }
public byte[]? FileContent { get; set; }
public byte[]? FileBytes { get; set; }
public Stream? FileContent =>
FileBytes is null ? null : new MemoryStream(FileBytes);
public double? Lat { get; set; }
public double? Lng { get; set; }

View File

@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto;
public class CRMAttachedResponseDTO
{
[JsonPropertyName("fileName")]
public string FileName { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("dateAttached")]
public DateTime DateAttached { get; set; }
[JsonPropertyName("fileSize")]
public decimal FileSize { get; set; }
[JsonPropertyName("refUuid")]
public string RefUuid { get; set; }
[JsonPropertyName("refAttached")]
public string RefAttached { get; set; }
[JsonPropertyName("activity")]
public bool IsActivity { get; set; }
}

View File

@@ -0,0 +1,19 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.Contact;
public class CRMAnagRequestDTO
{
[JsonPropertyName("filterDate")]
public DateTime? FilterDate { get; set; }
[JsonPropertyName("flagStato")]
public string? FlagStato { get; set; }
[JsonPropertyName("partitaIva")]
public string? PartIva { get; set; }
[JsonPropertyName("codAnag")]
public string? CodAnag { get; set; }
[JsonPropertyName("returnPersRif")]
public bool ReturnPersRif { get; set; }
}

View File

@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.Contact;
public class CRMProspectRequestDTO
{
[JsonPropertyName("filterDate")]
public DateTime? FilterDate { get; set; }
[JsonPropertyName("partitaIva")]
public string? PartIva { get; set; }
[JsonPropertyName("codPpro")]
public string? CodPpro { get; set; }
[JsonPropertyName("returnPersRif")]
public bool ReturnPersRif { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace salesbook.Shared.Core.Dto.Contact;
public class WhereCondContact
{
public string? FlagStato { get; set; }
public string? PartIva { get; set; }
public string? CodAnag { get; set; }
public bool OnlyContact { get; set; }
}

View File

@@ -0,0 +1,9 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.JobProgress;
public class CRMJobProgressResponseDTO
{
[JsonPropertyName("steps")]
public List<CRMJobStepDTO> Steps { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.JobProgress;
public class CRMJobStatusDTO
{
[JsonPropertyName("completed")]
public bool Completed { get; set; }
[JsonPropertyName("progress")]
public bool Progress { get; set; }
[JsonPropertyName("skip")]
public bool Skip { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto.JobProgress;
public class CRMJobStepDTO
{
[JsonPropertyName("stepName")]
public string? StepName { get; set; }
[JsonPropertyName("status")]
public CRMJobStatusDTO? Status { get; set; }
[JsonPropertyName("date")]
public DateTime? Date { get; set; }
}

View File

@@ -0,0 +1,8 @@
using salesbook.Shared.Core.Dto.JobProgress;
namespace salesbook.Shared.Core.Dto.PageState;
public class JobSteps
{
public List<CRMJobStepDTO>? Steps { get; set; }
}

View File

@@ -0,0 +1,21 @@
using salesbook.Shared.Core.Dto.Users;
namespace salesbook.Shared.Core.Dto.PageState;
public class UserListState
{
public List<UserDisplayItem>? GroupedUserList { get; set; }
public List<UserDisplayItem>? FilteredGroupedUserList { get; set; }
public bool IsLoaded { get; set; }
public bool IsLoading { get; set; }
public event Action? OnUsersLoaded;
public void NotifyUsersLoaded()
{
IsLoaded = true;
IsLoading = false;
OnUsersLoaded?.Invoke();
}
}

View File

@@ -0,0 +1,17 @@
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Dto.JobProgress;
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Dto.PageState;
public class UserPageState
{
public string? CodUser { get; set; }
public ContactDTO Anag { get; set; }
public List<PersRifDTO>? PersRif { get; set; }
public List<JtbComt> Commesse { get; set; }
public StbUser? Agente { get; set; }
public Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; }
public List<ActivityDTO> Activitys { get; set; }
}

View File

@@ -8,6 +8,9 @@ public class SettingsResponseDTO
[JsonPropertyName("activityTypes")]
public List<StbActivityType>? ActivityTypes { get; set; }
[JsonPropertyName("activityTypeUsers")]
public List<SrlActivityTypeUser>? ActivityTypeUsers { get; set; }
[JsonPropertyName("activityResults")]
public List<StbActivityResult>? ActivityResults { get; set; }

View File

@@ -0,0 +1,8 @@
namespace salesbook.Shared.Core.Dto.Users;
public class UserDisplayItem
{
public required ContactDTO User { get; set; }
public bool ShowHeader { get; set; }
public string? HeaderLetter { get; set; }
}

View File

@@ -3,7 +3,7 @@ using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Dto;
public class TaskSyncResponseDTO
public class UsersSyncResponseDTO
{
[JsonPropertyName("anagClie")]
public List<AnagClie>? AnagClie { get; set; }

View File

@@ -107,4 +107,7 @@ public class JtbComt
[Column("note_tecniche"), JsonPropertyName("noteTecniche")]
public string NoteTecniche { get; set; }
[Ignore, JsonIgnore]
public DateTime? LastUpd { get; set; }
}

View File

@@ -0,0 +1,56 @@
using SQLite;
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Entity;
[Table("srl_activity_type_user")]
public class SrlActivityTypeUser
{
[PrimaryKey, Column("composite_key")]
public string CompositeKey { get; set; }
private string? _activityTypeId;
[Column("activity_type_id"), JsonPropertyName("activityTypeId"), Indexed(Name = "ActivityTypePK", Order = 1, Unique = true)]
public string? ActivityTypeId
{
get => _activityTypeId;
set
{
_activityTypeId = value;
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
UpdateCompositeKey();
}
}
private string? _flagTipologia;
[Column("flag_tipologia"), JsonPropertyName("flagTipologia"), Indexed(Name = "ActivityTypePK", Order = 2, Unique = true)]
public string? FlagTipologia
{
get => _flagTipologia;
set
{
_flagTipologia = value;
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
UpdateCompositeKey();
}
}
private string? _userName;
[Column("user_name"), JsonPropertyName("userName"), Indexed(Name = "ActivityTypePK", Order = 3, Unique = true)]
public string? UserName
{
get => _userName;
set
{
_userName = value;
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
UpdateCompositeKey();
}
}
private void UpdateCompositeKey() =>
CompositeKey = $"{ActivityTypeId}::{FlagTipologia}::{UserName}";
}

View File

@@ -7,5 +7,7 @@ class IconConstants
public const string Stato = "ri-list-check-3 fa-fw fa-chip";
public const string User = "ri-user-fill fa-fw fa-chip";
public const string Time = "ri-time-line fa-fw fa-chip";
public const string FileTextLine = "ri-file-text-line fa-fw fa-chip";
public const string Tag = "ri-price-tag-3-fill fa-fw fa-chip";
}
}

View File

@@ -1,5 +1,6 @@
using AutoMapper;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Helpers;

View File

@@ -1,6 +1,7 @@
using MudBlazor;
using salesbook.Shared.Components.SingleElements.Modal;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
namespace salesbook.Shared.Core.Helpers;
@@ -85,23 +86,4 @@ public class ModalHelpers
return await modal.Result;
}
public static async Task<DialogResult?> OpenViewAttach(IDialogService dialog, string? fileViewUrl)
{
var modal = await dialog.ShowAsync<ViewAttached>(
"View attached",
new DialogParameters<ViewAttached>
{
{ x => x.FileViewerUrl, fileViewUrl }
},
new DialogOptions
{
FullScreen = true,
CloseButton = true,
NoHeader = true
}
);
return await modal.Result;
}
}

View File

@@ -7,4 +7,5 @@ public interface IAttachedService
Task<AttachedDTO?> SelectImage();
Task<AttachedDTO?> SelectFile();
Task<AttachedDTO?> SelectPosition();
Task OpenFile(Stream file, string fileName);
}

View File

@@ -1,15 +1,21 @@
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Dto.JobProgress;
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Interface;
public interface IIntegryApiService
{
Task<List<StbActivity>?> RetrieveActivity(string? dateFilter = null);
Task<bool> SystemOk();
Task<List<StbActivity>?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest);
Task<List<JtbComt>?> RetrieveAllCommesse(string? dateFilter = null);
Task<TaskSyncResponseDTO> RetrieveAnagClie(string? dateFilter = null);
Task<TaskSyncResponseDTO> RetrieveProspect(string? dateFilter = null);
Task<UsersSyncResponseDTO> RetrieveAnagClie(CRMAnagRequestDTO request);
Task<UsersSyncResponseDTO> RetrieveProspect(CRMProspectRequestDTO request);
Task<SettingsResponseDTO> RetrieveSettings();
Task<List<CRMAttachedResponseDTO>?> RetrieveAttached(string codJcom);
Task DeleteActivity(string activityId);
@@ -21,6 +27,9 @@ public interface IIntegryApiService
Task UploadFile(string id, byte[] file, string fileName);
Task<List<ActivityFileDto>> GetActivityFile(string activityId);
Task<Stream> DownloadFile(string activityId, string fileName);
Task<Stream> DownloadFileFromRefUuid(string refUuid, string fileName);
Task<CRMJobProgressResponseDTO> RetrieveJobProgress(string codJcom);
//Position
Task<PositionDTO> SavePosition(PositionDTO position);

View File

@@ -1,17 +1,22 @@
using System.Linq.Expressions;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Entity;
using System.Linq.Expressions;
namespace salesbook.Shared.Core.Interface;
public interface IManageDataService
{
Task<List<T>> GetTable<T>(Expression<Func<T, bool>>? whereCond = null) where T : new();
Task<List<ActivityDTO>> GetActivity(Expression<Func<StbActivity, bool>>? whereCond = null);
Task<List<ContactDTO>> GetContact();
Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null);
Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null);
Task<List<ContactDTO>> GetContact(WhereCondContact whereCond);
Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact);
Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false);
Task InsertOrUpdate<T>(T objectToSave);
Task InsertOrUpdate<T>(List<T> listToSave);

View File

@@ -2,5 +2,7 @@
public interface INetworkService
{
public bool ConnectionAvailable { get; set; }
public bool IsNetworkAvailable();
}

View File

@@ -2,9 +2,6 @@
public interface ISyncDbService
{
Task GetAndSaveActivity(string? dateFilter = null);
Task GetAndSaveCommesse(string? dateFilter = null);
Task GetAndSaveProspect(string? dateFilter = null);
Task GetAndSaveClienti(string? dateFilter = null);
Task GetAndSaveSettings(string? dateFilter = null);
}

View File

@@ -1,5 +1,5 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
namespace salesbook.Shared.Core.Messages.Activity.Copy;

View File

@@ -1,5 +1,5 @@
using CommunityToolkit.Mvvm.Messaging;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
namespace salesbook.Shared.Core.Messages.Activity.Copy;

View File

@@ -1,21 +1,33 @@
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
using IntegryApiClient.Core.Domain.RestClient.Contacts;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Dto.JobProgress;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Interface;
using System.Net.Http.Headers;
using salesbook.Shared.Core.Dto.Contact;
namespace salesbook.Shared.Core.Services;
public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUserSession userSession)
: IIntegryApiService
{
public Task<List<StbActivity>?> RetrieveActivity(string? dateFilter)
public async Task<bool> SystemOk()
{
var queryParams = new Dictionary<string, object> { { "dateFilter", dateFilter ?? "2020-01-01" } };
return integryApiRestClient.AuthorizedGet<List<StbActivity>?>("crm/retrieveActivity", queryParams);
try
{
await integryApiRestClient.Get<object>("system/ok");
return true;
}
catch (Exception e)
{
return false;
}
}
public Task<List<StbActivity>?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest) =>
integryApiRestClient.AuthorizedPost<List<StbActivity>?>("crm/retrieveActivity", activityRequest);
public Task<List<JtbComt>?> RetrieveAllCommesse(string? dateFilter)
{
@@ -29,33 +41,26 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
return integryApiRestClient.AuthorizedGet<List<JtbComt>?>("crm/retrieveCommesse", queryParams);
}
public Task<TaskSyncResponseDTO> RetrieveAnagClie(string? dateFilter)
{
var queryParams = new Dictionary<string, object>();
public Task<UsersSyncResponseDTO> RetrieveAnagClie(CRMAnagRequestDTO request) =>
integryApiRestClient.AuthorizedPost<UsersSyncResponseDTO>("crm/retrieveClienti", request)!;
if (dateFilter != null)
{
queryParams.Add("dateFilter", dateFilter);
}
return integryApiRestClient.AuthorizedGet<TaskSyncResponseDTO>("crm/retrieveClienti", queryParams)!;
}
public Task<TaskSyncResponseDTO> RetrieveProspect(string? dateFilter)
{
var queryParams = new Dictionary<string, object>();
if (dateFilter != null)
{
queryParams.Add("dateFilter", dateFilter);
}
return integryApiRestClient.AuthorizedGet<TaskSyncResponseDTO>("crm/retrieveProspect", queryParams)!;
}
public Task<UsersSyncResponseDTO> RetrieveProspect(CRMProspectRequestDTO request) =>
integryApiRestClient.AuthorizedPost<UsersSyncResponseDTO>("crm/retrieveProspect", request)!;
public Task<SettingsResponseDTO> RetrieveSettings() =>
integryApiRestClient.AuthorizedGet<SettingsResponseDTO>("crm/retrieveSettings")!;
public Task<List<CRMAttachedResponseDTO>?> RetrieveAttached(string codJcom)
{
var queryParams = new Dictionary<string, object>
{
{ "codJcom", codJcom }
};
return integryApiRestClient.AuthorizedGet<List<CRMAttachedResponseDTO>?>("crm/retrieveAttachedForCodJcom",
queryParams);
}
public Task DeleteActivity(string activityId)
{
var queryParams = new Dictionary<string, object>
@@ -137,6 +142,17 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
public Task<Stream> DownloadFile(string activityId, string fileName) =>
integryApiRestClient.Download($"downloadStbFileAttachment/{activityId}/{fileName}")!;
public Task<Stream> DownloadFileFromRefUuid(string refUuid, string fileName)
{
var queryParams = new Dictionary<string, object>
{
{ "refUuid", refUuid },
{ "fileName", fileName }
};
return integryApiRestClient.Download("downloadFileFromRefUuid", queryParams);
}
public Task<PositionDTO> SavePosition(PositionDTO position) =>
integryApiRestClient.Post<PositionDTO>("savePosition", position)!;
@@ -146,4 +162,11 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
return integryApiRestClient.Get<PositionDTO>("retrievePosition", queryParams)!;
}
public Task<CRMJobProgressResponseDTO> RetrieveJobProgress(string codJcom)
{
var queryParams = new Dictionary<string, object> { { "codJcom", codJcom } };
return integryApiRestClient.Get<CRMJobProgressResponseDTO>("crm/retrieveJobProgress", queryParams)!;
}
}

View File

@@ -0,0 +1,55 @@
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Dto.PageState;
using salesbook.Shared.Core.Dto.Users;
using salesbook.Shared.Core.Interface;
namespace salesbook.Shared.Core.Services;
public class PreloadService(IManageDataService manageData, UserListState userState)
{
public async Task PreloadUsersAsync()
{
if (userState.IsLoaded || userState.IsLoading)
return;
userState.IsLoading = true;
var users = await manageData.GetContact(new WhereCondContact { FlagStato = "A" });
var sorted = users
.Where(u => !string.IsNullOrWhiteSpace(u.RagSoc))
.OrderBy(u => char.IsLetter(char.ToUpper(u.RagSoc[0])) ? char.ToUpper(u.RagSoc[0]).ToString() : "ZZZ")
.ThenBy(u => u.RagSoc)
.ToList();
userState.GroupedUserList = BuildGroupedList(sorted);
userState.FilteredGroupedUserList = userState.GroupedUserList;
userState.NotifyUsersLoaded();
}
private static List<UserDisplayItem> BuildGroupedList(List<ContactDTO> users)
{
var grouped = new List<UserDisplayItem>();
string? lastHeader = null;
foreach (var user in users)
{
var firstChar = char.ToUpper(user.RagSoc[0]);
var currentLetter = char.IsLetter(firstChar) ? firstChar.ToString() : "#";
var showHeader = currentLetter != lastHeader;
lastHeader = currentLetter;
grouped.Add(new UserDisplayItem
{
User = user,
ShowHeader = showHeader,
HeaderLetter = currentLetter
});
}
return grouped;
}
}