├── .gitattributes
├── .gitignore
├── LICENSE.txt
├── README.md
├── XRFID.Sample.Client.Mobile
├── App.xaml
├── App.xaml.cs
├── AppShell.xaml
├── AppShell.xaml.cs
├── Base
│ └── BaseRfidViewModel.cs
├── Behavior
│ ├── BorderlessEntry.cs
│ └── CustomBehavior.cs
├── Data
│ ├── Dto
│ │ ├── ItemExtDto.cs
│ │ └── OrderExtDto.cs
│ ├── Enums
│ │ ├── InputTypes.cs
│ │ ├── InventoryStates.cs
│ │ ├── MovementTypes.cs
│ │ ├── RfidScannerType.cs
│ │ ├── Sessions.cs
│ │ └── TagViewStatus.cs
│ ├── Interfaces
│ │ └── IRFIDConfig.cs
│ ├── RfidConfig.cs
│ ├── Services
│ │ ├── AlertService.cs
│ │ ├── AppSettings.cs
│ │ ├── GeneralSettings.cs
│ │ ├── Interfaces
│ │ │ ├── IAlertService.cs
│ │ │ ├── IAppSettings.cs
│ │ │ ├── IGeneralSettings.cs
│ │ │ ├── IServiceHelper.cs
│ │ │ └── ISetting.cs
│ │ └── ServiceHelper.cs
│ └── ViewData
│ │ ├── FindProductViewData.cs
│ │ ├── InventoryProductViewData.cs
│ │ ├── InventoryStatsViewData.cs
│ │ ├── OrderViewData.cs
│ │ └── TagViewData.cs
├── Helpers
│ └── RestApiHelper.cs
├── MainPage.xaml
├── MainPage.xaml.cs
├── MainViewModel.cs
├── MauiProgram.cs
├── Messages
│ ├── BarcodeMessage.cs
│ └── ReaderTag.cs
├── Platforms
│ └── Android
│ │ ├── AndroidManifest.xml
│ │ ├── CustomShellRenderer.cs
│ │ ├── Interfaces
│ │ ├── IBarcodeService.cs
│ │ ├── IEMDKService.cs
│ │ └── IRFIDService.cs
│ │ ├── MainActivity.cs
│ │ ├── MainApplication.cs
│ │ ├── Resources
│ │ └── values
│ │ │ └── colors.xml
│ │ └── Services
│ │ ├── BarcodeService.cs
│ │ ├── EmdkService.cs
│ │ └── RFIDService.cs
├── Properties
│ └── launchSettings.json
├── Resources
│ ├── AppIcon
│ │ ├── appicon.svg
│ │ └── appiconfg.svg
│ ├── Fonts
│ │ ├── OpenSans-Regular.ttf
│ │ └── OpenSans-Semibold.ttf
│ ├── Images
│ │ ├── back_button.svg
│ │ ├── check_item.svg
│ │ ├── find_item.svg
│ │ ├── home_icon.svg
│ │ ├── info_about.svg
│ │ ├── info_icon.svg
│ │ ├── inventory.svg
│ │ ├── menu_icon.svg
│ │ ├── rapid_read.svg
│ │ ├── settings_gear_blue.svg
│ │ └── settings_gear_orange.svg
│ ├── Raw
│ │ └── AboutAssets.txt
│ ├── Splash
│ │ ├── dotnet_splash.svg
│ │ └── splash.svg
│ └── Styles
│ │ ├── Colors.xaml
│ │ └── Styles.xaml
├── ViewModels
│ ├── CheckItem
│ │ ├── CheckItemRfidViewModel.cs
│ │ └── CheckItemViewModel.cs
│ ├── FindItem
│ │ ├── FindItemRfidViewModel.cs
│ │ └── FindItemViewModel.cs
│ ├── InventoryViewModel.cs
│ ├── RapidReadViewModel.cs
│ └── SettingsViewModel.cs
├── Views
│ ├── AboutView.xaml
│ ├── AboutView.xaml.cs
│ ├── CheckItem
│ │ ├── CheckItemRfidView.xaml
│ │ ├── CheckItemRfidView.xaml.cs
│ │ ├── CheckItemView.xaml
│ │ └── CheckItemView.xaml.cs
│ ├── FindItem
│ │ ├── FindItemRfidView.xaml
│ │ ├── FindItemRfidView.xaml.cs
│ │ ├── FindItemView.xaml
│ │ └── FindItemView.xaml.cs
│ ├── Inventory
│ │ ├── InventoryView.xaml
│ │ └── InventoryView.xaml.cs
│ ├── PageSettings
│ │ ├── FindSettings.xaml
│ │ ├── FindSettings.xaml.cs
│ │ ├── InventoryRapidReadSettings.xaml
│ │ └── InventoryRapidReadSettings.xaml.cs
│ ├── RapidReadView.xaml
│ ├── RapidReadView.xaml.cs
│ ├── SettingsPage.xaml
│ └── SettingsPage.xaml.cs
└── XRFID.Sample.Client.Mobile.csproj
├── XRFID.Sample.Common
├── Dto
│ ├── Create
│ │ └── MinimalReaderCreateDto.cs
│ ├── LoadingUnitDto.cs
│ ├── LoadingUnitItemDto.cs
│ ├── MovementDto.cs
│ ├── MovementItemDto.cs
│ ├── ProductDto.cs
│ └── ReaderDto.cs
└── XRFID.Sample.Common.csproj
├── XRFID.Sample.Webservice
├── Controllers
│ ├── AuthorizationController.cs
│ ├── LoadingUnitController.cs
│ ├── LoadingUnitItemController.cs
│ ├── MovementController.cs
│ ├── PingController.cs
│ ├── ProductController.cs
│ └── ReaderController.cs
├── Database
│ ├── UnitOfWork.cs
│ └── XRFIDSampleContext.cs
├── Entities
│ ├── AuditEntity.cs
│ ├── LoadingUnit.cs
│ ├── LoadingUnitItem.cs
│ ├── Movement.cs
│ ├── MovementItem.cs
│ ├── Product.cs
│ └── Reader.cs
├── Mapper
│ └── XRFIDSampleProfile.cs
├── Migrations
│ ├── 20230830145542_Initial.Designer.cs
│ ├── 20230830145542_Initial.cs
│ └── XRFIDSampleContextModelSnapshot.cs
├── Persist
│ └── persist.db
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Repositories
│ ├── BaseRespository.cs
│ ├── LoadingUnitItemRepository.cs
│ ├── LoadingUnitRepository.cs
│ ├── MovementItemRepository.cs
│ ├── MovementRepository.cs
│ ├── ProductRepository.cs
│ └── ReaderRepository.cs
├── Services
│ ├── LoadingUnitItemService.cs
│ ├── LoadingUnitService.cs
│ ├── MovementService.cs
│ ├── ProductService.cs
│ └── ReaderService.cs
├── XRFID.Sample.Webservice.csproj
├── appsettings.Development.json
└── appsettings.json
├── XRFID.Sample.sln
├── dll
└── XamarinZebraRFID.dll
└── img
└── logo.svg
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Pernix Srl, Axter Srl, Xerum Srl, Xholding Group
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using TinyMvvm;
2 | using XRFID.Sample.Client.Mobile.Behavior;
3 |
4 | namespace XRFID.Sample.Client.Mobile;
5 |
6 | public partial class App : TinyApplication
7 | {
8 | public App()
9 | {
10 | Syncfusion.Licensing.SyncfusionLicenseProvider
11 | .RegisterLicense("your_syncfusion_license"); //You need to edit the content with your syncfusion license
12 |
13 | InitializeComponent();
14 |
15 | MainPage = new AppShell();
16 |
17 | Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(nameof(BorderlessEntry), (handler, view) =>
18 | {
19 | #if __ANDROID__
20 | handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
21 | #elif __IOS__
22 | #endif
23 | });
24 | }
25 |
26 | protected override async Task Initialize()
27 | {
28 | await base.Initialize();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
25 |
26 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
37 |
39 |
40 |
41 |
42 |
44 |
45 |
46 |
47 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Views.CheckItem;
2 | using XRFID.Sample.Client.Mobile.Views.FindItem;
3 | using XRFID.Sample.Client.Mobile.Views.PageSettings;
4 |
5 | namespace XRFID.Sample.Client.Mobile;
6 |
7 | public partial class AppShell : Shell
8 | {
9 | public AppShell()
10 | {
11 | InitializeComponent();
12 |
13 | Routing.RegisterRoute("checkitem/rfid", typeof(CheckItemRfidView));
14 | Routing.RegisterRoute("finditemrfid", typeof(FindItemRfidView));
15 | Routing.RegisterRoute("inventoryrapidreadsettings", typeof(InventoryRapidReadSettings));
16 | Routing.RegisterRoute("findsettings", typeof(FindSettings));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Behavior/BorderlessEntry.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Behavior;
2 | public class BorderlessEntry : Entry
3 | {
4 | }
5 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Behavior/CustomBehavior.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.Maui.DataGrid;
2 | using System.Globalization;
3 | using System.Windows.Input;
4 |
5 | namespace XRFID.Sample.Client.Mobile.Behavior;
6 |
7 | // Behavior
8 | public class CustomBehavior : Behavior
9 | {
10 | public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(CustomBehavior), null);
11 | public static readonly BindableProperty InputConverterProperty = BindableProperty.Create("Converter", typeof(IValueConverter), typeof(CustomBehavior), null);
12 |
13 | public ICommand Command
14 | {
15 | get { return (ICommand)GetValue(CommandProperty); }
16 | set { SetValue(CommandProperty, value); }
17 | }
18 |
19 | public IValueConverter Converter
20 | {
21 | get { return (IValueConverter)GetValue(InputConverterProperty); }
22 | set { SetValue(InputConverterProperty, value); }
23 | }
24 |
25 | public SfDataGrid AssociatedObject { get; private set; }
26 |
27 | protected override void OnAttachedTo(SfDataGrid bindable)
28 | {
29 | base.OnAttachedTo(bindable);
30 | AssociatedObject = bindable;
31 | bindable.BindingContextChanged += OnBindingContextChanged;
32 | bindable.SelectionChanged += Bindable_SelectionChanged;
33 | }
34 |
35 | private void Bindable_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
36 | {
37 | if (Command == null)
38 | {
39 | return;
40 | }
41 |
42 | object gridSelectionChangedEventArgs = Converter.Convert(e, typeof(object), null, null);
43 | if (Command.CanExecute(gridSelectionChangedEventArgs))
44 | {
45 | Command.Execute(gridSelectionChangedEventArgs);
46 | }
47 | }
48 |
49 | protected override void OnDetachingFrom(SfDataGrid bindable)
50 | {
51 | base.OnDetachingFrom(bindable);
52 | bindable.BindingContextChanged -= OnBindingContextChanged;
53 | bindable.SelectionChanged -= Bindable_SelectionChanged;
54 | AssociatedObject = null;
55 | }
56 |
57 | private void OnBindingContextChanged(object sender, EventArgs e)
58 | {
59 | OnBindingContextChanged();
60 | }
61 |
62 | protected override void OnBindingContextChanged()
63 | {
64 | base.OnBindingContextChanged();
65 | BindingContext = AssociatedObject.BindingContext;
66 | }
67 | }
68 |
69 | public class CustomConverter : IValueConverter
70 | {
71 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
72 | {
73 | return value;
74 | }
75 |
76 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
77 | {
78 | throw new NotImplementedException();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Dto/ItemExtDto.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.Dto;
5 | public class ItemExtDto : INotifyPropertyChanged
6 | {
7 | public Guid Id { get; set; }
8 |
9 | public string Epc { get; set; }
10 |
11 | public string SerialNumber { get; set; }
12 |
13 | public string SkuCode { get; set; }
14 |
15 | public string Description { get; set; }
16 |
17 | public Guid? OrderLineId { get; set; }
18 |
19 | public string OrderLineDescription { get; set; }
20 |
21 | public bool Checked { get; set; }
22 |
23 | public bool CHECKED { get { return Checked; } set { Checked = value; OnPropertyChanged(); } }
24 |
25 | public bool UnexpectedTag { get; set; }
26 |
27 | public event PropertyChangedEventHandler PropertyChanged;
28 |
29 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
30 | }
31 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Dto/OrderExtDto.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.Dto;
5 | public class OrderExtDto : INotifyPropertyChanged
6 | {
7 | //customer
8 | public string CustomerReference { get; set; }
9 |
10 | public string CustomerName { get; set; }
11 |
12 | public string DestinationReference { get; set; }
13 |
14 | public string DestinationName { get; set; }
15 |
16 | //order
17 | public string OrderReference { get; set; }
18 |
19 | public Guid CustomerId { get; set; }
20 |
21 | public Guid Id { get; set; }
22 |
23 | public string Epc { get; set; }
24 |
25 | public string SerialNumber { get; set; }
26 |
27 | public string SkuCode { get; set; }
28 |
29 | public string Description { get; set; }
30 |
31 | public const string OrderLinesPropertyName = "OrderLines";
32 |
33 | public bool Checked { get; set; }
34 | public bool CHECKED { get { return Checked; } set { Checked = value; OnPropertyChanged(); } }
35 |
36 | public event PropertyChangedEventHandler PropertyChanged;
37 |
38 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
39 | }
40 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/InputTypes.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum InputTypes
4 | {
5 | Rfid = 0,
6 | Barcode = 1
7 | }
8 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/InventoryStates.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum InventoryStates
4 | {
5 | StateA = 0,
6 | StateB = 1,
7 | FlipAB = 2
8 | }
9 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/MovementTypes.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum MovementTypes
4 | {
5 | Empty = 0,
6 | Inventory = 1,
7 | EmptyList = 2
8 | }
9 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/RfidScannerType.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum RfidScannerType
4 | {
5 | Serial = 0,
6 | Usb = 1,
7 | Bluetooth = 2,
8 | All = 10,
9 | }
10 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/Sessions.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum Sessions
4 | {
5 | S0 = 0,
6 | S1 = 1,
7 | S2 = 2,
8 | S3 = 3
9 | }
10 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Enums/TagViewStatus.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | public enum TagViewStatus
4 | {
5 | Default = 0,
6 | Found = 1,
7 | Error = 2,
8 | }
9 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Interfaces/IRFIDConfig.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Interfaces;
2 |
3 | public interface IRFIDConfig
4 | {
5 | Guid Id { get; set; }
6 | string Name { get; set; }
7 | bool IsActive { get; set; }
8 | int Power { get; set; }
9 | bool DynamicPower { get; set; }
10 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/RfidConfig.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Data.Enums;
2 | using XRFID.Sample.Client.Mobile.Data.Interfaces;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data;
5 | public class RfidConfig : IRFIDConfig
6 | {
7 | public Guid Id { get; set; }
8 | public string Name { get; set; }
9 | public bool IsActive { get; set; }
10 | public int Power { get; set; }
11 | public Sessions Session { get; set; }
12 | public InventoryStates InventoryState { get; set; }
13 | public bool DynamicPower { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/AlertService.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Maui.Alerts;
2 | using CommunityToolkit.Maui.Core;
3 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
4 |
5 | namespace XRFID.Sample.Client.Mobile.Data.Services;
6 | public class AlertService : IAlertService
7 | {
8 | public AlertService()
9 | {
10 | }
11 |
12 | public void LongToast(string message)
13 | {
14 | Toast.Make(message, ToastDuration.Long).Show();
15 | }
16 |
17 | public void ShortToast(string message)
18 | {
19 | Toast.Make(message, ToastDuration.Short).Show();
20 | }
21 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/GeneralSettings.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Data.Dto;
2 | using XRFID.Sample.Client.Mobile.Data.Enums;
3 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
4 |
5 | namespace XRFID.Sample.Client.Mobile.Data.Services;
6 | public class GeneralSettings : IGeneralSettings
7 | {
8 | private AppSettings _appSettings = new AppSettings();
9 | private IServiceHelper _serviceHelper;
10 |
11 | public string ApiServer { get => _appSettings.ApiServer; set => _appSettings.ApiServer = value; }
12 | public InputTypes InputType { get => _appSettings.InputType; set => _appSettings.InputType = value; }
13 | public MovementTypes MovementType { get => _appSettings.MovementType; set => _appSettings.MovementType = value; }
14 | public string MovementListName { get => _appSettings.MovementListName; set => _appSettings.MovementListName = value; }
15 | public Guid ReaderId { get => _appSettings.ReaderId; set => _appSettings.ReaderId = value; }
16 | public string DeviceId { get => _appSettings.DeviceId; set => _appSettings.DeviceId = value; }
17 | public string DeviceIp { get => _appSettings.DeviceIp; set => _appSettings.DeviceIp = value; }
18 | public string DeviceModel { get => _appSettings.DeviceModel; set => _appSettings.DeviceModel = value; }
19 | public string DeviceName { get => _appSettings.DeviceName; set => _appSettings.DeviceName = value; }
20 | public string DeviceVersion { get => _appSettings.DeviceVersion; set => _appSettings.DeviceVersion = value; }
21 | public string DevicePlatform { get => _appSettings.DevicePlatform; set => _appSettings.DevicePlatform = value; }
22 | public string DeviceManufacturer { get => _appSettings.DeviceManufacturer; set => _appSettings.DeviceManufacturer = value; }
23 | public int ReaderIndex { get => _appSettings.ReaderIndex; set => _appSettings.ReaderIndex = value; }
24 | public List Orders { get; set; }
25 |
26 | public List RfidConfigs
27 | {
28 | get
29 | {
30 | return _appSettings.RfidConfigs;
31 | }
32 | set
33 | {
34 | _appSettings.RfidConfigs = value;
35 | }
36 | }
37 |
38 | public GeneralSettings()
39 | {
40 | }
41 |
42 | public void Load(IServiceHelper serviceHelper)
43 | {
44 | this._serviceHelper = serviceHelper;
45 | _appSettings.Load(_serviceHelper);
46 | }
47 |
48 | public void SaveRfidConfig(RfidConfig rfidConfig)
49 | {
50 | _appSettings.Save(rfidConfig);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/Interfaces/IAlertService.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
2 | public interface IAlertService
3 | {
4 | void ShortToast(string message);
5 |
6 | void LongToast(string message);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/Interfaces/IAppSettings.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Data.Enums;
2 |
3 | namespace XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
4 |
5 | public interface IAppSettings : ISetting
6 | {
7 | string ApiServer { get; set; }
8 | InputTypes InputType { get; set; }
9 | MovementTypes MovementType { get; set; }
10 | string MovementListName { get; set; }
11 | Guid ReaderId { get; set; }
12 | string DeviceId { get; set; }
13 | string DeviceIp { get; set; }
14 | string DeviceModel { get; set; }
15 | string DeviceName { get; set; }
16 | string DeviceVersion { get; set; }
17 | string DevicePlatform { get; set; }
18 | string DeviceManufacturer { get; set; }
19 | int ReaderIndex { get; set; }
20 |
21 | List RfidConfigs { get; set; }
22 |
23 | void Load(IServiceHelper serviceHelper);
24 |
25 | void Save(RfidConfig rfidConfig);
26 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/Interfaces/IGeneralSettings.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Data.Dto;
2 | using XRFID.Sample.Client.Mobile.Data.Enums;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
5 |
6 | public interface IGeneralSettings
7 | {
8 | string ApiServer { get; set; }
9 | InputTypes InputType { get; set; }
10 | MovementTypes MovementType { get; set; }
11 | string MovementListName { get; set; }
12 | Guid ReaderId { get; set; }
13 | string DeviceId { get; set; }
14 | string DeviceIp { get; set; }
15 | string DeviceModel { get; set; }
16 | string DeviceName { get; set; }
17 | string DeviceVersion { get; set; }
18 | string DevicePlatform { get; set; }
19 | string DeviceManufacturer { get; set; }
20 | int ReaderIndex { get; set; }
21 | List RfidConfigs { get; set; }
22 | List Orders { get; set; }
23 |
24 | void Load(IServiceHelper serviceHelper);
25 |
26 | void SaveRfidConfig(RfidConfig rfidConfig);
27 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/Interfaces/IServiceHelper.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
2 |
3 | public interface IServiceHelper
4 | {
5 | string GetDeviceIp();
6 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/Interfaces/ISetting.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
2 | public interface ISetting
3 | {
4 | }
5 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/Services/ServiceHelper.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Net.Wifi;
3 | using Android.Text.Format;
4 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
5 |
6 | namespace XRFID.Sample.Client.Mobile.Data.Services;
7 | public class ServiceHelper : IServiceHelper
8 | {
9 | public ServiceHelper()
10 | {
11 | }
12 |
13 | public string GetDeviceIp()
14 | {
15 | WifiManager wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Service.WifiService);
16 | return Formatter.FormatIpAddress(wifiManager.ConnectionInfo.IpAddress);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/ViewData/FindProductViewData.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.ComponentModel;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.ViewData;
5 | public class FindProductViewData : ObservableObject, INotifyPropertyChanged
6 | {
7 | private string name = "";
8 | public string Name { get => name; set => SetProperty(ref name, value); }
9 |
10 | private string code = "";
11 | public string Code { get => code; set => SetProperty(ref code, value); }
12 |
13 | private string epc = "";
14 | public string Epc { get => epc; set => SetProperty(ref epc, value); }
15 | }
16 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/ViewData/InventoryProductViewData.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.ComponentModel;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.ViewData;
5 | public class InventoryProductViewData : ObservableObject, INotifyPropertyChanged
6 | {
7 | private string productName = "N/A";
8 | public string ProductName
9 | {
10 | get => productName;
11 | set => SetProperty(ref productName, value);
12 | }
13 | private string epc = string.Empty;
14 | public string Epc
15 | {
16 | get => epc;
17 | set => SetProperty(ref epc, value);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/ViewData/InventoryStatsViewData.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.ComponentModel;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.ViewData;
5 | public class InventoryStatsViewData : ObservableObject, INotifyPropertyChanged
6 | {
7 | private int tagRead = 0;
8 | public int TagRead { get => tagRead; set => SetProperty(ref tagRead, value); }
9 |
10 | private int productFound = 0;
11 | public int ProductFound { get => productFound; set => SetProperty(ref productFound, value); }
12 |
13 | private int unexpectedTag = 0;
14 | public int UnexpectedTag { get => unexpectedTag; set => SetProperty(ref unexpectedTag, value); }
15 | }
16 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/ViewData/OrderViewData.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.ComponentModel;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.ViewData;
5 | public class OrderViewData : ObservableObject, INotifyPropertyChanged
6 | {
7 | public Guid Id { get; set; }
8 | public string Name { get; set; } = string.Empty;
9 | }
10 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Data/ViewData/TagViewData.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using System.ComponentModel;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Data.ViewData;
5 | public class TagViewData : ObservableObject, INotifyPropertyChanged
6 | {
7 | public string Epc { get; set; } = string.Empty;
8 | private string status = string.Empty;
9 | public string Status { get => status; set => SetProperty(ref status, value); }
10 | }
11 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile;
2 |
3 | public partial class MainPage
4 | {
5 | public MainPage()
6 | {
7 | InitializeComponent();
8 |
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using TinyMvvm;
2 |
3 | namespace XRFID.Sample.Client.Mobile;
4 | public class MainViewModel : TinyViewModel
5 | {
6 | public MainViewModel()
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Maui;
2 | using Syncfusion.Maui.Core.Hosting;
3 | using TinyMvvm;
4 | using XRFID.Sample.Client.Mobile.Base;
5 | using XRFID.Sample.Client.Mobile.Data.Services;
6 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
7 | using XRFID.Sample.Client.Mobile.Helpers;
8 | using XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
9 | using XRFID.Sample.Client.Mobile.Platforms.Android.Services;
10 | using XRFID.Sample.Client.Mobile.ViewModels;
11 | using XRFID.Sample.Client.Mobile.Views;
12 | using XRFID.Sample.Client.Mobile.Views.CheckItem;
13 | using XRFID.Sample.Client.Mobile.Views.FindItem;
14 | using XRFID.Sample.Client.Mobile.Views.Inventory;
15 | using XRFID.Sample.Client.Mobile.Views.PageSettings;
16 |
17 | namespace XRFID.Sample.Client.Mobile;
18 | public static class MauiProgram
19 | {
20 | private static EmdkService emdkControl = new EmdkService();
21 | public static MauiApp CreateMauiApp()
22 | {
23 | MauiAppBuilder builder = MauiApp.CreateBuilder();
24 | builder
25 | .UseMauiApp()
26 | .UseMauiCommunityToolkit()
27 | .ConfigureSyncfusionCore()
28 | .ConfigureFonts(fonts =>
29 | {
30 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
31 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
32 | })
33 | .UseTinyMvvm();
34 |
35 | builder.Services.ConfigureMauiHandlers(handlers =>
36 | {
37 | #if ANDROID
38 | handlers.AddHandler(typeof(Shell), typeof(Platforms.Android.CustomShellRenderer));
39 | #endif
40 | });
41 | ;
42 | builder.Services.AddSingleton();
43 | builder.Services.AddSingleton();
44 |
45 | //Instance api helper for api call
46 | builder.Services.AddSingleton();
47 |
48 | //for RFID viewmodel
49 | builder.Services.AddSingleton();
50 | builder.Services.AddSingleton();
51 | builder.Services.AddSingleton();
52 |
53 | builder.Services.AddTransient();
54 |
55 | builder.Services.AddTransient();
56 | builder.Services.AddTransient();
57 |
58 | builder.Services.AddTransient();
59 | builder.Services.AddTransient();
60 |
61 | builder.Services.AddTransient();
62 | builder.Services.AddTransient();
63 |
64 | builder.Services.AddTransient();
65 | builder.Services.AddTransient();
66 |
67 | builder.Services.AddTransient();
68 | builder.Services.AddTransient();
69 |
70 | builder.Services.AddTransient();
71 | builder.Services.AddTransient();
72 |
73 | builder.Services.AddTransient();
74 | builder.Services.AddTransient();
75 |
76 | builder.Services.AddTransient();
77 | builder.Services.AddTransient();
78 |
79 | builder.Services.AddTransient();
80 |
81 | MauiApp host = builder.Build();
82 |
83 | ServiceHelper serviceHelper = new ServiceHelper();
84 | host.Services.GetService().Load(serviceHelper);
85 |
86 | return host;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Messages/BarcodeMessage.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Messaging.Messages;
2 | using Symbol.XamarinEMDK.Barcode;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Messages;
5 | public class BarcodeMessage : ValueChangedMessage>
6 | {
7 |
8 | public BarcodeMessage(IList value) : base(value)
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Messages/ReaderTag.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Messages;
5 | public class ReaderTag : INotifyPropertyChanged
6 | {
7 | public int Id { get; set; }
8 | public string Epc { get; set; }
9 | public short? Rssi { get; set; }
10 | public string Tid { get; set; }
11 | public string PC { get; set; }
12 | public int ReadsCount { get; set; }
13 | public bool Checked { get; set; }
14 | public DateTime FirstRead { get; set; }
15 | public Guid? MovementListId { get; set; }
16 | public Guid ReaderId { get; set; }
17 | public Guid? ItemId { get; set; }
18 | public int Status { get; set; }
19 |
20 | public int RDistance { get; set; }
21 |
22 | public int TagCount { get { return ReadsCount; } set { ReadsCount = value; OnPropertyChanged(); } }
23 |
24 | public short? RSSI { get { return Rssi; } set { Rssi = value; OnPropertyChanged(); } }
25 |
26 | public bool CHECKED { get { return Checked; } set { Checked = value; OnPropertyChanged(); } }
27 |
28 | public int RelativeDistance { get { return RDistance; } set { RDistance = value; OnPropertyChanged(); } }
29 |
30 | public event PropertyChangedEventHandler PropertyChanged;
31 |
32 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
33 | }
34 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/Interfaces/IBarcodeService.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
2 |
3 | public interface IBarcodeService
4 | {
5 | bool IsEnabled { get; }
6 | void InitBarcodeReader();
7 | void DeinitBarcodeReader();
8 | void EnableBarcodeReader();
9 | void DisableBarcodeReader();
10 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/Interfaces/IEMDKService.cs:
--------------------------------------------------------------------------------
1 | using Symbol.XamarinEMDK.Barcode;
2 |
3 | namespace XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
4 |
5 | public interface IEMDKService
6 | {
7 | BarcodeManager GetBarcodeManager();
8 | void SetBarcodeManager(BarcodeManager barcodeManager);
9 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/Interfaces/IRFIDService.cs:
--------------------------------------------------------------------------------
1 | using Com.Zebra.Rfid.Api3;
2 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
3 | using XRFID.Sample.Client.Mobile.Messages;
4 |
5 | namespace XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
6 |
7 | public delegate void TagReadHandler(IList tags);
8 | public delegate void TriggerHandler(bool pressed);
9 | public delegate void StatusHandler(Events.StatusEventData statusEvent);
10 | public delegate void ConnectionHandler(bool connected);
11 | public delegate void ReaderAppearanceHandler(bool appeared);
12 | public interface IRFIDService
13 | {
14 | event TagReadHandler TagRead;
15 | event TriggerHandler TriggerEvent;
16 | event StatusHandler StatusEvent;
17 | event ConnectionHandler ReaderConnectionEvent;
18 | event ReaderAppearanceHandler ReaderAppearanceEvent;
19 |
20 | bool IsConnected { get; }
21 |
22 | void InitRfidReader(IGeneralSettings generalSettings);
23 |
24 | void ConfigureReader();
25 |
26 | void Disconnect();
27 |
28 | void Connect();
29 |
30 | void DeInit();
31 |
32 | bool PerformInventory();
33 |
34 | void StopInventory();
35 |
36 | void Locate(bool start, string tagPattern, string tagMask);
37 |
38 | void SetTriggerMode();
39 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 | using Symbol.XamarinEMDK;
5 | using Symbol.XamarinEMDK.Barcode;
6 | using XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
7 |
8 | namespace XRFID.Sample.Client.Mobile;
9 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
10 | public class MainActivity : MauiAppCompatActivity, EMDKManager.IEMDKListener, EMDKManager.IStatusListener
11 | {
12 | public EMDKManager emdkManager;
13 | private Symbol.XamarinEMDK.Notification.NotificationManager notificationManager;
14 |
15 | private IEMDKService emdkService;
16 | private BarcodeManager barcodeManager;
17 |
18 | void EMDKManager.IEMDKListener.OnClosed()
19 | {
20 | if (emdkManager != null)
21 | {
22 | emdkManager.Release();
23 | }
24 | }
25 |
26 | protected override void OnDestroy()
27 | {
28 | base.OnDestroy();
29 |
30 | // Clean up the objects created by EMDK manager
31 | if (emdkManager != null)
32 | {
33 | emdkManager.Release();
34 | emdkManager = null;
35 | }
36 | }
37 |
38 | protected override void OnCreate(Bundle savedInstanceState)
39 | {
40 | base.OnCreate(savedInstanceState);
41 |
42 | }
43 |
44 | protected override void OnPostCreate(Bundle savedInstanceState)
45 | {
46 | base.OnPostCreate(savedInstanceState);
47 | EMDKResults results = EMDKManager.GetEMDKManager(this, this);
48 | //WeakReferenceMessenger.Default.Send(results.StatusCode);
49 |
50 | }
51 |
52 | void EMDKManager.IEMDKListener.OnOpened(EMDKManager emdkManagerInstance)
53 | {
54 | //WeakReferenceMessenger.Default.Send("sopra");
55 | this.emdkManager = emdkManagerInstance;
56 | emdkService = MauiApplication.Current.Services.GetService();
57 |
58 | barcodeManager = (BarcodeManager)emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);
59 | emdkService.SetBarcodeManager(barcodeManager);
60 |
61 | try
62 | {
63 | emdkManager.GetInstanceAsync(EMDKManager.FEATURE_TYPE.Profile, this);
64 | emdkManager.GetInstanceAsync(EMDKManager.FEATURE_TYPE.Version, this);
65 | emdkManager.GetInstanceAsync(EMDKManager.FEATURE_TYPE.Notification, this);
66 | emdkManager.GetInstanceAsync(EMDKManager.FEATURE_TYPE.Barcode, this);
67 |
68 | }
69 | catch (Exception e)
70 | {
71 | //RunOnUiThread(() => statusTextView.Text = e.Message);
72 | Console.WriteLine("Exception: " + e.StackTrace);
73 | }
74 | //WeakReferenceMessenger.Default.Send("sotto");
75 |
76 | }
77 |
78 | void EMDKManager.IStatusListener.OnStatus(EMDKManager.StatusData statusData, EMDKBase emdkBase)
79 | {
80 | if (statusData.Result == EMDKResults.STATUS_CODE.Success)
81 | {
82 |
83 |
84 | }
85 | }
86 |
87 |
88 |
89 |
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace XRFID.Sample.Client.Mobile;
5 | [Application]
6 | public class MainApplication : MauiApplication
7 | {
8 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
9 | : base(handle, ownership)
10 | {
11 | }
12 |
13 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
14 | }
15 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #e55934
4 | #e55934
5 | #e55934
6 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Platforms/Android/Services/EmdkService.cs:
--------------------------------------------------------------------------------
1 | using AndroidX.Fragment.App;
2 | using Symbol.XamarinEMDK.Barcode;
3 | using XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
4 |
5 | namespace XRFID.Sample.Client.Mobile.Platforms.Android.Services;
6 | public class EmdkService : Fragment, IEMDKService
7 | {
8 | private BarcodeManager barcodeManager;
9 | public EmdkService()
10 | {
11 |
12 | }
13 |
14 | public BarcodeManager GetBarcodeManager()
15 | {
16 | return barcodeManager;
17 | }
18 |
19 | public void SetBarcodeManager(BarcodeManager barcodeManager)
20 | {
21 | this.barcodeManager = barcodeManager;
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/AppIcon/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/AppIcon/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XerumSrl/XRFID-Android-Samples/dcfbd1f42a9ea957b4e74eb7557638aea149cab5/XRFID.Sample.Client.Mobile/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Fonts/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XerumSrl/XRFID-Android-Samples/dcfbd1f42a9ea957b4e74eb7557638aea149cab5/XRFID.Sample.Client.Mobile/Resources/Fonts/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/back_button.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/check_item.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/find_item.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/home_icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/info_about.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/info_icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/inventory.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/menu_icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/rapid_read.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/settings_gear_blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Images/settings_gear_orange.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Raw/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories). Deployment of the asset to your application
3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4 |
5 |
6 |
7 | These files will be deployed with you package and will be accessible using Essentials:
8 |
9 | async Task LoadMauiAsset()
10 | {
11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12 | using var reader = new StreamReader(stream);
13 |
14 | var contents = reader.ReadToEnd();
15 | }
16 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Splash/dotnet_splash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Splash/splash.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Resources/Styles/Colors.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | #e55934
8 | #DFD8F7
9 | #e55934
10 | White
11 | Black
12 | #E1E1E1
13 | #C8C8C8
14 | #ACACAC
15 | #919191
16 | #6E6E6E
17 | #404040
18 | #212121
19 | #141414
20 | #33658A
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | #F7B548
37 | #FFD590
38 | #FFE5B9
39 | #28C2D1
40 | #7BDDEF
41 | #C3F2F4
42 | #3E8EED
43 | #72ACF1
44 | #A7CBF6
45 |
46 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/ViewModels/CheckItem/CheckItemRfidViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 | using System.Collections.ObjectModel;
3 | using XRFID.Sample.Client.Mobile.Base;
4 | using XRFID.Sample.Client.Mobile.Data.Enums;
5 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
6 | using XRFID.Sample.Client.Mobile.Data.ViewData;
7 | using XRFID.Sample.Client.Mobile.Messages;
8 | using XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
9 |
10 | namespace XRFID.Sample.Client.Mobile.ViewModels;
11 |
12 | [QueryProperty(nameof(TagsView), nameof(TagsView))]
13 | public partial class CheckItemRfidViewModel : BaseRfidViewModel
14 | {
15 | private readonly IAlertService alertService;
16 |
17 | #region collections
18 | private Dictionary tagDict = new Dictionary();
19 |
20 | private ObservableCollection tagsView = new ObservableCollection();
21 | public ObservableCollection TagsView
22 | {
23 | get => tagsView;
24 | set => SetProperty(ref tagsView, value);
25 | }
26 | private ObservableCollection InitalView { get => tagsView; }
27 | #endregion
28 |
29 | #region commands
30 | [RelayCommand]
31 | public async Task ResetCommand()
32 | {
33 | StatsReset();
34 | }
35 |
36 | [RelayCommand]
37 | public async Task ConfirmCommand()
38 | {
39 | alertService.LongToast("Confirmation command is ok");
40 | }
41 | #endregion
42 |
43 | public CheckItemRfidViewModel(IRFIDService rfidService,
44 | IGeneralSettings generalSettings,
45 | IAlertService alertService) : base(rfidService, generalSettings)
46 | {
47 | this.alertService = alertService;
48 | }
49 |
50 | #region view methods
51 | public override Task OnAppearing()
52 | {
53 | UpdateIn();
54 | return base.OnAppearing();
55 | }
56 | public override Task OnDisappearing()
57 | {
58 | Dispose(); //This dispose method is in base, but due to inherithance implementation details it calls the overridden UpdateOut()
59 | return base.OnDisappearing();
60 | }
61 | #endregion
62 |
63 | #region workflow methods
64 | public void StatsReset()
65 | {
66 | tagDict.Clear();
67 | foreach (TagViewData tag in TagsView)
68 | {
69 | tag.Status = TagViewStatus.Default.ToString();
70 | }
71 | }
72 | #endregion
73 |
74 | #region RFID method
75 | public override void UpdateIn()
76 | {
77 | rfidService.TagRead += TestTagReadEvent;
78 | rfidService.TriggerEvent += HHTriggerEvent;
79 | rfidService.ReaderConnectionEvent += ReaderConnectionEvent;
80 |
81 | disposedValue = false;
82 | }
83 | public override void UpdateOut()
84 | {
85 | rfidService.TagRead -= TestTagReadEvent;
86 | rfidService.TriggerEvent -= HHTriggerEvent;
87 | rfidService.ReaderConnectionEvent -= ReaderConnectionEvent;
88 | }
89 |
90 | private void TestTagReadEvent(IList aryTags)
91 | {
92 | lock (tagreadlock)
93 | {
94 | foreach (ReaderTag tag in aryTags)
95 | {
96 | TestUpdateUi(tag.Epc, tag.TagCount, tag.Rssi);
97 | }
98 | }
99 | }
100 |
101 | private void TestUpdateUi(string id, int count, short? rssi)
102 | {
103 | if (tagDict.ContainsKey(id))
104 | {
105 | tagDict[id] = tagDict[id] + count;
106 | UpdateCount(id, tagDict[id], rssi);
107 | }
108 | else
109 | {
110 | tagDict.Add(id, count);
111 | UpdateList(id, count, rssi);
112 | }
113 | totalTagCount += count;
114 | UpdateCounts();
115 | }
116 | #endregion
117 |
118 | #region custom tag methods
119 | protected override void UpdateList(String tag, int count, short? rssi)
120 | {
121 | TagViewData find = TagsView.FirstOrDefault(q => q.Epc == tag);
122 | if (find is not null)
123 | {
124 | find.Status = "FOUND!";
125 | }
126 | }
127 |
128 | protected override void UpdateCount(String tag, int count, short? rssi)
129 | {
130 |
131 | }
132 | #endregion
133 | }
134 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/ViewModels/FindItem/FindItemRfidViewModel.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.Base;
2 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
3 | using XRFID.Sample.Client.Mobile.Data.ViewData;
4 | using XRFID.Sample.Client.Mobile.Platforms.Android.Interfaces;
5 |
6 | namespace XRFID.Sample.Client.Mobile.ViewModels;
7 |
8 | [QueryProperty(nameof(Product), nameof(Product))]
9 | public partial class FindItemRfidViewModel : BaseRfidViewModel
10 | {
11 | #region properties
12 | private const int TIMER_DELAY = 5000;
13 |
14 | private short rssiLow = -80;
15 | private short rssiHigh = -30;
16 | private short rssiMagicNumber;//Calculate constant to sum to make rssi always positive
17 | private float rssiScaleFactor;//calculte scale factor from normalized rssi values to Percentage values, this is basically the *100/maxvalue part of the proportion
18 |
19 | private const short PERC_LOW = 33;
20 | private const short PERC_HIGH = 66;
21 |
22 | private readonly SolidColorBrush PercLow = new SolidColorBrush(new Color(231, 29, 54)); //red //cannot be const due to c# limitations
23 | private readonly SolidColorBrush PercMid = new SolidColorBrush(new Color(253, 197, 0)); //yellow
24 | private readonly SolidColorBrush PercHigh = new SolidColorBrush(new Color(70, 200, 53)); //green?
25 |
26 | private Timer resetTimer;
27 |
28 | private FindProductViewData product = new FindProductViewData();
29 | public FindProductViewData Product
30 | {
31 | get => product;
32 | set => SetProperty(ref product, value);
33 | }
34 |
35 | private Brush color;
36 | public Brush Color
37 | {
38 | get => color;
39 | set => SetProperty(ref color, value);
40 | }
41 |
42 | private double percent;
43 | public double Percent
44 | {
45 | get => percent;
46 | set => SetProperty(ref percent, value);
47 | }
48 |
49 | private bool isReading = false;
50 | #endregion
51 |
52 | public FindItemRfidViewModel(IRFIDService rfidService, IGeneralSettings generalSettings) : base(rfidService, generalSettings)
53 | {
54 | resetTimer = new Timer(ResetPercentage, new AutoResetEvent(false), Timeout.Infinite, Timeout.Infinite);
55 | Color = PercLow;
56 |
57 | rssiMagicNumber = (short)(rssiLow * -1);
58 | rssiScaleFactor = 100f / (float)(rssiHigh + rssiMagicNumber);
59 | }
60 |
61 | #region view methods
62 | public override Task OnAppearing()
63 | {
64 | Percent = 0;
65 | isReading = false;
66 | rssiHigh = (short)Preferences.Default.Get("findsensitivity", -30);
67 | rssiMagicNumber = (short)(rssiLow * -1);
68 | rssiScaleFactor = 100f / (float)(rssiHigh + rssiMagicNumber);
69 | UpdateIn();
70 | return base.OnAppearing();
71 | }
72 | public override Task OnDisappearing()
73 | {
74 | Dispose(); //This dispose method is in base, but due to inherithance implementation details it calls the overridden UpdateOut()
75 | return base.OnDisappearing();
76 | }
77 | #endregion
78 |
79 | #region WorkFlow Methods
80 | public void ContinousRead(bool pressed)
81 | {
82 | if (pressed)
83 | {
84 | PerformInventory();
85 | }
86 | else
87 | {
88 | StopInventory();
89 | }
90 | }
91 |
92 | private void ResetPercentage(object e)
93 | {
94 | Percent = 0;
95 | }
96 |
97 | private void PercentageCalculation(short rssi)
98 | {
99 | if (rssi > rssiHigh)
100 | {
101 | rssi = rssiHigh;
102 | }
103 | else if (rssi < rssiLow)
104 | {
105 | rssi = rssiLow;
106 | }
107 |
108 | // rssi to positive
109 | rssi += rssiMagicNumber;
110 |
111 | //Calculate scaled percentage with " oneHundredPerc:100 = rssi:X "
112 | Percent = Math.Round(rssi * rssiScaleFactor);
113 |
114 | switch (Percent)
115 | {
116 | case <= PERC_LOW:
117 | Color = PercLow;
118 | break;
119 | case > PERC_HIGH:
120 | Color = PercHigh;
121 | break;
122 | default:
123 | Color = PercMid;
124 | break;
125 | }
126 |
127 | }
128 | #endregion
129 |
130 | #region RFID method
131 | public override void UpdateIn()
132 | {
133 | rfidService.TagRead += TagReadEvent;
134 | rfidService.TriggerEvent += HHTriggerEvent;
135 | rfidService.ReaderConnectionEvent += ReaderConnectionEvent;
136 |
137 | disposedValue = false;
138 | }
139 | public override void UpdateOut()
140 | {
141 | rfidService.TagRead -= TagReadEvent;
142 | rfidService.TriggerEvent -= HHTriggerEvent;
143 | rfidService.ReaderConnectionEvent -= ReaderConnectionEvent;
144 | }
145 |
146 | protected override void HHTriggerEvent(bool pressed)
147 | {
148 | if (pressed)
149 | {
150 | isReading = true;
151 | Task.Run(ContinousInventory);
152 | }
153 | else
154 | {
155 | isReading = false;
156 | StopInventory();
157 | }
158 | }
159 |
160 | protected override void UpdateUi(string id, int count, short? rssi)
161 | {
162 | if (Product.Epc.Equals(id))
163 | {
164 | PercentageCalculation(rssi ?? rssiLow);
165 | resetTimer.Change(TIMER_DELAY, Timeout.Infinite);
166 | }
167 | }
168 |
169 | private void ContinousInventory()
170 | {
171 | do
172 | {
173 | PerformInventory();
174 | Thread.Sleep(100);
175 | StopInventory();
176 |
177 | } while (isReading);
178 | }
179 | #endregion
180 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/ViewModels/FindItem/FindItemViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 | using System.Collections.ObjectModel;
3 | using TinyMvvm;
4 | using XRFID.Sample.Client.Mobile.Data.Services.Interfaces;
5 | using XRFID.Sample.Client.Mobile.Data.ViewData;
6 | using XRFID.Sample.Client.Mobile.Helpers;
7 | using XRFID.Sample.Common.Dto;
8 |
9 | namespace XRFID.Sample.Client.Mobile.ViewModels;
10 |
11 | public partial class FindItemViewModel : TinyViewModel
12 | {
13 | private readonly RestApiHelper apiHelper;
14 | private readonly IAlertService alertService;
15 |
16 | #region collections
17 | private ObservableCollection productList = new ObservableCollection();
18 | public ObservableCollection ProductList
19 | {
20 | get => productList;
21 | set => SetProperty(ref productList, value);
22 | }
23 |
24 | private FindProductViewData itemTapped;
25 | public FindProductViewData ItemTapped
26 | {
27 | get => itemTapped;
28 | set
29 | {
30 | if (itemTapped != value)
31 | {
32 | itemTapped = value;
33 | OnTapped(value);
34 | }
35 | }
36 | }
37 | #endregion
38 |
39 | #region properties
40 | private string searchEntry;
41 | public string SearchEntry
42 | {
43 | get => searchEntry;
44 | set => SetProperty(ref searchEntry, value);
45 | }
46 |
47 | private bool searchEntryEnabled = true;
48 | public bool SearchEntryEnabled
49 | {
50 | get => searchEntryEnabled;
51 | set => SetProperty(ref searchEntryEnabled, value);
52 | }
53 | #endregion
54 |
55 | #region commands
56 | public IAsyncRelayCommand SearchCommandAsync { get; }
57 | #endregion
58 |
59 | public FindItemViewModel(RestApiHelper apiHelper, IAlertService alertService)
60 | {
61 | this.apiHelper = apiHelper;
62 | this.alertService = alertService;
63 | SearchCommandAsync = new AsyncRelayCommand(SearchItemByNameAsync);
64 | }
65 |
66 | #region view methods
67 | public override Task OnDisappearing()
68 | {
69 | return base.OnDisappearing();
70 | }
71 | #endregion
72 |
73 | #region WorkFlow Methods
74 | public async Task SearchItemByNameAsync()
75 | {
76 | try
77 | {
78 | if (IsBusy || string.IsNullOrWhiteSpace(SearchEntry))
79 | {
80 | return;
81 | }
82 | IsBusy = true;
83 | SearchEntryEnabled = false;
84 |
85 | List products = await apiHelper.GetProductsSearchAsync(SearchEntry);
86 | if (products is null || !products.Any())
87 | {
88 | SearchEntryEnabled = true;
89 | IsBusy = false;
90 | return;
91 | }
92 |
93 | ProductList.Clear();
94 |
95 | foreach (ProductDto prod in products)
96 | {
97 | ProductList.Add(new FindProductViewData
98 | {
99 | Name = prod.Name,
100 | Epc = prod.Epc,
101 | Code = prod.Code,
102 | });
103 | }
104 |
105 | SearchEntryEnabled = true;
106 | IsBusy = false;
107 | }
108 | catch (Exception)
109 | {
110 | SearchEntryEnabled = true;
111 | IsBusy = false;
112 | return;
113 | }
114 | }
115 |
116 | private void OnTapped(FindProductViewData value)
117 | {
118 | FindProductViewData item = value;
119 | if (item is null)
120 | {
121 | return;
122 | }
123 | Task result = Shell.Current.GoToAsync("/../finditemrfid", new Dictionary { ["Product"] = item, });
124 | }
125 | #endregion
126 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/ViewModels/SettingsViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Maui.Alerts;
2 | using CommunityToolkit.Maui.Core;
3 | using CommunityToolkit.Mvvm.Input;
4 | using System.Text.RegularExpressions;
5 | using TinyMvvm;
6 |
7 | namespace XRFID.Sample.Client.Mobile.ViewModels;
8 |
9 | public class SettingsViewModel : TinyViewModel
10 | {
11 | #region Constants
12 | private readonly Regex guidRegex = new Regex(@"^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$", RegexOptions.Compiled);
13 | public string GuidRegex => guidRegex.ToString();
14 |
15 | private readonly Regex uriRegex = new Regex(@"^https?://[0-9a-zA-Z._\-/:]*/$", RegexOptions.Compiled);
16 | public string UriRegex => uriRegex.ToString();
17 |
18 | private readonly Regex hostnameRegex = new Regex(@"^[a-zA-Z0-9\-_]{1,63}$", RegexOptions.Compiled);
19 | public string HostnameRegex => hostnameRegex.ToString();
20 |
21 | private readonly Regex apiClientRegex = new Regex(@"^[a-zA-Z0-9\-_.]*$", RegexOptions.Compiled);
22 | public string ApiClientRegex => apiClientRegex.ToString();
23 |
24 | private readonly Regex apiScopeRegex = new Regex(@"^[a-zA-Z0-9\x20]*$", RegexOptions.Compiled);
25 | public string ApiScopeRegex => apiScopeRegex.ToString();
26 | #endregion
27 |
28 | #region BoundProps
29 | private string apiEndpoint;
30 | public string ApiEndpoint
31 | {
32 | get => apiEndpoint;
33 | set => SetProperty(ref apiEndpoint, value);
34 | }
35 |
36 | private string deviceId;
37 | public string DeviceId
38 | {
39 | get => deviceId;
40 | set => SetProperty(ref deviceId, value);
41 | }
42 |
43 | private string deviceName;
44 | public string DeviceName
45 | {
46 | get => deviceName;
47 | set => SetProperty(ref deviceName, value);
48 | }
49 | #endregion
50 |
51 | public IRelayCommand SaveCommand { get; }
52 |
53 | public SettingsViewModel()
54 | {
55 | SaveCommand = new RelayCommand(SaveSettings);
56 | }
57 |
58 | private async void SaveSettings()
59 | {
60 | CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
61 |
62 | try
63 | {
64 | if (!uriRegex.IsMatch(apiEndpoint))
65 | {
66 | throw new ArgumentException("API Endpoint is not a valid URL");
67 | }
68 |
69 | if (!hostnameRegex.IsMatch(deviceName))
70 | {
71 | throw new ArgumentException("Device Name does not conform to the hostname ruleset");
72 | }
73 | }
74 | catch (ArgumentException ex)
75 | {
76 | SnackbarOptions snackbarOptions = new SnackbarOptions
77 | {
78 | BackgroundColor = Colors.WhiteSmoke,
79 | TextColor = Colors.Red,
80 | ActionButtonTextColor = Colors.Black,
81 | CornerRadius = new CornerRadius(10)
82 | };
83 |
84 | string btntext = "OK";
85 | TimeSpan duration = TimeSpan.FromSeconds(5);
86 |
87 | await Snackbar.Make(ex.Message, null, btntext, duration, snackbarOptions).Show(cancellationTokenSource.Token);
88 | return;
89 | }
90 |
91 | Preferences.Default.Set("device_name", DeviceName);
92 | Preferences.Default.Set("api_endpoint", ApiEndpoint);
93 |
94 | await Toast.Make("success, reboot application for changes to take effect", ToastDuration.Short).Show(cancellationTokenSource.Token);
95 | }
96 |
97 | public override Task OnAppearing()
98 | {
99 | DeviceName = Preferences.Default.Get("device_name", string.Empty);
100 | if (string.IsNullOrEmpty(DeviceName))
101 | {
102 | DeviceName = DeviceInfo.Current.Name;
103 | Preferences.Default.Set("device_name", DeviceName);
104 | }
105 |
106 | DeviceId = Preferences.Default.Get("device_id", string.Empty);
107 | if (string.IsNullOrEmpty(DeviceId))
108 | {
109 | DeviceId = Guid.NewGuid().ToString();
110 | Preferences.Default.Set("device_id", DeviceId);
111 | }
112 |
113 | ApiEndpoint = Preferences.Default.Get("api_endpoint", string.Empty);
114 | if (string.IsNullOrEmpty(ApiEndpoint))
115 | {
116 | ApiEndpoint = "https://localhost:5001/api/";
117 | Preferences.Default.Set("api_endpoint", ApiEndpoint);
118 | }
119 |
120 | return base.OnAppearing();
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/AboutView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/AboutView.xaml.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XerumSrl/XRFID-Android-Samples/dcfbd1f42a9ea957b4e74eb7557638aea149cab5/XRFID.Sample.Client.Mobile/Views/AboutView.xaml.cs
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/CheckItem/CheckItemRfidView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
55 |
56 |
63 |
64 |
65 |
69 |
70 |
71 |
76 |
77 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/CheckItem/CheckItemRfidView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.OS;
2 | using XRFID.Sample.Client.Mobile.ViewModels;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Views.CheckItem;
5 |
6 | public partial class CheckItemRfidView
7 | {
8 |
9 | public CheckItemRfidView(CheckItemRfidViewModel viewModel)
10 | {
11 | InitializeComponent();
12 | BindingContext = viewModel;
13 | }
14 |
15 | protected override void OnNavigatedTo(NavigatedToEventArgs args)
16 | {
17 | base.OnNavigatedTo(args);
18 | }
19 |
20 | protected override bool OnBackButtonPressed()
21 | {
22 | Dispatcher.Dispatch(async () =>
23 | {
24 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
25 |
26 | if (leave)
27 | {
28 | Process.KillProcess(Process.MyPid());
29 | }
30 | });
31 |
32 | return true;
33 | }
34 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/CheckItem/CheckItemView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
32 |
33 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
63 |
64 |
65 |
74 |
75 |
76 |
80 |
81 |
82 |
83 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
112 |
113 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/CheckItem/CheckItemView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.Content;
2 | using Android.OS;
3 | using Android.Views.InputMethods;
4 | using CommunityToolkit.Maui.Behaviors;
5 | using CommunityToolkit.Maui.Converters;
6 | using System.Collections.ObjectModel;
7 | using XRFID.Sample.Client.Mobile.Data.ViewData;
8 | using XRFID.Sample.Client.Mobile.ViewModels;
9 |
10 | namespace XRFID.Sample.Client.Mobile.Views.CheckItem;
11 |
12 | public partial class CheckItemView
13 | {
14 | private readonly CheckItemViewModel viewModel;
15 |
16 | public CheckItemView(CheckItemViewModel viewModel)
17 | {
18 | InitializeComponent();
19 |
20 | BindingContext = viewModel;
21 | this.viewModel = viewModel;
22 |
23 | EventToCommandBehavior behavior = new EventToCommandBehavior
24 | {
25 | EventName = nameof(ListView.ItemSelected),
26 | EventArgsConverter = new SelectedItemEventArgsConverter()
27 | };
28 | }
29 |
30 | private void OnClickSelect(object sender, EventArgs e)
31 | {
32 | HideKeyboard();
33 | }
34 |
35 | private void ShowInfoPage(object sender, EventArgs e)
36 | {
37 | App.Current.MainPage.DisplayAlert("Page Info", "page information will be written here", "OK");
38 | }
39 |
40 | void OnEntryCompleted(object sender, EventArgs e)
41 | {
42 | HideKeyboard();
43 | string barcode = ((Entry)sender).Text;
44 | try
45 | {
46 | Task> task = Task.Run(() => viewModel.ShipmentCreateItemsByScan(barcode));
47 | task.Wait();
48 |
49 | if (task.Result is not null && task.Result.Any())
50 | {
51 | Task result = Shell.Current.GoToAsync("rfid", new Dictionary { ["TagsView"] = task.Result, });
52 |
53 | // last current page action after navigation
54 | if (result.IsCompletedSuccessfully)
55 | {
56 |
57 | }
58 | else if (!result.IsCanceled)
59 | {
60 |
61 | }
62 | }
63 | }
64 | catch (Exception)
65 | {
66 |
67 | }
68 | }
69 |
70 | protected override bool OnBackButtonPressed()
71 | {
72 | if (!IsBusy)
73 | {
74 | Dispatcher.Dispatch(async () =>
75 | {
76 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
77 |
78 | if (leave)
79 | {
80 | Process.KillProcess(Process.MyPid());
81 | }
82 | });
83 | }
84 | return true;
85 | }
86 |
87 | private static void HideKeyboard()
88 | {
89 | Context context = Platform.AppContext;
90 | InputMethodManager inputMethodManager = context.GetSystemService(Context.InputMethodService) as InputMethodManager;
91 | if (inputMethodManager != null)
92 | {
93 | Android.App.Activity activity = Platform.CurrentActivity;
94 | IBinder token = activity.CurrentFocus?.WindowToken;
95 | inputMethodManager.HideSoftInputFromWindow(token, HideSoftInputFlags.None);
96 | activity.Window.DecorView.ClearFocus();
97 | }
98 | }
99 |
100 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/FindItem/FindItemRfidView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
29 |
30 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
66 |
67 |
68 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
87 |
88 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
106 |
107 |
108 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/FindItem/FindItemRfidView.xaml.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Client.Mobile.ViewModels;
2 |
3 | namespace XRFID.Sample.Client.Mobile.Views.FindItem;
4 |
5 | public partial class FindItemRfidView
6 | {
7 | private readonly FindItemRfidViewModel viewModel;
8 |
9 | public FindItemRfidView(FindItemRfidViewModel viewModel)
10 | {
11 | InitializeComponent();
12 |
13 | BindingContext = viewModel;
14 | this.viewModel = viewModel;
15 | }
16 | private void SettingsNavigation(object sender, EventArgs e)
17 | {
18 | Shell.Current.GoToAsync("findsettings?setting=findsensitivity");
19 | }
20 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/FindItem/FindItemView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
66 |
67 |
68 |
77 |
78 |
79 |
83 |
84 |
85 |
86 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/FindItem/FindItemView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.Content;
2 | using Android.OS;
3 | using Android.Views.InputMethods;
4 | using XRFID.Sample.Client.Mobile.ViewModels;
5 |
6 | namespace XRFID.Sample.Client.Mobile.Views.FindItem;
7 |
8 | public partial class FindItemView
9 | {
10 |
11 |
12 | public FindItemView(FindItemViewModel viewModel)
13 | {
14 | InitializeComponent();
15 |
16 | BindingContext = viewModel;
17 | }
18 | private void ShowInfoPage(object sender, EventArgs e)
19 | {
20 | App.Current.MainPage.DisplayAlert("Page Info", "page information will be written here", "OK");
21 | }
22 |
23 | void OnEntryCompleted(object sender, EventArgs e)
24 | {
25 | HideKeyboard();
26 | }
27 |
28 | private void OnClickSelect(object sender, EventArgs e)
29 | {
30 | HideKeyboard();
31 | }
32 |
33 | protected override bool OnBackButtonPressed()
34 | {
35 | if (!IsBusy)
36 | {
37 | Dispatcher.Dispatch(async () =>
38 | {
39 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
40 |
41 | if (leave)
42 | {
43 | Process.KillProcess(Process.MyPid());
44 | }
45 | });
46 | }
47 | return true;
48 | }
49 |
50 | public static void HideKeyboard()
51 | {
52 | Context context = Platform.AppContext;
53 | InputMethodManager inputMethodManager = context.GetSystemService(Context.InputMethodService) as InputMethodManager;
54 | if (inputMethodManager != null)
55 | {
56 | Android.App.Activity activity = Platform.CurrentActivity;
57 | IBinder token = activity.CurrentFocus?.WindowToken;
58 | inputMethodManager.HideSoftInputFromWindow(token, HideSoftInputFlags.None);
59 | activity.Window.DecorView.ClearFocus();
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/Inventory/InventoryView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.OS;
2 | using Syncfusion.Maui.ListView;
3 | using XRFID.Sample.Client.Mobile.Data.ViewData;
4 | using XRFID.Sample.Client.Mobile.ViewModels;
5 | using SwipeEndedEventArgs = Syncfusion.Maui.ListView.SwipeEndedEventArgs;
6 |
7 | namespace XRFID.Sample.Client.Mobile.Views.Inventory;
8 |
9 | public partial class InventoryView
10 | {
11 | public InventoryView(InventoryViewModel viewModel)
12 | {
13 | InitializeComponent();
14 | BindingContext = viewModel;
15 | }
16 |
17 | public void SwipeEnded(object sender, SwipeEndedEventArgs e)
18 | {
19 | SfListView castedSender = (SfListView)sender;
20 | if (e.Offset == 0)
21 | {
22 | return;
23 | }
24 |
25 | InventoryProductViewData value = e.DataItem as InventoryProductViewData;
26 |
27 | Task result = Shell.Current.GoToAsync("/../finditemrfid", new Dictionary { ["Product"] = new FindProductViewData { Epc = value.Epc, Name = value.ProductName } });
28 | castedSender.ResetSwipeItem(true);
29 | }
30 |
31 | private void ShowInfoPage(object sender, EventArgs e)
32 | {
33 | App.Current.MainPage.DisplayAlert("Page Info", "page information will be written here", "OK");
34 | }
35 |
36 | private void GoToSettings(object sender, EventArgs e)
37 | {
38 | //modify the value of the query to modify setting name, you also need to modify the constant in the ViewModel in OnAppearing
39 | Shell.Current.GoToAsync("inventoryrapidreadsettings?setting=inventory");
40 | }
41 |
42 | protected override bool OnBackButtonPressed()
43 | {
44 | Dispatcher.Dispatch(async () =>
45 | {
46 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
47 |
48 | if (leave)
49 | {
50 | Process.KillProcess(Process.MyPid());
51 | }
52 | });
53 |
54 | return true;
55 | }
56 |
57 | private void SfDataGrid_QueryRowHeight(object sender, Syncfusion.Maui.DataGrid.DataGridQueryRowHeightEventArgs e)
58 | {
59 | if (e.RowIndex != 0)
60 | {
61 | e.Height = e.GetIntrinsicRowHeight(e.RowIndex);
62 | e.Handled = true;
63 | }
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/PageSettings/FindSettings.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
41 |
42 |
46 |
47 |
48 |
49 |
53 |
54 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/PageSettings/FindSettings.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Views.PageSettings;
2 |
3 | [QueryProperty(nameof(Setting), "setting")]
4 | public partial class FindSettings : ContentPage
5 | {
6 | #region RssiConstants
7 | #region Constants
8 | private const int MAX_SENSITIVITY = -50;
9 | private const int MIN_SENSITIVITY = -30;
10 | #endregion
11 |
12 | #region TransitiveConstants
13 | //automatically calculated do not touch
14 | private const int NORM_MAX_SENS = MAX_SENSITIVITY * -1;
15 | private const int NORM_MIN_SENS = MIN_SENSITIVITY * -1;
16 | private const double SCALE_FACTOR = (NORM_MAX_SENS - NORM_MIN_SENS) / 100d;
17 | #endregion
18 | #endregion
19 |
20 | public string Setting { get; set; } = string.Empty;
21 |
22 | public FindSettings()
23 | {
24 | InitializeComponent();
25 | BindingContext = this;
26 | }
27 |
28 | private int PercentToRssi(double value)
29 | {
30 | double current;
31 | current = value * SCALE_FACTOR;//crush 0-100 to 0-deltamaxmin
32 | current += NORM_MIN_SENS;//move up to (min*-1) to 80
33 | current *= -1;//multiply *-1 as the rssi is in this range, but negative, high rssi=strog signal enche the multiplication instead of a transpose
34 |
35 | return (int)Math.Round(current);
36 | }
37 |
38 | private double RssiToPercent(int rssi)
39 | {
40 | double current;
41 | current = rssi * -1;
42 | current -= NORM_MIN_SENS;
43 | current /= SCALE_FACTOR;
44 |
45 | if (current > 100)
46 | {
47 | current = 100;
48 | }
49 |
50 | return current;
51 | }
52 |
53 | protected override void OnAppearing()
54 | {
55 | sens.Value = RssiToPercent(Preferences.Default.Get(Setting, MAX_SENSITIVITY));
56 | base.OnAppearing();
57 | }
58 |
59 | protected override void OnDisappearing()
60 | {
61 | Preferences.Default.Set(Setting, PercentToRssi(sens.Value));
62 | base.OnDisappearing();
63 | }
64 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/PageSettings/InventoryRapidReadSettings.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
41 |
42 |
46 |
47 |
48 |
49 |
53 |
54 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/PageSettings/InventoryRapidReadSettings.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Client.Mobile.Views.PageSettings;
2 |
3 | [QueryProperty(nameof(Setting), "setting")]
4 | public partial class InventoryRapidReadSettings : ContentPage
5 | {
6 | #region RssiConstants
7 | #region Constants
8 | private const int MAX_SENSITIVITY = -80;
9 | private const int MIN_SENSITIVITY = -40;
10 | #endregion
11 |
12 | #region TransitiveConstants
13 | //automatically calculated do not touch
14 | private const int NORM_MAX_SENS = MAX_SENSITIVITY * -1;
15 | private const int NORM_MIN_SENS = MIN_SENSITIVITY * -1;
16 | private const double SCALE_FACTOR = (NORM_MAX_SENS - NORM_MIN_SENS) / 100d;
17 | #endregion
18 | #endregion
19 |
20 | public string Setting { get; set; } = string.Empty;
21 |
22 | public InventoryRapidReadSettings()
23 | {
24 | InitializeComponent();
25 | BindingContext = this;
26 | }
27 |
28 | private int PercentToRssi(double value)
29 | {
30 | double current;
31 | current = value * SCALE_FACTOR;//crush 0-100 to 0-deltamaxmin
32 | current += NORM_MIN_SENS;//move up to (min*-1) to 80
33 | current *= -1;//multiply *-1 as the rssi is in this range, but negative, high rssi=strog signal enche the multiplication instead of a transpose
34 |
35 | return (int)Math.Round(current);
36 | }
37 |
38 | private double RssiToPercent(int rssi)
39 | {
40 | double current;
41 | current = rssi * -1;
42 | current -= NORM_MIN_SENS;
43 | current /= SCALE_FACTOR;
44 |
45 | if (current > 100)
46 | {
47 | current = 100;
48 | }
49 |
50 | return current;
51 | }
52 |
53 | protected override void OnAppearing()
54 | {
55 | sens.Value = RssiToPercent(Preferences.Default.Get(Setting, MAX_SENSITIVITY));
56 | base.OnAppearing();
57 | }
58 |
59 | protected override void OnDisappearing()
60 | {
61 | Preferences.Default.Set(Setting, PercentToRssi(sens.Value));
62 | base.OnDisappearing();
63 | }
64 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/RapidReadView.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
59 |
60 |
65 |
66 |
67 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
83 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
104 |
105 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/RapidReadView.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.OS;
2 | using XRFID.Sample.Client.Mobile.ViewModels;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Views;
5 |
6 | public partial class RapidReadView
7 | {
8 |
9 |
10 | public RapidReadView(RapidReadViewModel viewModel)
11 | {
12 | InitializeComponent();
13 |
14 | BindingContext = viewModel;
15 | }
16 |
17 | private void ShowInfoPage(object sender, EventArgs e)
18 | {
19 | App.Current.MainPage.DisplayAlert("Page Info", "page information will be written here", "OK");
20 | }
21 |
22 | private void GoToSettings(object sender, EventArgs e)
23 | {
24 | //modify the value of the query to modify setting name, also need to modify the constant in the ViewModel in OnAppearing
25 | Shell.Current.GoToAsync("inventoryrapidreadsettings?setting=rapidread");
26 | }
27 |
28 | protected override bool OnBackButtonPressed()
29 | {
30 | if (!IsBusy)
31 | {
32 | Dispatcher.Dispatch(async () =>
33 | {
34 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
35 |
36 | if (leave)
37 | {
38 | Process.KillProcess(Process.MyPid());
39 | }
40 | });
41 | }
42 | return true;
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/SettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
43 |
44 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
62 |
63 |
70 |
71 |
72 |
73 |
74 |
75 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/XRFID.Sample.Client.Mobile/Views/SettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Android.OS;
2 | using XRFID.Sample.Client.Mobile.ViewModels;
3 |
4 | namespace XRFID.Sample.Client.Mobile.Views;
5 |
6 | public partial class SettingsPage
7 | {
8 | public SettingsPage(SettingsViewModel viewModel)
9 | {
10 | InitializeComponent();
11 | BindingContext = viewModel;
12 | }
13 |
14 | protected override bool OnBackButtonPressed()
15 | {
16 | if (!IsBusy)
17 | {
18 | Dispatcher.Dispatch(async () =>
19 | {
20 | bool leave = await DisplayAlert("Application Closing", "Are you sure you want to close the application?", "Yes", "No");
21 |
22 | if (leave)
23 | {
24 | Process.KillProcess(Process.MyPid());
25 | }
26 | });
27 | }
28 | return true;
29 | }
30 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/Create/MinimalReaderCreateDto.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Common.Dto.Create;
2 |
3 | public class MinimalReaderCreateDto
4 | {
5 | public Guid Id { get; set; } = Guid.NewGuid();
6 | public string Name { get; set; } = string.Empty;
7 | }
8 |
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/LoadingUnitDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 |
3 | namespace XRFID.Sample.Common.Dto;
4 |
5 | public class LoadingUnitDto : RestEntityDto
6 | {
7 | public int Sequence { get; set; }
8 |
9 | public string Description { get; set; } = string.Empty;
10 |
11 | public DateTime Timestamp { get; set; } = DateTime.Now;
12 |
13 | public bool IsActive { get; set; }
14 |
15 | public bool IsValid { get; set; }
16 |
17 | public bool IsConsolidated { get; set; }
18 |
19 | public Guid ReaderId { get; set; }
20 |
21 | public Guid? OrderId { get; set; }
22 |
23 | public string? OrderReference { get; set; }
24 |
25 | public List LoadingUnitItems { get; set; } = new List();
26 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/LoadingUnitItemDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 | using Xerum.XFramework.Common.Enums;
3 |
4 | namespace XRFID.Sample.Common.Dto;
5 |
6 | public class LoadingUnitItemDto : RestEntityDto
7 | {
8 | public string Description { get; set; } = string.Empty;
9 |
10 | public string? SerialNumber { get; set; }
11 |
12 | public string Epc { get; set; } = string.Empty;
13 |
14 | public bool IsConsolidated { get; set; }
15 |
16 | public ItemStatus Status { get; set; }
17 |
18 | public bool IsValid { get => Status == ItemStatus.Found; }
19 |
20 | public Guid LoadingUnitId { get; set; }
21 |
22 | public string LoadingUnitReference { get; set; } = string.Empty;
23 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/MovementDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 | using Xerum.XFramework.Common.Enums;
3 |
4 | namespace XRFID.Sample.Common.Dto;
5 |
6 | public class MovementDto : RestEntityDto
7 | {
8 | public int Sequence { get; set; }
9 |
10 | public string Description { get; set; } = string.Empty;
11 |
12 | public DateTime Timestamp { get; set; } = DateTime.Now;
13 |
14 | public bool IsValid { get; set; }
15 |
16 | public bool UnexpectedItem { get; set; }
17 |
18 | public bool MissingItem { get; set; }
19 |
20 | public bool OverflowItem { get; set; }
21 |
22 | public bool IsActive { get; set; }
23 |
24 | public bool IsConsolidated { get; set; }
25 |
26 | ///
27 | /// init, processing, completed
28 | ///
29 | public MovementStatus WorkingStatus
30 | {
31 | get
32 | {
33 | if (IsActive && !IsConsolidated)
34 | {
35 | if (MovementItems.Any())
36 | {
37 | return MovementStatus.Processing;
38 | }
39 | else
40 | {
41 | return MovementStatus.Initialize;
42 | }
43 | }
44 | else
45 | {
46 | return MovementStatus.Completed;
47 | }
48 | }
49 | }
50 |
51 | public MovementStatus Status
52 | {
53 | get
54 | {
55 | if (IsValid)
56 | {
57 | return MovementStatus.Valid;
58 | }
59 | else if (UnexpectedItem)
60 | {
61 | return MovementStatus.Unexpected;
62 | }
63 | else if (MissingItem)
64 | {
65 | return MovementStatus.Missing;
66 | }
67 | else if (OverflowItem)
68 | {
69 | return MovementStatus.Overflow;
70 | }
71 | else
72 | {
73 | return MovementStatus.Error;
74 | }
75 | }
76 | }
77 |
78 | public Guid ReaderId { get; set; }
79 |
80 | public List MovementItems { get; set; } = new List();
81 |
82 | public Guid? OrderId { get; set; }
83 |
84 | public string? OrderReference { get; set; }
85 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/MovementItemDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 | using Xerum.XFramework.Common.Enums;
3 |
4 | namespace XRFID.Sample.Common.Dto;
5 |
6 | public class MovementItemDto : RestEntityDto
7 | {
8 | public string Description { get; set; } = string.Empty;
9 |
10 | public string SerialNumber { get; set; } = string.Empty;
11 |
12 | public string Epc { get; set; } = string.Empty;
13 |
14 | public short Rssi { get; set; }
15 |
16 | public string? Tid { get; set; }
17 |
18 | public string? PC { get; set; }
19 |
20 | public int ReadsCount { get; set; }
21 |
22 | public bool Checked { get; set; }
23 |
24 | public DateTime FirstRead { get; set; } = DateTime.Now;
25 |
26 | public DateTime LastRead { get; set; } = DateTime.Now;
27 |
28 | public DateTime IgnoreUntil { get; set; } = (DateTime.Now + TimeSpan.FromDays(1)).Date;//ignore until today at midnight
29 |
30 | public ItemStatus Status { get; set; } = ItemStatus.NotFound;
31 |
32 | public bool IsValid { get => Status == ItemStatus.Found; }
33 |
34 | public bool IsConsolidated { get; set; }
35 |
36 | public Guid MovementId { get; set; }
37 |
38 | public Guid? ProductId { get; set; }
39 |
40 | public Guid? LoadingUnitItemId { get; set; }
41 | }
42 |
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/ProductDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 | using Xerum.XFramework.Common.Enums;
3 |
4 | namespace XRFID.Sample.Common.Dto;
5 |
6 | public class ProductDto : RestEntityDto
7 | {
8 | public string Description { get; set; } = string.Empty;
9 |
10 | public string Type { get; set; } = string.Empty;
11 |
12 | public string? Note { get; set; }
13 |
14 | public string? Attrib1 { get; set; }
15 |
16 | public string? Attrib2 { get; set; }
17 |
18 | public string? Attrib3 { get; set; }
19 |
20 | public ItemStatus Status { get; set; }
21 |
22 | public string Epc { get; set; } = string.Empty;
23 |
24 | public int ContentQuantity { get; set; }
25 |
26 | public string SerialNumber { get; set; } = string.Empty;
27 |
28 | public string? OrderReference { get; set; }
29 | }
30 |
--------------------------------------------------------------------------------
/XRFID.Sample.Common/Dto/ReaderDto.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Dto;
2 | using Xerum.XFramework.Common.Enums;
3 |
4 | namespace XRFID.Sample.Common.Dto;
5 |
6 | public class ReaderDto : RestEntityDto
7 | {
8 | public Guid? ActiveMovementId { get; set; }
9 |
10 | public string? Uid { get; set; }
11 |
12 | public string? MacAddress { get; set; }
13 |
14 | public string? Model { get; set; }
15 |
16 | public string? Version { get; set; }
17 |
18 | public string? SerialNumber { get; set; }
19 |
20 | public string? ReaderOS { get; set; }
21 |
22 | public string Ip { get; set; } = "127.0.0.1";
23 |
24 | public ReaderStatus Status { get; set; } = ReaderStatus.Disconnected;
25 | }
26 |
--------------------------------------------------------------------------------
/XRFID.Sample.Common/XRFID.Sample.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/AuthorizationController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore;
2 | using Microsoft.AspNetCore.Mvc;
3 | using Microsoft.IdentityModel.Tokens;
4 | using OpenIddict.Abstractions;
5 | using OpenIddict.Server.AspNetCore;
6 | using System.Security.Claims;
7 | using static OpenIddict.Abstractions.OpenIddictConstants;
8 |
9 | namespace XRFID.Sample.Webservice.Controllers;
10 |
11 | [ApiController]
12 | public class AuthorizationController : ControllerBase
13 | {
14 | private readonly IOpenIddictApplicationManager applicationManager;
15 | private readonly IOpenIddictScopeManager scopeManager;
16 |
17 | public AuthorizationController(IOpenIddictApplicationManager applicationManager, IOpenIddictScopeManager scopeManager)
18 | {
19 | this.applicationManager = applicationManager;
20 | this.scopeManager = scopeManager;
21 | }
22 |
23 | [HttpPost("~/connect/token")]
24 | [IgnoreAntiforgeryToken]
25 | [ProducesResponseType(200)]
26 | [ProducesResponseType(400)]
27 | [ProducesResponseType(404)]
28 | [ProducesResponseType(500)]
29 | public async Task Connect()
30 | {
31 | OpenIddictRequest? clientRequest = HttpContext.GetOpenIddictServerRequest();
32 | if (clientRequest is null || clientRequest.ClientId is null || !clientRequest.IsClientCredentialsGrantType())
33 | {
34 | return BadRequest();
35 | }
36 |
37 | var clientApplication = await applicationManager.FindByClientIdAsync(clientRequest.ClientId);
38 | if (clientApplication is null)
39 | {
40 | return NotFound();
41 | }
42 |
43 | ClaimsIdentity identity = new ClaimsIdentity(TokenValidationParameters.DefaultAuthenticationType, Claims.Name, Claims.Role);
44 | identity.SetClaim(Claims.Subject, await applicationManager.GetClientIdAsync(clientApplication));
45 | identity.SetClaim(Claims.Name, await applicationManager.GetDisplayNameAsync(clientApplication));
46 | identity.SetScopes(clientRequest.GetScopes());
47 | identity.SetResources(scopeManager.ListResourcesAsync(identity.GetScopes()).ToBlockingEnumerable().ToList());
48 | identity.SetDestinations(GetDestinations);
49 |
50 | return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
51 | }
52 |
53 | private static IEnumerable GetDestinations(Claim claim)
54 | {
55 | return claim.Type switch
56 | {
57 | Claims.Name or
58 | Claims.Subject
59 | => new[] { Destinations.AccessToken, Destinations.IdentityToken },
60 |
61 | _ => new[] { Destinations.AccessToken },
62 | };
63 | }
64 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/LoadingUnitItemController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System.Data;
3 | using Xerum.XFramework.Common;
4 | using XRFID.Sample.Common.Dto;
5 | using XRFID.Sample.Webservice.Services;
6 |
7 | namespace XRFID.Sample.Webservice.Controllers;
8 |
9 | [Route("api/[controller]")]
10 | [Produces("application/json")]
11 | [ApiController]
12 | public class LoadingUnitItemController : ControllerBase
13 | {
14 | private readonly XResponseDataFactory _responseDataFactory;
15 | private readonly ILogger _logger;
16 | private readonly LoadingUnitItemService _loadingUnitItemService;
17 |
18 | public LoadingUnitItemController(XResponseDataFactory responseDataFactory, ILogger logger, LoadingUnitItemService loadingUnitItemService)
19 | {
20 | _responseDataFactory = responseDataFactory;
21 | _logger = logger;
22 | _loadingUnitItemService = loadingUnitItemService;
23 | }
24 |
25 | [HttpGet("ByLoadingUnitId")]
26 | [ProducesResponseType(typeof(XResponseData>), 200)]
27 | [ProducesResponseType(typeof(XResponseData), 400)]
28 | [ProducesResponseType(typeof(XResponseData), 404)]
29 | [ProducesResponseType(typeof(XResponseData), 500)]
30 | [ProducesResponseType(typeof(XResponseData), 501)]
31 | public async Task GetByLoadingUnitIdAsync(Guid luId)
32 | {
33 | XResponseData response;
34 | try
35 | {
36 | response = _responseDataFactory.Ok>(await _loadingUnitItemService.GetByLoadingUnitIdAsync(luId));
37 | }
38 | catch (KeyNotFoundException ex)
39 | {
40 | response = _responseDataFactory.NotFound(ex.Message);
41 | }
42 | catch (ArgumentException ex)
43 | {
44 | response = _responseDataFactory.BadRequest(ex.Message);
45 | }
46 | catch (NotImplementedException ex)
47 | {
48 | response = _responseDataFactory.NotImplemented(ex.Message);
49 | }
50 | catch (Exception ex)
51 | {
52 | response = _responseDataFactory.InternalError(ex.Message);
53 | }
54 |
55 | return StatusCode(response.Code, response);
56 | }
57 |
58 | [HttpPost]
59 | [ProducesResponseType(typeof(XResponseData), 201)]
60 | [ProducesResponseType(typeof(XResponseData), 400)]
61 | [ProducesResponseType(typeof(XResponseData), 500)]
62 | [ProducesResponseType(typeof(XResponseData), 501)]
63 | public async Task PostAsync(LoadingUnitItemDto loadingUnitItemCreateDto)
64 | {
65 | XResponseData response;
66 | try
67 | {
68 | response = _responseDataFactory.Created(await _loadingUnitItemService.CreateAsync(loadingUnitItemCreateDto));
69 | }
70 | catch (Exception ex) when (ex is ArgumentException or DuplicateNameException)
71 | {
72 | response = _responseDataFactory.BadRequest(loadingUnitItemCreateDto, ex.Message);
73 | }
74 | catch (NotImplementedException ex)
75 | {
76 | response = _responseDataFactory.NotImplemented(loadingUnitItemCreateDto, ex.Message);
77 | }
78 | catch (Exception ex)
79 | {
80 | response = _responseDataFactory.InternalError(loadingUnitItemCreateDto, ex.Message);
81 | }
82 |
83 | return StatusCode(response.Code, response);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/MovementController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System.Data;
3 | using Xerum.XFramework.Common;
4 | using XRFID.Sample.Common.Dto;
5 | using XRFID.Sample.Webservice.Services;
6 |
7 | namespace XRFID.Sample.Webservice.Controllers;
8 | [Route("api/[controller]")]
9 | [Produces("application/json")]
10 | [ApiController]
11 | public class MovementController : ControllerBase
12 | {
13 | private readonly XResponseDataFactory _responseDataFactory;
14 | private readonly ILogger _logger;
15 | private readonly MovementService _movementService;
16 |
17 | public MovementController(XResponseDataFactory responseDataFactory, ILogger logger, MovementService movementService)
18 | {
19 | _responseDataFactory = responseDataFactory;
20 | _logger = logger;
21 | _movementService = movementService;
22 | }
23 |
24 | [HttpPost]
25 | [ProducesResponseType(typeof(XResponseData), 201)]
26 | [ProducesResponseType(typeof(XResponseData), 400)]
27 | [ProducesResponseType(typeof(XResponseData), 500)]
28 | [ProducesResponseType(typeof(XResponseData), 501)]
29 | public async Task PostAsync(MovementDto movementCreateDto)
30 | {
31 | XResponseData response;
32 | try
33 | {
34 | response = _responseDataFactory.Created(await _movementService.CreateAsync(movementCreateDto));
35 | }
36 | catch (Exception ex) when (ex is ArgumentException or DuplicateNameException)
37 | {
38 | response = _responseDataFactory.BadRequest(movementCreateDto, ex.Message);
39 | }
40 | catch (NotImplementedException ex)
41 | {
42 | response = _responseDataFactory.NotImplemented(movementCreateDto, ex.Message);
43 | }
44 | catch (Exception ex)
45 | {
46 | response = _responseDataFactory.InternalError(movementCreateDto, ex.Message);
47 | }
48 |
49 | return StatusCode(response.Code, response);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/PingController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Authorization;
2 | using Microsoft.AspNetCore.Mvc;
3 | using OpenIddict.Validation.AspNetCore;
4 |
5 | namespace XRFID.Sample.Webservice.Controllers;
6 |
7 | [Route("api/[controller]")]
8 | [ApiController]
9 | public class PingController : ControllerBase
10 | {
11 | private readonly ILogger _logger;
12 |
13 | public PingController(ILogger logger)
14 | {
15 | _logger = logger;
16 | }
17 |
18 | [Authorize(AuthenticationSchemes = OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme)]
19 | [HttpGet("authenticated")]
20 | [ProducesResponseType(401)]
21 | [ProducesResponseType(typeof(String), 200)]
22 | public IActionResult AuthenticatedPing()
23 | {
24 | return Ok("Authenticatedpong");
25 | }
26 |
27 | [HttpGet("unauthenticated")]
28 | [ProducesResponseType(typeof(String), 200)]
29 | public IActionResult Ping()
30 | {
31 | return Ok("pong");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/ProductController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System.Data;
3 | using Xerum.XFramework.Common;
4 | using XRFID.Sample.Common.Dto;
5 | using XRFID.Sample.Webservice.Services;
6 |
7 | namespace XRFID.Sample.Webservice.Controllers;
8 |
9 | [Route("api/[controller]")]
10 | [Produces("application/json")]
11 | [ApiController]
12 | public class ProductController : ControllerBase
13 | {
14 | private readonly XResponseDataFactory _responseDataFactory;
15 | private readonly ILogger _logger;
16 | private readonly ProductService _productService;
17 |
18 | public ProductController(XResponseDataFactory responseDataFactory, ILogger logger, ProductService productService)
19 | {
20 | _responseDataFactory = responseDataFactory;
21 | _logger = logger;
22 | _productService = productService;
23 | }
24 |
25 | [HttpGet("Search")]
26 | [ProducesResponseType(typeof(XResponseData>), 200)]
27 | [ProducesResponseType(typeof(XResponseData), 400)]
28 | [ProducesResponseType(typeof(XResponseData), 404)]
29 | [ProducesResponseType(typeof(XResponseData), 500)]
30 | [ProducesResponseType(typeof(XResponseData), 501)]
31 | public async Task GetSearchAsync(string term)
32 | {
33 | XResponseData response;
34 | try
35 | {
36 | response = _responseDataFactory.Ok>(await _productService.GetAsync(term));
37 | }
38 | catch (KeyNotFoundException ex)
39 | {
40 | response = _responseDataFactory.NotFound(ex.Message);
41 | }
42 | catch (ArgumentException ex)
43 | {
44 | response = _responseDataFactory.BadRequest(ex.Message);
45 | }
46 | catch (NotImplementedException ex)
47 | {
48 | response = _responseDataFactory.NotImplemented(ex.Message);
49 | }
50 | catch (Exception ex)
51 | {
52 | response = _responseDataFactory.InternalError(ex.Message);
53 | }
54 |
55 | return StatusCode(response.Code, response);
56 | }
57 |
58 | [HttpGet("ByEpc")]
59 | [ProducesResponseType(typeof(XResponseData), 200)]
60 | [ProducesResponseType(typeof(XResponseData), 400)]
61 | [ProducesResponseType(typeof(XResponseData), 404)]
62 | [ProducesResponseType(typeof(XResponseData), 500)]
63 | [ProducesResponseType(typeof(XResponseData), 501)]
64 | public async Task GetByEpcAsync(string epc)
65 | {
66 | XResponseData response;
67 | try
68 | {
69 | response = _responseDataFactory.Ok(await _productService.GetByEpcAsync(epc));
70 | }
71 | catch (KeyNotFoundException ex)
72 | {
73 | response = _responseDataFactory.NotFound(ex.Message);
74 | }
75 | catch (ArgumentException ex)
76 | {
77 | response = _responseDataFactory.BadRequest(ex.Message);
78 | }
79 | catch (NotImplementedException ex)
80 | {
81 | response = _responseDataFactory.NotImplemented(ex.Message);
82 | }
83 | catch (Exception ex)
84 | {
85 | response = _responseDataFactory.InternalError(ex.Message);
86 | }
87 |
88 | return StatusCode(response.Code, response);
89 | }
90 |
91 | [HttpPost]
92 | [ProducesResponseType(typeof(XResponseData), 201)]
93 | [ProducesResponseType(typeof(XResponseData), 400)]
94 | [ProducesResponseType(typeof(XResponseData), 500)]
95 | [ProducesResponseType(typeof(XResponseData), 501)]
96 | public async Task PostAsync(ProductDto productCreateDto)
97 | {
98 | XResponseData response;
99 | try
100 | {
101 | response = _responseDataFactory.Created(await _productService.CreateAsync(productCreateDto));
102 | }
103 | catch (Exception ex) when (ex is ArgumentException or DuplicateNameException)
104 | {
105 | response = _responseDataFactory.BadRequest(productCreateDto, ex.Message);
106 | }
107 | catch (NotImplementedException ex)
108 | {
109 | response = _responseDataFactory.NotImplemented(productCreateDto, ex.Message);
110 | }
111 | catch (Exception ex)
112 | {
113 | response = _responseDataFactory.InternalError(productCreateDto, ex.Message);
114 | }
115 |
116 | return StatusCode(response.Code, response);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Controllers/ReaderController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using System.Data;
3 | using Xerum.XFramework.Common;
4 | using XRFID.Sample.Common.Dto;
5 | using XRFID.Sample.Common.Dto.Create;
6 | using XRFID.Sample.Webservice.Services;
7 |
8 | namespace XRFID.Sample.Webservice.Controllers;
9 |
10 | [Route("api/[controller]")]
11 | [Produces("application/json")]
12 | [ApiController]
13 | public class ReaderController : ControllerBase
14 | {
15 | private readonly XResponseDataFactory _responseDataFactory;
16 | private readonly ILogger _logger;
17 | private readonly ReaderService _readerService;
18 |
19 | public ReaderController(XResponseDataFactory responseDataFactory, ILogger logger, ReaderService readerService)
20 | {
21 | _responseDataFactory = responseDataFactory;
22 | _logger = logger;
23 | _readerService = readerService;
24 | }
25 |
26 | [HttpGet("ByName")]
27 | [ProducesResponseType(typeof(XResponseData), 200)]
28 | [ProducesResponseType(typeof(XResponseData), 400)]
29 | [ProducesResponseType(typeof(XResponseData), 404)]
30 | [ProducesResponseType(typeof(XResponseData), 500)]
31 | [ProducesResponseType(typeof(XResponseData), 501)]
32 | public async Task GetBynameAsync(string name)
33 | {
34 | XResponseData response;
35 | try
36 | {
37 | response = _responseDataFactory.Ok(await _readerService.GetByNameAsync(name));
38 | }
39 | catch (KeyNotFoundException ex)
40 | {
41 | response = _responseDataFactory.NotFound(ex.Message);
42 | }
43 | catch (ArgumentException ex)
44 | {
45 | response = _responseDataFactory.BadRequest(ex.Message);
46 | }
47 | catch (NotImplementedException ex)
48 | {
49 | response = _responseDataFactory.NotImplemented(ex.Message);
50 | }
51 | catch (Exception ex)
52 | {
53 | response = _responseDataFactory.InternalError(ex.Message);
54 | }
55 |
56 | return StatusCode(response.Code, response);
57 | }
58 |
59 | [HttpPost]
60 | [ProducesResponseType(typeof(XResponseData), 201)]
61 | [ProducesResponseType(typeof(XResponseData), 400)]
62 | [ProducesResponseType(typeof(XResponseData), 500)]
63 | [ProducesResponseType(typeof(XResponseData), 501)]
64 | public async Task PostAsync(ReaderDto readerCreateDto)
65 | {
66 | XResponseData response;
67 | try
68 | {
69 | response = _responseDataFactory.Created(await _readerService.CreateAsync(readerCreateDto));
70 | }
71 | catch (Exception ex) when (ex is ArgumentException or DuplicateNameException)
72 | {
73 | response = _responseDataFactory.BadRequest(readerCreateDto, ex.Message);
74 | }
75 | catch (NotImplementedException ex)
76 | {
77 | response = _responseDataFactory.NotImplemented(readerCreateDto, ex.Message);
78 | }
79 | catch (Exception ex)
80 | {
81 | response = _responseDataFactory.InternalError(readerCreateDto, ex.Message);
82 | }
83 |
84 | return StatusCode(response.Code, response);
85 | }
86 |
87 | [HttpPost("Minimal")]
88 | [ProducesResponseType(typeof(XResponseData), 201)]
89 | [ProducesResponseType(typeof(XResponseData), 400)]
90 | [ProducesResponseType(typeof(XResponseData), 500)]
91 | [ProducesResponseType(typeof(XResponseData), 501)]
92 | public async Task PostMinimalAsync(MinimalReaderCreateDto minimalReaderCreateDto)
93 | {
94 | XResponseData response;
95 | try
96 | {
97 | response = _responseDataFactory.Created(await _readerService.CreateAsync(minimalReaderCreateDto));
98 | }
99 | catch (Exception ex) when (ex is ArgumentException or DuplicateNameException)
100 | {
101 | response = _responseDataFactory.BadRequest(minimalReaderCreateDto, ex.Message);
102 | }
103 | catch (NotImplementedException ex)
104 | {
105 | response = _responseDataFactory.NotImplemented(minimalReaderCreateDto, ex.Message);
106 | }
107 | catch (Exception ex)
108 | {
109 | response = _responseDataFactory.InternalError(minimalReaderCreateDto, ex.Message);
110 | }
111 |
112 | return StatusCode(response.Code, response);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Database/UnitOfWork.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Webservice.Database;
2 |
3 | public class UnitOfWork : IDisposable
4 | {
5 | private XRFIDSampleContext _context;
6 |
7 | private bool isDisposed = false;
8 |
9 | public UnitOfWork(XRFIDSampleContext context)
10 | {
11 | _context = context;
12 | }
13 |
14 | public void Save()
15 | {
16 | _context.SaveChanges();
17 | }
18 | public async Task SaveAsync()
19 | {
20 | await _context.SaveChangesAsync();
21 | }
22 |
23 | private void Dispose(bool disposing)
24 | {
25 | if (!isDisposed && disposing)
26 | {
27 | _context.Dispose();
28 | }
29 |
30 | isDisposed = true;
31 | }
32 |
33 | public void Dispose()
34 | {
35 | Dispose(true);
36 | GC.SuppressFinalize(this);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Database/XRFIDSampleContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Database;
5 |
6 | public class XRFIDSampleContext : DbContext
7 | {
8 | public DbSet LoadingUnits { get; set; }
9 | public DbSet LoadingUnitItems { get; set; }
10 |
11 | public DbSet Movements { get; set; }
12 | public DbSet MovementItems { get; set; }
13 |
14 | public DbSet Products { get; set; }
15 |
16 | public DbSet Readers { get; set; }
17 |
18 | public XRFIDSampleContext(DbContextOptions options) : base(options)
19 | {
20 | }
21 |
22 | protected override void OnModelCreating(ModelBuilder modelBuilder)
23 | {
24 | modelBuilder.Entity().HasKey(k => k.Id);
25 | modelBuilder.Entity().HasKey(k => k.Id);
26 | modelBuilder.Entity().HasKey(k => k.Id);
27 | modelBuilder.Entity().HasKey(k => k.Id);
28 | modelBuilder.Entity().HasKey(k => k.Id);
29 | modelBuilder.Entity().HasKey(k => k.Id);
30 |
31 | base.OnModelCreating(modelBuilder);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/AuditEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace XRFID.Sample.Webservice.Entities;
4 |
5 | public abstract class AuditEntity
6 | {
7 | public Guid Id { get; set; } = Guid.NewGuid();
8 | public string? Name { get; set; }
9 | public string? Code { get; set; }
10 | public string? Reference { get; set; }
11 |
12 | public string? CreatorUserId { get; set; }
13 | public DateTime CreationTime { get; set; } = DateTime.Now;
14 | public string? LastModifierUserId { get; set; }
15 | public DateTime LastModificationTime { get; set; } = DateTime.Now;
16 | }
17 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/LoadingUnit.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Webservice.Entities;
2 |
3 | public class LoadingUnit : AuditEntity
4 | {
5 | public int Sequence { get; set; }
6 |
7 | public string Description { get; set; } = string.Empty;
8 |
9 | public DateTime Timestamp { get; set; } = DateTime.Now;
10 |
11 | public bool IsActive { get; set; }
12 |
13 | public bool IsValid { get; set; }
14 |
15 | public bool IsConsolidated { get; set; }
16 |
17 | public Guid ReaderId { get; set; }
18 |
19 | public Guid? OrderId { get; set; }
20 |
21 | public string? OrderReference { get; set; }
22 |
23 | public List LoadingUnitItems { get; set; } = new List();
24 | }
25 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/LoadingUnitItem.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Enums;
2 |
3 | namespace XRFID.Sample.Webservice.Entities;
4 |
5 | public class LoadingUnitItem : AuditEntity
6 | {
7 | public string Description { get; set; } = string.Empty;
8 |
9 | public string? SerialNumber { get; set; }
10 |
11 | public string Epc { get; set; } = string.Empty;
12 |
13 | public bool IsConsolidated { get; set; }
14 |
15 | public ItemStatus Status { get; set; }
16 |
17 | public bool IsValid { get => Status == ItemStatus.Found; }
18 |
19 | public Guid LoadingUnitId { get; set; }
20 | public LoadingUnit LoadingUnit { get; set; }
21 |
22 | public string LoadingUnitReference { get; set; } = string.Empty;
23 | }
24 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/Movement.cs:
--------------------------------------------------------------------------------
1 | namespace XRFID.Sample.Webservice.Entities;
2 |
3 | public class Movement : AuditEntity
4 | {
5 | public int Sequence { get; set; }
6 |
7 | public string Description { get; set; } = string.Empty;
8 |
9 | public DateTime Timestamp { get; set; } = DateTime.Now;
10 |
11 | public bool IsValid { get; set; }
12 |
13 | public bool UnexpectedItem { get; set; }
14 |
15 | public bool MissingItem { get; set; }
16 |
17 | public bool OverflowItem { get; set; }
18 |
19 | public bool IsActive { get; set; }
20 |
21 | public bool IsConsolidated { get; set; }
22 |
23 | public Guid ReaderId { get; set; }
24 |
25 | public List MovementItems { get; set; } = new List();
26 |
27 | public Guid? OrderId { get; set; }
28 |
29 | public string? OrderReference { get; set; }
30 | }
31 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/MovementItem.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Enums;
2 |
3 | namespace XRFID.Sample.Webservice.Entities
4 | {
5 | public class MovementItem : AuditEntity
6 | {
7 | public string Description { get; set; } = string.Empty;
8 |
9 | public string SerialNumber { get; set; } = string.Empty;
10 |
11 | public string Epc { get; set; } = string.Empty;
12 |
13 | public short Rssi { get; set; }
14 |
15 | public string? Tid { get; set; }
16 |
17 | public string? PC { get; set; }
18 |
19 | public int ReadsCount { get; set; }
20 |
21 | public bool Checked { get; set; }
22 |
23 | public DateTime FirstRead { get; set; } = DateTime.Now;
24 |
25 | public DateTime LastRead { get; set; } = DateTime.Now;
26 |
27 | public DateTime IgnoreUntil { get; set; } = (DateTime.Now + TimeSpan.FromDays(1)).Date;//ignore until today at midnight
28 |
29 | public ItemStatus Status { get; set; } = ItemStatus.NotFound;
30 |
31 | public bool IsValid { get; set; }
32 |
33 | public bool IsConsolidated { get; set; }
34 |
35 | public Guid MovementId { get; set; }
36 | public Movement Movement { get; set; }
37 |
38 |
39 | public Guid? ProductId { get; set; }
40 | public Product? Product { get; set; }
41 |
42 | public Guid? LoadingUnitItemId { get; set; }
43 | public LoadingUnitItem? LoadingUnitItem { get; set; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/Product.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Enums;
2 |
3 | namespace XRFID.Sample.Webservice.Entities;
4 |
5 | public class Product : AuditEntity
6 | {
7 | public string Description { get; set; } = string.Empty;
8 |
9 | public string Type { get; set; } = string.Empty;
10 |
11 | public string? Note { get; set; }
12 |
13 | public string? Attrib1 { get; set; }
14 |
15 | public string? Attrib2 { get; set; }
16 |
17 | public string? Attrib3 { get; set; }
18 |
19 | public ItemStatus Status { get; set; }
20 |
21 | public string Epc { get; set; } = string.Empty;
22 |
23 | public int ContentQuantity { get; set; }
24 |
25 | public string SerialNumber { get; set; } = string.Empty;
26 |
27 | public string? OrderReference { get; set; }
28 | }
29 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Entities/Reader.cs:
--------------------------------------------------------------------------------
1 | using Xerum.XFramework.Common.Enums;
2 |
3 | namespace XRFID.Sample.Webservice.Entities;
4 |
5 | public class Reader : AuditEntity
6 | {
7 | public Guid? ActiveMovementId { get; set; }
8 |
9 | public string? Uid { get; set; }
10 |
11 | public string? MacAddress { get; set; }
12 |
13 | public string? Model { get; set; }
14 |
15 | public string? Version { get; set; }
16 |
17 | public string? SerialNumber { get; set; }
18 |
19 | public string? ReaderOS { get; set; }
20 |
21 | public string Ip { get; set; } = "127.0.0.1";
22 |
23 | public ReaderStatus Status { get; set; } = ReaderStatus.Disconnected;
24 | }
25 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Mapper/XRFIDSampleProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using XRFID.Sample.Common.Dto;
3 | using XRFID.Sample.Webservice.Entities;
4 |
5 | namespace XRFID.Sample.Webservice.Mapper
6 | {
7 | public class XRFIDSampleProfile : Profile
8 | {
9 | public XRFIDSampleProfile()
10 | {
11 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
12 |
13 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
14 |
15 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
16 |
17 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
18 |
19 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
20 |
21 | CreateMap().ReverseMap().ForAllMembers(opt => opt.AllowNull());
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Persist/persist.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XerumSrl/XRFID-Android-Samples/dcfbd1f42a9ea957b4e74eb7557638aea149cab5/XRFID.Sample.Webservice/Persist/persist.db
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.Net.Http.Headers;
3 | using Microsoft.OpenApi.Models;
4 | using Serilog;
5 | using Xerum.XFramework.Common;
6 | using Xerum.XFramework.DefaultLogging;
7 | using XRFID.Sample.Webservice.Database;
8 | using XRFID.Sample.Webservice.Mapper;
9 | using XRFID.Sample.Webservice.Repositories;
10 | using XRFID.Sample.Webservice.Services;
11 |
12 | var builder = WebApplication.CreateBuilder(args);
13 |
14 | Log.Logger = LogHelper.CreateStatic(builder.Configuration);
15 |
16 | Log.ForContext().Information("Host starting...");
17 |
18 | try
19 | {
20 | builder.Host.UseWindowsService(ws => ws.ServiceName = "XRFID sample WS");
21 |
22 | builder.Host.AddLogging(Log.Logger);
23 |
24 | builder.Services.AddSingleton();
25 |
26 | builder.Services.AddAutoMapper(m => m.AddProfile());
27 |
28 | builder.Services.AddTransient();
29 | builder.Services.AddTransient();
30 | builder.Services.AddTransient();
31 | builder.Services.AddTransient();
32 | builder.Services.AddTransient();
33 |
34 | builder.Services.AddScoped();
35 |
36 | builder.Services.AddDbContext(optionsAction: options => options.UseSqlite("Data Source = Persist/persist.db"));
37 |
38 | builder.Services.AddScoped();
39 | builder.Services.AddScoped();
40 | builder.Services.AddScoped();
41 | builder.Services.AddScoped();
42 | builder.Services.AddScoped();
43 | builder.Services.AddScoped();
44 |
45 | builder.Services.AddEndpointsApiExplorer();
46 | builder.Services.AddSwaggerGen(c =>
47 | {
48 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "XRFID Sample Api", Version = "v1" });
49 | c.AddSecurityDefinition(
50 | "oauth2",
51 | new OpenApiSecurityScheme
52 | {
53 | Flows = new OpenApiOAuthFlows
54 | {
55 | ClientCredentials = new OpenApiOAuthFlow
56 | {
57 | Scopes = new Dictionary
58 | {
59 | ["api"] = "api scope"
60 | },
61 | TokenUrl = new Uri("/connect/token", UriKind.Relative),
62 | },
63 | },
64 | In = ParameterLocation.Header,
65 | Name = HeaderNames.Authorization,
66 | Type = SecuritySchemeType.OAuth2
67 | }
68 | );
69 | c.AddSecurityRequirement(
70 | new OpenApiSecurityRequirement
71 | {
72 | {
73 | new OpenApiSecurityScheme
74 | {
75 | Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" }
76 |
77 | },
78 | new[] { "api" }
79 | }
80 | });
81 |
82 | c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
83 | c.IgnoreObsoleteActions();
84 | c.IgnoreObsoleteProperties();
85 | c.CustomSchemaIds(type => type.FullName);
86 | });
87 |
88 | builder.Services.AddAuthorization();
89 | builder.Services.AddOpenIddict()
90 | .AddCore(options =>
91 | {
92 | options.UseEntityFrameworkCore().UseDbContext();
93 | })
94 | .AddServer(options =>
95 | {
96 | options.SetTokenEndpointUris("connect/token");
97 | //options.SetIntrospectionEndpointUris("/connect/introspect");
98 | options.AllowClientCredentialsFlow();
99 |
100 | //options.AddDevelopmentEncryptionCertificate();
101 | //options.AddDevelopmentSigningCertificate();
102 | options.AddEphemeralEncryptionKey()
103 | .AddEphemeralSigningKey();
104 |
105 | // Note: to use JWT access tokens instead of the default
106 | // encrypted format, the following lines are required:
107 | //options.DisableAccessTokenEncryption();
108 |
109 | options.UseAspNetCore()
110 | .EnableTokenEndpointPassthrough();
111 | })
112 | .AddValidation(options =>
113 | {
114 | options.UseLocalServer();
115 | options.UseAspNetCore();
116 | });
117 |
118 | builder.Services.AddControllers()
119 | .ConfigureApiBehaviorOptions(x => x.SuppressMapClientErrors = true)
120 | .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
121 |
122 | var app = builder.Build();
123 |
124 | // Configure the HTTP request pipeline.
125 | if (app.Environment.IsDevelopment())
126 | {
127 | app.UseSwagger();
128 | app.UseSwaggerUI();
129 | }
130 |
131 | if (builder.Configuration.GetValue("ForceHttps", false))
132 | {
133 | app.UseHttpsRedirection();
134 | }
135 |
136 | app.UseAuthentication();
137 | app.UseAuthorization();
138 |
139 | app.UseRouting();
140 |
141 | app.MapControllers();
142 | app.MapDefaultControllerRoute();
143 |
144 | app.Run();
145 |
146 | return 0;
147 | }
148 | catch (HostAbortedException)//EF core migration genaration causes this to be thrown, and it pollutes the logs
149 | {
150 | return 1;
151 | }
152 | catch (Exception ex)
153 | {
154 | Log.ForContext().Fatal(ex, "Host terminated unexpectedly");
155 | return -1;
156 | }
157 | finally
158 | {
159 | Log.CloseAndFlush();
160 | }
161 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:32417",
8 | "sslPort": 44386
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "launchUrl": "swagger",
17 | "applicationUrl": "http://localhost:5098",
18 | "environmentVariables": {
19 | "ASPNETCORE_ENVIRONMENT": "Development"
20 | }
21 | },
22 | "https": {
23 | "commandName": "Project",
24 | "dotnetRunMessages": true,
25 | "launchBrowser": true,
26 | "launchUrl": "swagger",
27 | "applicationUrl": "https://localhost:7177;http://localhost:5098",
28 | "environmentVariables": {
29 | "ASPNETCORE_ENVIRONMENT": "Development"
30 | }
31 | },
32 | "IIS Express": {
33 | "commandName": "IISExpress",
34 | "launchBrowser": true,
35 | "launchUrl": "swagger",
36 | "environmentVariables": {
37 | "ASPNETCORE_ENVIRONMENT": "Development"
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/BaseRespository.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.ChangeTracking;
3 | using System.Data;
4 | using System.Linq.Expressions;
5 | using XRFID.Sample.Webservice.Database;
6 | using XRFID.Sample.Webservice.Entities;
7 |
8 | namespace XRFID.Sample.Webservice.Repositories;
9 |
10 | public abstract class BaseRepository where T : AuditEntity
11 | {
12 | private readonly DbSet _table;
13 | private readonly ILogger _logger;
14 |
15 | protected BaseRepository(XRFIDSampleContext context, ILogger logger)
16 | {
17 | _table = context.Set();
18 | _logger = logger;
19 | }
20 |
21 | public async Task> GetAsync()
22 | {
23 | return await _table.ToListAsync();
24 | }
25 |
26 | public async Task> GetAsync(Expression> query)
27 | {
28 | return await _table.Where(query).ToListAsync();
29 | }
30 |
31 | public async Task GetAsync(Guid id)
32 | {
33 | return await _table.FirstOrDefaultAsync(f => f.Id == id);
34 | }
35 |
36 | public async Task CreateAsync(T entity)
37 | {
38 | if (entity == null)
39 | {
40 | throw new ArgumentNullException(nameof(entity));
41 | }
42 |
43 | if (await _table.AnyAsync(c => c.Id == entity.Id))
44 | {
45 | throw new DuplicateNameException();
46 | }
47 |
48 | EntityEntry result = await _table.AddAsync(entity);
49 |
50 | return result.Entity;
51 | }
52 |
53 | public async Task> CreateAsync(List entities)
54 | {
55 | foreach (T entity in entities)
56 | {
57 | if (entity == null)
58 | {
59 | throw new ArgumentNullException(nameof(entity));
60 | }
61 |
62 | if (await _table.AnyAsync(c => c.Id == entity.Id))
63 | {
64 | throw new DuplicateNameException();
65 | }
66 | }
67 | List result = new List();
68 | foreach (T entity in entities)
69 | {
70 | result.Add((await _table.AddAsync(entity)).Entity);
71 | }
72 | return result;
73 | }
74 |
75 | public async Task DeleteAsync(T entity)
76 | {
77 | if (!await _table.AnyAsync(c => c.Id == entity.Id))
78 | {
79 | throw new KeyNotFoundException("Resource not found");
80 | }
81 |
82 | int affectedRows = await _table.Where(c => c.Id == entity.Id).ExecuteDeleteAsync();
83 |
84 | if (affectedRows == 0)
85 | {
86 | throw new Exception("database has failed to delete entity");
87 | }
88 | return entity;
89 | }
90 |
91 | public async Task UpdateAsync(T entity)
92 | {
93 | T? existingEntity = await _table.FirstOrDefaultAsync(c => c.Id == entity.Id);
94 | if (existingEntity is null)
95 | {
96 | throw new KeyNotFoundException("Resource not found");
97 | }
98 |
99 | //to do use a modified Deepcopy to procedurally update?
100 |
101 | return existingEntity;
102 | }
103 | }
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/LoadingUnitItemRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class LoadingUnitItemRepository : BaseRepository
7 | {
8 | public LoadingUnitItemRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/LoadingUnitRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class LoadingUnitRepository : BaseRepository
7 | {
8 | public LoadingUnitRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/MovementItemRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class MovementItemRepository : BaseRepository
7 | {
8 | public MovementItemRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/MovementRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class MovementRepository : BaseRepository
7 | {
8 | public MovementRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/ProductRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class ProductRepository : BaseRepository
7 | {
8 | public ProductRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Repositories/ReaderRepository.cs:
--------------------------------------------------------------------------------
1 | using XRFID.Sample.Webservice.Database;
2 | using XRFID.Sample.Webservice.Entities;
3 |
4 | namespace XRFID.Sample.Webservice.Repositories;
5 |
6 | public class ReaderRepository : BaseRepository
7 | {
8 | public ReaderRepository(XRFIDSampleContext context, ILogger logger) : base(context, logger)
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Services/LoadingUnitItemService.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Microsoft.IdentityModel.Tokens;
3 | using XRFID.Sample.Common.Dto;
4 | using XRFID.Sample.Webservice.Database;
5 | using XRFID.Sample.Webservice.Entities;
6 | using XRFID.Sample.Webservice.Repositories;
7 |
8 | namespace XRFID.Sample.Webservice.Services;
9 |
10 | public class LoadingUnitItemService
11 | {
12 | private readonly LoadingUnitItemRepository repository;
13 | private readonly IMapper mapper;
14 | private readonly UnitOfWork uowk;
15 |
16 | public LoadingUnitItemService(LoadingUnitItemRepository repository, IMapper mapper, UnitOfWork uowk)
17 | {
18 | this.repository = repository;
19 | this.mapper = mapper;
20 | this.uowk = uowk;
21 | }
22 |
23 | public async Task> GetByLoadingUnitIdAsync(Guid luId)
24 | {
25 | List result = await repository.GetAsync(q => q.LoadingUnitId == luId);
26 | if (result.IsNullOrEmpty())
27 | {
28 | throw new KeyNotFoundException("Resource not found");
29 | }
30 | return mapper.Map>(result);
31 | }
32 |
33 | public async Task CreateAsync(LoadingUnitItemDto loadingUnitDto)
34 | {
35 | LoadingUnitItem result = await repository.CreateAsync(mapper.Map(loadingUnitDto));
36 |
37 | await uowk.SaveAsync();
38 |
39 | return mapper.Map(result);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Services/LoadingUnitService.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Microsoft.IdentityModel.Tokens;
3 | using XRFID.Sample.Common.Dto;
4 | using XRFID.Sample.Webservice.Database;
5 | using XRFID.Sample.Webservice.Entities;
6 | using XRFID.Sample.Webservice.Repositories;
7 |
8 | namespace XRFID.Sample.Webservice.Services;
9 |
10 | public class LoadingUnitService
11 | {
12 | private readonly LoadingUnitRepository repository;
13 | private readonly LoadingUnitItemRepository itemRepository;
14 | private readonly IMapper mapper;
15 | private readonly UnitOfWork uowk;
16 |
17 | public LoadingUnitService(LoadingUnitRepository repository, LoadingUnitItemRepository itemRepository, IMapper mapper, UnitOfWork uowk)
18 | {
19 | this.repository = repository;
20 | this.itemRepository = itemRepository;
21 | this.mapper = mapper;
22 | this.uowk = uowk;
23 | }
24 |
25 | public async Task> GetAsync()
26 | {
27 | List result = await repository.GetAsync();
28 | if (result.IsNullOrEmpty())
29 | {
30 | throw new KeyNotFoundException("Resource not found");
31 | }
32 | return mapper.Map>(result);
33 | }
34 |
35 | public async Task GetByReferenceAsync(string reference)
36 | {
37 | List resultList = await repository.GetAsync(q => q.OrderReference != null && q.OrderReference == reference);
38 | if (resultList.IsNullOrEmpty())
39 | {
40 | throw new KeyNotFoundException("Resource not found");
41 | }
42 |
43 | LoadingUnit? result = resultList.FirstOrDefault() ?? throw new KeyNotFoundException("Resource not found");
44 | return mapper.Map(result);
45 | }
46 |
47 | public async Task GetWithItemsAsync(string reference)
48 | {
49 | List resultList = await repository.GetAsync(q => (q.OrderReference != null && q.OrderReference == reference)
50 | || (q.Reference != null && q.Reference == reference));
51 | if (resultList.IsNullOrEmpty())
52 | {
53 | throw new KeyNotFoundException("Resource not found");
54 | }
55 |
56 | LoadingUnit? result = resultList.FirstOrDefault() ?? throw new KeyNotFoundException("Resource not found");
57 | List itemResult = await itemRepository.GetAsync(q => q.LoadingUnitId == result.Id);
58 |
59 | if (result.LoadingUnitItems is null)
60 | {
61 | result.LoadingUnitItems = new List();
62 | }
63 | result.LoadingUnitItems = itemResult;
64 |
65 | return mapper.Map(result);
66 | }
67 |
68 | public async Task CreateAsync(LoadingUnitDto loadingUnitDto)
69 | {
70 | LoadingUnit result = await repository.CreateAsync(mapper.Map(loadingUnitDto));
71 |
72 | await uowk.SaveAsync();
73 |
74 | return mapper.Map(result);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Services/MovementService.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using XRFID.Sample.Common.Dto;
3 | using XRFID.Sample.Webservice.Database;
4 | using XRFID.Sample.Webservice.Entities;
5 | using XRFID.Sample.Webservice.Repositories;
6 |
7 | namespace XRFID.Sample.Webservice.Services;
8 |
9 | public class MovementService
10 | {
11 | private readonly MovementRepository repository;
12 | private readonly IMapper mapper;
13 | private readonly UnitOfWork uowk;
14 |
15 | public MovementService(MovementRepository repository, IMapper mapper, UnitOfWork uowk)
16 | {
17 | this.repository = repository;
18 | this.mapper = mapper;
19 | this.uowk = uowk;
20 | }
21 |
22 | public async Task CreateAsync(MovementDto movementDto)
23 | {
24 | Movement result = await repository.CreateAsync(mapper.Map(movementDto));
25 |
26 | await uowk.SaveAsync();
27 |
28 | return mapper.Map(result);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Services/ProductService.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Microsoft.IdentityModel.Tokens;
3 | using XRFID.Sample.Common.Dto;
4 | using XRFID.Sample.Webservice.Database;
5 | using XRFID.Sample.Webservice.Entities;
6 | using XRFID.Sample.Webservice.Repositories;
7 |
8 | namespace XRFID.Sample.Webservice.Services;
9 |
10 | public class ProductService
11 | {
12 | private readonly ProductRepository repository;
13 | private readonly IMapper mapper;
14 | private readonly UnitOfWork uowk;
15 |
16 | public ProductService(ProductRepository repository, IMapper mapper, UnitOfWork uowk)
17 | {
18 | this.repository = repository;
19 | this.mapper = mapper;
20 | this.uowk = uowk;
21 | }
22 |
23 | public async Task> GetAsync(string term)
24 | {
25 | List result = await repository.GetAsync(q => (q.Name != null && q.Name.Contains(term)) || (q.Code != null && q.Code.Contains(term)));
26 | if (result.IsNullOrEmpty())
27 | {
28 | throw new KeyNotFoundException("Resource not found");
29 | }
30 | return mapper.Map>(result);
31 | }
32 |
33 | public async Task GetByEpcAsync(string epc)
34 | {
35 | List resultList = await repository.GetAsync(q => q.Epc == epc);
36 | if (resultList.IsNullOrEmpty())
37 | {
38 | throw new KeyNotFoundException("Resource not found");
39 | }
40 |
41 | Product? result = resultList.FirstOrDefault() ?? throw new KeyNotFoundException("Resource not found");
42 | return mapper.Map(result);
43 | }
44 |
45 | public async Task CreateAsync(ProductDto loadingUnitDto)
46 | {
47 | Product result = await repository.CreateAsync(mapper.Map(loadingUnitDto));
48 |
49 | await uowk.SaveAsync();
50 |
51 | return mapper.Map(result);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/Services/ReaderService.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Microsoft.IdentityModel.Tokens;
3 | using XRFID.Sample.Common.Dto;
4 | using XRFID.Sample.Common.Dto.Create;
5 | using XRFID.Sample.Webservice.Database;
6 | using XRFID.Sample.Webservice.Entities;
7 | using XRFID.Sample.Webservice.Repositories;
8 |
9 | namespace XRFID.Sample.Webservice.Services;
10 |
11 | public class ReaderService
12 | {
13 | private readonly ReaderRepository repository;
14 | private readonly IMapper mapper;
15 | private readonly UnitOfWork uowk;
16 |
17 | public ReaderService(ReaderRepository repository, IMapper mapper, UnitOfWork uowk)
18 | {
19 | this.repository = repository;
20 | this.mapper = mapper;
21 | this.uowk = uowk;
22 | }
23 |
24 | public async Task GetByNameAsync(string name)
25 | {
26 | List resultList = await repository.GetAsync(q => q.Name == name);
27 | if (resultList.IsNullOrEmpty())
28 | {
29 | throw new KeyNotFoundException("Resource not found");
30 | }
31 |
32 | Reader? result = resultList.FirstOrDefault() ?? throw new KeyNotFoundException("Resource not found");
33 | return mapper.Map(result);
34 | }
35 |
36 | public async Task CreateAsync(ReaderDto readerDto)
37 | {
38 | Reader result = await repository.CreateAsync(mapper.Map(readerDto));
39 |
40 | await uowk.SaveAsync();
41 |
42 | return mapper.Map(result);
43 | }
44 |
45 | public async Task CreateAsync(MinimalReaderCreateDto readerDto)
46 | {
47 | Reader result = await repository.CreateAsync(new Reader { Id = readerDto.Id, Name = readerDto.Name });
48 | await uowk.SaveAsync();
49 | return mapper.Map(result);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/XRFID.Sample.Webservice.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | all
21 | runtime; build; native; contentfiles; analyzers; buildtransitive
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Serilog": {
3 | "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
4 | "MinimumLevel": {
5 | "Default": "Debug",
6 | "Override": {
7 | "Microsoft": "Warning",
8 | "Microsoft.Hosting.Lifetime": "Information",
9 | "Microsoft.AspNetCore": "Warning",
10 | "Quartz.Core.QuartzSchedulerThread": "Information",
11 | "Quartz.Core.JobRunShell": "Information",
12 | "Quartz.ContainerConfigurationProcessor": "Information"
13 | }
14 | },
15 | "Enrich": [ "FromLogContext" ],
16 | "WriteTo": [
17 | {
18 | "Name": "Async",
19 | "Args": {
20 | "configure": [
21 | {
22 | "Name": "File",
23 | "Args": {
24 | "path": "logs/webservice_.log",
25 | "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level}] [{SourceContext}] {Message} {NewLine}{Exception}",
26 | "rollingInterval": "Day",
27 | "retainedFileCountLimit": null,
28 | "retainedFileTimeLimit": "7.00:00:00",
29 | "fileSizeLimitBytes": 52428800,
30 | "rollOnFileSizeLimit": true,
31 | "shared": true
32 | }
33 | },
34 | {
35 | "Name": "Console",
36 | "Args": {
37 | "formatter": {
38 | "type": "Serilog.Templates.ExpressionTemplate, Serilog.Expressions",
39 | "template": "[{@t:HH:mm:ss.fff}] [{@l:u3}] [{Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)}] {@m}\n{@x}",
40 | "theme": "Serilog.Templates.Themes.TemplateTheme::Literate, Serilog.Expressions"
41 | }
42 | }
43 | },
44 | {
45 | "Name": "EventLog",
46 | "Args": {
47 | "source": "Xerum XRFID Sample Webservice",
48 | "logName": "Xerum XRFID Sample Webservice",
49 | "manageEventSource": false,
50 | "restrictedToMinimumLevel": "Error"
51 | }
52 | }
53 | ]
54 | }
55 | }
56 | ]
57 | },
58 | "ForceHttps": false
59 | }
60 |
--------------------------------------------------------------------------------
/XRFID.Sample.Webservice/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Kestrel": {
3 | "Endpoints": {
4 | "Https": {
5 | "Url": "https://*:7098"
6 | },
7 | "Http": {
8 | "Url": "http://*:5098"
9 | }
10 | },
11 | "Limits": {
12 | "MaxConcurrentConnections": 100,
13 | "MaxConcurrentUpgradedConnections": 100
14 | }
15 | },
16 | "Serilog": {
17 | "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
18 | "MinimumLevel": {
19 | "Default": "Information",
20 | "Override": {
21 | "Microsoft": "Warning",
22 | "Microsoft.Hosting.Lifetime": "Information",
23 | "Microsoft.AspNetCore": "Warning",
24 | "Quartz.Core.QuartzSchedulerThread": "Information",
25 | "Quartz.Core.JobRunShell": "Information",
26 | "Quartz.ContainerConfigurationProcessor": "Information"
27 | }
28 | },
29 | "Enrich": [ "FromLogContext" ],
30 | "WriteTo": [
31 | {
32 | "Name": "Async",
33 | "Args": {
34 | "configure": [
35 | {
36 | "Name": "File",
37 | "Args": {
38 | "path": "logs/webservice_.log",
39 | "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level}] [{SourceContext}] {Message} {NewLine}{Exception}",
40 | "rollingInterval": "Day",
41 | "retainedFileCountLimit": null,
42 | "retainedFileTimeLimit": "7.00:00:00",
43 | "fileSizeLimitBytes": 52428800,
44 | "rollOnFileSizeLimit": true,
45 | "shared": true
46 | }
47 | },
48 | {
49 | "Name": "Console",
50 | "Args": {
51 | "formatter": {
52 | "type": "Serilog.Templates.ExpressionTemplate, Serilog.Expressions",
53 | "template": "[{@t:HH:mm:ss.fff}] [{@l:u3}] [{Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)}] {@m}\n{@x}",
54 | "theme": "Serilog.Templates.Themes.TemplateTheme::Literate, Serilog.Expressions"
55 | }
56 | }
57 | },
58 | {
59 | "Name": "EventLog",
60 | "Args": {
61 | "source": "Xerum XRFID Sample Webservice",
62 | "logName": "Xerum XRFID Sample Webservice",
63 | "manageEventSource": false,
64 | "restrictedToMinimumLevel": "Error"
65 | }
66 | }
67 | ]
68 | }
69 | }
70 | ]
71 | },
72 | "AllowedHosts": "*",
73 | "ForceHttps": false
74 | }
75 |
--------------------------------------------------------------------------------
/XRFID.Sample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.34009.444
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XRFID.Sample.Webservice", "XRFID.Sample.Webservice\XRFID.Sample.Webservice.csproj", "{37F168AF-CE80-4B82-9478-F3389D4D62DB}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XRFID.Sample.Common", "XRFID.Sample.Common\XRFID.Sample.Common.csproj", "{A7039A16-5042-4486-9457-31C86A66F67D}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XRFID.Sample.Client.Mobile", "XRFID.Sample.Client.Mobile\XRFID.Sample.Client.Mobile.csproj", "{D1041C18-A1F8-44A6-B512-4458FC766521}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {37F168AF-CE80-4B82-9478-F3389D4D62DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {37F168AF-CE80-4B82-9478-F3389D4D62DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {37F168AF-CE80-4B82-9478-F3389D4D62DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {37F168AF-CE80-4B82-9478-F3389D4D62DB}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {A7039A16-5042-4486-9457-31C86A66F67D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {A7039A16-5042-4486-9457-31C86A66F67D}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {A7039A16-5042-4486-9457-31C86A66F67D}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {A7039A16-5042-4486-9457-31C86A66F67D}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
29 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {D1041C18-A1F8-44A6-B512-4458FC766521}.Release|Any CPU.Deploy.0 = Release|Any CPU
32 | EndGlobalSection
33 | GlobalSection(SolutionProperties) = preSolution
34 | HideSolutionNode = FALSE
35 | EndGlobalSection
36 | GlobalSection(ExtensibilityGlobals) = postSolution
37 | SolutionGuid = {5B467AC4-9FC0-4F11-9782-BA682127A0F7}
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/dll/XamarinZebraRFID.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XerumSrl/XRFID-Android-Samples/dcfbd1f42a9ea957b4e74eb7557638aea149cab5/dll/XamarinZebraRFID.dll
--------------------------------------------------------------------------------
/img/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------