Fix e migliorati caricamenti
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace salesbook.Maui
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
private readonly IMessenger _messenger;
|
||||
|
||||
public App(IMessenger messenger)
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
_messenger = messenger;
|
||||
}
|
||||
|
||||
protected override Window CreateWindow(IActivationState? activationState)
|
||||
{
|
||||
return new Window(new MainPage(_messenger));
|
||||
return new Window(new MainPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,39 @@ public class AttachedService : IAttachedService
|
||||
{
|
||||
public async Task<AttachedDTO?> SelectImage()
|
||||
{
|
||||
var perm = await Permissions.RequestAsync<Permissions.Photos>();
|
||||
if (perm != PermissionStatus.Granted) return null;
|
||||
// Richiesta permessi base
|
||||
var cameraPerm = await Permissions.RequestAsync<Permissions.Camera>();
|
||||
var storagePerm = await Permissions.RequestAsync<Permissions.StorageRead>();
|
||||
|
||||
var result = await FilePicker.PickAsync(new PickOptions
|
||||
if (cameraPerm != PermissionStatus.Granted && storagePerm != PermissionStatus.Granted)
|
||||
return null;
|
||||
|
||||
// Mostro all'utente un popup di scelta
|
||||
var action = await Application.Current.MainPage.DisplayActionSheet(
|
||||
"Aggiungi immagine",
|
||||
"Annulla",
|
||||
null,
|
||||
"Scatta foto",
|
||||
"Scegli dalla galleria");
|
||||
|
||||
FileResult? result = null;
|
||||
|
||||
try
|
||||
{
|
||||
PickerTitle = "Scegli un'immagine",
|
||||
FileTypes = FilePickerFileType.Images
|
||||
});
|
||||
if (action == "Scatta foto")
|
||||
{
|
||||
result = await MediaPicker.Default.CapturePhotoAsync();
|
||||
}
|
||||
else if (action == "Scegli dalla galleria")
|
||||
{
|
||||
result = await MediaPicker.Default.PickPhotoAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore selezione immagine: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return result is null ? null : await ConvertToDto(result, AttachedDTO.TypeAttached.Image);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
using AutoMapper;
|
||||
using MudBlazor.Extensions;
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Storage;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
using salesbook.Shared.Core.Interface.System.Network;
|
||||
using Sentry.Protocol;
|
||||
using System.Linq.Expressions;
|
||||
using salesbook.Shared.Core.Helpers;
|
||||
using salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
namespace salesbook.Maui.Core.Services;
|
||||
|
||||
public class ManageDataService(
|
||||
LocalDbService localDb,
|
||||
IMapper mapper,
|
||||
UserListState userListState,
|
||||
IIntegryApiService integryApiService,
|
||||
INetworkService networkService
|
||||
) : IManageDataService
|
||||
@@ -86,7 +87,7 @@ public class ManageDataService(
|
||||
return prospect;
|
||||
}
|
||||
|
||||
public async Task<List<ContactDTO>> GetContact(WhereCondContact? whereCond)
|
||||
public async Task<List<ContactDTO>> GetContact(WhereCondContact? whereCond, DateTime? lastSync)
|
||||
{
|
||||
List<AnagClie>? contactList;
|
||||
List<PtbPros>? prospectList;
|
||||
@@ -94,26 +95,37 @@ public class ManageDataService(
|
||||
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var response = new UsersSyncResponseDTO();
|
||||
|
||||
var clienti = await integryApiService.RetrieveAnagClie(
|
||||
new CRMAnagRequestDTO
|
||||
{
|
||||
CodAnag = whereCond.CodAnag,
|
||||
FlagStato = whereCond.FlagStato,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
ReturnPersRif = !whereCond.OnlyContact,
|
||||
FilterDate = lastSync
|
||||
}
|
||||
);
|
||||
_ = UpdateDbUsers(clienti);
|
||||
|
||||
response.AnagClie = clienti.AnagClie;
|
||||
response.VtbDest = clienti.VtbDest;
|
||||
response.VtbCliePersRif = clienti.VtbCliePersRif;
|
||||
|
||||
var prospect = await integryApiService.RetrieveProspect(
|
||||
new CRMProspectRequestDTO
|
||||
{
|
||||
CodPpro = whereCond.CodAnag,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
ReturnPersRif = !whereCond.OnlyContact,
|
||||
FilterDate = lastSync
|
||||
}
|
||||
);
|
||||
_ = UpdateDbUsers(prospect);
|
||||
|
||||
response.PtbPros = prospect.PtbPros;
|
||||
response.PtbProsRif = prospect.PtbProsRif;
|
||||
|
||||
_ = UpdateDbUsers(response);
|
||||
|
||||
contactList = clienti.AnagClie;
|
||||
prospectList = prospect.PtbPros;
|
||||
@@ -230,17 +242,20 @@ public class ManageDataService(
|
||||
.Distinct().ToList();
|
||||
|
||||
var jtbComtList = await localDb.Get<JtbComt>(x => codJcomList.Contains(x.CodJcom));
|
||||
var commesseDict = jtbComtList.ToDictionary(x => x.CodJcom, x => x.Descrizione);
|
||||
|
||||
var codAnagList = activities
|
||||
.Select(x => x.CodAnag)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.Distinct().ToList();
|
||||
var clientList = await localDb.Get<AnagClie>(x => codAnagList.Contains(x.CodAnag));
|
||||
var distinctClient = clientList.ToDictionary(x => x.CodAnag, x => x.RagSoc);
|
||||
|
||||
var prospectList = await localDb.Get<PtbPros>(x => codAnagList.Contains(x.CodPpro));
|
||||
var distinctProspect = prospectList.ToDictionary(x => x.CodPpro, x => x.RagSoc);
|
||||
IDictionary<string, string?>? distinctUser = null;
|
||||
|
||||
if (userListState.AllUsers != null)
|
||||
{
|
||||
distinctUser = userListState.AllUsers
|
||||
.Where(x => codAnagList.Contains(x.CodContact))
|
||||
.ToDictionary(x => x.CodContact, x => x.RagSoc);
|
||||
}
|
||||
|
||||
var returnDto = activities
|
||||
.Select(activity =>
|
||||
@@ -269,16 +284,14 @@ public class ManageDataService(
|
||||
{
|
||||
string? ragSoc;
|
||||
|
||||
if (distinctClient.TryGetValue(activity.CodAnag, out ragSoc) ||
|
||||
distinctProspect.TryGetValue(activity.CodAnag, out ragSoc))
|
||||
if (distinctUser != null && (distinctUser.TryGetValue(activity.CodAnag, out ragSoc) ||
|
||||
distinctUser.TryGetValue(activity.CodAnag, out ragSoc)))
|
||||
{
|
||||
dto.Cliente = ragSoc;
|
||||
}
|
||||
}
|
||||
|
||||
dto.Commessa = activity.CodJcom != null && commesseDict.TryGetValue(activity.CodJcom, out var descr)
|
||||
? descr
|
||||
: null;
|
||||
dto.Commessa = jtbComtList.LastOrDefault();
|
||||
return dto;
|
||||
})
|
||||
.ToList();
|
||||
@@ -322,6 +335,26 @@ public class ManageDataService(
|
||||
public Task InsertOrUpdate<T>(T objectToSave) =>
|
||||
localDb.InsertOrUpdate<T>([objectToSave]);
|
||||
|
||||
public async Task DeleteProspect(string codPpro)
|
||||
{
|
||||
var persRifList = await GetTable<PtbProsRif>(x => x.CodPpro!.Equals(codPpro));
|
||||
|
||||
if (!persRifList.IsNullOrEmpty())
|
||||
{
|
||||
foreach (var persRif in persRifList)
|
||||
{
|
||||
await localDb.Delete(persRif);
|
||||
}
|
||||
}
|
||||
|
||||
var ptbPros = (await GetTable<PtbPros>(x => x.CodPpro!.Equals(codPpro))).FirstOrDefault();
|
||||
|
||||
if (ptbPros != null)
|
||||
{
|
||||
await localDb.Delete(ptbPros);
|
||||
}
|
||||
}
|
||||
|
||||
public Task Delete<T>(T objectToDelete) =>
|
||||
localDb.Delete(objectToDelete);
|
||||
|
||||
|
||||
@@ -1,23 +1,10 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Messages.Back;
|
||||
|
||||
namespace salesbook.Maui
|
||||
{
|
||||
public partial class MainPage : ContentPage
|
||||
{
|
||||
private readonly IMessenger _messenger;
|
||||
|
||||
public MainPage(IMessenger messenger)
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_messenger = messenger;
|
||||
}
|
||||
|
||||
protected override bool OnBackButtonPressed()
|
||||
{
|
||||
_messenger.Send(new HardwareBackMessage("back"));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.BATTERY_STATS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
@@ -39,8 +39,11 @@
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>L'app utilizza la tua posizione per allegarla alle attività.</string>
|
||||
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Questa app necessita di accedere alla fotocamera per scattare foto.</string>
|
||||
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Consente di selezionare immagini da allegare alle attività.</string>
|
||||
<string>Questa app necessita di accedere alla libreria foto.</string>
|
||||
|
||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||
<string>Permette all'app di salvare file o immagini nella tua libreria fotografica se necessario.</string>
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net9.0-ios'">
|
||||
<CodesignKey>Apple Distribution: Integry S.r.l. (UNP26J4R89)</CodesignKey>
|
||||
<CodesignProvision></CodesignProvision>
|
||||
<CodesignKey>Apple Development: Created via API (5B7B69P4JY)</CodesignKey>
|
||||
<CodesignProvision>VS: it.integry.salesbook Development</CodesignProvision>
|
||||
<ProvisioningType>manual</ProvisioningType>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -95,16 +95,6 @@
|
||||
<BundleResource Include="Platforms\iOS\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0-android'">
|
||||
<GoogleServicesJson Include="google-services.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</GoogleServicesJson>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0-ios'">
|
||||
<BundleResource Include="GoogleService-Info.plist" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||
<!-- Android App Icon -->
|
||||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" ForegroundScale="0.65" />
|
||||
@@ -130,16 +120,26 @@
|
||||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||
<GoogleServicesJson Include="google-services.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</GoogleServicesJson>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
|
||||
<BundleResource Include="GoogleService-Info.plist" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Maui" Version="12.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.Maui" Version="12.2.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="IntegryApiClient.MAUI" Version="1.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.81" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.81" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.81" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.6" />
|
||||
<PackageReference Include="Sentry.Maui" Version="5.11.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.110" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.110" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.110" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
|
||||
<PackageReference Include="Sentry.Maui" Version="5.15.0" />
|
||||
<PackageReference Include="Shiny.Hosting.Maui" Version="3.3.4" />
|
||||
<PackageReference Include="Shiny.Notifications" Version="3.3.4" />
|
||||
<PackageReference Include="Shiny.Push" Version="3.3.4" />
|
||||
|
||||
Reference in New Issue
Block a user